akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>     
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#define INF 2000000
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define mk make_pair
#define en endl
#define RE return 0
//#define int ll
#define P pair<int,int>
using namespace std;
int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}
int lcm(int a,int b){if(a==0){return b;} return a/gcd(a,b)*b;}    

int main(){
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;

	int ans=0;
	if(m1>m2) ans=(h2-h1-1)*60+60-m1+m2;
	else ans=(h2-h1)*60+m2-m1;

	cout<<ans-k<<endl;
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    vec p(n);
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }

    int res = 0;

    rep(i, n-1) {
        if (p[i] == i) {
            swap(p[i], p[i+1]);
            res++;
        }
    }
    if (p[n-1] == n-1) res++;

    cout << res << endl;
    return 0;
}

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

using ll = long long int;
using P = pair<ll, ll>;
using P3 = pair<double,P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9+7);
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-8;


int main(){
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
#define int long long
//template
/*
問題の言い換え
//0の行き先が0じゃなかったら0にしてans++;
0を根とする根付き木を考える
各部分根付き木の深さが(根の深さを0として）K以下になるように分解するとき最小でいくつに分解しないといけないか
これは葉から決めていけばよさそう
*/
//main
signed main(){
  int N,K,ans=0;cin>>N>>K;
  std::vector<int> v(N),in(N,0),depth(N,1);;
  for(int i=0;i<N;i++)cin>>v[i],v[i]--;
  if(v[0])ans++;v[0]=0;
  for(int i=0;i<N;i++)in[v[i]]++;
  queue<int> que;
  for(int i=0;i<N;i++)if(!in[i])que.push(i);
  while(que.size()){
    int p=que.front();que.pop();if(p==0)continue;
    if(depth[p]==K&&v[p])depth[p]=0,ans++;
    depth[v[p]]=max(depth[v[p]],depth[p]+1);
    if(!--in[v[p]])que.push(v[p]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3456
// Problem : D - Derangement
// Contest : AtCoder Regular Contest 082
// URL : https://atcoder.jp/contests/arc082/tasks/arc082_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define size(x) (int)x.size()

const int N = 1e6 + 1, mod = 1e9 + 7, inf = 2e9;

int n, ans = 0, p[N];

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> p[i];
	}
	for (int i = 1; i < n; i++) {
		if (p[i] == i) {
			swap(p[i], p[i + 1]);
			ans++;
		}
	}
	if (p[n] == n) ans++;
	cout << ans;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(void) {
	int N; cin >> N;
	vector<string> W;
	for (int i = 0; i < N; i++) {
		string w; cin >> w;
		if (i != 0 && w.at(0) != W.at(i-1).at(W.at(i-1).size() - 1)) {
			cout << "No" << endl; return 0;
		}
		for (auto j:W)
			if (j == w) {
				cout << "No" << endl; return 0;
			}
		W.push_back(w);
	}

	cout << "Yes" << endl;
	//for (auto i : W) cout << i << endl;
}
// vectorの最後尾の参照に-1を使えない
// 文字列の末尾を参照する方法は？


Measured memory_bytes: 256
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A, B, K = get_ints

a = A
b = B

if K <= A
  a -= K
else
  a = 0
  b = B - (K - A)
  b = 0 if b < 0
end

puts "#{a} #{b}"


Measured memory_bytes: 14508
# Node
class Node
  attr_accessor :id, :parent, :children

  def initialize(id, parent = nil, children = [])
    @id, @parent, @children = id, parent, children
  end
end

# RootedTree
class RootedTree
  attr_accessor :nodes

  def initialize(data)
    @nodes = data.each_with_object({}) do |(key, value), hash|
      hash[key] = Node.new(key, value[:parent], value[:children])
    end
  end

  def depth(id)
    node = @nodes[id]
    unless node.parent.nil?
      return depth(node.parent) + 1
    else
      return 0
    end
  end

  def root?(id)
    node = @nodes[id]
    node.parent.nil?
  end

  def leaf?(id)
    node = @nodes[id]
    node.children.empty?
  end
end

data = {}
children = {}

n = gets.chop.to_i

n.times do
  id, k, *c = gets.chop.split.map(&:to_i)
  data[id] = {}
  data[id][:children] = c
  c.each do |child|
    children[child] = id
  end
end

data = Hash[data.sort]

data.each do |key, value|
  value[:parent] = (!children[key].nil?) ? children[key] : nil
end

t = RootedTree.new(data)

t.nodes.each do |id, node|
  puts "node #{id}: parent = " + ((!node.parent.nil?) ? node.parent : -1).to_s + ", depth = " + t.depth(id).to_s + ", " + (t.root?(id) ? "root" : t.leaf?(id) ? "leaf" : "internal node").to_s + ", #{node.children}"
end

Measured memory_bytes: 148248
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10, 18);
const int MOD = pow(10, 9) + 7;
/* contest template */
int H, W;
vector<string> v(50);
bool flag = true;

int main() {
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (v[i][j] == '#') {
        if (i == 0) {
          if (j == 0) {
            if (v[i][j + 1] == '.' && v[i + 1][j] == '.') {
              flag = false;
            }
          } else if (j == W - 1) {
            if (v[i + 1][j] == '.' && v[i][j - 1] == '.') {
              flag = false;
            }
          } else {
            if (v[i][j + 1] == '.' && v[i + 1][j] == '.' &&
                v[i][j - 1] == '.') {
              flag = false;
            }
          }
        } else if (i == H - 1) {
          if (j == 0) {
            if (v[i][j + 1] == '.' && v[i - 1][j] == '.') {
              flag = false;
            }
          } else if (j == W - 1) {
            if (v[i - 1][j] == '.' && v[i][j - 1] == '.') {
              flag = false;
            }
          } else {
            if (v[i][j + 1] == '.' && v[i - 1][j] == '.' &&
                v[i][j - 1] == '.') {
              flag = false;
            }
          }
        } else {
          if (j == 0) {
            if (v[i][j + 1] == '.' && v[i + 1][j] == '.' &&
                v[i - 1][j] == '.') {
              flag = false;
            }
          } else if (j == W - 1) {
            if (v[i + 1][j] == '.' && v[i][j - 1] == '.' &&
                v[i - 1][j] == '.') {
              flag = false;
            }
          } else {
            if (v[i][j + 1] == '.' && v[i + 1][j] == '.' &&
                v[i][j - 1] == '.' && v[i - 1][j] == '.') {
              flag = false;
            }
          }
        }
      }
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int main()
{
	string st;
	cin>>st;
	if(st=="ABC") cout<<"ARC"<<endl;
	else cout<<"ABC"<<endl;
	return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, k);
  out(k / 2 * (k - k / 2));
}


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

int main() {
    int N,D;
    cin >>N>>D;
    int ans =0;

    vector<vector<int>>data(N,vector<int>(D));
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++)cin >>data[i][j];
}


    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            int norm =0;
            for(int k=0;k<D;k++){
                int sa =data[j][k]-data[i][k];
                norm += sa*sa;
            }
            bool judge =false;
            for(int k=0;k<=norm;k++){
                if(k*k == norm){
                    judge =true;
                    break;
                }   
            }
            if(judge)ans++;
        }
    }
    cout <<ans<<endl;

}


Measured memory_bytes: 256
program kth
    integer :: i, j, k, total, targetnum, num(32)

    num(1) = 1 ; num(2) = 1 ; num(3) = 1
    num(4) = 2 ; num(5) = 1 ; num(6) = 2
    num(7) = 1 ; num(8) = 5 ; num(9) = 2
    num(10) = 2 ; num(11) = 1 ; num(12) = 5
    num(13) = 1 ; num(14) = 2 ; num(15) = 1
    num(16) = 14 ; num(17) = 1 ; num(18) = 5
    num(19) = 1 ; num(20) = 5 ; num(21) = 2
    num(19) = 1 ; num(20) = 5 ; num(21) = 2
    num(22) = 2 ; num(23) = 1 ; num(24) = 15
    num(25) = 2 ; num(26) = 2 ; num(27) = 5 
    num(28) = 4 ; num(29) = 1 ; num(30) = 4
    num(31) = 1 ; num(32) = 51

    read *, targetnum

    print *, num(targetnum)

end program kth


Measured memory_bytes: 640
#include<iostream>
#include<set>
using namespace std;
int X,N,P;
main()
{
	cin>>X>>N;
	set<int>S;
	for(int i=0;i<N;i++)
	{
		cin>>P;
		S.insert(P);
	}
	for(int k=0;;k++)
	{
		if(S.find(X-k)==S.end())
		{
			cout<<X-k<<endl;
			return 0;
		}
		else if(S.find(X+k)==S.end())
		{
			cout<<X+k<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3604
def main():
    import sys
    input = sys.stdin.buffer.readline
    from itertools import accumulate

    def Eratosthenes(x: int) -> set:
        from math import sqrt
        sup = int(x)
        primes = {i for i in range(2, sup+1)}
        for i in range(2, int(sqrt(sup+1))+1):
            if i in primes:
                mul = 2
                while i*mul <= sup:
                    primes.discard(i*mul)
                    mul += 1
        return primes
    P = Eratosthenes(10**5+5)
    A = [0]*(10**5+5)
    for i in range(3, 10**5+5):
        if i in P and (i+1)//2 in P:
            A[i] += 1
    S = list(accumulate(A))

    Q = int(input())
    LR = [[int(i) for i in input().split()] for j in range(Q)]
    for le, ri in LR:
        print(S[ri] - S[le-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 68708
#include<stdio.h>

int main(void){
  int i;
  int n,cur;
  int r,t;

  for(;;){
    scanf("%d",&n);
    if(n==0)
      break;

    cur=0;

    for(r=0;r*r*r<=n;r++)
      for(t=0;t*(t+1)*(t+2)/6<=n;t++)
        if(cur<r*r*r+t*(t+1)*(t+2)/6 &&
            r*r*r+t*(t+1)*(t+2)/6<=n)
          cur=r*r*r+t*(t+1)*(t+2)/6;

    printf("%d\n",cur);
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			int w = cin.nextInt();
			int h = cin.nextInt();
			if(w+h==0){
				break;
			}
			Room[][] r= new Room[h][w];
			boolean[][] a = new boolean[h*2-1][w];
			for(int i = 0; i < h*2-1;i++){
				for(int j = 0;j < w;j++){
					if(i%2==0){
						if(w-1==j){
							break;
						}
					}
					int c = cin.nextInt();
					a[i][j]=c==1;
				}
			}
			for(int i = 1; i < h-1; i++){
				for(int j = 1;j  < w-1;j++){
					r[i][j]=new Room(a[i*2-1][j],
							a[i*2+1][j],
							a[i*2][j-1],
							a[i*2][j]);
				}
			}
			
			r[0][0] = new Room(true, a[1][0],true, a[0][0]);
			r[0][w-1] = new Room(true, a[1][w-1], a[0][w-1], true);
			r[h-1][0] = new Room(a[h*2-2][0],true,true,a[h*2-2][0]);
			r[h-1][w-1]=new Room(a[h*2-2][0],true,a[h*2-2][w-1],true);
			for(int i = 1; i < w-1;i++){
				r[0][i]=new Room(true, a[1][i],a[0][i-1],a[0][i]);
				r[h-1][i]=new Room(a[h*2-3][i],true,a[h*2-2][i-1],a[h*2-2][i]);
			}
			for(int i = 1; i < h-1;i++){
				r[i][0]=new Room(a[i*2-1][0],a[i*2+1][0],true,a[i*2][0]);
				r[i][w-1]=new Room(a[i*2-1][w-1],a[i*2+1][w-1],a[i*2][w-1],true);
			}
			Queue<Integer[]> q = new LinkedList<Integer[]>();
			Integer[] pair = {0,0};
			int[][] saitan = new int[h][w];
			for(int i = 0; i < h;i++){
				for(int j = 0; j < w;j++){
					saitan[i][j]=1000000;
				}
			}
			//System.out.println(r[1][1].a());
			saitan[0][0]=1;
			q.add(pair);
			while(!q.isEmpty()){
				Integer[] p = q.poll();
				int x = p[0];
				int y = p[1];
				//System.out.println(x+ " " +y+" " + saitan[x][y]);
				if(x-1>=0){
					if(!r[x][y].top&&saitan[x-1][y]>saitan[x][y]+1){
						Integer[] next1={x-1,y};
						q.add(next1);
						saitan[x-1][y]=saitan[x][y]+1;
					}
				}
				if(y-1>=0){
					if(!r[x][y].left&&saitan[x][y-1]>saitan[x][y]+1){
						Integer[] next2={x,y-1};
						q.add(next2);
						saitan[x][y-1]=saitan[x][y]+1;
					}
				}
				if(x+1<h){
					if(!r[x][y].bottom&&saitan[x+1][y]>saitan[x][y]+1){
						Integer[] next3={x+1,y};
						q.add(next3);
						saitan[x+1][y]=saitan[x][y]+1;
					}
				}
				if(y+1<w){
					if(!r[x][y].right&&saitan[x][y+1]>saitan[x][y]+1){
						Integer[] next4={x,y+1};
						q.add(next4);
						saitan[x][y+1]=saitan[x][y]+1;
					}
				}
			}
			/*
			for(int i = 0; i < h;i++){
				for(int j = 0;j < w;j++){
					System.out.print(saitan[i][j] + " ");		
				}
				System.out.println();
			}
			*/
			if(saitan[h-1][w-1]==1000000){
				System.out.println(0);
			}
			else{
				System.out.println(saitan[h-1][w-1]);
			}
			
		}
	}
}
class Room{
	boolean top;
	boolean bottom;
	boolean left;
	boolean right;
	Room(boolean a,
			boolean b,
			boolean c,
			boolean d){
		top = a;
		bottom =b;
		left = c;
		right = d;
	}
	String a(){
		return (top + " " + bottom+" "+left+" "+right);
	}
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int q;
    cin >> q;
    rep(i, q) {
        string x, y;
        cin >> x >> y;
        vi l;
        rep(k, sz(y)) {
            int xbi = 0;
            bool skip = false;
            rep(j, sz(l)) {
                int p = x.find(y[k], xbi);
                if (p == (int)string::npos) {
                    skip = true;
                    break;
                }
                xbi = l[j];
                l[j] = min(l[j], p+1);
            }
            if (!skip) {
                int p = x.find(y[k], xbi);
                if (p != (int)string::npos) l.pb(p+1);
            }
        }
        cout << sz(l) << endl;
    }
    return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int a,b,c,d;cin>>a>>b>>c>>d;
  int ans=a*b;
  if(ans<d*c)ans=c*d;
  cout(ans);
  
  return 0;
}

Measured memory_bytes: 125568
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, T;
	cin>>n>>T;
	int ans=2000;
	for(int i=0; i<n; i++){
		int c, t;
		cin>>c>>t;
		if(t<=T){
			ans=min(ans, c);
		}
	}
	if(ans==2000){
		cout<<"TLE"<<endl;
	}else{
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
main = fmap (map read . words) getLine >>= \[n,a,b] -> print (solve n a b)

solve :: Int -> Int -> Int -> Int
solve 1 a b
  | a == b    = 1
  | otherwise = 0
solve n a b
  | a > b     = 0
  | otherwise = (n-2) * (b-a) + 1

Measured memory_bytes: 508
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
   	int a, b, k;
   	cin >> a >> b >> k;
   	for (int i = a ; i <= b ; i++) {
		if (i <= a + k - 1 || i >= b - k + 1) cout << i << endl; 
	} 
}

Measured memory_bytes: 3616
#include <stdio.h>

int main()
{
	int i, j, H, W;
	char a[101][101];
	scanf("%d %d", &H, &W);
	for (i = 1; i <= H; i++) scanf("%s", a[i]);
	
	for (j = 0; j <= W + 1; j++) printf("#");
	for (i = 1; i <= H; i++) printf("\n#%s#", a[i]);
	printf("\n");
	for (j = 0; j <= W + 1; j++) printf("#");
	printf("\n");
	fflush(stdout);
	return 0;
}

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

int main(){
    int y,m,d;
    char c0,c1;
    cin >> y >> c0 >> m >> c1 >> d;
    cout << (y<=2019&&m<=4?"Heisei":"TBD") << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def print_ans(input_line):
    """Test Case
    >>> print_ans(4)
    0.5000000000
    >>> print_ans(5)
    0.6000000000
    >>> print_ans(1)
    1.0000000000
    """
    q, mod = divmod(input_line,2)
    print((q + mod)/input_line)

if __name__ == '__main__':
    print_ans(int(input()))

Measured memory_bytes: 3060
<?php
$N=trim(fgets(STDIN));
$no1=0;
$no2=0;
$i1=0;
for($i=0;$i<$N;++$i){
$A[$i]=trim(fgets(STDIN));
}
$B=$A;

rsort($A);
$max=$A[0];
$max2=$A[1];

for($i=0;$i<$N;++$i){
if($B[$i]!==$max){
echo "$max"."\n";
}else{
echo "$max2"."\n";
}
  
}


Measured memory_bytes: 28528
#include "bits/stdc++.h"
using namespace std;

int main(void) {
    int a, b, c;
    cin >> a >> b >> c;
    int r = a - b;
    int ans = c - r;
    if (ans < 0) {
        ans = 0;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<numeric>
using namespace std;
 
int main(){
  long long n, a[10000];
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  cout << *min_element( a, a + n) << " "
       << *max_element( a, a + n) << " "
       << accumulate( a, a + n, 0LL) << endl;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
# define mod 1000000007
typedef long long ll;
int hoge[200005];

int		main()
{
	int N; cin >> N;
	for (int i = 0; i < N - 1; i++)
	{
		int a; cin >> a;
		hoge[a]++;
	}
	for (int i = 1; i <= N; i++)cout << hoge[i] << endl;
}



Measured memory_bytes: 4372
#include <bits/stdc++.h>
using namespace std;
int main() {
    // your code goes here
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    int ans=2000;
    for(int i=0;i<=s.size()-t.size();i++)
    {
    	int ct=0;
    	for(int j=0;j<t.size();j++)
    	{
    		ct+=s[i+j]!=t[j];
    	}
    	ans=min(ct,ans);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<string>

using namespace std;

int main(){
  int n;
  cin>>n;
  string originalS[n],S[n],copyS,checkS[n];
  int ortiginalR[n],R[n],j,copyI;
  for(int i=0;i<n;i++){
    cin>>originalS[i];
    S[i]=originalS[i];
  }
  //バブルソート
  for(int i=0;i<n;i++){
    R[i]=S[i][1]-'0';
    ortiginalR[i]=R[i];
    j=i;
    while(1){
      if(j==0){
        break;
      }else{
        if(R[j-1]>R[j]){
          copyI=R[j];
          R[j]=R[j-1];
          R[j-1]=copyI;
          copyS=S[j];
          S[j]=S[j-1];
          S[j-1]=copyS;
        }
      }
      j--;
    }
  }
  //コピーを残しておく
  for(int i=0;i<n;i++){
    checkS[i]=S[i];
  }
  //選択ソート
  int minv,copy;
  for(int i=0;i<n;i++){
    S[i]=originalS[i];
    R[i]=ortiginalR[i];
  }
  for(int i=0;i<n;i++){
    minv=i;
    for(int j=i;j<n;j++){
      if(R[j]<R[minv]){
        minv=j;
      }
    }
    copyI=R[i];
    R[i]=R[minv];
    R[minv]=copyI;
    copyS=S[i];
    S[i]=S[minv];
    S[minv]=copyS;
  }
  //アウトプット
  for(int i=0;i<n;i++){
    if(i==n-1){
      cout<<checkS[i]<<endl<<"Stable"<<endl;
    }else{
      cout<<checkS[i]<<" ";
    }
  }
  int checkCount=0;
  for(int i=0;i<n;i++){
    if(S[i]==checkS[i])checkCount++;
    if(i==n-1&&checkCount==n){
      cout<<S[i]<<endl<<"Stable"<<endl;
    }else if(i==n-1&&checkCount!=n){
      cout<<S[i]<<endl<<"Not stable"<<endl;
    }else{
      cout<<S[i]<<" ";
    }
  }
  return 0;
}



Measured memory_bytes: 3216
#include <iostream>

using namespace std;

int main(void)
{
  int N, M, K;
  cin >> N >> M >> K;
  for (int x = 0; x <= N; x++)
  {
    if (N - 2 * x == 0)
      continue;
    if ((K - M * x) / (N - 2 * x) < 0)
      continue;
    if ((K - M * x) % (N - 2 * x) == 0)
    {
      if ((K - M * x) / (N - 2 * x) > M)
        continue;
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


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

const int MOD = 1000000007;

int main()
{
  long long int H, N;
  cin >> H >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  long long int sum = 0;
  for (int i = 0; i < N; i++)
  {
    sum += A[i];
  }
  if (H > sum)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)

using ll = long long;
using namespace std;

int main() {
    int n;
    cin >> n;
    int total = 0;

    for(int i = 1; i <= n; i=i+2) {
        int cnt = 0;
        rep1(j,i) {
            if(i % j == 0) ++cnt;
        }
        if(cnt == 8) ++total;
    }
    cout << total;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
using namespace std;
int n,d,x[110][110];
int main()
{
  cin>>n>>d;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=d;j++) scanf("%d",&x[i][j]);
  int ans=0;
  for(int i=1;i<=n;i++)
    for(int j=i+1;j<=n;j++)
    {
	  int tmp=0;
	  for(int k=1;k<=d;k++)
	    tmp+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
	  if((double)sqrt(tmp)==(int)sqrt(tmp)) ans++;
	}
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[] a = new int[n];
		
		for(int i = 0; i < n; i++) {
			a[i] = stdIn.nextInt();
		}
		
		boolean flag = true;
		
		
		for(int i = 0; i < n; i++) {
			if(a[i]%2==0) {
				if(a[i]%3!=0 && a[i]%5!=0) {
					flag = false;
				}
				
			}
			
			
			
		}
		
		if(flag) {
			System.out.println("APPROVED");
		}else {
			System.out.println("DENIED");
		}
		
	}

}


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

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
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;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  vector <ll> v(3);
  rep(i, 3) cin >> v.at(i);
  sort(v.begin(), v.end());
  cout << v.at(2)-v.at(0) << endl;
}

Measured memory_bytes: 256
require 'pp'

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end

N, h_list = gets_n_and_i_list      

dp = []
dp[0] = 0

(1...N).each do |i|
  s1 = (h_list[i] - h_list[i - 1]).abs + dp[i - 1]
  if i >= 2
    s2 = (h_list[i] - h_list[i - 2]).abs +  + dp[i - 2]
  else
    s2 = Float::INFINITY
  end
  dp[i] = [s1, s2].min
end

puts dp.last

Measured memory_bytes: 12284
valid :: Int -> Int -> Int -> Int -> Bool
valid x y z w = x + y + z == w

countTrue :: (Int, Int, Int, Int) -> Int -> Int
countTrue (x, y, z, w) c = if valid x y z w then c + 1 else c

howManyWay :: Int -> Int -> Int
howManyWay n x = foldr countTrue 0 [(i, j, k, x) | i <- [1..n], j <- [1..n], k <- [1..n], j > i, k > j]

main :: IO ()
main = do
  [n, x] <- fmap (map read . words) getLine
  if n == 0 && x == 0
    then return ()
    else do
    print $ howManyWay n x
    main

Measured memory_bytes: 5328
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n,a;
  cin >> n >> a;
  vector<int>x(n);
  rep(i,n){
    cin >> x[i];
    x[i]-=a;
  }
  ll dp[n+10][5000]={};
  dp[0][2500]=1;
  
  rep(i,n){
    for(int j=0;j+x[i]<5000;j++){
      dp[i+1][j+x[i]]+=dp[i][j];
      dp[i+1][j]+=dp[i][j];
    }
  }
  ll res = dp[n][2500]-1;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i<3; i++) {
        if (s[i] == t[i]) {
            ans++;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n, m;
    cin >> n >> m;
    int cor = 0; int pen = 0;
    bool pro[100005] = {false};
    int pens[100005] = {0};
    for(int i = 0; i < m; i++){
        int p; string s;
        cin >> p >> s;
        if(!pro[p]){
            if(s == "AC") cor++, pro[p] = true;
            else pens[p]++;
        }
    }
    for(int i = 0; i <= n; i++){
        if(pro[i]) pen += pens[i];
    }
    cout << cor << ' ' << pen << endl;
    return 0;
}

Measured memory_bytes: 896
def Aeat(A,B):
    if A%2==0:
        tmp=A//2
        A-=tmp
        B+=tmp
    else:
        A-=1
        tmp=A//2
        A-=tmp
        B+=tmp
    return A, B

def Beat(A,B):
    A,B=B,A
    if A%2==0:
        tmp=A//2
        A-=tmp
        B+=tmp
    else:
        A-=1
        tmp=A//2
        A-=tmp
        B+=tmp
    A,B=B,A
    return A, B

A,B,K=map(int, input().split())
for i in range(K):
    if i%2==0:
        A,B=Aeat(A,B)
    else:
        A,B=Beat(A,B)
print(str(int(A))+' '+str(int(B)))

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

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()

const double eps=1e-5;
const long long INF=(LL)(1e9)*(LL)(1e9);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    vector<char> s(3001),w(3001);
    w[0]=1;s[0]=1;
    REP(i,3001)
    {
        if(i+a*100<=3000)
            w[i+a*100]|=w[i];
        if(i+b*100<=3000)
            w[i+b*100]|=w[i];
    }
    REP(i,3001)
    {
        if(i+c<=3000)
            s[i+c]|=s[i];
        if(i+d<=3000)
            s[i+d]|=s[i];
    }

    int ma=0,mb=0;
    double mr=-1;
    double r=(double)e/(100+e);
    REP(i,3001)
    REP(j,3001)
    {
        if(!w[i]||!s[j]) continue;
        if(i+j>f) continue;
        if(i+j==0) continue;
        double rt=(double)j/(i+j);
        //cout<<i<<" "<<j<<":"<<r<<" "<<rt<<endl;
        if(rt>r) continue;
        if(rt>mr)
        {
            mr=rt;
            ma=i+j;mb=j;
        }
    }
    cout<<ma<<" "<<mb<<endl;
}


Measured memory_bytes: 256
#include<iostream>

int gcd(int x,int y){
    if (x<y){
        return gcd(y,x);
    }
    
    int r = x%y;
    if (r == 0){
        return y;
    }else{
        return gcd(y,r);
    }
    return 0;
}

int main(){
    int x,y;
    std::cin >> x >> y;
    std::cout << gcd(x,y) << '\n';
    
    return 0;
}


Measured memory_bytes: 3088
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(stringLineScan())
	t, _ := strconv.Atoi(stringLineScan())
	a, _ := strconv.Atoi(stringLineScan())
	for i := 1; i < n; i++ {
		x, _ := strconv.Atoi(stringLineScan())
		y, _ := strconv.Atoi(stringLineScan())
		na := a
		if na%y != 0 {
			na += y - na%y
		}
		nat := na / y * x
		nt := t
		if t%x != 0 {
			nt += x - nt%x
		}
		nta := nt / x * y
		if (nat >= t && nt >= nat) || (nta < a || nta <= 0 || nt <= 0) {
			t, a = nat, na
		} else {
			t, a = nt, nta
		}
	}
	fmt.Println(t + a)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

ld dist2(ld a[], ld b[]){
    ld d = 0;
    rep(i, 2) d += (a[i]-b[i])*(a[i]-b[i]);
    return d;
}

ld dist(ld a[], ld b[]){
    return sqrt(dist2(a, b));
}

int main(){
    int N;
    cin >> N;
    ld x[N][2];
    rep(i, N) cin >> x[i][0] >> x[i][1];
    ld ans = 0, O[2];
    O[0] = 0, O[1] = 0;
    rep(i, N-1) rep2(j, i, N-1){
        ld d = dist(x[i], x[j])/2;
        ans = max(ans, d);
    }
    rep(i, N-2) rep2(j, i+1, N-2) rep2(k, j+1, N-1){
        ld a[2], b[2], o[2];
        rep(l, 2){
            a[l] = x[j][l]-x[i][l];
            b[l] = x[k][l]-x[i][l];
        }
        if(a[0]*b[1] == a[1]*b[0]) continue;
        ld r[3];
        r[0] = dist2(x[i], x[j]);
        r[1] = dist2(x[i], x[k]);
        r[2] = dist2(x[j], x[k]);
        sort(r, r+3);
        if(r[2] >= r[1]+r[0]) continue;
        ld p = dist2(a, O)/2, q = dist2(b, O)/2;
        o[0] = (p*b[1]-q*a[1]) / (a[0]*b[1]-a[1]*b[0]);
        o[1] = (q*a[0]-p*b[0]) / (a[0]*b[1]-a[1]*b[0]);
        ld d = dist(o, O);
        ans = max(ans, d);
    }
    cout << setprecision(15) << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
s  = input()
#  = int(input())
#  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
## c = collections.Counter()

if s.isupper():
    print('A')
else:
    print('a')


Measured memory_bytes: 9324
#include<stdio.h>
#define N 10000

int main(void){

  int n, q, C=0, i, j;
  int S[N], T[N];

  scanf("%d",&n);

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

  scanf("%d",&q);

  for(j=0;j<q;j++){
    scanf("%d",&T[j]);
  }

  for(j=0;j<q;j++){
    for(i=0;i<n;i++){

      if(S[i] == T[j]){
        C++;
        break;
      }
    }
  }

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

  return 0;
}



Measured memory_bytes: 2100
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	int maxMod = 1;
	if(n == 1){
		printf("%d\n",m);
		return 0;
	}
	for(int mod = 2; mod <= m ; mod++){
		int x = m - mod * (n-1);
		if( x >= mod){
			if(x % mod == 0) maxMod = mod;
		}else break;
	}
	printf("%d\n",maxMod);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll; //long longをllとして簡略

int main(){
      int n;
      string s;
      cin >> n >> s;
      int ans = 0;
      rep(i,n-2){
            if(s.substr(i,3)=="ABC") ans++;
      }
      cout << ans << endl;
      return 0;
}

Measured memory_bytes: 256
import sys

#最大公約数
def gcd(x, y):
    s = x / y
    r = x % y
    if r == 0:
        return y
    else:
        return gcd(y, r)

#最小公倍数
def lcm(x, y):
    return x*y/gcd(x, y)

def main():
    #print ("a")
    for line in iter(sys.stdin.readline, ""):
        #print (line)
        #tmp = sys.stdin.readline().split(" ")
        #print ("b")
        tmp = line.split(" ")
    
        a = int(tmp[0])
        b = int(tmp[1])
        #print ("a="+str(a))
        #print ("b="+str(b))
        #b = sys.stdin.readline()
        #print ("d")
        if a > b:
            c = a
            d = b
        else:
            c = b
            d = a

        print (str(gcd(c, d)) + " " + str(int(lcm(c,d))))

        #tmp = sys.stdin.readline()
        #if len(tmp) == 1:
        #    break
        #else:
        #    tmp = tmp.split(" ")

    #print ("exit")
     
if __name__ == "__main__":
    main()

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N;
    cin >> N;
    vector<unsigned long> a(N + 1);
    for(unsigned long i = 1, A; i <= N; ++i){
        cin >> A;
        a[i] = a[i - 1] ^ A;
    }
    auto f = [&MOD](auto& a, auto k){(a.second += (a.first += a.second * k) %= MOD) %= MOD; return a.first;};
    if(a.back()){
        unsigned long k = 0;
        pair<unsigned long, unsigned long> p{1, 0};
        for(const auto i : a)
            if(i == a.back())f(p, k), k = 0;
            else if(!i) ++k;
        cout << p.first << endl;
    }else{
        vector<pair<pair<unsigned long, unsigned long>, unsigned long>> tapi(1048576, {{1, 0}, 0});
        vector<unsigned long> zeros(N + 2);
        unsigned long ans{0}, t{250000002};
        for(unsigned long i = 0; i <= N; ++i){
            zeros[i + 1] = zeros[i] + !a[i];
            if(a[i]){
                ans += f(tapi[a[i]].first, zeros[i + 1] - zeros[tapi[a[i]].second]);
                tapi[a[i]].second = i + 1;
            }else (t *= 2) %= MOD;
        }
        cout << (ans + t) % MOD << endl;
    }
    return 0;
}

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

#define M_PI 3.14159265358979323846

using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a) * (a))
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
//------------------------------------------
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
//#define MOD 1000000007

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-8;

#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

#define MOD 1000000007
class UnionFind
{
public:
    vector<int> par;
    vector<int> siz;

    UnionFind(int sz_) : par(sz_), siz(sz_, 1)
    {
        for (int i = 0; i < sz_; ++i)
            par[i] = i;
    }
    void init(int sz_)
    {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i)
            par[i] = i;
    }

    int root(int x)
    {
        while (par[x] != x)
        {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool merge(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (siz[x] < siz[y])
            swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(int x, int y)
    {
        return root(x) == root(y);
    }

    int size(int x)
    {
        return siz[root(x)];
    }
};

ll modPow(ll x, ll n, ll mod = MOD)
{
    if (n == 0)
        return 1;
    ll res = 1;
    while (n)
    {
        if (n & 1)
            res = (res * x) % mod;

        res %= mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
ll arr[100010];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(6);

    ll N, K;
    cin >> N >> K;

    ll ans = 0;
    for (ll i = K; i >= 1; i--)
    {
        arr[i] = modPow(K / i, N, MOD);
        for (int j = 2 * i; j <= K; j += i)
        {
            arr[i] -= arr[j];
            arr[i] += MOD;
            arr[i] %= MOD;
        }

        ans += i * arr[i];
        ans %= MOD;
    }

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


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,m,s,t;
    cin >> n >> m >> s >> t;
    --s;    --t;
    vector<vector<pair<ll,ll>>> graph1(n);
    vector<vector<pair<ll,ll>>> graph2(n);
    for(i = 0;i < m;++i){
        ll u,v,a,b;
        cin >> u >> v >> a >> b;
        --u;    --v;
        graph1.at(u).emplace_back(a, v);
        graph1.at(v).emplace_back(a, u);
        graph2.at(u).emplace_back(b, v);
        graph2.at(v).emplace_back(b, u);
    }

    ll INF = 1e16;

    priority_queue<pair<ll,ll>> pq; //優先度付きキュー
    vector<ll> vdistyen(n,INF); //距離
    ll top = s; //開始点
    vdistyen.at(top) = 0;
    pq.emplace(0, top);
    while(!pq.empty()){
        auto x = pq.top();
        pq.pop();
        ll now = x.second;
        ll dist = -x.first;
        if(vdistyen.at(now) < dist) continue;
        for(i = 0;i < graph1.at(now).size();++i){
            ll next = graph1.at(now).at(i).second;
            ll nd = dist + graph1.at(now).at(i).first;
            if(vdistyen.at(next) > nd){
                vdistyen.at(next) = nd;
                pq.emplace(-nd, next);
            }
        }
    }

    vector<ll> vdistsunu(n,INF); //距離
    top = t; //開始点
    vdistsunu.at(top) = 0;
    pq.emplace(0, top);
    while(!pq.empty()){
        auto x = pq.top();
        pq.pop();
        ll now = x.second;
        ll dist = -x.first;
        if(vdistsunu.at(now) < dist) continue;
        for(i = 0;i < graph2.at(now).size();++i){
            ll next = graph2.at(now).at(i).second;
            ll nd = dist + graph2.at(now).at(i).first;
            if(vdistsunu.at(next) > nd){
                vdistsunu.at(next) = nd;
                pq.emplace(-nd, next);
            }
        }
    }

    vector<ll> ans(n,INF);
    ans.at(n-1) = vdistyen.at(n-1) + vdistsunu.at(n-1);
    for(i = n-2;i >= 0;--i){
        ans.at(i) = min(ans.at(i+1), vdistyen.at(i) + vdistsunu.at(i));
    }
    for(i = 0;i < n;++i){
        ll tmp = 1e15;
        cout << tmp - ans.at(i) << endl;
    }


    return 0;
}

Measured memory_bytes: 19576
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

string s;
long long int sum;
long long int ma;
long long int lens;
long long int t;
int main()
{
	cin >> s;
	lens = s.length();
	if (lens == 1)sum = 0;
	else
	{
		for (long long int i=0;i<lens;i++)
		{
			if (s[i] == 'B')sum++;
			else ma += sum;
		}
	}
	cout << ma;

}

Measured memory_bytes: 640