akhauriyash/Code-Regression huggingface dataset:
<?php
fscanf(STDIN, "%d%d", $n, $m);
for($i = 1; $i <= $n; $i++){
    $wrongCount[$i] = 0;
    $correctCount[$i] = 0;
}
$pena = 0;
$correct = 0;
for($i = 0; $i < $m; $i++){
    list($no, $result) = explode(" ", trim(fgets(STDIN)));
    if($result == "WA"){
        $wrongCount[$no]++;
    }else{
        if($correctCount[$no] == 0){
            $pena += $wrongCount[$no];
            $correct ++;
        }
        $correctCount[$no]++;
    }
}
echo $correct," ",$pena;

Measured memory_bytes: 14840
import java.util.Scanner;

public class Main {

    static int mod = (int)1e9 + 7;

    static int max = 1000000 * 2;
    static long[] fact = new long[max];
    static long[] modinv = new long[max];
    static long[] factinv = new long[max];

    public static void initCombi() {
        fact[0] = 1;
        fact[1] = 1;
        modinv[1] = 1;
        factinv[0] = 1;
        factinv[1] = 1;

        for (int i = 2; i < max; i++) {
            fact[i] = fact[i - 1] * i % mod;
            modinv[i] = mod - modinv[mod % i] * (mod / i) % mod;
            factinv[i] = factinv[i - 1] * modinv[i] % mod;
        }
    }

    public static long combi(int n, int k) {
        return fact[n] * (factinv[k] * factinv[n - k] % mod) % mod;
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int s = Integer.parseInt(scan.next());
        scan.close();

        initCombi();

        long ans = 0;
        int i = 0;
        s -= 3;
        while (s >= i) {
            ans += combi(s, i);
            ans %= mod;
            s -= 2;
            i += 1;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 99916
import itertools


def main():
    x, y = map(int, input().split())
    if x % y == 0:
        result = -1
    else:
        result = next(filter(lambda i: i % y != 0, map(lambda i: i * x, itertools.count(1))))
    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<ll,ll>
#define vll vector<ll>
#define pb push_back
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
ll read(){
	ll g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const ll N=1e4+5;
const ll M=1005;
ll vis[N],p[N],tot,a[M][M],n;
void init(ll n){
	for(ll i=2;i<=n;i++){
		if(!vis[i])p[++p[0]]=i;
		for(ll j=1;j<=p[0]&&i*p[j]<=n;j++){
			vis[i*p[j]]=1;
			if(!(i%p[j]))break;
		}
	}
}
ll gcd(ll x,ll y){
	if(y==0)return x;
	else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	if(!x||!y)return x+y;
	return x/gcd(x,y)*y;
}
signed main(){
	n=read();init(1e4);
	if(n==2)return cout<<"4 7\n23 10",signed();
	for(ll i=1;i<=n;i++)for(ll j=(i+1&1)+1;j<=n;j+=2)a[i][j]=p[(i+j)/2]*p[n+(i-j)/2+(n+1)/2];
	for(ll i=1;i<=n;i++)for(ll j=(i&1)+1;j<=n;j+=2)if((i+j)&1)a[i][j]=lcm(a[i-1][j],lcm(a[i+1][j],lcm(a[i][j-1],a[i][j+1])))+1;
	for(ll i=1;i<=n;i++,cout<<'\n')for(ll j=1;j<=n;j++,cout<<' ')cout<<a[i][j];
	return signed();
}

Measured memory_bytes: 7576
N,Y = map(int,input().split(" "))

Y //= 1000

n = 0
y = 0
while y <= Y and n <= N:
    yy = y
    nn = n
    while yy <= Y and nn <= N:
        if Y - yy == N - nn:
            print(y//10,(yy-y)//5,Y-yy)
            exit()
        yy += 5
        nn += 1
    y += 10
    n += 1

print(-1,-1,-1)

Measured memory_bytes: 3064
import copy

k, n = map(int, input().split())

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

# print(k, n)
# print(a)

dis = copy.deepcopy(a)
dis[-1] = k - a[-1] + a[0]
for i in range (len(a)-1):
  dis[i] = a[i+1] - a[i]

# print(dis)

max_d = max(dis)
ans = sum(dis) - max_d

print(ans)

Measured memory_bytes: 25420
from collections import deque
import sys
input = sys.stdin.readline
n = int(input())
d = deque()
for _ in range(n):
    l = input().strip()
    if "deleteFirst" == l:d.popleft();continue
    elif "deleteLast" == l: d.pop();continue
    c, s = l.split()
    if c == "insert": d.appendleft(s);continue
    elif s in d: d.remove(s)
print(*d)


Measured memory_bytes: 69724
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,x;
  cin>>x>>a>>b;
  if(abs(x-a)>abs(x-b)){
    cout<<"B"<<'\n';
  }
  else{
    cout<<"A"<<'\n';
  }
  
  return(0);
}


Measured memory_bytes: 256
class UnionFind(): # 0インデックス
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]


if __name__ == "__main__":
    N, M = map(int, input().split()) # N人、M個の関係
    union_find = UnionFind(N)
    for _ in range(M):
        A, B = map(int, input().split())
        A -= 1
        B -= 1
        union_find.union(A, B)

    answer = 0
    for i in range(N):
        answer = max(answer, union_find.size(i))

    print(answer)
  

 

Measured memory_bytes: 14516
package main

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

func main() {
	N := readInt()

	if N == 2 {
		// K = 2
		fmt.Println(1)
		return
	}

	if N == 3 {
		// K = 2, 3
		fmt.Println(2)
		return
	}

	if N == 4 {
		// K = 2, 3, 4
		fmt.Println(3)
		return
	}

	if N == 5 {
		// K = 2, 4, 5
		fmt.Println(3)
		return
	}

	if N == 6 {
		// K = 2, 5, 6
		fmt.Println(3)
		return
	}

	r := int(math.Sqrt(float64(N)))
	// K = N - 1, N
	result := 2
	for K := 2; K <= r; K++ {
		t := N
		for t >= K && t%K == 0 {
			t /= K
		}
		if t%K == 1 {
			result++
		}

		k := 0
		if N%K == 0 {
			k = N / K
		} else if (N-1)%K == 0 {
			k = (N - 1) / K
		}
		if k != 0 && k != K {
			t = N
			for t >= k && t%k == 0 {
				t /= k
			}
			if t%k == 1 {
				result++
			}

		}
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func readInts(n int) []int {
	result := make([]int, n)
	for i := 0; i < n; i++ {
		result[i] = readInt()
	}
	return result
}


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

int n;

int main() {
	cin >> n;
	int a = 0, b = 0, c = 0;
	for (int i = 1; i <= n; ++i) {
		int t;
		scanf("%d", &t);
		if (t % 2) {
			++a;
		} else {
			if (t % 4) {
				++b;
			} else {
				++c;
			}
		}
	}
	if (c < a - 1 || c == a - 1 && b) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 256
#!/usr/bin/env python3
def main():
    from itertools import permutations

    N = int(input())
    P = tuple(int(x) for x in input().split())
    Q = tuple(int(x) for x in input().split())

    for i, p in enumerate(permutations(range(1, N + 1), N)):
        if p == P:
            a = i
    for i, q in enumerate(permutations(range(1, N + 1), N)):
        if q == Q:
            b = i
    print(abs(a - b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
#include <iostream>

using namespace std;

char count_mine(string grid[], int height, int width, int H, int W)
{
    int sum=0;
    for (int i=-1;i<=1;i++) {
        for (int j=-1;j<=1;j++) {
            if (!(i==0 && j==0)) {
                if ( height+i>=0 && height+i<H && width+j>=0 && width+j<W ) {
                    if (grid[height+i][width+j]=='#')
                        sum++;
                }
            }
        }
    }
    return '0'+sum;
}

int main()
{
    int H, W;
    cin>>H>>W;
    string grid[H];
    for (int i=0;i<H;i++) {
        cin>>grid[i];
    }
    for (int height=0;height<H;height++) {
        for (int width=0;width<W;width++) {
            if (grid[height][width]!='#')
                grid[height][width]=count_mine(grid, height, width, H, W);
        }
    }
    for (int height=0;height<H;height++) {
        cout<<grid[height]<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		int d = a / b;
		int r = a % b;
		double f = (double)a / (double)b;
		System.out.printf("%d %d %.7f\n", d, r, f);
	}
}

Measured memory_bytes: 17344
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        final long mod = 1_000_000_007;
        final int H = in.nextInt();
        final int W = in.nextInt();
        final int K = in.nextInt();
        final long[] dp = new long[W];
        final long[] cl = new long[W]; // current line. reset every iteration.
        dp[0] = 1;
        for (int h = 0; h < H; h++) {
            for (int i = 0; i < W; i++) {
                cl[i] = 0;
            }
            for (int i = 0; i < W; i++) {
                int leftOff = count(i - 1, false);
                int leftOn = count(i - 1, true);
                int rightOff = count(W - i - 2, false);
                int rightOn = count(W - i - 2, true);
                if (dp[i] > 0) {
                    cl[i] += dp[i] * (leftOff * rightOff);
                    cl[i] %= mod;
                }
                if (i - 1 >= 0 && dp[i - 1] > 0) {
                    cl[i] += dp[i - 1] * (leftOn * rightOff);
                    cl[i] %= mod;
                }
                if (i + 1 < W && dp[i + 1] > 0) {
                    cl[i] += dp[i + 1] * (leftOff * rightOn);
                    cl[i] %= mod;
                }
            }
            for (int i = 0; i < W; i++) {
                dp[i] = cl[i];
            }
            // System.out.println(Arrays.toString(dp));
        }
        System.out.println(dp[K - 1]);
    }

    private static int count(int len, boolean on) {
        if (len <= 0) {
            return 1;
        }
        int ret = count(len - 1, false);
        if (!on) {
            ret += count(len - 1, true);
        }
        return ret;
    }
}

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

template <typename T>
struct graph {
	
	struct edge {
		int from, to;
		T cost;
	};
	
	vector<edge> edges;
	vector<vector<int>> g;
	int n;
	
	graph(int n) : n(n) {
		g.resize(n);
	}
	
	virtual void add(int from, int to, T cost) = 0;
};

template <typename T>
struct directed_graph : graph<T> {
	using graph<T>::edges;
	using graph<T>::g;
	using graph<T>::n;
	
	directed_graph(int n) : graph<T>(n) {
	}
	
	void add(int from, int to, T cost = 1) {
		assert(0 <= from && from < n && 0 <= to && to < n);
		g[from].emplace_back(edges.size());
		edges.push_back({from, to, cost});
	}
};

template <typename T>
vector<T> dijkstra(const graph<T> &g, int start) {
	assert(0 <= start && start < g.n);
	vector<T> dist(g.n, numeric_limits<T>::max());
	priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> s;
	dist[start] = 0;
	s.emplace(dist[start], start);
	while (!s.empty()) {
		T expected = s.top().first;
		int i = s.top().second;
		s.pop();
		if (expected != dist[i]) {
			continue;
		}
		for (int id : g.g[i]) {
			auto &e = g.edges[id];
			int to = e.from ^ e.to ^ i;
			if (dist[i] + e.cost < dist[to]) {
				dist[to] = dist[i] + e.cost;
				s.emplace(dist[to], to);
			}
		}
	}
	return dist;
}

int main() {
	int64_t n;
	cin >> n;
	directed_graph<int> g(n);
	for (int i = 0; i < n; i++) {
		g.add(i, (i + 1) % n);
		g.add(i, (i * 10) % n, 0);
	}
	auto d = dijkstra(g, 1);
	cout << d[0] + 1 << endl;
	return 0;
}

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

typedef long long ll;

int main(){
  long long a,b,n,x;

  scanf("%lld %lld %lld", &a, &b, &n);

  x = n;

  if(n >= b - 1) x = b - 1;

  printf("%lld\n", a*(x % b)/b);

  return 0;
}


Measured memory_bytes: 1704
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			while (n-- != 0)
			{
				int[] b = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
				Console.WriteLine(f(b) ? "YES" : "NO");
			}
		}

		static bool f(int[] ball)
		{
			int b = 0, c = 0;
			foreach (int a in ball)
			{
				if (a > b)
					b = a;
				else if (a > c)
					c = a;
				else
					return false;
			}
			return true;
		}
	}
}

Measured memory_bytes: 5692
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;


int main()
{
    f_io;
    ll x,k,d;
    cin >> x >> k >> d;
    x = abs(x);
    ll diff = abs(x);
    ll steps = diff/d;
    x = x - min(steps,k)*d;
    k -= min(steps,k);
    k%=2;
    x-=k*d;
    cout << abs(x);
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <utility>

using namespace std;
using pii = pair<int,int>;
int n,used[700][700];
pii color[700][700];
void dfs1(int s,int t, int c,int x, vector<vector<vector<pii>>> &G ){
    //cout << s << " " << t << endl;
    used[s][t] = 1;
    if(x==1) color[s][t].first = c;
    if(x==2) color[s][t].second = c;
    for(auto&&p :G[s][t]){
        if(used[p.first][p.second]!=-1) continue;
        dfs1(p.first,p.second,3-c,x,G);
    }
}

void dfs2(int d,int x){
    vector<pii> v;
    vector<vector<vector<pii>>> G(2 * n, vector<vector<pii>>(2 * n));
    for(int i=0; i*i<=d;i++){
        int k = d - i*i;
        for(int j = 0;j*j<=k;j++){
            if(j*j==k){
                //cout <<x << " " <<  i << " " << j << endl;
                v.push_back(make_pair(i,j));
                if(i!=j) v.push_back(make_pair(j,i));
            }
        }
    }
    for(int i=0;i<2*n;i++){
        for(int j=0;j<2*n;j++){
            for(int k = 0;k<v.size();k++){
                int y = i+v[k].first, z = j+v[k].second;
                if(y<2*n && z<2*n){
                    //cout << i << j << x << y << endl;
                    G[i][j].push_back({y,z}); G[y][z].push_back({i,j});
                }
                y = i-v[k].first;
                if(y>=0 && z<2*n){
                    G[i][j].push_back({y,z}); G[y][z].push_back({i,j});
                }
                z = j-v[k].second;
                if(y>=0 && z>=0){
                    G[i][j].push_back({y,z}); G[y][z].push_back({i,j});
                }
                y = i+v[k].first;
                if(y<2*n && z>=0){
                    G[i][j].push_back({y,z}); G[y][z].push_back({i,j});
                }
            }
        }
    }
    for(int i=0;i<2*n;i++){
        for(int j=0;j<2*n;j++){
            used[i][j] = -1;
        }
    }
    for(int i=0;i<2*n;i++){
        for(int j=0;j<2*n;j++){
            if(used[i][j]==-1) dfs1(i,j,1,x,G);
        }
    }
}

int main(){
    int d,e;
    cin >> n >> d >> e;
    dfs2(d,1);
    dfs2(e,2);
    vector<pii> sum1, sum2, sum3, sum4;
    for(int i=0;i<2*n;i++){
        for(int j=0;j<2*n;j++){
            int x = color[i][j].first,y = color[i][j].second;
            //cout << i << " "<< j << " " << x << " " << y << endl;
            if(x==1 && y==1) sum1.push_back({i,j});
            if(x==2 && y==1) sum2.push_back({i,j});
            if(x==2 && y==2) sum3.push_back({i,j});
            if(x==1 && y==2) sum4.push_back({i,j});
        }
    }
    if(sum1.size()>=n*n){
        for(int i=0;i<n*n;i++){
            cout << sum1[i].first << " " << sum1[i].second << endl;
        }
        return 0;
    }
    if(sum2.size()>=n*n){
        for(int i=0;i<n*n;i++){
            cout << sum2[i].first << " " << sum2[i].second << endl;
        }
        return 0;
    }
    if(sum3.size()>=n*n){
        for(int i=0;i<n*n;i++){
            cout << sum3[i].first << " " << sum3[i].second << endl;
        }
        return 0;
    }
    if(sum4.size()>=n*n){
        for(int i=0;i<n*n;i++){
            cout << sum4[i].first <<  " " << sum4[i].second << endl;
        }
        return 0;
    }
}

Measured memory_bytes: 381184
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
 
int main(){
  long n;
  cin >> n;
  long srt;
  srt = sqrt(n) + 1;
  long a, b;
  rep(i,srt){
    if(n % (srt - i) == 0){
      a = srt - i;
      b = n / (srt - i);
      break;
    }
  }
  cout << a + b - 2 << endl;
}
    

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

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

void solve() {
    int X, N;
    cin >> X >> N;
    vector<bool> p(102, false);
    rep(i, N){
        int tmp;
        cin >> tmp;
        p[tmp] = true;
    }
    int min=100000;
    int ans;
    for(int i=101; i>=0; i--){
        if(p[i]) continue;
        int a = abs(i-X);
        if(a <= min){
            min = a;
            ans = i;
        }
    }
    out(ans);
}
int main() {
    INCANT;
    solve();
    return 0;
}




Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int A,B;
  cin>>A>>B;
  cout<<A*B<<endl;
}


Measured memory_bytes: 3640
N = int(input())
if N == 1:
  print('Yes')
  print(2)
  print(1, 1)
  print(1, 1)
  quit()

S = [{1, 2}, {1, 3}, {2, 3}]
n = 3
while n < N:
  l = len(S)
  s = set()
  for i in range(l):
    n += 1
    S[i].add(n)
    s.add(n)
  S.append(s)

if n == N:
  print('Yes')
  print(len(S))
  for s in S:
    print(len(s), *s)
else:
  print('No')

Measured memory_bytes: 22024
n = int(input())
if n >= 2000:
    print(1)
else:
    d = n % 100
    l = (d // 5) + (d % 5 != 0)
    #print(d,l)
    if (n // 100) >= l and n != 0:
        print(1)
    else:
        print(0)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  double x,sum=0;
  string s;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x>>s;
    if(s=="JPY"){
      sum+=x;
    }else{
      x*=380000.0;
      sum+=x;
    }
  }
  cout<<sum<<endl;
  return 0;
}


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

using namespace std ;


int main(){
    int a[3],i;

    set<int>p;


    for(i=0;i<3;i++){
    cin>>a[i] ;
    p.insert(a[i]) ;

    }

    if(p.size()==2){
        printf("Yes\n") ;
    }

    else {
        printf("No\n") ;
    }

}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <climits>
#include <string>
#include <map>
#include <set>
#include <list>

int main() {
    int a, b, c;
    std::cin >> a >> b >> c;
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
        puts("0");
        return 0;
    }
    if (a == std::max(a, std::max(b, c))) {
        std::cout << (long long) b * (long long) c; 
        return 0;
    }
    if (b == std::max(a, std::max(b, c))) {
        std::cout << (long long) a * (long long) c; 
        return 0;
    }
    if (c == std::max(a, std::max(b, c))) {
        std::cout << (long long) b * (long long) a; 
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
public class Program {
  public static void Main() {
    int[] AB = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    int A = AB[0], B = AB[1];
    int diff = B-A;
    int towerB = Enumerable.Range(1, diff).Sum();
    int snow = towerB - B;
    Console.WriteLine(snow);
  }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

int main() {
	int  a;
	std::cin >> a;
	if (a < 3) {
		std::cout << "0" << std::endl;
		return 0;
	}
	std::cout << a / 3 << std::endl;




}

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

using namespace std;

int64_t modpow(int64_t a, int64_t b, int64_t MOD) {
	int64_t ret = 1;
	while (b > 0) {
		if (b & 1) { (ret *= a) %= MOD; }
		(a *= a) %= MOD;
		b >>= 1;
	}
	return ret % MOD;
}

const Int MOD = 1e9 + 7;
Int func(Int a, Int b) {
	Int x = 1, y = 1;
	b = min(b, a - b);
	for (Int i = 0; i < b; ++i) {
		(x *= (a - i)) %= MOD;
	}
	for (Int i = 1; i <= b; ++i) {
		(y *= i) %= MOD;
	}
	Int ret = (x * modpow(y, MOD - 2, MOD)) % MOD;
	return ret;
}

int main() {
	int N, a, b;
	cin >> N >> a >> b;

	Int ans = (modpow(2, N, MOD) + MOD - 1) % MOD;
	Int xa = func(N, a);
	ans = (ans + MOD - xa) % MOD;
	if (a != b) {
		Int xb = func(N, b);
		ans = (ans + MOD - xb) % MOD;
	}
	cout << ans % MOD << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
long long int INF = 1000000000LL;
vector<long long int> dijkstra(int s, int v, vector< vector< pair<long long int,int> > > G){
  //s: ?§????, v: ????????°, G: ??£??\?????????
  priority_queue< pair<long long int, int> > wait;
  vector<long long int> result(v, INF);
  result[s] = 0LL;
  wait.push(make_pair(0LL, s));
  while(!wait.empty()){
    int nowpoint = wait.top().second;
    int nowcost = wait.top().first;
    wait.pop();
    if(nowcost <= result[nowpoint]){
      for(int i = 0; i < G[nowpoint].size(); ++i){
	int nextpoint = G[nowpoint][i].second;
	int nextcost = -nowcost + G[nowpoint][i].first;
	if(nextcost < result[nextpoint]){
	  wait.push(make_pair(-nextcost, nextpoint));
	  result[nextpoint] = nextcost;
	}
      }
    }
  }
  return result;
}



int main(){
  int n;
  while(cin >> n, n){
    long long int ans = 0LL;
    /*
    long long int G[n][n];
    for(int i = 0; i < n; ++i)
      fill(G[i],G[i]+n,INF);
    for(int i = 0; i < n; ++i)
      G[i][i] = 0;
    */
    int p[n], deg[n];
    fill(deg,deg+n,-1);
    for(int i = 1; i < n; ++i){
      cin >> p[i];
      --p[i];
      ++deg[p[i]];
      ++deg[i];
    }
    long long int d[n];
    for(int i = 1; i < n; ++i){
      cin >> d[i];
      if(deg[i] && deg[p[i]]) ans += 3*d[i];
      else ans += d[i];
    }
    vector< vector< pair<long long int, int> > > G(n);
    for(int i = 1; i < n; ++i){
      if(deg[i] && deg[p[i]]){
	G[i].push_back(make_pair(d[i],p[i]));
	G[p[i]].push_back(make_pair(d[i],i));
      }
    }
    int s = -1;
    for(int i = 0; i < n; ++i){
      if(deg[i]) s = i;
    }
    vector<long long int> D = dijkstra(s,n,G);
    long long int M = 0LL;
    for(int i = 0; i < n; ++i){
      if(D[i] < INF && D[i] > M){
	s = i;
	M = D[i];
      }
    }
    D = dijkstra(s,n,G);
    M = 0LL;
    for(int i = 0; i < n; ++i)
      if(D[i] < INF)
	M = max(M,D[i]);
    /*
    for(int i = 1; i < n; ++i){
      if(deg[i] && deg[p[i]]){
	 G[i][p[i]] = d[i];
	 G[p[i]][i] = d[i];
      }
    }
    for(int k = 0; k < n; ++k)
      for(int i = 0; i < n; ++i)
	for(int j = 0; j < n; ++j)
	  G[i][j] = min(G[i][j],G[i][k] + G[k][j]);
	  
    for(int i = 0; i < n; ++i)
      for(int j = i; j < n; ++j)
	if(G[i][j] < INF)
	  M = max(M,G[i][j]);
    */
    ans -= M;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3272
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define P pair<int,int>
#define ll long long
#define f first
#define s second
using namespace std;
int n,nn,nx,mx=-INF,mn=INF;
P a[200005];
ll ans;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
    n=read();
    for(int i=1;i<=n;++i){
        a[i].f=read(),a[i].s=read();
        if(a[i].f>a[i].s) swap(a[i].f,a[i].s);
        mx=max(mx,a[i].s),mn=min(mn,a[i].s);
    }
    sort(a+1,a+n+1);
    ans=1ll*(mx-mn)*(a[n].f-a[1].f),nn=nx=a[1].s;
    for(int i=2;i<=n;++i){
        ans=min(ans,1ll*(mx-a[1].f)*(max(nx,a[n].f)-min(nn,a[i].f)));
        nn=min(nn,a[i].s),nx=max(nx,a[i].s); 
    }
    printf("%lld",ans);
}

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

int main() {
	long long A, B, N;
	long long ANS = 0;
	cin >> A >> B >> N;
	for (long long i = 1; i <= B; i++) {
		long long X = i * B - 1;
		if (X > N) break;
		ANS = max(ANS, (A * X) / B - A * (X / B));
	}
	ANS = max(ANS, (A * N) / B - A * (N / B));
	cout << ANS << endl;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;

int main(){
  int A, B;
  char op;
  cin >> A >> op >> B;
  if(op == '+'){
    cout << A + B << endl;
  }
  else{
    cout << A-B << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>

using namespace std;

const int INF = 2e9;
int n, m;
int d[4500];

int main()
{
    //freopen("input.txt", "r", stdin);
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= (1 << n); i++) d[i] = INF;
    for(int i = 0; i < m; i++)
    {
        int a, b, c, now = 0;
        scanf("%d%d", &a, &b);
        for(int i = 0; i < b; i++)
        {
            scanf("%d", &c);
            now |= (1 << c) / 2;
        }
        for(int j = (1 << n); j >= 0; j--)
        {
            if(d[j] < INF) d[j | now] = min(d[j | now], d[j] + a);
        }
    }
    if(d[(1 << n) - 1] == INF) printf("-1");
    else
    {
        printf("%d", d[(1 << n) - 1]);
    }
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int
typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  int n;
  cin >> n;
  vector<int> v(n, 0);
  vector<int> tmp(n, 0);
  for (int i = 0; i < n; i++)
  {
    cin >> v[i];
    v[i] -= (i+1);
  }

  sort(all(v));

  // for(int i : tmp) cout << i << endl;
  int median = v[n/2];
  // if(n % 2 == 0) median = (tmp[n/2] + tmp[n/2 - 1]) / 2;
  // cout << median << endl;

  ll res = 0;
  for (int i = 0; i < n; i++)
  {
    res += abs(v[i] - median);
  }

  cout << res << endl;
}

Measured memory_bytes: 1792
// ABS Practice A
#include<bits/stdc++.h>

using namespace std;
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#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())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define PB(a) push_back(a)
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  int a,b;
  cin >> a >>b;
  str ans;
//  VI a(N);
  ans = (a*b)%2==0?"Even":"Odd";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    ll n ; cin >> n;
    vector<vector<pair<ll,ll>>> dis(n);

    rep(i,n-1){
        ll a,b,c; cin >> a >> b >> c;
        a--; b--;
        dis.at(a).push_back(make_pair(b,c));
        dis.at(b).push_back(make_pair(a,c));
    }

    ll q,k; cin >> q >> k;
    k--;

    vector<ll> disfromk(n);
    disfromk.at(k) = 0;

    vector<bool> visited(n,0);
    visited.at(k) = 1;

    queue<ll> qq;
    qq.push(k);

    while(qq.size()){
        ll x = qq.front();
        qq.pop();
        ll nowdis = disfromk.at(x);

        for(auto z:dis.at(x)){
            ll to = z.first;
            if(!visited.at(to)){
                disfromk.at(to) =  nowdis + z.second;
                visited.at(to) = 1;
                qq.push(to);
            }
        }
    }

    rep(i,q){
        ll qx,qy; cin >> qx >> qy;
        qx--; qy--;
        cout << disfromk.at(qx) + disfromk.at(qy) << endl;
    }
    return 0;
}

Measured memory_bytes: 9984
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,m] <- getIntList
    bridges <- VU.replicateM m $ do
        [a,b] <- getIntList
        return (a-1, b-1)
    let ns = V.create $ do
            vec <- VM.replicate n []
            VU.forM_ bridges $ \(a,b) -> do
                VM.modify vec (b:) a
                VM.modify vec (a:) b
            return vec
    let l2 = map (ns V.!) (ns V.! 0)
    putStrLn $ if any ((n-1) `elem`) l2 then "POSSIBLE" else "IMPOSSIBLE"

Measured memory_bytes: 33532
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

vector<int> checked;
vector<vector<int>> to;
vector<ll> black,white;

void dfs(int v,int p=-1){
    if(checked[v])return;
    checked[v]=1;
    if(to[v].size()==1 && to[v][0]==p){
        black.at(v)=1;
        white.at(v)=1;
        return;
    }
    ll bl=1,wh=1;
    for(int u:to[v]){
        if(u==p)continue;
        dfs(u,v);
        bl*=white[u];
        wh*=(black[u]+white[u])%MOD;
        bl%=MOD;wh%=MOD;
    }
    black.at(v)=bl;
    white.at(v)=wh;
    return;
}

int main() {
    int N;
    cin>>N;
    checked.resize(N);
    to.resize(N,vector<int>(0));
    black.resize(N);
    white.resize(N);
    rep(i,N-1){
        int x,y;
        cin>>x>>y;
        --x;--y;
        to[x].pb(y);
        to[y].pb(x);
    }
    dfs(0);
    ll ans=black[0]+white[0];
    ans%=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 17580
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#include <climits>

#define DEBUG if(false)

using namespace std;

int main(){

  string T;
  cin >> T;
  for(int i = 0; i < T.length(); i++){
    if(T[i] == '?'){
      T[i] = 'D';
    }
  }
  cout << T << endl;

  return 0;
}


Measured memory_bytes: 3756
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;
int A[100000];
int N;

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

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	int ans = partition(0, N - 1);
	for (int i = 0; i < N; i++)
	{
		if (i > 0) cout << ' ';
		if (i == ans) cout << '[';
		cout<< A[i];
		if (i == ans) cout << ']';	
	}
	cout << endl;
	return 0;
}


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

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

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

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

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

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

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

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

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = *this^(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

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

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

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


///////////////////////////
ll p(ll n) {
	if (n == 0) { return 1; }
	return 10 * p(n - 1);
}

ll D;

ll dfs(ll X, ll d, ll i) {
	if (d-i==i) {
		if (X == 0) { return 10; }
		else { return 0; }
	}

	if (d - i < i) {
		if (X == 0) { return 1; }
		else { return 0; }
	}

	ll ret = 0;

	ll j = X / p(i) % 10;
	if (j < 0) { j += 10; }

	ll a = 10 - j;
	if (a != 10) {
		ll Y = X - a * (p(d - i) - p(i));

		if (i == 0)ret += (9 - abs(a)) * dfs(Y, d, i + 1);
		else ret += (10 - abs(a)) * dfs(Y, d, i + 1);
	}

	a = -j;
	ll Y = X - a * (p(d - i) - p(i));
	if (i == 0)ret += (9 - abs(a)) * dfs(Y, d, i + 1);
	else ret += (10 - abs(a)) * dfs(Y, d, i + 1);

	return ret;
}

int main() {
	cin >> D;

	ll ans = 0;

	rep(d, 18) {
		ans += dfs(D, d, 0);
	}
	
	cout << ans << endl;

}


Measured memory_bytes: 384
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

// AOJ 0076
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (sc.hasNext()) {
			String s = sc.next();
			String res = "";
			for (int i = 0; i < s.length(); i++) {
				char c = s.charAt(i);
				if (c == '@') {
					int rep = s.charAt(i + 1) - '0';
					char b = s.charAt(i + 2);
					for (int j = 0; j < rep; j++)
						res += b;
					i += 2;
				} else {
					res += c;
				}
			}
			System.out.println(res);
		}
	}	
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(ll i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0)
            s+=i;
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;

template <class T> using V = vector<T>;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;

using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;



#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);



ll Sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}



const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


#define comuse Comuse()

ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}


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


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}

ll modpow(ll a,ll n,ll mod){
  ll ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
//segtreeの葉の先頭の添え字はn-1
void Solve(){
  //vll segtree(524287);
  //ll N=262144;
  ll n;
    cin>>n;
  st s;
    cin>>s;
  ll ans=0;
  FOR(i,0,n-2){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
      ans++;
    }
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int d;
  cin >> d;
  if(d == 25){
    cout << "Christmas" << endl;
  }else if(d == 24){
    cout << "Christmas Eve" << endl;
  }else if(d == 23){
    cout << "Christmas Eve Eve" << endl;
  }else{
    cout << "Christmas Eve Eve Eve" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
vector<int> v;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,k;
    cin>>a>>b>>k;
    for(int i=1;i<=min(a,b);i++){
        if(a%i==0&&b%i==0){
            v.push_back(i);
        }
    }
    int n=v.size();
    cout<<v[n-k]<<endl;

    return 0;
}



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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main(void){
	queue<char> q[3];
	rep(i,3){
		string s;
		cin >> s;
		for(auto &c:s) q[i].push(c);
	}

	int cur=0;
	while(1){
		if(q[cur].empty()){
			cout << char(cur+'A') << endl;
			return 0;
		}
		int nxt=q[cur].front()-'a';
		q[cur].pop();
		cur=nxt;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a)  (a).begin(),(a).end()
#define elif else if


int low(V<int> a,int b){
  decltype(a)::iterator c=lower_bound(a.begin(),a.end(),b);
  int d=c-a.bgn;
  return d;
}
int upp(V<int> a,int b){
  decltype(a)::iterator c=upper_bound(a.begin(),a.end(),b);
  int d=c-a.bgn;
  return d;
}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int INF=1000000007;
int kaijou(int a){
  int b=1;
  fo(i,a)
    b*=i+1;
  return b;
}

V<P<int,int>> factorize(int n){
  V<P<int,int>> res;
  for(int i=2; i*i<=n; i++){
    if(n%i)
      continue;
    res.emplace_back(i,0);
    while(n%i==0){
      n/=i;
      res.back().second++;
    }
  }
  if(n!=1)
    res.emplace_back(n,1);
  return res;
}

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

signed main(){
  int n,q;
  cin>>n>>q;
  string s;
  cin>>s;
  V<int> b(n+2,0);
  fo(i,n){
    if(s[i]=='A'&&s[i+1]=='C'){
      b[i]++;
    }
    if(i)
      b[i]+=b[i-1];
  }
  fo(i,q){
    int c,d;
    cin>>c>>d;
    if(c-2<0)
      cout<<b[d-2]<<endl;
    else
      cout<<b[d-2]-b[c-2]<<endl;
  }
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
int exsearch(int*, int, int);
main()
{
        int i, n, q, m, *a;
        scanf("%d", &n);
        a = (int*)malloc(sizeof(int) * n);
        for(i = 0; i < n; i++){
        scanf("%d%*c", &a[i]);
        }
        scanf("%d", &q);
        for(i = 0; i < q; i++){
                scanf("%d%*c", &m);
                if(exsearch(a, m, n)){
                        printf("yes\n");
                }else{
                        printf("no\n");
                }
        }
        free(a);
}
int exsearch(int *a, int m, int n)
{
        int result;
        if(!m){
        return 1;
        }else if(!n || m < 0 ){
                return 0;
        }else{
                result = exsearch(a, m - a[n - 1], n - 1) || exsearch(a, m, n - 1);
        }
        return result;
}

Measured memory_bytes: 1804
import java.util.*;

public class Main{
    static int count=0;
    static int count1=0;
    public static void main(String[] args){
        int a=0;
        int b=0;
        Scanner sc = new Scanner(System.in);
        a=sc.nextInt();
        b=sc.nextInt();
       
        count = func(a);
        count1=func2(b);
        
        System.out.println((count)+(count1));
    }
    static int func(int a){
    if(a>=1)     
    count =(a-1)+func(a-1);
    return count;
    
    }
    static int func2(int b){
    if(b>=2)     
    count1 =(b-1)+func2(b-1);
    return count1;
    
    }
}

Measured memory_bytes: 21712
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#include<set>
#include<map>
#include<utility>
#include<string>
#include<vector>

using namespace std;

#define LL long long

LL n,fib[50];

int main() {
	cin>>n;
	for(int i=0;i<=n;i++){
		if(i==0||i==1)fib[i]=1;
		else fib[i]=fib[i-1]+fib[i-2];
	}
	cout<<fib[n]<<endl;
	return 0;
}


Measured memory_bytes: 3112
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

// 約数の列挙O(√n)
int divisor(int n) {
  vector<int> res;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  return res.size();
}

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 2 == 1 && divisor(i) == 8) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604