akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
using namespace std;

int main(){
  unsigned long a, b, n;
  cin >> a >> b >> n;
  if(b>n){
    cout << floor((a*n)/b) << endl;
  }else if(b-1 > 0){
    cout << floor((a*(b-1))/b) << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 3716
def main():
  r,g,b,n=map(int,input().split())
  cnt=0
  for i in range(n//r+1):
    for j in range((n-i*r)//g+1):
      tmp=r*i+g*j
      q,mod=divmod(n-tmp,b)
      if (q>=0 and mod==0):
        cnt+=1
  print(cnt)
  
main()


Measured memory_bytes: 40432
//include
//------------------------------------------
#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;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//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 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,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    string s;
    cin >> s;
    for(int i=0;i<19;++i){
        if(s[i]==','){
            s[i]=' ';
        }
    }
    cout << s;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		}

		ptr = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}

		return buflen > 0;
	}

	private int readByte() {
		return hasNextByte() ? buffer[ptr++] : -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public String nextLine() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b) || b == ' ') {
			sb.appendCodePoint(b);
			b = readByte();
		}

		while (b != '\n') {
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int[] a = new int[n];
		int aMax = 0;
		for (int i = 0; i < n; ++i) {
			int tmp = sc.nextInt();
			a[i] = tmp;
			aMax = Math.max(aMax, tmp);
		}
		Arrays.sort(a);

		boolean[] sieve = new boolean[aMax + 10];
		Arrays.fill(sieve, true);

		for (int i = 0; i < n; ++i) {
			if (!sieve[a[i]]) {
				continue;
			}

			if (i < n - 1 && a[i] == a[i + 1]) {
				sieve[a[i]] = false;
			}

			for (int j = a[i] * 2; j <= aMax; j += a[i]) {
				if (sieve[j]) {
					sieve[j] = false;
				}
			}
		}

		int ans = 0;
		for (int num : a) {
			if (sieve[num]) {
				++ans;
			}
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 40420
package main

import (
	"fmt"
)

func countBits(n int) int {
	var cnt int
	for ; n > 0; n /= 2 {
		if n&1 == 1 {
			cnt += 1
		}
	}
	return cnt
}

func checkHonest(n, i int) bool {
	return n&(1<<uint(i)) > 0
}

const (
	NOT_HONEST = 0
	HONEST     = 1
)

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

	xy := make([]map[int]int, n+1)
	for i := 0; i < n+1; i++ {
		xy[i] = map[int]int{}
	}
	var a, x, y int
	for i := 1; i < n+1; i++ {
		fmt.Scan(&a)
		for j := 0; j < a; j++ {
			fmt.Scan(&x, &y)
			xy[i][x] = y
		}
	}

	var max, bits int
	maxBits := 1 << uint(n)
	for ; bits < maxBits; bits++ {
		honestCount := countBits(bits)
		result := make([][]int, n+1)
		isCorrect := true
	LOOPA:
		for i := 1; i < n+1; i++ {
			isHonest := bits&(1<<uint(i-1)) > 0
			if !isHonest {
				continue
			}
			for k, v := range xy[i] {
				if (v == HONEST) && !checkHonest(bits, k-1) || (v == NOT_HONEST) && checkHonest(bits, k-1) {
					isCorrect = false
					break LOOPA
				}
				result[k] = append(result[k], v)
			}
		}
	LOOPB:
		for i := 1; i < n+1; i++ {
			if len(result[i]) < 1 {
				continue
			}
			for j := 1; j < len(result[i]); j++ {
				if result[i][j] != result[i][j-1] {
					isCorrect = false
					break LOOPB
				}
			}
		}
		if isCorrect && max < honestCount {
			max = honestCount
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 5504
N,M=list(map(int,input().strip().split(' ')))


dic_connect={}

for _ in range(M):
    X=list(map(int,input().strip().split(' ')))
    X=X[1:]
    for x in X:
        if x in dic_connect:
            dic_connect[x]+=[_+1]
        else:
            dic_connect[x]=[_+1]    


P=[-1]+list(map(int,input().strip().split(' ')))
count=0

def check(s,N,M):
    count_bulbs=[0]*(M+1)
    for i in range(len(s)):
        if s[i]=='1':
            switch=i+1
            if switch in dic_connect:
                for b in dic_connect[switch]:
                    count_bulbs[b]+=1
    
    for i in range(1,M+1):
        if (count_bulbs[i]-P[i])%2!=0:
            return 0
    
    return 1

#print(dic_connect)

for i in range(2**N):
    s="0"*(N-len(bin(i)[2:]))+bin(i)[2:]
    count+=check(s,N,M)
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
 
struct UnionFind
{
  vector<int> par;
  vector<int> sizes;
 
  UnionFind(int n) : par(n), sizes(n, 1) {
    rep(i,n) par[i] = i;
  }
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]); 
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
 
    if (x == y) return;

    if (sizes[x] < sizes[y]) swap(x, y);

    par[y] = x;
    sizes[x] += sizes[y];
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int size(int x) {
    return sizes[find(x)];
  }
};
 
int main(){
    ll n; cin>>n;
    ll m; cin>>m;
  	UnionFind uf(n);
    int a[m],b[m];
    rep(i,m){
         cin>>a[i]>>b[i];
         a[i]--;b[i]--;
    }
 
    ll rec=n*(n-1)/2;
    
    vector<ll> ans;
    ans.push_back(rec);
 
    
    for(int i=m-1;i>=0;i--){
            if(!uf.same(a[i],b[i])){
                ll t1=uf.size(a[i]);
                ll t2=uf.size(b[i]);
                rec -= t1*t2;
                uf.unite(a[i],b[i]);
                ans.push_back(rec);
            }
            else ans.push_back(rec);
    }
       
    for(int i=1;i<ans.size();i++){
        cout<<ans[ans.size()-1-i]<<endl;
    }
}

Measured memory_bytes: 3828
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Program
{

    public void Proc()
    {
		int[] cnt = new int['z' + 1];
        while(true) {
            string inpt = Reader.ReadLine();
            if(inpt == null) {
                break;
            }
            inpt = inpt.ToLower();
			for (int i = 0; i < inpt.Length; i++)
			{
				if (inpt[i] < 'a' || inpt[i] > 'z')
				{
					continue;
				}
				cnt[inpt[i]]++;
			}
		}
        for (char c = 'a'; c <= 'z'; c++) {
            Console.WriteLine(c + " : " + cnt[c]);
        }
    }

    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"

This is a pen.


";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

Measured memory_bytes: 9116
n = int(input())
s = input()
black = s[:0].count("#")
white = s[0:].count(".")
count = [black+white]    
    
for i in range(1, n+1):
    if s[i-1]== "#":
        black +=1
    else:
        white -=1
    count.append(white+black)
    
print(min(count))

Measured memory_bytes: 11264
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        if((a+b)%3==0||a%3==0||b%3==0)
            cout<<"Possible"<<endl;
        else
            cout<<"Impossible"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//  
//

#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 ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;

//#define __DBG__


void solve(void){
  
  int N;
  string S;
  bool flag=true;
  
  cin >> N >> S;
  
  if(N%2){
    flag=false;
  }
  else
  {
    string S1, S2;
    S1=S.substr(0,N/2);
    S2=S.substr(N/2,N/2);
    if(S1!=S2){
      flag=false;
    }
  }
  puts(flag?"Yes":"No");
  
  return;
   
}


int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
 
    return 0;
}




Measured memory_bytes: 256
def evaluate_mark(scores):
    if scores[0] == -1 or scores[1] == -1:
        return 'F'

    total = scores[0] + scores[1]

    if 80 <= total:
        return 'A'
    elif 65 <= total < 80:
        return 'B'
    elif 50 <= total < 65:
        return 'C'
    elif 30 <= total < 50:
        if 50 <= scores[2]:
            return 'C'
        else:
            return 'D'
    else:
        return 'F'


if __name__ == "__main__":
    student_score_list = []

    absence_code = -1

    while True:
        score_input = input()

        scores = list(map(int, score_input.split()))

        if all(map(lambda score: score == -1, scores)):
            break

        student_score_list.append(scores)

    marks = list(map(evaluate_mark, student_score_list))

    for mark in marks:
        print(mark)



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  int flag = 0;
  for(int i = S.size() - 1;;) {
    if(i == -1) {
      flag = 1;
      break;
    }
    if(i < 4) break;
    if(S.substr(i - 4, 5) == "dream" || S.substr(i - 4, 5) == "erase") {
      i -= 5;
      continue;
    }
    if(i < 5) break;
    if(S.substr(i - 5, 6) == "eraser") {
      i -= 6;
      continue;
    }
    if(i < 6) break;
    if(S.substr(i - 6, 7) == "dreamer") {
      i -= 7;
      continue;
    }else break;
  }
  if(flag == 0)cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}


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

const string YES = "POSSIBLE";
const string NO = "IMPOSSIBLE";

void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b) {
    set<ll> oneset, nset;
    rep(i, M) {
        if (a[i] == 1) {
            oneset.insert(b[i]);
        }
        if (b[i] == N) {
            nset.insert(a[i]);
        }
    }
    for (auto i = oneset.begin(); i != oneset.end(); i++) {
        if (nset.find(*i) != nset.end()) {
            cout << YES << endl;
            return;
        }
    }
    cout << NO << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> a(M);
    std::vector<long long> b(M);
    for (int i = 0; i < M; i++) {
        scanf("%lld", &a[i]);
        scanf("%lld", &b[i]);
    }
    solve(N, M, std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 15644
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
using namespace std;

int main() {
    int i, sum;
    vector<string> vec;
    vector<string>::iterator it;
    string str;

    while(1) {
        cin >> str;
        if(str[0] == '0') break;
        vec.push_back(str);
    }

    for(it=vec.begin(); it!=vec.end(); ++it) {
        sum = 0;
        for(i=0; i<(*it).length(); ++i) {
            sum += (*it)[i] - '0';
        }
        cout << sum << endl;
    }

    return 0;
}

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

int main(void){
  int n, i, j;
  scanf("%d", &n);
  int max = 1;
  
  for(i = 2; i < n / 2; i++){
    for(j = 1; (int)pow(i, j) <= n; j++){
      if(max < (int)pow(i, j)) max = (int)pow(i, j);
    }
  }
  
  printf("%d\n", max);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
int n;
double ans=0;
cin>>n;
while(n--)
{
    double m;
    string k;
    cin>>m>>k;
    if(k=="BTC")m=m*380000.0;
    ans+=m;
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll N, M;
  cin >> N >> M;
  ll ans;
  if (N - M / 2 >= 0) {
    ans = M / 2;
  } else {
    ans = N + (M - 2 * N) / 4;
  }
  cout << ans;
  return 0;
}

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

int main()
{
    ll idx,n,k,q;
    cin>>n>>k>>q;

    vector<ll> arr(n,0);
    ll sum = q;
    for(ll i=0;i<q;i++){
        cin>>idx;
        arr[idx-1]++;
    }

    for(ll i=0;i<n;i++){
        ll fail = sum - arr[i];
        if(fail>=k)
            cout<<"No\n";
        else
            cout<<"Yes\n";
    }
}


Measured memory_bytes: 1408
a, b, c, d = map(int, input().split())

if c % b == 0:
    takahashi = c // b
else:
    takahashi = c // b + 1

if a % d == 0:
    aoki = a // d
else:
    aoki = a // d + 1

# print(takahashi)
# print(aoki)

if takahashi <= aoki:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9180
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <tuple>

using namespace std;

int main()
{
 string A,B,C;
 cin >> A >> B >> C;
 if(A[A.size()-1] == B[0] && B[B.size()-1] == C[0]) cout << "YES" << endl;
 else cout << "NO" << endl;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INFLL=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

vector<int> graph[10000],ans;
bool done[10000];

void topo_dfs(int v){
    if(done[v]) return;
    done[v]=true;
    for(auto u:graph[v]) topo_dfs(u);
    ans.push_back(v);
}

void solve(){
    int v,e;
    cin >> v >> e;
    rep(i,0,e){
        int s,t;
        cin >> s >> t;
        graph[s].push_back(t);
    }
    
    rep(i,0,v) topo_dfs(i);
    
    reverse(ans.begin(),ans.end());
    
    for(auto x:ans) cout << x << endl;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 1956
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.next().toCharArray();
			int max = 1 << (s.length - 1);
			System.out.println(IntStream.range(0, max).mapToLong(i -> eval(i, s)).sum());
		}
	}

	/**
	 * @param n 「+」ありなしの2進数
	 * @param s 入力数字の文字列
	 * @return 文字列に「+」を追加した後の数式の計算結果
	 */
	private static long eval(int n, char[] s) {
		StringBuilder sb = new StringBuilder();
		long sum = 0L;
		for (int i = 0; i < s.length - 1; i++) {
			sb.append(s[i]);
			if (1 == ((n >> i) & 1)) {
				sum += Long.parseLong(sb.toString());
				sb.setLength(0);
			}
		}
		// 最後の項目を追加
		sb.append(s[s.length - 1]);
		return sum + Long.parseLong(sb.toString());
	}
}


Measured memory_bytes: 36516
// atcoder/abc059/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string a, b;
  while (cin >> a >> b) {
    while (a.size() < b.size()) a = string("0") + a;
    while (a.size() > b.size()) b = string("0") + b;
    assert(a.size() == b.size());
    string s = "EQUAL";
    for (int i = 0; i < a.size(); ++i) {
      if (a[i] > b[i]) {
        s = "GREATER";
        break;
      }
      if (a[i] < b[i]) {
        s = "LESS";
        break;
      }
    }
    cout << s << endl;
  }

  return 0;
}


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


int main(){
    int n,x;
    cin>>x>>n;
    int arr[104];
    fill(arr,arr+104,0);
    for(int i=0;i<n;i++)
    {
        int a;cin>>a;
        arr[a]=1;
    }
    
    int ans ;
    int diff = 10000;
    for(int i=0;i<=102;i++){
        
        if(diff>abs(i-x) && arr[i]==0){
            ans=i;
            diff= abs(i-x);
        }
    }
    
    cout<<ans;
}

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

int main(){
  int n,o,c;
  cin >> n;
  c = 0;
  o = 0;
  vector<int> vec(n);
  for(int i = 0;i < n;i++){
    cin >> vec.at(i);
  }
  for(;;c++){
    for(int j = 0;j < n;j++){
      if(vec.at(j)%2 != 0){
        o = 1;
      }
      vec.at(j) /= 2;
    }
    if(o == 1){
      break;
    }
  }
  cout << c << endl;
}


Measured memory_bytes: 256
n = int(input())
ss = []
for i in range(n):
    ss.append(input())


a = 0
b = 0
c = 0
d = 0
for s in ss:

    d += s.count("AB")
    if s[0] == "B" and s[-1] == "A":
        c += 1
    elif s[0] == "B":
        b += 1
    elif s[-1] == "A":
        a += 1


if c > 0:
    d+= c-1
    if a > 0 :
        d+=1
        a -= 1
    if b > 0 :
        d+=1
        b -= 1

print(d + min(a,b))

Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int n = 0;
	cin >> n;
	string* a = new string[n];
	string* e = new string[n];
	int* b = new int[n];
	int* c = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		e[i] = a[i];
		cin >> b[i];
	}
	sort(a, a + n);
	string d = "";
	for (int i = 0; i < n; i++) {
		if (d != a[i]) {
			d = a[i];
			int cnt = 0;
			for (int m = 0; m < n; m++) {
				if (d == e[m]) {
					c[cnt] = b[m];
					cnt++;
				}
			}
			sort(c, c+cnt, greater<int>());
			for (int z = 0; z < cnt; z++) {
				for (int j = 0; j < n; j++) {
					if (b[j] == c[z]) {
						cout << j+1 << endl;
					}
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[10][10];

int sq(int x)
{
    return x * x;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, d;
    cin >> n >> d;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < d; ++j)
            cin >> a[i][j];

    int sol = 0;
    for (int i = 0; i < n; ++i)
    {
        for (int j = i + 1; j < n; ++j)
        {
            int sum = 0;
            for (int k = 0; k < d; ++k)
                sum += sq(a[i][k] - a[j][k]);
            int r = sqrt(sum);
            if (sum == r * r)
                sol++;
        }
    }
    cout << sol;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long x, k, d, zahyou, move;
    cin >> x >> k >> d;
    if(abs(x)/d<k){
    //座標の符号が途中で変化する場合
    zahyou = x%d;
    move = k-abs(x)/d;
    if(move%2!=0 && x>=0) zahyou -= d;
    else if(move%2!=0 && x<0) zahyou+=d;
    cout << abs(zahyou) <<endl;
    return 0;
    }
    else{
    //最後まで座標の符号が変化しない場合
    if(x>0) zahyou = x-(k*d);
    else zahyou = x + (k*d);
    cout << abs(zahyou) <<endl;
    return 0;
    }
}

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(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 main(){
    int h, w;
    cin >> h >> w;
    vector<string> grid(h+10);
    rep(i, h){
        cin >> grid[i];
        grid[i] += ' ';
    }
  
    vector<vector<ll>> dp(h+10, vector<ll>(w+10, 0));
    dp[0][0] = 1;
    rep(i, h){
        rep(j, w){
            if(grid[i][j] == '#') continue;
            if(grid[i+1][j] == '.'){
                dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MOD;
            }
            if(grid[i][j+1] == '.'){
                dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % MOD;
            }
        }
    }
    cout << dp[h-1][w-1] << ln;
}

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

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

    int ma = max(a,c);
    int mi = min(b,d);

    if(ma <= mi){
        cout << mi - ma << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x,y;
    cin >> n;
    vector<pair<int,int>> v(n);
    for(int i = 0; i < n;i ++){
        cin >> x >> y;
        v[i] = make_pair(x,y);
    }
    sort(v.begin(), v.end());
    int ans = 0;
    for(int i=0; i< n; i++){
        for(int j = i+1; j< n; j++){
            int cnt = 0;
            // 頂点 i -> j への変異をp, qと過程する
            int p = v[j].first - v[i].first;
            int q = v[j].second - v[i].second;
            // cout << endl << p << " " << q << endl;
            for(int x = 0; x < n; x++){
                if(find(v.begin(), v.end(), make_pair(v[x].first-p, v[x].second-q)) != v.end()){
                    cnt++;
                    // cout << "find " << v[x].first << ", " << v[x].second << endl;
                }
            }
            ans = max(ans, cnt);
        }
    }
    cout << n - ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

long long int N, A[3][101] = {}, sum[3][101] = {}, ans = 0;

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

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(Args&&... args) const { print(std::forward<Args>(args)...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(T&& head, Tail&&... tail) const { std::cout << head, print_rest(std::forward<Tail>(tail)...); }
        template <class T, class... Tail>
        void print_rest(T&& head, Tail&&... tail) const { std::cout << sep << head, print_rest(std::forward<Tail>(tail)...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
    template <class T>
    void print_vec(const std::vector<T>& vec, const char* sep = " ", const char* term = "\n") const {
        const size_t sz = vec.size();
        for (size_t i = 0; i < sz; i++) std::cout << vec[i] << (i == sz - 1 ? term : sep);
    }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll cnt = 0;
    ll left = 0, right = N - 1;
    while (left < right) {
        while (left < N && S[left] != 'W') ++left;
        while (right >= 0 && S[right] != 'R') --right;
        if (left < right) {
            ++cnt;
            ++left;
            --right;
        }
    }
    prints()(cnt);
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


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

    int n;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    int num;
    ll ans=0;
    vector<char> s(n);
    for(int i=0;i<n;i++){
        if(v[i]==i+1)s[i]='x';
        else s[i]='o';
    }
    for(int i=0;i<n;i++){

        if(s[i]=='x'){
            s[i]='o';
            if(i<n-1)s[i+1]='o';
            ans++;
        }
    }
    fin(ans);

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    
    int x,a,b;
    cin>>x>>a>>b;
    string ans="dangerous";
    if(a-b>=0)ans="delicious";
    else if(b-a<=x)ans="safe";
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAX=1e+5;
vector<int> g[MAX];
int check[MAX]={0};
void dfs(int v){
	int u;
	for(int i=0;i<g[v].size();i++){
		u=g[v][i];
		if(check[u]==0){
			check[u]++;
			dfs(u);
		}
	}return;
}
int main(){
	int N,M;cin>>N>>M;
	int x,y,z;
	for(int i=0;i<M;i++){
		cin>>x>>y>>z;
		x--;y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}int count=0;
	for(int j=0;j<N;j++){
		if(check[j]==0){
			check[j]++;
			count++;
			dfs(j);
		}
	}cout<<count<<endl;
}

Measured memory_bytes: 9216
int main(int argc, const char * argv[]){
    int S,h,m,s;
    scanf("%d",&S);
    h=S; m=S; s=S;
    h=h/3600; m=(m%3600)/60; s=(s%3600)%60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

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

#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using ll = long long;

const int MX = 3005;

int h, w, k;
ll dp[MX][MX][4], val[MX][MX];

int main() {
	cin.tie(0)->sync_with_stdio(0);
    cin >> h >> w >> k;
    for (int i = 0; i < k; ++i) {
        int hi, wi, v;
        cin >> hi >> wi >> v;
        --hi, --wi;
        val[hi][wi] = v;
    }
    
    dp[0][0][1] = val[0][0];
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            ll mx = -1e9;
            for (int l = 0; l < 4; ++l) {
                mx = max(mx, dp[i][j][l]);
                if (l < 3) {
                    dp[i][j + 1][l + 1] = max(dp[i][j + 1][l + 1], dp[i][j][l] + val[i][j + 1]);
                }
                dp[i][j + 1][l] = max(dp[i][j + 1][l], dp[i][j][l]);
            }
            dp[i + 1][j][0] = max(dp[i + 1][j][0], mx);
            dp[i + 1][j][1] = max(dp[i + 1][j][1], mx + val[i + 1][j]);
        }
    }

    ll ans = -1e18;
    for (int i = 0; i < 4; ++i) {
        ans = max(ans, dp[h - 1][w - 1][i]);
    }
    cout << ans;
}


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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars
    }
    let mut s = s;
    let mut ans = vec![0; s.len()];
    s.push('R');
    let mut r_start = 0;
    let mut l_start = 0;
    let mut prev_char = 'L';
    for i in 0..s.len() {
        if prev_char == 'R' && s[i] == 'L' {
            l_start = i;
        }

        if prev_char == 'L' && s[i] == 'R' {
            if l_start != 0 {
                if (i - r_start) % 2 == 0 {
                    ans[l_start - 1] = (i - r_start + 1) / 2;
                    ans[l_start] = (i - r_start + 1) / 2;
                } else {
                    if (i - l_start) % 2 == 0 {
                        ans[l_start - 1] = (i - r_start + 1) / 2;
                        ans[l_start] = (i - r_start + 1) / 2 - 1;
                    } else {
                        ans[l_start - 1] = (i - r_start + 1) / 2 - 1;
                        ans[l_start] = (i - r_start + 1) / 2;
                    }
                }
            }
            r_start = i;
        }

        prev_char = s[i]
    }
    for a in ans {
        print!("{} ", a);
    }
}


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

int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if(H == 0 && W ==0){
            break;
        }
        else{
            for(int i = 0;i < H;i++){
                for(int j = 0;j < W;j++){
                    if(i == 0 || i == H-1){
                        cout << "#";
                    }
                    else if(i > 0 && i < H-1){
                        if(j == 0 || j == W-1){
                            cout << "#";
                        }
                        else{
                            cout << ".";
                        }
                    }
                }
                cout << "" << endl;
            }
            cout << "" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>

int main(void){
  char s[200001], s2[200001];
  int i=0, j=0;
  long count = 0, acount;
  scanf("%s", s);
  while(s[i] != '\0'){
    if(s[i] == 'B' && s[i+1] == 'C'){
      s2[j] = 'D';
      j++;
      i++; i++;
      continue;
    }
    s2[j] = s[i];
    i++;
    j++;
  }
  i=0;
  while(s2[i] != '\0'){
    acount = 0;
    while(s2[i] == 'A' || s2[i] == 'D'){
      if(s2[i] == 'A') acount++;
      if(s2[i] == 'D') count += acount;
      i++;
    }
    i++;
  }
  printf("%ld", count);
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 200000;
int main()
{
  int n,k,a,i,res=0;
  int c[N_MAX];
  cin >> n >> k;
  fill(c,c+n,0);
  for(i=0;i<n;i++){
    cin >> a;
    c[a-1]++;
  }
  sort(c,c+n,greater<int>());
  for(i=0;i<k;i++)
    res+=c[i];
  res=n-res;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1024
// Mehul Mathur randi hai
// Murali big ghey
// RisHiH is slave
// Anamaya is Sexy
// Arihanth is gay

#include <bits/stdc++.h>

using namespace std;

typedef double ld;

int main()
{
    ld n;
    cin>>n;
    
    ld ans = n/3;
    ans = ans * ans *ans;

    printf("%lf",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int h,w,n;
    cin >> h >> w >> n;
    std::map<pii,int> counter;
    for(int i = 0; i < n; i++){
        int x,y;
        cin >> x >> y;
        x--;
        y--;
        if(x - 1 >= 0 && y - 1 >= 0 && x + 1 < h && y + 1 < w){
            counter[pii(x,y)]++;
        }
        if(x - 2 >= 0 && x < h){
            if(y - 1 >= 0 && y + 1 < w){
                counter[pii(x - 1,y)]++;
            }
            if(y - 2 >= 0 && y < w){
                counter[pii(x - 1,y - 1)]++;
            }
            if(y + 2 < w && y >= 0){
                counter[pii(x - 1,y + 1)]++;
            }
        }
        if(y - 2 >= 0 && y < w && x - 1 >= 0 && x + 1 < h){
            counter[pii(x,y - 1)]++;
        }
        if(x + 2 < h && x >= 0){
            if(y - 1 >= 0 && y + 1 < w){
                counter[pii(x + 1,y)]++;
            }
            if(y >= 0 && y + 2 < w){
                counter[pii(x + 1,y + 1)]++;
            }
            if(y - 2 >= 0 && y < w){
                counter[pii(x + 1,y - 1)]++;
            }
        }
        if(y + 2 < w && y >= 0 && x - 1 >= 0 && x + 1 < h){
            counter[pii(x, y + 1)]++;
        }
    }
    std::vector<int> out(10,0);
    int sum = 0;
    for(auto it = counter.begin(); it != counter.end(); it++){
        out[it->second]++;
    }
    for(int i = 1; i < 10; i++){
        sum += out[i];
    }
    out[0] = (h - 2) * (w - 2) - sum;
    for(int i = 0; i < 10; i++){
        cout << out[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 56576
#include <iostream>
#include <limits>
#include <cstdint>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <cstring>
#include <deque>
#include <stack>
#include <queue>
#include <utility> 
#include <iomanip>      // std::setprecision
using namespace std;
typedef long long int l1;
typedef long long unsigned int lu1;
typedef long double ld;
#define FIO std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
// #define __gcd(a,b) __algo_gcd(a,b)
#define PI acos(-1.0)
#define pb push_back
// #define SORT(A) sort(A.begin(), A.end());
// #define REVERSE(A) reverse(A.begin(), A.end());
#define PrintArray(arr) for(int i=0;i<(int)arr.size();i++)cout<<arr[i]<<" ";cout<<endl;
#define pii pair<int,int>
#define pll pair<long long int , long long int>
#define puu pair<long long unsigned , long long unsigned>
const int MOD = 1e9+7;

int main()
{
    FIO;
    int t;
    t = 1;
    // cin>>t; 
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    for(int tc=0;tc<t;tc++)
    {   
        int n,k;
        cin>>n>>k;
        vector<int> arr(n+1);
        for(int i1=1;i1<=n;i1++) cin>>arr[i1];
        vector<int> dp(n+1,1e9);
        dp[0]=0;
        dp[1] = 0;
        dp[2] = abs(arr[2]-arr[1]);
        for(int i=3;i<=n;i++)
        {
            for(int j=i-1;j>=max(1,i-k);j--)
            {
                dp[i] = min(dp[j]+abs(arr[i]-arr[j]),dp[i]);
            }
        }
        // PrintArray(dp);
        cout<<dp[n]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

public class AtCoder_162_C
{
    public static void Main()
    {
        long n = long.Parse(Console.ReadLine());

        long sum = 0;
        for (long i = 1; i <= n; i++)
        {
            for (long j = 1; j <= n; j++)
            {
                for (long k = 1; k <= n; k++)
                {
                    long ab = Gcd(i, j);
                    sum += Gcd(ab, k);
                }
            }
        }

        Console.WriteLine(sum);
    }

    public static long Gcd(long a, long b)
    {
        if (a < b)
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }

        return a;
    }
}


Measured memory_bytes: 27536
n,m=map(int,input().split())
ac,wa,k,l=0,0,[0]*n,[0]*n
for _ in range(m):
  p,s=input().split()
  if k[int(p)-1]==0:
    if s=='AC':
      ac+=1
      k[int(p)-1]=1
      wa+= l[int(p)-1]
    else:
      l[int(p)-1]+=1
print(ac,wa)

Measured memory_bytes: 4596
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();
        int c = sc.nextInt();
        if(a < b){
            if(b < c){
                System.out.printf("%d %d %d\n", a, b, c);
            }else{
                if(c < a){
                    System.out.printf("%d %d %d\n", c, a, b);
                }else{
                    System.out.printf("%d %d %d\n", a, c, b);
                }
            }
        }else{
            if(b < c){
                if(c < a){
                    System.out.printf("%d %d %d\n", b, c, a);
                }else{
                    System.out.printf("%d %d %d\n", b, a, c);
                }
            }else{
                System.out.printf("%d %d %d\n", c, b, a);
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 26296
#include <iostream>
using namespace std;
bool exist[100001];
int main(void) {
  int n;
  cin >> n;
  int dup = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (exist[a]) dup++;
    else exist[a] = 1;
  }
  cout << n - dup - dup % 2 << endl;
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
    string W,T;
    int n=0;
    cin>>W;
    while(1){
      cin>>T;
      if(T == "END_OF_TEXT") break;
      for(int i = 0;i<T.size();i++){
        if('A' <= T[i] && T[i] <= 'Z') T[i] = tolower(T[i]);
      }
      if (W==T) n++;
        
    }
    cout<<n<<endl;
    return  0;
    
}


Measured memory_bytes: 3136
#include"iostream"
#include"vector"
using namespace std;
int main(void) {
	int bc[9];
	bool bcres[9];
	int a;

	for (int i = 0; i < 9; i++) {
		bcres[i] = false;
	}

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

	vector<int> v;
	int tmp;
	for (int i = 0; i < a; i++) {
		cin >> tmp;
		v.push_back(tmp);
	}

	bool res = false;

	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < 9; j++) {
			if (v.at(i) == bc[j]) {
				bcres[j] = true;
			}
		}
	}

	if (bcres[0] == true && bcres[1] == true && bcres[2] == true){
		res = true;
	}else if(bcres[3] == true && bcres[4] == true && bcres[5] == true){
		res = true;
	}else if(bcres[6] == true && bcres[7] == true && bcres[8] == true){
		res = true;
	}else if(bcres[0] == true && bcres[3] == true && bcres[6] == true){
		res = true;
	}else if(bcres[1] == true && bcres[4] == true && bcres[7] == true) {
		res = true;
	}else if(bcres[2] == true && bcres[5] == true && bcres[8] == true) {
		res = true;
	}else if(bcres[0] == true && bcres[4] == true && bcres[8] == true) {
		res = true;
	}else if(bcres[2] == true && bcres[4] == true && bcres[6] == true) {
		res = true;
	}



	if (res) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}


}


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

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

    for (int j = 0; j < N; j++) {
        cout << B[j] << endl;
    
    }


    return 0;
}

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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
        #define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/
int n, m;
vector<int> g[100000];
vector<int> ans;
bool used[100000];

void dfs(int x)
{
  used[x] = true;
  ans.pb(x);

  for(auto e: g[x]){
    if(!used[e]){
      dfs(e);
      break;
    }
  }
}

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

  int sa, sb;
  cin >> sa >> sb;
  sa--; sb--;
  rep(i, m-1){
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].pb(b);
    g[b].pb(a);
  }

  used[sa] = used[sb] = true;

  dfs(sa);
  reverse(all(ans));
  dfs(sb);

  cout << ans.size() << endl;
  rep(i, ans.size()){
    cout << ans[i]+1 << " \n"[i == ans.size()-1];
  }

  return 0;
}


Measured memory_bytes: 9464
import sys
read=sys.stdin.read
readline=sys.stdin.readline

def main():
  def isinsums(x,lst):
    s=sum(lst)
    t=(s+x)//2
    if s==0 and x==0:
      return True
    if (s-x)%2 or t<0:
      return False
    t=(s+x)//2
    m1=(1<<(t+1))-1
    m2=1<<t
    sums=0
    for e in lst:
      sums=(sums|(1+sums)<<e)&m1
      if (sums+1)&m2>0:
        return True
    return False
  s=readline().strip()
  x,y=map(int,readline().split())
  
  s=s.replace('TF','T F')
  s=s.replace('FT','F T')
  bs=s.split()
  if bs[0][0]=='F':
    x-=len(bs[0])
    del bs[0]
  xy=[[],[]]
  f=0
  for i,e in enumerate(bs):
    if not i%2:
      l=len(e)
    else:
      f^=l%2
      xy[f].append(len(e))
  if isinsums(x,xy[0]) and isinsums(y,xy[1]):
    print('Yes')
  else:
    print('No')

if __name__=='__main__':
  main()

Measured memory_bytes: 9416