akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>

using namespace std;

int main(void){
    int n, a[200005];
    cin >> n;
    long long snuke=0, arai=0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(i==0){
            snuke += a[i];
        }else{
            arai += a[i];
        }
    }
    long long ans = abs(snuke-arai);
    for(int i=1; i<n-1; i++){
        snuke += a[i];
        arai -= a[i];
        ans = min(ans, abs(snuke-arai));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
N,M,C = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

ans = 0
for _ in range(N):
    A = [int(j) for j in input().split()]
    p = C
    for i in range(M):
        p += A[i]*B[i]
    if p > 0:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i,N){
        cin >> a[i];
    }
    int num = 1;
    int ans = 0;
    for(int i=0;i<N;i++){
        if(a[i]!=num){
            ans++;
        }else{
            num++;
        }
    }
    if(ans == N){
        ans = -1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
	int a,b,c,d,res=0;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	if(a < b){
		res += a;
	}else{
		res += b;
	}
	if(c < d){
		res += c;
	}else{
		res += d;
	}
	printf("%d\n",res);
	return 0;
}

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

int main(){
  int A,B,C;
  string flag="NO";
  cin >> A >> B >> C;
  
  for(int i=1;i*A<=B*A;i++){
    if((i*A)%B==C){
      flag="YES";
      break;
    }
  }
  
  cout << flag;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using Lint=long long;

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

    int N; cin>>N;
    vector<vector<int>> G(N,vector<int>(N));
    for(int i=0;i<N;i++){
        int u,k; cin>>u>>k;
        u--;
        while(k--){
            int v; cin>>v;
            v--;
            G[u][v]=1;
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cout<<G[i][j]<<(j==N-1? '\n':' ');
        }
    }
    return 0;
}


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

int main(void){
	int D, T, S;
	cin >> D >> T >> S;
	if (D <= T*S) cout << "Yes" << endl;
	else cout << "No" << endl;
return 0;
}


Measured memory_bytes: 3628
n, q = map(int, input().split())
s = input()
cum = [0] * n  # i文字目までに含まれるACの個数
for i in range(1, n):
    if s[i-1:i+1] == 'AC':
        cum[i] = cum[i-1] + 1
    else:
        cum[i] = cum[i-1]

for i in range(q):
    l, r = map(int, input().split())
    l, r = l-1, r-1
    print(cum[r] - cum[l])


Measured memory_bytes: 51160
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    int N;
    int L;
    cin >> N;
    cin >> L;

    int sum=0;
    int eaten;

    eaten = L + 1 -1;
    for( int ni = 0 ; ni < N ; ni++ ){
        sum+=L+(ni+1)-1;
        if(abs(L+(ni+1)-1) < abs(eaten)) eaten = L+(ni+1)-1;
    }
    //cout << sum << endl;
    //cout << eaten << endl ;
    sum -= eaten;
    cout << sum << endl;

}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define rep(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define irep(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define rrep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

const int MOD = 1e9 + 7;

int count_children(int now, vector<vector<int>> &edges, vector<int> &num_children, vector<int> &parent) {
    int cnt = 1;
    for (auto child : edges[now]) {
        if (child == parent[now])
            continue;
        cnt += count_children(child, edges, num_children, parent);
    }
    num_children[now] = cnt;
    return cnt;
}

void get_parent(int node, vector<vector<int>> &edges,vector<int> &parent) {
    for (auto t : edges[node]) {
        if (t == parent[node])
            continue;
        parent[t] = node;
        get_parent(t, edges, parent);
    }
}

vector<int> get_path(int node, vector<int> &parent) {
    vector<int> ret;
    while (node != 0) {
        ret.push_back(node);
        node = parent[node];
    }
    ret.push_back(0);

    return ret;
}


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

    vector<vector<int>> edges(n);
    rep(i, 0, n - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vector<int> parent(n);
    get_parent(0, edges, parent);

    vector<int> num_children(n, 0);
    count_children(0, edges, num_children, parent);


    vector<int> path = get_path(n - 1, parent);

    int sz = path.size();
    int battle = path[(sz-2) / 2];
    int fennec = num_children[0] - num_children[battle];
    int snuke = num_children[battle];


    cout << (fennec > snuke ? "Fennec" : "Snuke") << endl;



    return 0;
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> A( N );
	vector<int> B( N );
	vector<int> C( N - 1 );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}
	for( int i = 0; i < N; i++ ) {
		cin >> B[i];
	}
	for( int i = 0; i < N - 1; i++ ) {
		cin >> C[i];
	}

	int ans = 0;
	int last = -10;
	for( int i = 0; i < N; i++ ) {
		ans += B[ A[i] - 1 ];
		if( A[i] == last + 1 ) {
			ans += C[ A[i - 1] - 1];
		}
		last = A[i];
	}

	cout << ans << endl;
}


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

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  int time = ( d%s == 0 ) ? d/s : d/s + 1;
  string ans = ( t >= time ) ? "Yes" : "No";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];

    int ans = 0;
    int count = 1;
    rep(i, n) {
        if (a[i] == count) count++;
        else ans++;
    }
    
    if (ans == n) {
        puts("-1");
        return 0;
    }

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

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

int main() {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> a(n, vector<int>(d));

  for(int i=0; i<n; i++) {
    for(int j=0; j<d; j++) {
      cin >> a[i][j];
    }
  }
  
  int answer = 0;
  for(int i=0; i<n; i++) {
    for(int j=i+1; j<n; j++) {
      int dis = 0;
      for(int k=0; k<d; k++) {
        dis += pow(a[i][k] - a[j][k], 2);
      }
      
      if (ceil(sqrtf(dis)) == floor(sqrtf(dis))) {
        answer++;
      }
    }
  }
  
  cout << answer;
  
  return 0;
}

Measured memory_bytes: 256
#define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

template < class Value >
bool bat(Value x, std::size_t pos) { return (x >> pos) & Value{1}; }

/*
半分全列挙です。
まずは全部A引いておけば、合計0を探すのでよいです。
前半と後半、それぞれでありえる合計値を列挙し、前半を全探索して、後半を equal_range です。

間に合わないじゃないですか！！
値の範囲が狭いので重複度付き集合で対応です。
負の値もあるので、下駄を履かせます。
*/

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  int l = n / 2;
  int A; std::cin>>A;
  std::vector<int> a(n); std::cin>>a;
  for (int & x : a) x -= A;
  debug(a);

  int geta = 0;
  int max = 0;
  for (int x : a) {
    if (x < 0) geta += -x;
    else max += x;
  }
  debug(geta,max);

  auto make_sums = [&] (std::vector<int> const& a) {
    int n = a.size();
    int N = 1 << n;
    std::vector<int> now(n,0);
    std::vector<lint> ans(geta+max+1,0);
    lint sum = 0;
    rep(bs,0,N) {
      if (0 < bs) {
        int i = __builtin_ctz(bs);
        now.at(i) ^= 1;
        sum += (now.at(i) ? +1 : -1) * a.at(i);
      }
      ans.at(geta+sum)++;
    }
    return ans;
  };
  auto former = make_sums(std::vector<int>(a.begin(), a.begin() + l));
  auto latter = make_sums(std::vector<int>(a.begin() + l, a.end()));
  debug(former,latter);

  lint ans = 0;
  int d = std::min(geta,max);
  rep(i,-d,d+1) {
    int j = -i;
    lint x = former.at(geta+i);
    lint y = latter.at(geta+j);
    ans += x * y;
  }
  ans--;
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
var i,j:longint;
    s:ansistring;
begin
  readln(s);
  for i:=1 to length(s) do
    if s[i]='C' then break;
  for j:=i+1 to length(s) do
    if s[j]='F' then
    begin
      writeln('Yes');
      halt;
    end;
  writeln('No');
end.

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    vector<double> x(3),y(3);

    for(int i = 0; i < 3; i++){
        cin >> x[i] >> y[i];
    }

    vector<double> a;
    for(int i = 0; i < 3; i++){
        for(int j = i+1; j < 3; j++){
            a.push_back(sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j])));
        }
    }

    double maxa = 0.0;

    for(int i = 0; i < a.size(); i++){
        if(a[i] > maxa){
            maxa = a[i];
        }
    }

    double s = 0.0;

    for(int i = 0; i < a.size(); i++){
        s += a[i];
    }

    s /= 2;

    double S = s;

    for(int i = 0; i < a.size(); i++){
        S *= s - a[i];
    }

    S = sqrt(S);

    double r = S/s;

    cout << fixed;
    cout << setprecision(17) << (r*maxa)/(maxa+2*r) << endl;
    
    return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def c(i, j, k):
    return j - i != k - j


def main():
    N = I()
    s = S()
    # N = 2000
    # s = 'R' * 2000
    R = [0] * (N+1)
    G = [0] * (N+1)
    B = [0] * (N+1)

    for i in range(N):
        if s[i] == 'R':
            R[i] += 1
        elif s[i] == 'G':
            G[i] += 1
        elif s[i] == 'B':
            B[i] += 1
        R[i+1] = R[i]
        G[i+1] = G[i]
        B[i+1] = B[i]

    ans = 0
    for i in range(N):
        for j in range(i, N):
            if s[i] == 'R' and s[j] == 'G' or s[i] == 'G' and s[j] == 'R':
                nxt = j - i + j
                if nxt >= len(s):
                    ans += B[N] - B[j]
                elif s[nxt] != 'B':
                    ans += B[N] - B[j]
                else:
                    ans += B[N] - B[j]
                    ans -= 1
            elif s[i] == 'R' and s[j] == 'B' or s[i] == 'B' and s[j] == 'R':
                nxt = j - i + j
                if nxt >= len(s):
                    ans += G[N] - G[j]
                elif s[nxt] != 'G':
                    ans += G[N] - G[j]
                else:
                    ans += G[N] - G[j]
                    ans -= 1
            elif s[i] == 'B' and s[j] == 'G' or s[i] == 'G' and s[j] == 'B':
                nxt = j - i + j
                if nxt >= len(s):
                    ans += R[N] - R[j]
                elif s[nxt] != 'R':
                    ans += R[N] - R[j]
                else:
                    ans += R[N] - R[j]
                    ans -= 1


    print(ans)
    # print(R)
    # print(G)
    # print(B)


if __name__ == '__main__':
    main()


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

string A;
int cnt;
int ans;

void solve(int now) {
  if(now < 0) return;
  if(A[now] == 'A') {
    ans += cnt;
    solve(now - 1);
  }else if(A[now] == 'C' && now > 0 && A[now - 1] == 'B') {
    cnt++;
    solve(now - 2);
  }else {
    cnt = 0;
    solve(now - 1);
  }
}

int32_t main() {
  cin >> A;
  solve(A.size() - 1);
  cout << ans << "\n";
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define w(t) int t;cin>>t;while(t--)
#define pb push_back
#define mk make_pair
#define ascSort(v) sort(v.begin(), v.end())
#define descSort(v) sort(v.begin(), v.end(), greater<int>())
#define ff first
#define ss second
#define pi pair<int,int>
#define vi vector<int>
#define umapi unordered_map<int,int>

const int m=1e9+7;
using namespace std;

void FIO(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
}





int32_t main(){
	
	//FIO();
	int h,w;cin>>h>>w;
	char grid[h][w];
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			cin>>grid[i][j];
		}

	}
	
	int ans[h][w];ans[0][0]=1;

	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(grid[i][j]=='#'){
				ans[i][j]=0;

			}
			else{
				if(i-1>=0 && j-1>=0)
					ans[i][j]=(ans[i-1][j]+ans[i][j-1])%m;
				else if(i-1>=0)
				        ans[i][j]=(ans[i-1][j])%m;
				else if(j-1>=0)
					ans[i][j]=(ans[i][j-1])%m;
			}
		}
	}
	

	cout<<ans[h-1][w-1];




	return 0;
		
		
	
		
		
}


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

int main() {
  int N;cin>>N;
  vector<ll> L(N);rep(i,N) cin>>L[i];
  
  int ans = 0;
  for(int i=0;i<N-2;i++){
    for(int j=i+1;j<N-1;j++){
      for(int k=j+1;k<N;k++){
        ll maxL = max({L[i],L[j],L[k]});
        if(maxL < L[i]+L[j]+L[k]-maxL && L[i]!=L[j] && L[i]!=L[k] && L[j]!=L[k]) ans++;
      }
    }
  }
           
  cout << ans << endl;
  
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
using namespace std;
int main(){
  int n,m;
  while(cin >> n >> m && n||m){
    int cnt = n,ban = 0,cnter; bool ok[n+1];
    memset(ok,true,sizeof(ok));
    while(true){
      cnter = 0;
      do{
	do{
	  (ban==n) ? ban=1:ban++;
	}while(!ok[ban]);
	cnter++;
      }while(cnter!=m);
      cnt--;
      ok[ban] = false;
      if(cnt == 1) break;
    }
    for(int i=1;;i++){
      if(ok[i]){
	cout << i << endl;
	break;
      }
    }
  }
}

Measured memory_bytes: 1168
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static void Main(string[] args) {
        int N = cin.Int();
        var a = cin.ArrayLong(3*N);
        a = a.OrderByDescending(x => x).ToArray();
        long ans = 0;
        for(int i = 1; i <= 2 * N - 1; i += 2) {
            ans += a[i];
        }
        Console.WriteLine(ans);
        Console.ReadLine();
    }
}

Measured memory_bytes: 51080
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	string s;
	cin >> s;
	int n = s.size();
	int cntbc = 0;
	ll ans = 0;
	int fl = 0;
	for (int i = n - 2; i >= 0; i--) {
		if (s[i] == 'A') {
			if (s[i + 1] == 'C') {
				cntbc = 0;
				fl = 0;
			}
			else ans += cntbc;
		}
		else if (s[i] == 'B') {
			if (s[i + 1] == 'C') {
				fl = 1;
				cntbc++;
			}
			else {
				fl = 0;
				cntbc = 0;
			}
		}
		else if(s[i] == 'C'){
			if (s[i+1] == 'C') {
				fl = 0;
				cntbc = 0;
			}
		}
	}
	puts(ans);
	return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;

int main(){
  int n,m;  cin >> n >> m;
  cout << n*(n-1)/2+m*(m-1)/2 << endl;
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <bits/stdc++.h>

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

using namespace std;

int main(){
    string s;
    cin >>s;
    rep(i, s.length()){
        if(i % 2 == 0){
            if(s[i] == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(s[i] == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }
            }
    cout << "Yes" << 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 ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int D; cin >> D;
    vector<int> c(26+1, 0);
    for(int i = 1; i <= 26; i++) cin >> c[i];
    vector<vector<int>> s(D+1, vector<int>(26+1, 0));
    for(int i = 1; i <= D; i++)for(int j = 1; j <= 26; j++) cin >> s[i][j];
    vector<int> t(D+1, 0);
    for(int i = 1; i <= D; i++) {
        cin >> t[i];
    }
    int M; cin >> M;
    vector<int> d(M+1, 0);
    vector<int> q(M+1, 0);
    for(int i = 1; i <= M; i++) cin >> d[i] >> q[i];
    for(int i = 1; i <= M; i++){
        vector<int> last(26+1, 0);
        auto f = [&](int d){
            int res = 0;
            for(int i = 1; i <= 26; i++){
                res += c[i] * (d - last[i]);
            }
            return res;
        };
        t[d[i]] = q[i];
        int ans = 0;
        for(int day = 1; day <= D; day++){
            int con = t[day];
            ans += s[day][con];
            last[con] = day;
            ans -= f(day); 
        }
        cout << ans << endl;
    }
    //for(int i = 1; i <= D; i++) cout << t[i] << endl;
}

Measured memory_bytes: 3964
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=x && x<w && 0<=y && y<h)

const int INF = 10000000;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef pair<int, int> P;

/** Problem0503 : Biased Dice **/
int num[200][200];
int top[200][200];
const int North[6] = {2, 1, 5, 3, 0, 4};
const int East[6] = {0, 4, 1, 2, 3, 5};
const int West[6] = {0, 2, 3, 4, 1, 5};
const int South[6] = {4, 1, 0, 3, 5, 2};
const int Right[6] = {1, 5, 2, 0, 4, 3};
const int Left[6] = {3, 0, 2, 5, 4, 1};


int dice[6];

void rotate(int d) {
	int t[6]; rep(i, 6) t[i]=dice[i];
	
	switch (d) {
		case 0:
			rep(i, 6) dice[i]=t[West[i]];
			break;
		case 1:
			rep(i, 6) dice[i]=t[South[i]];
			break;
		case 2:
			rep(i, 6) dice[i]=t[East[i]];
			break;
		case 3:
			rep(i, 6) dice[i]=t[North[i]];
			break;
		case 4:
			rep(i, 6) dice[i]=t[Right[i]];
			break;
	}
}

void preDice(int t, int f)
{
	if (dice[2]==t && dice[5]==f) return;
	
	while (1) {
		rotate(1);
		rep(i, 4) {
			if (dice[2]==t && dice[5]==f) return;
			rotate(4);
		}
		rotate(2);
		rep(i, 4) {
			if (dice[2]==t && dice[5]==f) return;
			rotate(4);
		}
	}
}

void move(int t)
{
	const int idx[4] = {1, 5, 3, 0};
	int x=100, y=100;
	
	while (1) {
		for (int b=6; b>3; b--) {
			rep(j, 4) {
				if (dice[idx[j]]==b) {
					int nx = x+dx[j], ny = y+dy[j];
					if_range(nx, ny, 200, 200) {
						if (num[x][y]>num[nx][ny]) {
							rotate(j);
							
							x=nx; y=ny;

							goto end;
						}
					}
				}
			}
		}
		break;
	end:;
	}
	
	top[x][y] = dice[2];
	num[x][y]++;
}

int main()
{
	int n;
	while (cin>>n, n) {
		fill(num[0], num[0]+200*200, 0);
		fill(top[0], top[0]+200*200, 0);

		rep(z, n) {
			dice[0]=4; dice[1]=2; dice[2]=1; dice[3]=5; dice[4]=6; dice[5]=3;
			
			int t, f;
			cin>>t>>f;
			
			preDice(t, f);
			
			move(t);
			
		}
		int ans[6] = {0};
		rep(y, 200) {
			rep(x, 200) {
				if (top[x][y]>0) {
					ans[top[x][y]-1]++;
				}
			}
		}
		cout << ans[0];
		REP(j, 1, 6) {
			cout << " " << ans[j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1476
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

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

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

	int n;
	cin >> n;
	vector<string> s(n);
	rep(i, n)
		cin >> s[i];

	for (int i = 0; i < n - 1; i++)
	{
		if (s[i][s[i].size() - 1] == s[i + 1][0])
			for (int j = i + 1; j < n; j++)
			{
				if (s[i] == s[j])
				{
					cout << "No" << endl;
					return 0;
				}

			}
		else
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll; 

ll gcd(ll x, ll y){ return y ? gcd(y, x%y):x; }

//素因数分解
vector<pair<ll, ll> >factorization(ll n){
    vector<pair<ll, ll> >tmp;
    for(ll i = 2; i*i <= n; i++){
	if(n%i)	continue;
	tmp.push_back(pair<ll, ll>(i, 0));
	while(n%i == 0){
	    n/=i;
	    tmp.back().second++;
	}
    }
    if(n!=1)	tmp.push_back(pair<ll, ll>(n, 1));
    return tmp;
}

int main(){
    ll a,b; cin >> a >> b;
    //solve
    ll g = gcd(a, b);
    vector<pair<ll, ll> >ans = factorization(g);
    cout << ans.size() + 1 << endl;;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
	static void Main(string[] args) {
		int n = int.Parse(Console.ReadLine());
		if (n % 2 == 0) {
			Console.WriteLine(n);
		} else {
			Console.WriteLine(n * 2);
		}
	}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;

#define pb push_back
#define F  first
#define S  second
#define int ll
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MOD = 1e9 + 7, N = 5e5 + 10;
const ll LINF = LLONG_MAX;


int32_t main() {
    fast();
	int n,k;
	cin >> n >> k;
	vec q(n);
	f(i,0,n){
		cin >> q[i];
	}   
	sort(all(q));
	reverse(all(q));
	if(k>=n){
		cout<<0;
		return 0;
	}
	f(i,0,k){
		q[i]=0;
	}
	int c=0;
	f(i,k,n){
		c+=q[i];
	}
	cout<<c;

    return 0;
}
 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll n,m;
ll x[100005];
ll d[100005];
ll ans;
int main(void){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>x[i];
	}
	sort(x,x+m);
	for(int i=0;i<m-1;i++){
		d[i]=x[i+1]-x[i];
	}
	sort(d,d+m);
	for(int i=0;i<m-n+1;i++){
		ans+=d[i];
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 1792
x = raw_input()
n = x.count('N')
e = x.count('E')
w = x.count('W')
s = x.count('S')
if n > 0:n = 1
if e > 0:e = 1
if w > 0:w = 1
if s > 0:s = 1

if (n == s) and (e == w):print "Yes"
else: print "No"


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

int maxnum = 0;

int n, m, q;
int a[51];
int b[51];
int c[51];
int d[51];

void sum(vector<int> A, int id)
{
    if(id != n){
        while(A[id] <= m)
        {
            sum(A, id+1);
            A[id]++;
            for (int i = id + 1; i <= n; i++)
            {
                A[i] = A[id];
            }
        }
    }
    else{
        while(A[id] <= m)
        {
            int add = 0;
            for (int i = 0; i < q; i++)
            {
                if(A[b[i]] - A[a[i]] == c[i]) add += d[i];
            }
            
            if(maxnum < add) maxnum = add;
            A[id]++;
        }
    }
}

int main()
{
    cin >> n >> m >> q;

    for (int i = 0; i < q; i++)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    vector<int>A;
    
    for (int i = 0; i <= n; i++)
    {
        A.push_back(1);
    }

    sum(A, 0);

    cout << maxnum << endl;
    
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#ifdef dbg
#include "./printer.hpp"
#else
#define dump(x) void(0)
#endif

#define MOD 1000000007
using namespace std;
#define ll long long
inline long  toInt(string s) {long  v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

int main(){
  ll a,b;
  while(cin >> a >> b){
    cout << __gcd(a,b) << endl;
  }

}

Measured memory_bytes: 2992
#include <stdio.h>

using namespace std;


int main(){
	int count[10001],tmp,num=3;
	for(int i=0;i<10001;i++)count[i]=0;

	for(int i=0;i<10;i++){
		scanf("%d",&tmp);
		count[tmp]++;
	}

	for(int i=10000;i>=0&&num>0;i--){
		if(count[i]>0){
			for(int k=0;k<count[i]&&num>0;k++){
				printf("%d\n",i);
				num--;
			}
		}
	}

    return 0;
}


Measured memory_bytes: 2780
N = gets.to_i
fs = []
N.times do |i|
    fs[i] = gets.gsub(' ', '').to_i(2)
end
ps = []
N.times do |i|
    ps[i] = gets.split.map(&:to_i)
end

max = -Float::INFINITY
(1..1023).each do |i|
    sum = 0
    N.times do |j|
        t = (i & fs[j]).to_s(2).count('1')
        sum += ps[j][t]
    end
    max = sum if max < sum
end

print max

Measured memory_bytes: 1788
#!/usr/bin/env python3
import sys
import math


def solve(N: int):
    if N %2 ==1:
        print(0)
        exit()
    else:
        sum = 0
        digit = 1
        while 5**digit*2 <= N:
            sum += N//(5**digit*2)
            digit+=1
        print(sum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;

const int MAX_N = 1e3;
int n;
int a[MAX_N][MAX_N - 1];

struct ver {
    vector<int> to;
    int dist = -1;
    bool reach = false;
};
ver v[MAX_N * (MAX_N - 1) / 2];

bool dfs(int x) {
    if (v[x].dist >= 0) return true;

    if (v[x].reach) {
        return false;
    }
    v[x].reach = true;
    
    int ans = 0;
    for (auto &i : v[x].to) {
        if (!dfs(i)) return false;
        ans = max(ans, v[i].dist + 1);
    }
    v[x].dist = ans;
    return true;
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n - 1; j++) {
            scanf("%d", &a[i][j]);
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n - 2; j++) {
            int ind1 = max(i, a[i][j] - 1) * (max(i, a[i][j] - 1) - 1) / 2
                     + min(i, a[i][j] - 1);
            int ind2 = max(i, a[i][j + 1] - 1) * (max(i, a[i][j + 1] - 1) - 1) / 2
                     + min(i, a[i][j + 1] - 1);
            v[ind1].to.push_back(ind2);
        }
    }

    for (int i = 0; i < n; i++) {
        if (!dfs(max(i, a[i][0] - 1) * (max(i, a[i][0] - 1) - 1) / 2
               + min(i, a[i][0] - 1))) {
            printf("-1\n");
            return 0;
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans = max(ans, v[max(i, a[i][0] - 1) * (max(i, a[i][0] - 1) - 1) / 2
                       + min(i, a[i][0] - 1)].dist);
    }

    printf("%d\n", ans + 1);
    return 0;
}


Measured memory_bytes: 35456
N = int(input())
A = list(map(int, input().split()))
cnt = 0
 
while True:
    for i in range(len(A)):
        if A[i]%2 != 0:
            break
        elif A[i]%2 == 0:
            A[i] /= 2
    else:
        cnt += 1
        continue
    break
    
print(cnt)

Measured memory_bytes: 3060
while True:
    try:
        a=input()
        cj=0
        ci=0
        for i in range(len(a)-2):
            if a[i+1]=="O" and a[i+2]=="I":
                if a[i]=="J":
                    cj+=1
                elif a[i]=="I":
                    ci+=1
        print(cj)
        print(ci)
    except:
        break


Measured memory_bytes: 5568
#include <iostream>
#include <type_traits>
#include <vector>

using namespace std;

template <class M, class N>
common_type_t<M, N> gcd(M a, N b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}

using ll = long long;

template <typename T, typename = typename std::enable_if<
                          std::is_integral<T>::value, T>::type>
vector<pair<T, int>> prime_factorize(T n) {
  vector<pair<T, int>> cnts{{1, 1}};
  if (n == 1) {
    return cnts;
  }

  T a = 2;
  while (n >= a * a) {
    int cnt = 0;
    while (n % a == 0) {
      n /= a;
      cnt++;
    }

    if (cnt > 0) {
      cnts.push_back({a, cnt});
    }

    a++;
  }

  if (n != 1) {
    cnts.push_back({n, 1});
  }

  return cnts;
}

int main(int argc, const char *argv[]) {
  ll a, b;
  cin >> a >> b;

  ll ab_gcd = gcd(a, b);
  auto prime_facts = prime_factorize(ab_gcd);
  cout << prime_facts.size() << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int A[1010];

int partation (int l, int r) {
    
    int temp;
    int i = l-1;
    int x = A[r];
    for (int j = l; j < r; j++) {
        if (A[j] >= x) {
            i++;
            temp = A[i];
            A[i] = A[j];
            A[j] = temp;
        }
    }
    temp = A[i+1];
    A[i+1] = A[r];
    A[r] = temp;

    return i+1;
}

int quickSort (int l, int r) {

    int m;
    if (l < r) {
        m = partation(l, r);
        quickSort(l, m-1);
        quickSort(m+1, r);
    }

    return 0;
}

int main () {

    int n, m;
    int sum = 0;

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

    quickSort(0, n-1);


    if (double(A[m-1]) >= ((double(sum)/double(4*m)))) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 3716
import java.awt.geom.*;
import java.util.*;

import static java.lang.Math.*;
public class Main {
	final Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	Main(){
		new AOJ1211();
	}
	
	class AOJ1211{
		AOJ1211(){
			int cnt=0;
			while(true){
				N=sc.nextInt();
				if(N==0)	break;
				if(cnt>0)	System.out.println("----------");
				solve();
				++cnt;
			}
		}
		int N;
		final int vx[]={-1,0,1,1,1,0,-1,-1},vy[]={1,1,1,0,-1,-1,-1,0};
		final int offsetx[]={-1,-1,0,0},offsety[]={0,1,1,0};
		void solve(){
			StringBuilder[] str=new StringBuilder[N];
			sc.nextLine();
			for(int i=0; i<N; ++i)	str[i]=new StringBuilder(sc.nextLine());
			TreeMap<Integer,Integer> ans=new TreeMap<Integer,Integer>();
			ArrayList<Point2D> ps = new ArrayList<Point2D>(4);
			for(int y=0; y<N; ++y){
				for(int x=0; x<str[y].length(); ++x){
					if(str[y].charAt(x)=='*'){
						int xx=x, yy=y;
						for(int i=0; i<4; ++i){
							ps.add(new Point2D.Double(xx+offsetx[i],yy+offsety[i]));
							str[yy].setCharAt(xx, '.');
							int v=0;
							while(!(0<=yy+vy[v]&&yy+vy[v]<N&&0<=xx+vx[v]&&xx+vx[v]<str[yy+vy[v]].length()) || str[yy+vy[v]].charAt(xx+vx[v])!='*')	++v;
//							System.out.println("V"+v+" "+xx+","+yy+" "+str[yy].charAt(xx)+" "+str[yy+vy[v]].charAt(xx+vx[v]));
							while(0<=yy+vy[v]&&yy+vy[v]<N&&0<=xx+vx[v]&&xx+vx[v]<str[yy+vy[v]].length() && str[yy+vy[v]].charAt(xx+vx[v])=='*'){
								xx+=vx[v];	yy+=vy[v];
								str[yy].setCharAt(xx, '.');
							}
						}
//						System.out.println(ps);
//						System.out.println(area(ps));
						int area=(int)area(ps);
						if(ans.containsKey(area))	ans.put(area, ans.get(area)+1);
						else	ans.put(area, 1);
						ps.clear();
					}
				}
			}
			for(Map.Entry<Integer, Integer> e:ans.entrySet()){
				System.out.println(e.getKey()+" "+e.getValue());
			}
		}
		double cross(Point2D p1,Point2D p2){
			return p1.getX()*p2.getY() - p2.getX()*p1.getY();
		}
		double area(ArrayList<Point2D> points){
			double ret=0.0;
			for(int i=0; i<points.size(); ++i){
				Point2D p1=points.get(i), p2=points.get((i+1)%points.size());
				ret+=cross(p1, p2);
			}
			return Math.abs(ret)/2.0;
		}
	}
}

Measured memory_bytes: 24292
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

const int P = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    map<int,int> Mp;
    rep(i,1,n+1){
        int t = i;
        for(int j=2;j*j<=t;++j) if(t % j == 0){
            while(t % j == 0) t /= j , Mp[j]++;
        }
        if(t > 1) Mp[t]++;
    }
    int ans = 1;
    for(auto e : Mp) ans = 1ll * ans * (e.se + 1) % P;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
int main(void){
    char str[1201][1201];
    int i,j;
    int cnt[30]={0};
    for(i=0;i<1200;i++){
        gets(str[i]);
        if(str[i][0]=='\0')
            break;
    }
    for(j=0;str[j][0]!='\0';j++)
        for(i=0;str[j][i]!='\0';i++)
            str[j][i]=tolower(str[j][i]);
    for(j=0;str[j][0]!='\0';j++)
        for(i=0;str[j][i]!='\0';i++)
            if(str[j][i]>='a' && str[j][i]<='z')
                cnt[str[j][i]-'a']++;
    for(i=0;i<26;i++){
        printf("%c : %d\n",'a'+i,cnt[i]);
    }
    return 0;
}

Measured memory_bytes: 528
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];

  using P = pair<Int, Int>;
  vector<P> vp;
  Int tmp=0;
  for(Int i=0;i<n;i++){
    if(tmp<as[i]){
      vp.emplace_back(i,tmp);
      tmp=as[i];
    }
  }
  vector<Int> bs(as);
  sort(bs.begin(),bs.end());
  vector<Int> sm(n+1,0);
  for(Int i=0;i<n;i++) sm[i+1]=sm[i]+bs[i];

  Int m=vp.size();
  vector<Int> res(m+1,0);
  for(Int i=0;i<m;i++){
    Int k=lower_bound(bs.begin(),bs.end(),vp[i].second)-bs.begin();
    //cout<<vp[i].second<<" "<<k<<":"<<bs[k]<<endl;
    res[i]=(sm[n]-sm[k])-(n-k)*vp[i].second;
    //cout<<i<<" "<<res[i]<<endl;
  }

  for(Int i=0;i<m;i++)
    res[i]-=res[i+1];

  vector<Int> ans(n);
  for(Int i=0;i<m;i++)
    ans[vp[i].first]=res[i];

  for(Int i=0;i<n;i++) cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()
 
#define cMOD 1000000007ULL
#define cINF ((1ll<<62)-1)
#define cINFINT ((1<<30)-1)
 
template<typename T>
T trisectionSearch( T begin, T end, const function<T(T index)>& func )
{
	T lb = begin, ub = end;
	REP( i, 300 /* doubleの精度(2^52)までに必要なループ数 */ )
	{
		T midL = ( lb * 2.0 + ub ) / 3.0;
		T midU = ( lb + ub * 2.0 ) / 3.0;
		// 極大値探索
		//if( func( midL ) < func( midU ) ) lb = midL;
		// 極小値探索
		if( func( midU ) < func( midL ) ) lb = midL;
		else ub = midU;
	}
	return ub;
}
/*template<typename T>
T trisectionSearchInteger( T begin, T end, const function<T(T index)>& func )
{
	T lb = begin-1, ub = end-1;
	while( lb <= ub - 3 )
	{
		T midL = ( lb * 2 + ub ) / 3;
		T midU = ( lb + ub * 2 ) / 3;
		// 極大値探索
		if( func( midL ) < func( midU ) ) lb = midL;
		// 極小値探索
		//if( func( midU ) < func( midL ) ) lb = midL;
		else ub = midU;
	}
	if( func( ub-1 ) < func( ub ) ) return ub;
	return ub-1;
}*/
 
int main()
{
	ll n; cin>>n;
	vector<double> x(n,0),y(n,0),ddx(n,0),ddy(n,0);
	REP(i,n)
	{
		string s; cin>>x[i]>>y[i]>>s;
		if( s[0] == 'R' ) { ddx[i]=1; ddy[i]=0; }
		if( s[0] == 'L' ) { ddx[i]=-1;ddy[i]=0; }
		if( s[0] == 'U' ) { ddx[i]=0; ddy[i]=1; }
		if( s[0] == 'D' ) { ddx[i]=0; ddy[i]=-1; }
	}

	auto calc = [&n,&x,&y,&ddx,&ddy]( double t ){
		double xM=-cINF,xm=cINF,yM=-cINF,ym=cINF;
		REP(i,n)
		{
			double xx = x[i]+ddx[i]*t;
			double yy = y[i]+ddy[i]*t;
			xM = max(xM,xx);
			xm = min(xm,xx);
			yM = max(yM,yy);
			ym = min(ym,yy);
		}
		return (xM - xm) * (yM - ym);
	};

	auto res = trisectionSearch<double>(0,100000000000.0,calc);
	cout << fixed << setprecision(16) << calc(res) << endl;
	
	return 0;
}

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

int main(){
    string s;cin>>s;
    int n=s.size();
    int a=-1,b=-1;
    for(int i=0;i<n-1;i++){
        if(s[i]==s[i+1]){
            a=i+1;b=i+2;
            cout<<a<<" "<<b<<endl;
            return 0;
        }
    }
    for(int i=0;i<n-2;i++){
        if(s[i]==s[i+2]){
            a=i+1;b=i+3;
            cout<<a<<" "<<b<<endl;
            return 0;
        }
    }
    cout<<a<<" "<<b<<endl;
    return 0;   

}

Measured memory_bytes: 512
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 r: i64 = input();
    let g: i64 = input();
    let b: i64 = input();
    println!(
        "{}",
        if (100 * r + 10 * g + b) % 4 == 0 {
            "YES"
        } else {
            "NO"
        }
    );
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;

int main() {

	int N;
	int i;
	int C0 = 0, C1 = 0, C2 = 0, C3 = 0;
	cin >> N ;
	string A[N];
	for (i = 0; i < N;i++) {
		cin >> A[i];
	}
	for (i = 0; i < N; i++) {
	
		if (A[i]=="AC") {
			C0++;
		
		}
		else if (A[i]=="WA") {
			C1++;
		}
		else if(A[i]=="TLE")
		{
			C2++;
		}
		else if (A[i]=="RE") {
			C3++;
		}
	
	}

	printf("AC x %d\n",C0);
	printf("WA x %d\n", C1);
	printf("TLE x %d\n", C2);
	printf("RE x %d\n", C3);
	return 0;
}

Measured memory_bytes: 6824
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
    fmt.Scan(&n)

	p := make([]int, n)
	for i := 0; i<n; i++ {
		fmt.Scan(&p[i])
	}
	pSort := make([]int, n)
	for i := 0; i<n; i++ {
		pSort[i] = p[i]
	}
	sort.Ints(pSort)
	var cnt int
	for i := 0; i<n; i++ {
		if pSort[i] != p[i] {
			cnt++
		}
	}
	if cnt > 2 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}

}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<Double> li = new ArrayList<Double>();
		for(int i = 0; i < N; i++) {
			li.add(sc.nextDouble());
		}
		Collections.sort(li);
		double sum = 0;
		for(int i = 1; i < N; i++) {
			if(i != 1) {
				sum = (sum + li.get(i)) / 2;
			}else {
				sum = (li.get(i) + li.get(i - 1)) / 2;
			}

		}
		System.out.println(sum);

	}

}

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

int main(){
    string s;
    cin >> s;
    int ans1 = 0, ans2 = 0;
    for(int i=0; i<s.length(); i++){
        if(i%2==0){
            if(s[i]=='1'){
                ans1++;
            }
        }
        else{
            if(s[i]=='0'){
                ans1++;
            }
        }
    }
    for(int i=0; i<s.length(); i++){
        if(i%2==0){
            if(s[i]=='0'){
                ans2++;
            }
        }
        else{
            if(s[i]=='1'){
                ans2++;
            }
        }
    }
    cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll x,y;
  cin >> x >> y;
  cout << x+y/2 << endl;
}

Measured memory_bytes: 256
N, L = list(map(lambda x: int(x), input().split(" ")))
 
S = int(N * (N-1) / 2) + L * N
 
if L >= 0:
  print(S - L)
elif L + N - 1 <= 0:
  print(S - L - N + 1)
else:
  print(S)

Measured memory_bytes: 9160
N = input()
T, A = map(int, input().split())
H = list(map(int, input().split()))

ans=0
mindif=float("inf")
i=0
for h in H:
    i+=1
    dif = abs(T-h*0.006-A)
    if dif < mindif:
        mindif = dif
        ans=i
print(ans)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <cstdio>
using namespace std;

int main(void) {
	double r=0.0;
	cin >> r;

	printf("%f %f\n", M_PI*r*r, 2*r*M_PI);
	
	
	//cout << M_PI*r*r << " " << 2 * r*M_PI << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 1232