akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    int sum = 0;
    int sq = 0;
    REP(i, n){
        int a;
        cin >> a;
        sum += a;
        sq += a * a;
    }

    cout << (sum * sum - sq) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        StringBuilder sb = new StringBuilder();
        int n = sc.nextInt();
        int e = 0;
        int imax = n-(n%2);
        for(int i = 1; i <= imax; i++){
            for(int j = i+1; j <= imax; j++){
                if(i+j == imax+1){
                    continue;
                }
                e++;
                sb.append(i + " " + j).append("\n");
            }
        }
        if(n % 2 != 0){
            for(int i = 0; i < n-1; i++){
                e++;
                sb.append((i+1) + " " + n).append("\n");
            }
        }
        pw.println(e);
        pw.print(sb.toString());
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 27184
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775802
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, M, P;
	cin >> N >> M >> P;
	
	VI a(M), b(M), c(M), dis(N);
	REP(i, N)
		dis[i] = -LLINF;
	REP(i, M) {
		cin >> a[i] >> b[i] >> c[i];
		c[i] -= P;
	}
	dis[0] = 0;

	int tmp;


	REP(j,2*(N - 1)) {
		REP(i, M) {
			
			if (dis[a[i] - 1] == -LLINF)continue;

			if (a[i] == b[i] && c[i]>0)c[i]=LLINF;


			if (c[i] == LLINF) {
				dis[b[i] - 1] = LLINF;
			}
			else if (dis[a[i] - 1] == LLINF) {
				dis[b[i] - 1] = LLINF;
			}
			else if (dis[b[i] - 1] < dis[a[i] - 1] + c[i]) {
				dis[b[i] - 1] = dis[a[i] - 1] + c[i];
			}
		}
		
		//cout << dis[0] << " " << dis[1] << " " << dis[2] << endl;

		if (j == N - 2) {
			tmp = dis[N - 1];
		}

	}


	
	if(tmp!=dis[N-1] || dis[N-1]==LLINF){
		cout << -1 << endl;
	}
	else cout << max(0LL, dis[N - 1]) << endl;
	


	return 0;
}



Measured memory_bytes: 384
#include<stdio.h>
long long w[101],c[101],f[100009]={0}; 
int main() {   
    int m,n,i,v;     
//	freopen("d.in", "r", stdin);
//	freopen("d.out", "w", stdout);
    scanf("%d %d",&n,&m);   
    for(i=1;i<=n;i++) scanf("%d %d",&w[i],&c[i]);   
    for(i=1;i<=n;i++)   
       for(v=m;v>=w[i];v--)   
          if(f[v]<f[v-w[i]]+c[i]) f[v]=f[v-w[i]]+c[i];   
    printf("%lld",f[m]);   
    return 0;   
}  


Measured memory_bytes: 896
use proconio::*;

fn solve1(n: u64) -> usize {
    let mut is_prime = vec![true; 1000010];
    is_prime[0] = false;
    is_prime[1] = false;

    let mut n = n;

    let mut ans = 0;
    for i in 2..1000010u64 {
        if is_prime[i as usize] {
            let mut tmp = 0;
            while n % i == 0 {
                tmp += 1;
                n /= i;
            }

            for k in 1..50 {
                if tmp >= k {
                    ans += 1;
                    tmp -= k;
                } else {
                    break;
                }
            }

            if i*i >= 1000010 {
                continue;
            }
            for j in (i*i..1000010u64).step_by(i as usize) {
                is_prime[j as usize] = false;
            }
        }
    }

    if n > 1 {
        ans += 1;
    }

    ans
}

fn main() {
    input!{
        mut n: u64,
    }

    println!("{}", solve1(n));
}


Measured memory_bytes: 3072
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    int ans = -1;
    rep(i, n) {
      vector<int> alp(26);
      int count = 0;
      string t, u;
      t = s.substr(0, i + 1);
      rep(j, t.size()) {
        alp[t[j] - 'a']++;
      }
      u = s.substr(i + 1, s.size() - i + 1);
      rep(j, u.size()) {
        if (alp[u[j] - 'a'] > 0) {
          alp[u[j] - 'a'] = 0;
          count++;
        }
      }
      ans = max(ans, count);
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 100005
#define INF 1000000
using namespace std;
 
int main(){
  int k, a[MAX];
  deque<int> dq;
  scanf("%d", &k);
  for(int i = 0; i < MAX; i++) a[i] = INF;
  a[1] = 1; dq.push_front(1);
  while(!dq.empty()){
    int t = dq.front(); dq.pop_front();
    if(a[t*10%k] > a[t]){
      a[t*10%k] = a[t];
      dq.push_front(t*10%k);
    }
    if(a[(t+1)%k] > a[t] + 1){
      a[(t+1)%k] = a[t] + 1;
      dq.push_back((t+1)%k);
    }
  }
  printf("%d\n", a[0]);
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define sz() size()
#define fr first
#define sc second
#define int long long
#define mp make_pair
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
using namespace std;

const int mod = 1e9+7;
const int nmax = 500005;

int n,m,fact[nmax],ans;

int lgp(int a,int b){
    int res = 1LL, pop = a;
    for(int i=0LL;(1LL<<i)<=b;i++){
        if(b & (1LL<<i)){
            res = (res * pop)%mod;
        }
        pop = (pop * pop)%mod;
    }
    return res;
}

int inv(int x){
    return lgp(x,mod-2);
}

int arr(int k,int n){
    if(k > n) return 0;
    if(k < 0) return 0;
    if(n < 0) return 0;
    int ans = fact[n];
    ans = ans*inv(fact[n-k])%mod;
    return ans;
}

int comb(int k,int n){
    if(k > n) return 0;
    if(k < 0) return 0;
    if(n < 0) return 0;
    int ans = fact[n];
    ans = ans*inv(fact[k])%mod;
    ans = ans*inv(fact[n-k])%mod;
    return ans;
}

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    srand(chrono::steady_clock::now().time_since_epoch().count());
    cin >> n >> m;
    fact[0] = 1;
    for(int i=1;i<=m;i++){
        fact[i] = (fact[i-1]*i)%mod;
    }
    for(int i=1;i<=n;i++){
        ans = (ans + lgp(-1,i-1)*comb(i,n)%mod*arr(i,m)%mod*arr(n-i,m-i)%mod*arr(n-i,m-i)%mod)%mod;
    }
    ans = (arr(n,m)*arr(n,m)%mod - ans + mod) % mod;
    rc(ans);
}





Measured memory_bytes: 7520
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    x = input()

    cnt_S = 0
    cnt_T = 0
    res = 0
    i = 0
    while i < len(x):
        if x[i] == "S":
            cnt_S += 1
            i += 1

        elif x[i] == "T" and cnt_S != 0:
            while i < len(x) and x[i] == "T":
                cnt_T += 1
                i += 1
            res += min(cnt_S, cnt_T) * 2
            cnt_S -= min(cnt_S, cnt_T)
            cnt_T = 0
        else:
            i += 1

    print(len(x) - res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 40672
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}

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

  return gcd(b, a%b);
}


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

/*
n
a1 ... an

n 3000
ai 10^5
 */
int n,a[3000];

int main(){
  cin>>n;
  int ans=0;
  REP(i,n){
    cin>>a[i];
    ans += a[i] - 1;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

H = list(map(int, input().split()))

S = [True]*N

for _ in range(M):
  a, b = map(int, input().split())
  if H[a-1] == H[b-1]:
    S[b-1] = False
    S[a-1] = False
  elif H[a-1] > H[b-1]:
    S[b-1] = False
  else:
    S[a-1] = False

print(sum(S))

Measured memory_bytes: 20144
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int w,h;
char s[99][99];
int cost[60][30][60][30][2];

struct Node{
  int lx,ly,rx,ry;
  int foot,cost;
  bool operator<(const Node &r)const{
    return cost>=r.cost;
  }
};
bool ok(Node &node){
  int lx=node.lx,rx=node.rx,ly=node.ly,ry=node.ry;
  if(lx<0||rx<0||ly<0||ry<0||lx>=w||rx>=w||ly>=h||ry>=h)return 0;
     if(s[ly][lx]=='X'||s[ry][rx]=='X')return 0;
     return lx<rx&&abs(lx-rx)+abs(ly-ry)<=3;
}

int main()
{
  while(cin>>w>>h,w){
  
    rep(i,h)rep(j,w)rep(ii,h)rep(jj,w)rep(k,2)cost[i][j][ii][jj][k]=inf;

    priority_queue<Node>Q;
    rep(i,h)rep(j,w){
      cin>>s[i][j];
      if(s[i][j]=='S'){
	Node node;
	node.ry=-inf,node.rx=-inf;
	node.ly=i,node.lx=j; node.foot=node.cost=0;
	Q.push(node);
	swap(node.ry,node.ly); swap(node.rx,node.lx);
	node.foot=1;
	Q.push(node);
      }
    }
    int ans=inf;
    while(!Q.empty()){
      Node cur=Q.top();
      //dbg(cur.ly);dbg(cur.lx);dbg(cur.ry);dbg(cur.rx);
      //dbg(cur.cost);dbg(cur.foot);
      Q.pop();
    
      if(ok(cur)&&(s[cur.ly][cur.lx]=='T'||s[cur.ry][cur.rx]=='T')){
	ans=cur.cost; break;
      }

      for(int dy=-3;dy<=3;dy++)for(int dx=-3;dx<=3;dx++){
	Node node=cur;
	int y,x;
	if(node.foot==0)y=node.ry=node.ly+dy,x=node.rx=node.lx+dx;
	else y=node.ly=node.ry+dy,x=node.lx=node.rx+dx;
	node.foot^=1;
	if(!ok(node))continue;

	node.cost+=isdigit(s[y][x])?s[y][x]-'0':0;
	int &c=cost[node.ly][node.lx][node.ry][node.rx][node.foot];
	if(node.cost>=c)continue;
	
	c=node.cost;
	Q.push(node);
      }
    }
    cout<<(ans==inf?-1:ans)<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 25000
import math
a,b,C=list(map(int,input().split()))
s=(a*b)*math.sin(math.radians(C))/2
L=a+b+math.sqrt(a*a+b*b-2*a*b*math.cos(math.radians(C)))
H=b*math.sin(math.radians(C))
print(s)
print(L)
print(H)


Measured memory_bytes: 5704
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    long long sum=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++){
                    if(a[i]+a[j]>a[k]) sum++;
                }
        }
    }
    cout<<sum;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long  a,b,c;
	long long k;
	cin>>a>>b>>c>>k;
	long long sum=0;
	while(k!=0)
	{
		if(k<=a){
			sum=sum+k;
			k=0;
		}
		else{
			if(k<=(a+b)){
				sum=sum+a;
				k=0;
			}
			else{
				if(k<=(a+b+c)){
					sum=sum+a-(k-(a+b));
					k=0;
				}
			}
		}
//      2 1 1 3		
//		1 2 3 4 
	}
	cout<<sum<<"\n";
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {

        void solve(InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int K = in.nextInt();
            Integer[] H = new Integer[N];
            for (int i = 0; i < N; ++i) H[i] = in.nextInt();
            Arrays.sort(H);
            
            long sum = 0;
            for (int i = 0; i < Math.max(0, N - K); ++i) {
                sum += H[i];
            }
            out.println(sum);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}


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

int main() {
  int Alice,Bob;
  int n;
  Alice = Bob =0;
  cin >> n;
  vector<int> a(n);
  
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  for(int i=0;(2*i<n)||(2*i+1<n);i++){
    if(2*i<n) Alice += a.at(2*i);
    if(2*i+1<n) Bob += a.at(2*i+1);
  }
  cout << abs(Alice-Bob) << endl;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main(){
    input!{
        n:i64,
        m:i64,
        c:i64,
        bm:[i64;m],
        anm:[[i64;m];n],
    }
    let ans = anm.iter().fold(0,|res,am|{
        let sum = am.iter().zip(bm.iter()).fold(0,|y,(a,b)|{
            y + a*b
        })+c;
        if sum > 0 {
            res + 1
        } else {
            res
        }
    });
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
#include <fstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include<iomanip>
#define sqr(x) (x)*(x)
#define ll long long
using namespace std;
int n,m,i,j,dp[100005],used[100005],x;
vector<int> bi[100005];
void dfs(int x)
{
	used[x]=1;
	int i;
	vector<int> win;
	for (i=0;i<bi[x].size();i++)
	{
		if (!used[bi[x][i]]) dfs(bi[x][i]);
		win.push_back(dp[bi[x][i]]); 
	}
	sort(win.begin(),win.end());
	for (i=0;i<bi[x].size();i++)
	{
		 dp[x]=max(int(win[i]+bi[x].size()-i-1),dp[x]);
	}
	dp[x]++;
}
int main()
{
	cin>>n;
	for (i=2;i<=n;i++)
	{
		cin>>x;
		bi[x].push_back(i);
	}
	dfs(1);
	cout<<dp[1]-1;
	return 0;
}

Measured memory_bytes: 14336
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
        int int1 = Integer.parseInt(scan.next());
        int int2 = Integer.parseInt(scan.next());
//        int int3 = Integer.parseInt(scan.next());
//        String temp_str1 = "";
//        String temp_str2 = "";
        int temp_int1 = 0;
//        String str1 = scan.next();
//        String str2 = scan.next();
//        String str3 = scan.next();
        int ans_int = 0;
        String ans = "";
//        double ans_dob = 0;
        if(int2+int1>=10){
            ans = "error";
        }else{
            ans = String.valueOf(int2+int1);
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(ans);
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 21844
def insertionSort(A):
	for i in range(1, len(A)):
		j = A[i]
		k = i
		while k - 1 >= 0:
			if A[k - 1] > j:
				A[k] = A[k - 1]
				A[k - 1] = j
			k = k - 1
	return A


def insertionSort(m, A, CNT):
	for i in range(m, len(A)):
		j = A[i]
		k = i
		while k - m >= 0 and A[k-m] > j:
			A[k] = A[k - m]
			A[k - m] = j
			CNT = CNT + 1
			k = k - m
#	while k - m >= 0:
#		if A[k - m] > j:
#			A[k] = A[k - m]
#			A[k - m] = j
#			CNT = CNT + 1
#		k = k - m
	return A, CNT


n = int(input())  # 例:6
a = []  # 例:[1, 4, 3, 6, 2, 5]
for i in range(0, n):
	a.append(int(input()))
cnt = 0

M = []
temp = 1
while temp <= n:
	M.append(temp)
	temp = 3 * temp + 1
M.sort(reverse=True)
#M=[1]
for j in M:
	a, cnt = insertionSort(j, a, cnt)

print(len(M))
print(' '.join([str(n) for n in M]))
print(cnt)
for k in a:
	print(k)



Measured memory_bytes: 45524
S = input().strip()
while len(S)>0:
	if S[-5:]=="dream":
		S = S[:len(S)-5]
		continue
	if S[-7:]=="dreamer":
		S = S[:len(S)-7]
		continue
	if S[-5:]=="erase":
		S = S[:len(S)-5]
		continue
	if S[-6:]=="eraser":
		S = S[:len(S)-6]
		continue
	print("NO")
	break
else:
	print("YES")


Measured memory_bytes: 3316
import java.util.*;
 
public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();

        Map<Integer, Integer> toN = new HashMap<>();
        int[][] a = new int[2][M];
        for(int i = 0; i < M; i++){
            a[0][i] = sc.nextInt();
            a[1][i] = sc.nextInt();
            if(a[1][i] == N){
                toN.put(a[0][i], N);
            }
        }
        sc.close();

        for(int i = 0; i < M; i++){
            if(a[0][i] == 1){
                if(toN.containsKey(a[1][i])){
                    System.out.println("POSSIBLE");
                    return;
                }
            }
        }
        System.out.println("IMPOSSIBLE");
    }
}

Measured memory_bytes: 111336
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
          if ( a > b ){
            System.out.println("a > b");
          }
          else if (a < b ){
            System.out.println("a < b");
          }
          else if ( a == b ){
            System.out.println("a == b");
          }
        }
      }


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


int main() {

  int a,b,c,d,sum;
  string s,t;
  cin>>a>>b;
  
  sum=0;
  for(int i=1;i<=b-a;i++){
  	sum += i;
  }
  sum -= b;
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (N, M) = nextIntList()
    val vote = IntArray(M + 1)
    repeat(N) {
        val A = nextIntList().drop(1)
        for (a in A) vote[a]++
    }
    println(vote.count { it == N })
}

Measured memory_bytes: 36020
#include<iostream>
#include<queue>
#include<cstring>
using namespace std;
int col[3300][3300];
int h, w, k, x_1, x_2, y_1, y_2, cnt, V, W;
queue<int>Q;
#define INF 1000000007
void A(int B, int C) {
	if (col[B][C] == 0) { Q.push(B * 10000 + C); col[B][C] = cnt; }
}
int main() {
	while (true) {
		memset(col, 0, sizeof(col));
		cin >> h >> w;
		if (h == 0 && w == 0) { break; }
		cin >> k;
		for (int i = 0; i < k; i++) {
			cin >> x_1 >> y_1 >> x_2 >> y_2;
			for (int j = y_1; j < y_2; j++) {
				for (int k = x_1; k < x_2; k++) {
					col[j][k] = INF;
				}
			}
		}
		cnt = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (col[i][j] == 0) {
					col[i][j] = 1;
					Q.push(i * 10000 + j);
					cnt++;
					while (!Q.empty()) {
						V = Q.front() / 10000;
						W = Q.front() % 10000;
						if (V != 0) { A(V - 1, W); }
						if (W != 0) { A(V, W - 1); }
						if (V != h - 1) { A(V + 1, W); }
						if (W != w - 1) { A(V, W + 1); }
						Q.pop();
					}
				}
			}
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 43772
#include <algorithm>
#include <iostream>
#include <vector>

void input_skewers(std::vector<int>& v) {
    int n, e, i;
    std::cin >> n;
    n *= 2;
    if (n > v.capacity()) {
        v.reserve(n);
    }
    for (i = 0; i < n; i++) {
        std::cin >> e;
        v.push_back(e);
    }
}

int main(int argc, char* argv[]) {
    int i = 0;
    int sum = 0;
    std::vector<int> skewers;
    input_skewers(skewers);
    std::sort(skewers.begin(), skewers.end());
    std::for_each(skewers.begin(), skewers.end(), 
        [&i, &sum](int& e) { 
            if (i % 2 == 0) {
                sum += e;
            }
            ++i;
        });
    std::cout << sum << std::endl;
    return 0;
}

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

int main(void)
{
        int n = 0, i = 0, flag1 = 10, flag2 = 0;
        double x1 = 0, x2 = 0, x3 = 0, x4 = 0;
        double y1 = 0, y2 = 0, y3 = 0, y4 = 0;
        double a12 = 0, a34 = 0;

        scanf("%d",&n);

        for(i = 0; i < n; i++)
        {
                scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);


                if( x1 - x2 == 0)
                {
                        flag1 = 1;
                }
                else if( y1 - y2 == 0)
                {
                        flag1 = 2;
                }
                else if(x1-x2 != 0.0 )
                {
                        a12 =(y1-y2)/(x1-x2);
                }


                if(x3-x4 == 0)
                {
                        flag2 = 1;
                }
                else if(y3-y4 == 0)
                {
                        flag2 = 2;
                }
                if(x3-x4 != 0.0 )
                {
                        a34 =(y3-y4)/(x3-x4);
                }


                if(flag1 == flag2)
                {
                        printf("YES\n");
                }
                else if(fabs(a12 - a34) < 0.000000001 && (flag1 == 10 && flag2 == 0))
                {
                        printf("YES\n");
                }
                else
                {
                        printf("NO\n");
                }
                flag1 = 10;
                flag2 = 0;
        }
        return 0;
}

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

int gcd(int a, int b)
{
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}


string s;

int main(){
  cin >> s;
  int y = stoi(s.substr(0,4));
  int m = stoi(s.substr(5,2));
  int d = stoi(s.substr(8,2));
  if(m >= 5 ) cout << "TBD" << endl;
  else cout << "Heisei" << endl;
}


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

typedef long long lint;

lint gcd(lint x, lint y){
  lint r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

int main(){
  lint n;
  cin >> n;
  cout << 2 / gcd(2, n) * n << endl;
  return 0;
}

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

int main()
{
    int n, m, x, minus, plus;
    cin >> n >> m >> x;
    minus = plus = 0;
    while(m--){
        int tmp;
        cin >> tmp;
        if(tmp < x && tmp > 0) minus++;
        else if(tmp > x && tmp < n) plus++;
    }
    cout << min(minus, plus) << endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    char s[n+1];
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    int A[n][26];
    int B[n][26];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 26; j++){
            A[i][j] = 0;
            B[i][j] = 0;
        }
    }
    int max = 0;
    for(int i = 1; i < n; i++){
        int sum = 0;
        for(int j = 0; j < i; j++){
            A[i][s[j] - 'a']++;
        }
        for(int j = i; j < n; j++){
            B[i][s[j] - 'a']++;
        }
        for(int j = 0; j < 26; j++){
            if(A[i][j] > 0 && B[i][j] > 0){
                sum++;
            }
        }
        if(sum > max)max = sum;
    }

    cout << max << endl;

    return 0;
}

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

using namespace std;
using ll = long long;

const long long INF = 1LL << 60;
const int MOD = 1000000007;

bool hasElement(const set<int>& st, int key){
    auto itr = st.find(key);
    if(itr != st.end()){
        return true;
    }
    return false;

}

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

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

    // しゃくとり法
    ll ans = 0;
    int right = 0;
    int sum = 0;
    for (int left = 0; left < n; ++left) {
        while (right < n && ( (sum ^ a[right]) == (sum + a[right]) )) {
            sum += a[right];
            ++right;
        }
        ans += (right - left);
        if (left == right){
            ++right;
        }
        else{
            sum -= a[left];
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define f                           first
#define s                           second
#define task                        "test"
#define fi			                freopen(task".inp", "r", stdin)
#define fo			                freopen(task".out", "w", stdout)
#define reset(a, b)                 memset(a, b, sizeof(a))
#define MAX(a, b)                   a = max(a, b)
#define MIN(a, b)                   a = min(a, b)
 
using namespace std;
 
typedef long long                   LL;
typedef pair<int,int>               II;
 
const LL mod = 1e9 + 7;
const LL N   = 1e5 + 5;
 
/* ------------- ------------- ------------- ------------- ------------- ------------- ------------- */
string k;
long long dp[10005][100][2];
int d;
 
long long calc(int idx, int sum, bool t)
{
    if (idx == k.size())
        return (!sum) ? 1 : 0;
    if (dp[idx][sum][t] != -1)
        return dp[idx][sum][t];
    int m = (t) ? (k[idx] - 48) : 9;
    LL res = 0;
    for (int i = 0; i <= m; i++)
    {
        bool nt = (i == (k[idx] - 48)) ? t : 0;
        res = ((LL) res + calc(idx + 1, (sum + i) % d, nt)) % mod;
    }
    return dp[idx][sum][t] = res;
}
 
void solve()
{
    cin >> k >> d;
    reset(dp, -1);
    cout << (calc(0, 0, 1) - 1 + mod) % mod;
}
 
int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(0); cout.tie(0);
//    fi;
//    fo;
    solve();
    return 0;
}

Measured memory_bytes: 16896
#include<bits/stdc++.h>
#define MAX 100
using namespace std;

int h,w,ans=0;
bool grid[MAX][MAX]={};
bool visited[MAX][MAX]={};
int X[4]={1,0,-1,0};
int Y[4]={0,1,0,-1};

void init(){
  ans=0;
  for(int i=0;i<MAX;i++){
    for(int j=0;j<MAX;j++){
      grid[i][j]=false;
      visited[i][j]=false;
    }
  }
}

bool in(int a,int b){
  if(a<0 || b<0 || w<=b || h<=a)return false;
  return true;
}

void dfs(int a,int b,int sum){
  visited[a][b]=true;
  ans=max(ans,sum);
  for(int i=0;i<4;i++){
    int na=a+Y[i],nb=b+X[i];
    if(!in(na,nb))continue;
    if(!grid[na][nb])continue;
    if(visited[na][nb])continue;
    dfs(na,nb,sum+1);
  }
  visited[a][b]=false;
}

int main()
{
  while(1){
    cin>>w>>h;
    if(w+h==0)break;
    init();
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++)cin>>grid[i][j];
    }
    
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++)dfs(i,j,0);
    }
    
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1180
import numpy as np
import math
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b

    return a

def multi_gcd(*numbers):
    return reduce(gcd, numbers)

N, X = map(int, input().split(' '))
city = np.array(list(map(int, input().split(' '))))

city -= X
print(abs(multi_gcd(*city)))

Measured memory_bytes: 23120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,Y;
  cin >> N >> Y;
  int EN10000=-1,EN15000=-1,EN1000=-1;
  
  for(int i=0; i<=N; i++){
    for(int j=0; j<=N; j++){
      int s = Y - i*10000 - j*5000;
      int sn = N - i - j;
      if ( s == sn*1000 && sn >= 0 ) {
        EN10000 = i;
        EN15000 = j;
        EN1000 = sn;
        break;
      }
    }
  }

  cout << EN10000 << " " << EN15000 << " " << EN1000 << endl;
  
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C, long long D){
    while (true) {
        C -= B;
        if (C <= 0) {
            cout << YES << endl;
            return;
        }
        A -= D;
        if (A <= 0) {
            cout << NO << endl;
            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)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    solve(A, B, C, D);
    return 0;
}


Measured memory_bytes: 3768
a = str(input()).split()
n = 0
if int(a[1]) < 10:
    n = 10
elif int(a[1]) < 100:
    n = 100
else:
    n = 1000
b = int(a[0]) * n + int(a[1])
for i in range(1,400):
    if b == i * i:
        print('Yes')
        break
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main (void) {
	int n; cin >> n;
	vector <int> v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	long long op = 0;
	long long prev_sum = 0;

	for (int i = 0; i < n; i++) {
		long long new_sum = prev_sum + v[i];
		if (i == 0 && v[i] != 0)
			prev_sum = new_sum;
		else if (i == 0 && v[i] == 0) {
			op += 1;
			prev_sum = 1;
		}
		else if (prev_sum >= 0 && new_sum >= 0) {
			op += new_sum + 1;
			prev_sum = -1;
		}
		else if (prev_sum <= 0 && new_sum <= 0) {
			op += -new_sum + 1;
			prev_sum = 1;
		}
		else
			prev_sum = new_sum;
	}
	prev_sum = 0;
	long long op2 = 0;
	for (int i = 0; i < n; i++) {
		long long new_sum = prev_sum + v[i];
		if (i == 0 && v[i] != 0)
			prev_sum = new_sum;
		else if (i == 0 && v[i] == 0) {
			op2 += 1;
			prev_sum = -1;
		}
		else if (prev_sum >= 0 && new_sum >= 0) {
			op2 += new_sum + 1;
			prev_sum = -1;
		}
		else if (prev_sum <= 0 && new_sum <= 0) {
			op2 += -new_sum + 1;
			prev_sum = 1;
		}
		else
			prev_sum = new_sum;
	}
	prev_sum = 0;
	long long op3 = 0;
	
	for (int i = 0; i < n; i++) {
		long long new_sum = prev_sum + v[i];
		if (i == 0 && v[i] > 0) {
			op3 += new_sum + 1;
			prev_sum = -1;
		}
		else if (i == 0 && v[i] < 0) {
			op3 += -new_sum + 1;
			prev_sum = 1;
		}
		
		else if (prev_sum >= 0 && new_sum >= 0) {
			op3 += new_sum + 1;
			prev_sum = -1;
		}
		else if (prev_sum <= 0 && new_sum <= 0) {
			op3 += -new_sum + 1;
			prev_sum = 1;
		}
		else
			prev_sum = new_sum;
	}
	
	//long long a = min (op2, op3);
	
	// cout << min(op, min(op4,a)) << endl;
	cout << min(op3,min(op,op2)) << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		String xx = "";
		
		for(int i=0;i<S.length();i++) {
			xx += "x";
		}
		
		System.out.println(xx);
	}
}

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

int main() {
	int get_gcd(int x, int y);
	int x, y;
	cin >> x >> y;
	int gcd = get_gcd(x, y);
	cout << gcd << endl;
}

int get_gcd(int x, int y) {
	// Euclidean Algorithm
	int r;
	if (x<y) swap(x, y);
	while (y >0) {
		r = x%y;
		x=y;
		y=r;
	}
	return x;
}


Measured memory_bytes: 3096
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

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

map<char, int> mp;

int main(){
	string s;
	while(getline(cin, s)){
		int n = s.size();
		rep(i, n) mp[s[i]]++;
		cout << min(min(mp['K'], mp['U']), min(mp['P'], mp['C'])) << endl;
		mp.clear();
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll N;
  string S;
  IN(N);
  IN(S);

  ll ans = 0;
  REP(i,N-2){
    if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') ans++;
  }

  OUT(ans);

  return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,x,y;
lol i[10000];
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    lol c,d=0,e=0,f=0,g=1,h=0;
    cin >>a>>b;
    for(int n=0;n<a;n++){
	cin >>i[n];
	if(i[n]%2==0) x++;
	else y++;
    }
    if(y){
	cout <<setprecision(64)<<pow(2,a-1)<<'\n';
    }else{
	if(b){
	    cout <<setprecision(64)<<0<<'\n';
	}
	else cout <<setprecision(64)<<pow(2,a)<<'\n';
    }
    return (0);
}


Measured memory_bytes: 256
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2020 Bjarni Dagur Thor Karason

#include <bits/stdc++.h>

using namespace std;

#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); i++)
#define MP make_pair
#define PB push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
#define PI 3.14159265359

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (a + b >= k) cout << min(a, k) << endl;
    else cout << a - (k - a - b) << endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> b(n), ans;
  for (int i = 0; i < n; i++) {
    cin >> b.at(i);
    b.at(i)--;
  }
  for (int i = 0; i < n; i++) {
    int bmax = -1;
    for (int j = 0; j < b.size(); j++) {
      if (b.at(j) == j) bmax = j;
    }
    if (bmax == -1) {
      cout << -1 << endl;
      return 0;
    }
    ans.push_back(bmax + 1);
    b.erase(b.begin() + bmax);
  }
  for (int i = n - 1; i >= 0; i--) {
    cout << ans.at(i) << endl;
  }
}


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int c = 0;
    for (int i = 0;i < 3;i++){
        if (n%10 == 7){
            c = 1;
            break;
        }
        n = n/10;
    }
    if (c == 1){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1234567890


int main(){
    ll i,j;
    ll n;
    cin>>n;
    cout<<n*(n-1)/2<<endl;
    return 0;
    

    return 0;   
}

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



int main(){
	vector<int> a;
	int temp;
	for(int i=0; i<3; ++i){
		cin >> temp;
		a.push_back(temp);
	}
	sort(a.begin(), a.end());
	
	cout << a[0]+a[1] ;
	
	return 0;
}

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

n = int(input())
w = ["" for i in range(n)]

for i in range(n):
    w[i] = input()

#重複なしかチェック
hasNoDuplicate = True
if len(set(w)) == len(w):
    pass
else:
    hasNoDuplicate = False

#しりとりになっているかチェック
isShiritori = True
for i in range(n):
    if i == 0:
        last = list(w[i])[-1]
    else:
        #前のlastと同じか確認
        if last == list(w[i])[0]:
            pass
            #文字を更新
            last = list(w[i])[-1]
        else:
            isShiritori = False
            break

if (isShiritori) and (hasNoDuplicate):
    print("Yes")
else:
    print("No")

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

int main(void)
{
	char ring[21];
	char temp[11];
	char search_ring[11];
	int num;
	int ok;
	int i, j;
	
	scanf("%s", search_ring);
	getchar();
	
	scanf("%d", &num);
	
	ok = 0;
	
	for (i = 0; i < num; i++){
		scanf("%s", ring);
		strcpy(temp, ring);
		strcat(ring, temp);
		
		for (j = 0; j < 10; j++){
			if (strncmp(search_ring, &ring[j], strlen(search_ring)) == 0){
				ok++;
				break;
			}
		}
	}
	
	printf("%d\n", ok);
	
	return (0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    //ios_base::sync_with_stdio(0);
    ll a;
    while(cin>>a){
        ll ans = a-1;
        int found = 0;
        for(ll i=1; i*i<=a; i++){
            if(a%i==0){
                ans = min(ans, (i + a/i)-2);
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256