akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const int MOD = 998244353;

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

long long solve(int n, const map<pair<int, int>, int>& cell)
{
    long long cnt = n * (long long)n - (5 * n - 6);
    for(const auto& p : cell){
        pair<int, int> tmp;
        int a, b, c;
        tie(tmp, c) = p;
        tie(a, b) = tmp;
        if(abs(a - b) > 2){
            auto it = cell.find(make_pair(b, a));
            if(it == cell.end())
                cnt -= 2;
            else if(c != it->second)
                return 0;
            else
                -- cnt;
        }
    }
    cnt /= 2;

    vector<long long> dp(2, 0);
    dp[0] = power(2, cnt);
    for(int i=0; i<n; ++i){
        vector<long long> nextDp(2, 0);
        for(int a=0; a<2; ++a){
            for(int b=0; b<2; ++b){
                auto it = cell.find(make_pair(i, i));
                if(it != cell.end() && b != it->second)
                    continue;

                long long tmp = 1;
                if(i > 0){
                    auto it1 = cell.find(make_pair(i-1, i));
                    auto it2 = cell.find(make_pair(i, i-1));
                    if(it1 == cell.end() && it2 == cell.end())
                        tmp *= 2;
                    else if(it1 != cell.end() && it2 != cell.end() && (it1->second + it2->second + a + b) % 2 != 0)
                        continue;
                }
                if(i > 0 && i < n - 1){
                    auto it1 = cell.find(make_pair(i-1, i+1));
                    auto it2 = cell.find(make_pair(i+1, i-1));
                    if(it1 == cell.end() && it2 == cell.end())
                        tmp *= 2;
                    else if(it1 != cell.end() && it2 != cell.end() && (it1->second + it2->second + b) % 2 != 0)
                        continue;
                }

                nextDp[b] += dp[a] * tmp;
                nextDp[b] %= MOD;
            }
        }
        dp = move(nextDp);
    }

    return (dp[0] + dp[1]) % MOD;
}

int main()
{
    int n, m;
    cin >> n >> m;
    map<pair<int, int>, int> cell;
    for(int i=0; i<m; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        -- a;
        -- b;
        cell[make_pair(a, b)] = c;
    }

    cout << solve(n, cell) << endl;

    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin >> a;
    int key = 0;
    for(int i = 1;i<10;i++){
        for(int j = 1;j<10;j++){
            if(a == i*j){
                key = 1;
            }
        }
    }
  if(key == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
/// 1行の文字を空白で分割してVec<T>にする。
fn read_split<T : std::str::FromStr>() -> Vec<T> {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}

fn read_one<T : std::str::FromStr>() -> T {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.trim().parse().ok().unwrap()
}

fn main() {
    let n : i32 = read_one();
    let mut h : Vec<i64> = read_split();
    h.reverse();
    if n == 1 {
        println!("Yes");
        return;
    }
    let mut ans = true;
    for i in 0..(n - 1) {
        let p = i as usize;
        if h[p] < h[p + 1] { h[p+1] -= 1 };
        if h[p] < h[p + 1] {
            ans = false;
            break;
        }
    }
    if ans {
        print!("Y");
        print!("e");
        print!("s");
    } else {
        print!("N");
        print!("o");
    }
}



Measured memory_bytes: 8444
nums=list(map(int, input().split()))
nums.sort()
odds=[nums[i]%2 for i in range(3)]
counter=0
if sum(odds)==2:
  for i in range(3):
    if odds[i]==1:
      nums[i]+=1
      
  counter+=1
  
if sum(odds)==1:
  for i in range(3):
    if odds[i]==0:
      nums[i]+=1
      
  counter+=1
  
counter+=(2*nums[2]-nums[0]-nums[1])//2
print(counter)

Measured memory_bytes: 3064
N = int(input())
M = 10 ** 9 + 7
set1 = (9 ** N) % M
set2 = (10 ** N) % M
set3 = (8 ** N) % M
tmp = (set2 + set3)% M
tmp = (tmp - set1)% M
print((tmp - set1)% M)

Measured memory_bytes: 78984
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

	ans := [3]int{-1, -1, -1}

	for i := 0; i <= n; i++ {
		for j := 0; j <= n-i; j++ {
			k := n - i - j

			if i+j+k == n && 10000*i+5000*j+1000*k == y {
				ans[0] = i
				ans[1] = j
				ans[2] = k
				goto Hoge
			}
		}
	}
Hoge:

	fmt.Printf("%d %d %d\n", ans[0], ans[1], ans[2])
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll h,w;
  cin>>h>>w;
  char a[h][w];
  ll sol[1001][1001]={0};
  ll i ,j;
  for(i=0;i<h;i++)
  {
    for(j=0;j<w;j++)
    {
      cin>>a[i][j];
    }
  }
  sol[0][0]=1;
  ll c=1e9+7;
  for(i=0;i<h;i++)
  {
	for(j=0;j<w;j++)
    { if(a[i][j]=='.')
      {
      if(i==0&&j==0)
        sol[i][j]=1;
      else if(i==0)
      {
        if(a[i][j-1]=='.')
          sol[i][j]=sol[i][j-1];
      }
      else if(j==0)
      {
        if(a[i-1][j]=='.')
          sol[i][j]=sol[i-1][j];
      }
      else 
      {
        if(a[i-1][j]=='.')
          sol[i][j]=(sol[i][j]%c+sol[i-1][j]%c)%c;
        if(a[i][j-1]=='.')
          sol[i][j]=(sol[i][j]%c+sol[i][j-1]%c)%c;
      }
      }
    }
  }
  cout<<sol[h-1][w-1]<<endl;
  
}

Measured memory_bytes: 9088
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <list>

#define ll long long

using namespace std;
int a[150] = {};
int b[150] = {};
int A[150] = {};
int B[150] = {};


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

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

	for (int i = 0; i < n; i++)
	{
		cin >> b[i];
	}
	A[0] = a[0];
	B[n - 1] = b[n - 1];

	for (int i = 1; i < n; i++)
	{
		A[i] = A[i - 1] + a[i];
	}

	for (int i = n - 2; i >= 0; i--)
	{
		B[i] = b[i] + B[i + 1];
	}

	int max = 0;
	for (int t = 0; t<n; t++) {
		int ans = A[t] + B[t];
		if (max < ans)max = ans;
	}

	cout << max << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>

typedef long long int llint;

class state{
public:
  std::array<int, 13> A;
  int cost;
  int next;
};

bool is_end(state now, int x, int m){
  //std::cout << "is_end()" << std::endl;
  //for(const auto& elem: now.A){
  //  std::cout << elem << " ";
  //}
  //std::cout << std::endl;
  for(int i=0; i<m; i++){
    if(now.A[i] < x) return false;
  }
  return true;
}

std::array<int, 13> add_arr(std::array<int, 13> a, std::array<int, 13> b){
  for(int i=0; i<13; i++){
    a[i] += b[i];
  }

  return a;
}

int main(void){

  int n, m, x;
  std::cin >> n >> m >> x;

  std::vector<std::array<int, 13> > books_reward(n);
  std::vector<int>                  books_cost(n);

  for(int i=0; i<n; i++){
    std::cin >> books_cost[i];
    for(int j=0; j<m; j++){
      std::cin >> books_reward[i][j];
    }
  }
  
  std::stack<state> st;

  state st_state = {{}, 0, 0};
  st.push(st_state);

  int ret = 100000000;
  bool ok = false;
  while(!st.empty()){
    state now = st.top();
    //std::cout << now.cost << " " << now.next << std::endl;
    st.pop();

    if(is_end(now, x, m)){
      ret = std::min(ret, now.cost);
      ok = true;
    }
    if(now.next == n) continue;

    now.next++;
    st.push(now);
    now.A = add_arr(now.A, books_reward[now.next-1]);
    now.cost += books_cost[now.next-1];
    st.push(now);
  }

  if(!ok) ret = -1;
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 3636
Option Infer On
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        Dim M = Pow(10, 9) + 7

        Dim ans = 1L

        For i = 1 To N
            Dim j = i Mod M
            ans = (ans * j) Mod M
        Next

        WriteLine(ans)
    End Sub

    Function Pow(a As Long, b As Integer) As Long
        Dim result = 1L
        For i = 1 To b
            result *= a
        Next
        Return result
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


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

int data_tmp[10][10000];
int main() {
  while(1){
    int n, m;
    cin >> n;
    cin >> m;
    if(n == 0 && m == 0) {
      return 0;
    }
    for(int ii = 0 ; ii < m ; ii ++) {
      for(int i = 0 ; i < n ;i++) {
        data_tmp[i][ii] = 0;
      }
    }
    for(int i = 0 ; i < n ;i++) {
      for(int ii = 0 ; ii < m ; ii ++) {
        int tmp;
        cin >> tmp;
        data_tmp[i][ii] = tmp;
      }
    }
    int max = 0;
    for(int c = 0 ; c < (1 << n) ;c++) {
      int tmp= 0;
      for(int ii = 0 ; ii < m ; ii ++) {
        int co = 0;
        for(int i = 0 ; i < n ;i++) {
          int f = (1 << i) & c;
          if(f!=0) {
            co += data_tmp[i][ii] == 0 ? 1 : 0;
          } else {
            co += data_tmp[i][ii];
          }
        }
        tmp += (float)n/2 > co ? n -co : co;
      }
      if (tmp > max) max = tmp;
    }
    cout << max <<endl;

  }
  return 0;
}


Measured memory_bytes: 3520
#include <iostream>
#include <cmath>
#include <iomanip>

#define NUM_S 6

using namespace std;

class Dice {
public:
	Dice(const int n[NUM_S]);

	int roll(char);
	int rollF();
	int rollR();
	int rollL();
	int rollB();
	int rollCwise();

	int getTop();
	int getF();
	int getR();
	int getL();
	int getB();
	int getBottom();

	void show();

private:
	int top, front, right, left, back, bottom;
};

bool sameDice(Dice, Dice);


int main(void){
	int s1[NUM_S], s2[NUM_S];
	
	for (int i = 0; i < NUM_S; i++) {
		cin >> s1[i];
	}
	for (int i = 0; i < NUM_S; i++) {
		cin >> s2[i];
	}

	Dice d1(s1);
	Dice d2(s2);

	if (d2.getR() == d1.getTop() || d2.getL() == d1.getTop()) {
		d2.rollR();
	}
	while (d2.rollF() != d1.getTop()) {
	}
	while (d2.getR() != d1.getR()) {
		d2.rollCwise();
	}
	if (sameDice(d1, d2)) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}


Dice::Dice(const int n[NUM_S]) {
	top = n[0];
	front = n[1];
	right = n[2];
	left = n[3];
	back = n[4];
	bottom = n[5];
}

int Dice::roll(char c) {
	if (c == 'S') {
		return rollF();
	}
	else if (c == 'E') {
		return rollR();
	}
	else if (c == 'W') {
		return rollL();
	}
	else if (c == 'N') {
		return rollB();
	}
	else {
		return 0;
	}
}

int Dice::rollF() {
	int buf = top;
	top = back;
	back = bottom;
	bottom = front;
	front = buf;
	return top;
}

int Dice::rollR() {
	int buf = top;
	top = left;
	left = bottom;
	bottom = right;
	right = buf;
	return top;
}

int Dice::rollL() {
	int buf = top;
	top = right;
	right = bottom;
	bottom = left;
	left = buf;
	return top;
}

int Dice::rollB() {
	int buf = top;
	top = front;
	front = bottom;
	bottom = back;
	back = buf;
	return top;
}

int Dice::rollCwise() {
	int buf = left;
	left = front;
	front = right;
	right = back;
	back = buf;
	return top;
}

int Dice::getTop() {
	return top;
}

int Dice::getF() {
	return front;
}

int Dice::getR() {
	return right;
}


int Dice::getL() {
	return left;
}


int Dice::getB() {
	return back;
}


int Dice::getBottom() {
	return bottom;
}


void Dice::show() {
	cout << top << "\n";
}

bool sameDice(Dice d1, Dice d2) {
	if (d1.getTop() == d2.getTop() && d1.getF() == d2.getF() && d1.getR() == d2.getR() && d1.getL() == d2.getL() && d1.getB() == d2.getB() && d1.getBottom() == d2.getBottom()) {
		return true;
	}
	else {
		return false;
	}
}

Measured memory_bytes: 3104
#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;

int main() {
  ll N;
  cin >> N;
  vector<ll> a(N), b(N);
  ll sum_a = 0, sum_b = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> b[i];
  }
  ll cnt_b = 0, cnt_a = 0;
  for (int i = 0; i < N; i++) {
    if (a[i] > b[i]) {
      cnt_b += a[i] - b[i];
    } else if (a[i] < b[i]) {
      cnt_a += (b[i] - a[i]) / 2;
    }
  }
  if (cnt_a < cnt_b) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 3768
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    Map<String, Integer> map = new HashMap<>();
    for(int i = 0; i < N; i++){
      String S = sc.nextLine();
      if(map.containsKey(S)){
        map.put(S, map.get(S)+1);
      }else{
        map.put(S, 1);
      }
    }
    
    int M = Integer.parseInt(sc.nextLine());
    for(int i = 0; i < M; i++){
      String S = sc.nextLine();
      if(map.containsKey(S)){
        map.put(S, map.get(S)-1);
      }
    }
    
    int max = 0;
    for(int val : map.values()){
      max = val > max ? val : max;
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>

#define ceil(a, b) ((a / b + (a % b != 0)) * b)

using namespace std;

int main() {
    int n;
    cin >> n;
    --n;
    vector<int> c(n), s(n), f(n);
    for (int i = 0; i < n; ++i) cin >> c.at(i) >> s.at(i) >> f.at(i);
    for (int i = 0; i < n; ++i) {
        int t = 0;
        for (int j = i; j < n; ++j) {
            if (t < s.at(j)) t = s.at(j);
            else if (t % f.at(j) != 0) t = ceil(t, f.at(j));
            t += c.at(j);
        }
        cout << t << endl;
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
import math

def trial_division(target):
    dest = int(math.sqrt(target))
 
    for i in range(2,dest):
        if target % i == 0:
            return False
    return True

if __name__ == "__main__":
    X = input()
    X = int(X)
    while(True):
        flg = trial_division(X)
        if flg:
            print(X)
            exit(0)
        else:
            X += 1
    print(X)


Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int A[100010];
    rep(i, n) cin >> A[i];
    int state = 0;
    int ans = 1;
    rep(i, n - 1) {
        if (state == 0 && A[i] == A[i + 1]) continue;
        if (state == 0 && A[i] < A[i + 1]) state = 1;
        else if (state == 0 && A[i] > A[i + 1]) state = -1;
        else if (state == 1 && A[i] > A[i + 1]) {state = 0; ans++;}
        else if (state == -1 && A[i] < A[i + 1]) {state = 0; ans++;}
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

using namespace std;

int W, H;
string m[30];
bool visit[30][30];
const int di[4] = {0,0,-1,1};
const int dj[4] = {1,-1,0,0};

int dfs(const int ci, const int cj) {
  int ret = 1;
  for (int i = 0; i < 4; ++i) {
    int ni = ci + di[i], nj = cj + dj[i];
    if (ni < 0 || nj < 0 || H <= ni || W <= nj) continue;
    if (m[ni][nj] == '#' || visit[ni][nj]) continue;
    visit[ni][nj] = true;
    ret += dfs(ni, nj);
  }
  return ret;
}

int solve() {
  memset(visit, 0, sizeof visit);
  int ret = 0;
  for (int i = 0; i < H; ++i)
    for (int j = 0; j < W; ++j)
      if (m[i][j] == '@')
        visit[i][j] = true , ret = dfs(i, j);
  return ret;
}

int main() {
  ios_base::sync_with_stdio(false);
  while (cin >> W >> H, W && H) {
    for (int i = 0; i < H; ++i)
      cin >> m[i];
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
#include <iostream>

using namespace std;

int main(){

    int n, k;
    cin >> n >> k;
    int * arr = new int [n];
    for(int i = 0; i < n; ++i) cin >> arr[i];


    for(int i = 0, j = k; j < n; ++i, ++j){

        if(arr[j] > arr[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    delete [] arr;
    return 0;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

ll h[MAX_N];
int n;
ll a,b;

bool possible(ll hoge)
{
    ll rem = a-b;
    ll buf[MAX_N];
    rep(i,n){
        buf[i] = h[i];
    }
    rep(i,n){
        buf[i] -= hoge*b;
    }
    ll cnt = 0;
    rep(i,n){
        if(buf[i] > 0){
            cnt += (buf[i]-1) / rem + 1;
        }
    }
    if(cnt > hoge){
        return false;
    }else{
        return true;
    }
}

int main()
{
	scanf("%d%lld%lld",&n,&a,&b);
    ll mx = 0;
	rep(i,n){
		scanf("%lld",&h[i]);
        if(mx < h[i]){
            mx = h[i];
        }
	}
    ll l = 0;
    ll h = mx / b + 1;
    while(1){
        ll mid = (l + h)/2;
        if(mid == l){
            printf("%lld\n",h);
            return 0;
        }
        if(possible(mid)){
            h = mid;
        }else{
            l = mid;
        }
    }
	return 0;
}


Measured memory_bytes: 1792
import itertools
N = str(input())
Keta = len(N)
N_List = ["3","5","7"]

Ans = 0
for i in range(3,Keta):
    Ans += 3**i
    Ans -= (2**i*3) -3

N = int(N)

if Keta >= 3:
    for Moji in itertools.product(N_List, repeat=Keta):
        Moji_Kazu = len(set(Moji))
        Str_Number = int("".join(Moji))
        if (Str_Number <= N) & (Moji_Kazu == 3):
            Ans += 1
    
print(Ans)


Measured memory_bytes: 9172
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;

#define rep(i, a, b) for (int (i)=(a);(i)<=(b);(i)++)
#define Rep(i, a, b) for (int (i)=(a)-1;(i)<(b);(i)++)
#define REP(i, a, b) for (int (i)=(a);(i)>=(b);(i)--)
#define reg(i, x) for (int (i)=head[x];(i);i=e[i].next)
#define clr(a) memset(a,0,sizeof(a))
#define Sort(a, len) sort(a + 1, a + len + 1)
#define Sort2(a, len, cmp) sort(a + 1, a + len + 1, cmp)
#define ass(a, sum) memset(a, sum, sizeof(a))

#define ull unsigned long long
#define ll long long
#define ls ((rt) << 1)
#define rs ((rt) << 1 | 1)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
#define Pii pair<int, int>

const int N = 100010 ;
const int iinf = INT_MAX/2 ;
const ll linf = LLONG_MAX/2 ;
const int MOD = 1e9+7 ;

inline int read(){
    int X = 0,w = 0 ;
	char ch = 0;
    while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
    while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
    return w ? -X : X;
}

void write(int x){
     if(x < 0) putchar('-'),x = -x;
     if(x > 9) write(x / 10);
     putchar(x%10 + '0');
}

void print(int x) {
	cout << x << endl ;
	exit(0) ;
}

void douout(double x){
	 printf("%lf\n", x + 0.0000000001) ;
}

string s ;

int main(){
	cin >> s ;
	for (int i = 0; i < s.size(); i++) 
	if (s[i] == '1') s[i] = '9' ; 
	else if (s[i] == '9') s[i] = '1' ;
	cout << s << endl ;
}

/*
写代码时请注意：
	1.是否要开Long Long？数组边界处理好了么？
	2.特殊情况处理好了么？
	3.做一些总比不做好。
	4.最大值和最小值问题可不可以用二分答案？
	5.有没有贪心策略？否则能不能dp？
	6.实数精度有没有处理？
*/


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int i,j;
    char s[90],t[90];
    for(;gets(s);)
    {
        for(i=0;i<27;i++)
        {
            for(j=0,memcpy(t,s,sizeof(s));s[j];j++)
                if(s[j]>=97&&s[j]<123)
                    t[j]=s[j]+i<123?s[j]+i:s[j]+i-26;
            if(strstr(t,"the")||strstr(t,"this")||strstr(t,"that"))
                break;
        }
        puts(t);
   }
    return 0;
}

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

namespace QQ
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] hill = new int[10];
            int a=0,b=0,c=0;
            for (int i = 0; i < 10; i++)
            {
                hill[i] = int.Parse(Console.ReadLine());
                if(a<hill[i]){
                    c = b;
                    b = a;
                    a = hill[i];
                }else if (b < hill[i])
                {
                    c = b;
                    b = hill[i];
                }
                else if (c < hill[i])
                {
                    c = hill[i];
                }
            }
            Console.WriteLine(a+"\n"+b+"\n"+c);
        }
    }
}

Measured memory_bytes: 5612
#include<iostream>
using namespace std;
long su[100000010] = { 0 };
long sai;
int main()
{
	long n, k;
	long i, j;
	long a;
	while (cin >> n >> k, n != 0 && k != 0)
	{
		for (i = 1; i <= n; i++)
		{
			cin >> a;
			su[i] = su[i - 1] + a;
		}
		sai = 0;
		for (i = k; i <= n; i++)
		{
			if (sai < su[i] - su[i - k])
			{
				sai = su[i] - su[i - k];
			}
		}
		cout << sai << endl;
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<long long> a(n);
    long long ans = 1;
    
    for(int i = 0;i < n;i++){
        cin >> a[i];
        if(a[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    sort(a.begin(),a.end());
    for(int i = 0;i < n;i++){
        if(a[i] > 1000000000000000000 / ans){
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
    }
    cout << ans << endl;
}


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

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

    int d = a / b;
    int r = a % b;
    double f = ((double)a) / b;

    cout << d << " " << r << " ";
    printf("%.8lf\n", f);
}


Measured memory_bytes: 3220
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;


vector<string> get_cards(const int n) {
    vector<string> cards(n);
    for (int i = 0; i < n; ++i) cin >> cards.at(i);
    return cards;
}

map<string, int> check_cards(const vector<string> cards) {
    map<string, int> word_value;
    for (string first: cards) {
        auto iter = word_value.find(first);
        if (iter == word_value.end()) word_value[first] = 0;
        else continue;
        for (string s: cards) if (s == first) ++word_value[first];
    }
    return word_value;
}

int main() {
    int n;
    cin >> n;
    auto blue = get_cards(n);
    auto kuroji = check_cards(blue);

    int m;
    cin >> m;
    auto red = get_cards(m);
    auto akaji = check_cards(red);

    map<string, int> goukei;
    for (auto i = kuroji.begin(); i != kuroji.end(); ++i) {
        auto key = i->first;
        auto card = akaji.find(key);
        if (card == akaji.end()) goukei[key] = i->second;
        else goukei[key] = kuroji[key] - akaji[key];
    }

    int num = 0;
    for (auto i = goukei.begin(); i != goukei.end(); ++i) {
        int value = i->second;
        if (num < value) num = value;
    }

    std::cout << num << std::endl;
}

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

#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

struct BIT {
	V data;
	int N;
	BIT(int n) { 
		data.resize(n + 1);
		N = n;
	};
	void add(int idx, int val) {
		idx++;
		for (int x = idx; x <= N; x += x & -x) data[x] += val;
	}
	int sum(int idx) {
		idx++;
		int ret = 0;
		for (int x = idx; x > 0; x -= x & -x) ret += data[x];
		return ret;
	}
};

signed main() {
	int n;
	while (cin >> n && n) {
		vector<P> v(n);
		rep(i, n) {
			int a, b;
			scanf("%lld %lld", &a, &b);
			v[i] = P(a, b);
		}
		sort(all(v));
		vector<P> ord(n);
		BIT sum(n), num(n);
		rep(i, n) {
			int b = v[i].second;
			ord[i] = (P(b, i));
			sum.add(i, v[i].first);
			num.add(i, 1);
		}
		sort(all(ord));

		int prea = 0;
		int ans = 0;
		for (P& p : ord) {
			int idx = p.second;
			int b = p.first;
			if (prea != b) {
				int left = 0, right = n;
				while (left + 1 < right) {
					int mid = (left + right) / 2;
					int val = sum.sum(mid);
					int k = num.sum(mid);
					if (val <= b * k) left = mid;
					else right = mid;
				}
				if (sum.sum(left) <= b * num.sum(left))
					maxup(ans, num.sum(left));
			}
			sum.add(idx, -v[idx].first);
			num.add(idx, -1);
			prea = p.first;
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 16880
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
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: 3504
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var N = one[0];
	var C = one[1];
	var clist = new Array(C);
	for(var i = 0; i < C; i++){
		clist[i] = nextIntArray();
	}
	var nlist = new Array(N);
	for(var i = 0; i < N; i++){
		nlist[i] = nextIntArray();
	}
	
	var change = {
		0 : new Array(C).fill(0),
		1 : new Array(C).fill(0),
		2 : new Array(C).fill(0)
	};
	for(var i = 0; i < N; i++){
		for(var j = 0; j < N; j++){
			var motoColor = nlist[i][j];
			for(var k = 0; k < C; k++){
				change[(i + j) % 3][k] += clist[motoColor - 1][k];
			}
		}
	}
	var output = Math.pow(10,15);
	for(var i = 0; i < C; i++){
		for(var j = 0; j < C; j++){
			for(var k = 0; k < C; k++){
				if(i != j && j != k && i != k){
					output = Math.min(output, change[0][i] + change[1][j] + change[2][k]);
				}
			}
		}
	}
	myout(output);
}


Measured memory_bytes: 37876
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) //[l, r)
#define rep(i,n) REP(i,0,n)           //[0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showslr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i];}cerr<<endl //[l, r))

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}

void _DEBUG(){cerr<<endl;}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<",";_DEBUG(b...);}

template<typename T> inline void in(T &e){cin>>e;}
template<typename H,typename... T>void in(H &a, T&... b){in(a);in(b...);}
template<typename T> inline void out(T e){cout<<e<<endl;}
template<typename H,typename... T> void out(H a, T... b){out(a);out(b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int a,b;

signed main(){
    io();

    in(a,b);
    if((a xor b) < 0 || a == 0 || b == 0){
        out("Zero");
        return 0;
    }
    if(a > 0){
        out("Positive");
        return 0;
    }
    int diff=b-a;
    if(diff&1){
        out("Positive");
    }else{
        out("Negative");
    }
    

    return 0;
}


Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long int64;
typedef pair<int, int> ii;
const int mod = 1e9 + 7;

struct vec2 {
    int64 idx, val;
};

class Solution {
private:
    
public:
    int64 solve(vector<vec2>& arr, int n) {
        sort(arr.begin(), arr.end(), [](const vec2& v1, const vec2& v2) -> bool {
            return v1.val > v2.val;
        });
        vector<vector<int64>> dp(n + 1, vector<int64>(n + 1, 0));
        int64 ret = 0;
        for(int i = 0; i <= n; ++i) {
            for(int j = 0; j <= n; ++j) {
                if(i + j == n) {
                    ret = max(ret, dp[i][j]);
                    break;
                }
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + arr[i + j].val * abs(arr[i + j].idx - i)); //put top i greater nums to the left side
                dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + arr[i + j].val * abs(n - 1 - j - arr[i + j].idx));
            }
        }
        return ret;
    }
    
};

int main() {
    
    int n;
    cin >> n;
    vector<vec2> arr(n);
    for(int i = 0; i < n; ++i) {
        cin >> arr[i].val;
        arr[i].idx = i;
    }
    Solution sol;
    auto ret = sol.solve(arr, n);
    cout << ret << endl;
}

Measured memory_bytes: 34688
nums = list(input())
for i in range(2**3):
    seven = int(nums[0])
    opt = []
    for j in range(3):
        if i >> j & 1:
            seven += int(nums[j+1])
            opt.append("+")
        else:
            seven -= int(nums[j+1])
            opt.append("-")
    if seven == 7:
        print(nums[0]+opt[0]+nums[1]+opt[1]+nums[2]+opt[2]+nums[3]+"=7")
        exit()


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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    ull n;
    cin >> n;
    if(n % 2) {
        cout << 0 << endl;
        return 0;
    }
    ull ans = 0;
    //for(int i = 1; i <= log10l(n) / log10l(5); i++) {
    int i = 1;
    while((n / 2) / (ull)(powl(5, i)) > 0) {
        ans += (n / 2) / (ull)(powl(5, i));
        //if(n >= pow(10, i) / 2) ans += n / pow(10, i);
        i++;
    }
    cout << ans << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
from __future__ import print_function

import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# import math
# import string
# import fractions
# from fractions import Fraction
# from fractions import gcd

# def lcm(n,m):
#     return int(n*m/gcd(n,m))

# import re
# import array
# import copy
# import functools
# import operator

# import collections
# import itertools
# import bisect
# import heapq


# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace

# from queue import PriorityQueue as pq

# def reduce(p, q):
#     common = fractions.gcd(p, q)
#     return (p//common , q//common )
# # from itertools import accumulate
# # from collections import deque

# from operator import mul
# from functools import reduce

# def combinations_count(n, r):
#     r = min(r, n - r)
#     numer = reduce(mul, range(n, n - r, -1), 1)
#     denom = reduce(mul, range(1, r + 1), 1)
#     return numer // denom

# import random

def main():
    a = int(input().strip())
    b = int(input().strip())
    s=set([1,2,3])
    s.remove(a)
    s.remove(b)
    for x in s:
        print(x)
        return
if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
typedef long long ll;
using namespace std;

int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    int ans;
    int x;
    int cnt = 0;
    for (int i = 100; i >= 1; i--){
        x = i;
        if(a % x == 0 && b % x == 0) {
            ans = x;
            cnt++;
            if (cnt == k) break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

N = Int()
A = IntList()

from collections import defaultdict
D = defaultdict(int)

for i in A:
    D[i] += 1
for i in range(1,N+1):
    print(D[i])

Measured memory_bytes: 115360
from collections import deque
from collections import defaultdict

n, m = map(int, input().split())
g = defaultdict(list)
s = set(list(range(1, n+1)))
ans = 0

for i in range(m):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

while s:
    root = s.pop()
    q = deque()
    q.append(root)
    done = set()
    done.add(root)

    while q:
        node = q.popleft()

        for adj in g[node]:
            if adj not in done:
                done.add(adj)
                q.append(adj)
                s.remove(adj)
    ans += 1

print(ans - 1)

Measured memory_bytes: 41472
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto s = readln.chomp;
  bool f1, f2;
  foreach (e; s) {
    if (!f1) {
      if (e == 'C') {
        f1 = true;
      }
    } else {
      if (e == 'F') {
        f2 = true;
      }
    }
  }
  if (f1 && f2) writeln("Yes");
  else writeln("No");
}


Measured memory_bytes: 256
#include<stdio.h>
int main ()
{
  int a,b;
  scanf("%d %d",&a,&b);
  if(a!=3 && b!=3)printf("3\n");
  if(a!=1 && b!=1)printf("1\n");
  if(a!=2 && b!=2)printf("2\n");

}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    long n, k, q;

    cin >> n >> k >> q;

    long *p = new long[n+1];

    for(long i=0;i<=n ;i++){
        p[i] = 0;
    }

    for(long i=1;i<=q ;i++){
        long a;
        cin >> a;
        p[a] += 1;
    }

    for(long i=1;i<=n ;i++){
        if(k-q+p[i] <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int N=200005;
const int mod=1e9+7;
const double eps=1e-8;
const double PI = acos(-1.0);
#define lowbit(x) (x&(-x))
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll qpow(ll a,ll b)
{
    ll res=1;
    while(b)
    {
        if(b&1) res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res;
}
ll inv(ll a,ll p)
{
    return qpow(a,p-2);
}
int main()
{
    std::ios::sync_with_stdio(false);
    string s[3];
    cin>>s[0]>>s[1]>>s[2];
    int i=0;
    while(1)
    {
   //     cout<<i<<" "<<s[i]<<endl;
        int l=s[i].length();
        if(l<=0)
        {
            if(i==0)
                cout<<"A"<<endl;
            else if(i==1)
                cout<<"B"<<endl;
            else
                cout<<"C"<<endl;
            break;
        }
        l--;
        int tmp=i;
        if(s[i][0]=='a')
            i=0;
        else if(s[i][0]=='b')
            i=1;
        else
            i=2;
        s[tmp].erase(s[tmp].begin());
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using vll = vector<ll>;
using vvll = vector<vll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
using plli = pair<ll, int>;
using vplli = vector<pair<ll, int>>;
using pllll = pair<ll, ll>;
using vpllll = vector<pair<ll, ll>>;

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;
}

//pow(llpow,modpow)
template <class T>
ll llpow(ll x, T n)
{
    ll ans = 1;
    if (x == 0)
        ans = 0;
    while (n)
    {
        if (n & 1)
            ans *= x;
        x *= x;
        n >>= 1;
    }
    return ans;
}
long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
template <class T>
inline T gcd(T x, T y)
{
    if (y == 0)
        return x;
    else
    {
        return gcd(y, x % y);
    }
}
//最小公倍数
template <class T>
inline T lcm(T x, T y) { return x / gcd(x, y) * y; }
//逆元
long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i - 1; i >= (ll)end_i; i--)

long long INF = 1LL << 60;
int dp[110][2][5];
int main()
{
    string s;
    int K;
    cin >> s >> K;
    int n = s.size();
    dp[0][0][0]=1;
    rep(i, 0, n)
    {
        rep(j, 0, 2)
        {
            rep(k, 0, K + 1)
            {
                rep(d, 0, 10)
                {
                    int ni = i + 1, nj = j, nk = k;
                    int now = s[i] - '0';
                    if (d != 0)
                        nk++;
                    if (j == 0)
                    {
                        if (now > d)
                            nj = 1;
                        else if (now < d)
                            continue;
                    }
                    dp[ni][nj][nk] += dp[i][j][k];
                }
            }
        }
    }
    cout<<dp[n][0][K]+dp[n][1][K]<<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);

		String type;
		String[] strings;
		int[] types = new int[4];

		while(sc.hasNext()){
			strings = sc.next().split(",");
			type = strings[1];

			if(type.equals("A")) types[0]++;
			else if(type.equals("B")) types[1]++;
			else if(type.equals("AB")) types[2]++;
			else types[3]++;
		}

		for(int value: types) System.out.println(value);
	}
}

Measured memory_bytes: 12000
program march
  implicit none
  integer :: n, i, j, k
  integer(8) :: c(0:5) = 0_8, a = 0_8
  character(1) :: s
  read(*,*) n
  do i = 1, n
    read(*,*) s
    j = f(ichar(s)-64)
    c(j) = c(j)+1_8
  end do
  do concurrent (i = 1:5, j = 1:5, k = 1:5, i < j .and. j < k)
    a = a+c(i)*c(j)*c(k)
  end do
  write(*,'(i0)') a
contains
  integer function f(x)
    integer, intent(in) :: x
    f = x
    if ((x-1)*(x-3) == 0) return
    f = (164-8*x)/(28-x)
    if ((x-8)*(x-13)*(x-18) == 0) return
    f = 0
  end
end program march

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 998244353
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

const int MAX=510000;
long long fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    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;
    }
}
long long COM(int n,int k){
    if(n<k) return 0;
    if(n<0 or k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
ll fact_mod(ll n) {
    ll ret=1; 
    for(ll i=2;i<=n;i++) ret=ret*(i%mod)%mod;
    return ret;
} 
ll pow_mod(ll x, ll n){
    if(n==0) return 1;
    ll ret=pow_mod((x*x) % mod, n/2);
    if(n&1) ret=(ret*x)%mod;
    return ret;
}
//O(r)
ll combination_mod(ll n, ll r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    ll a=1;
    for(ll i=0;i<r;i++) a=a*((n-i)%mod)%mod;
    ll b=pow_mod(fact_mod(r), mod-2);
    return (a%mod)*(b%mod)%mod;
}
ll inv_mod(ll n){
    return pow_mod(n,mod-2);
}

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

    ll n,m,k;cin>>n>>m>>k;
    ll ans=0;
    rep(i,k+1){
        ans+=m*COM(n-1,i)%mod*pow_mod(m-1,n-1-i)%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 15564
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n ;

int main ( ){
    ios ::sync_with_stdio(false);
 ll q , h ,  s , d ;
 cin >> q >> h >> s >> d ;

 cin >> n ;
 ll ANS = 0 ;
 if ( n & 1 ){
  ANS += ( min ( s , min (2LL*h , 4LL*q)));
  n-- ;
 }
 q *= 8LL;
 h *= 4LL ;
 s *= 2LL ;
 ll need = n/2LL ;
 ANS += min ( q*need , min ( h*need , min ( s*need , d*need)));
 cout << ANS ;
return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
 #define rep(i,n) for(int i=0;i<n;++i)
 #define all(v) v.begin(), v.end()
 typedef long long int ll;
 typedef unsigned long long ull;
 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;}
 typedef pair<ll,ll> P;
 const long long MOD = 1e9+7;
 const ll INF = 1LL << 60;

 int main(){
     int n,k;
     cin >> n >> k;
     vector<int> p(n);

     rep(i,n){
         cin >> p[i];
     }
     sort(all(p));
     int cnt = 0;
     rep(i,k){
         cnt += p[i];
     }
     cout << cnt << endl;
 }


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

ll n,k;
ll a[111111];

ll dp[50][2];

int main(){
  cin>>n>>k;
  ll sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }

  if(k==0){
    cout<<sum<<endl;
    return 0;
  }
  
  ll tmp=k;
  vector<ll> bi,bc;
  ll cnt=0;
  
  for(int i=0;i<45;i++){
    bi.pb(tmp%2);
    tmp/=2;
    bc.pb(pow(2LL,cnt));
    cnt++;
  }
  reverse(all(bi));
  reverse(all(bc));

  fill_n(*dp,50*2,-1);
  dp[0][1]=0;
  for(int i=0;i<45;i++){
 
	 ll cost[2]={};
	 for(int ai=0;ai<n;ai++){
	   for(int ci=0;ci<2;ci++){
		if((ci+(a[ai]>>(44-i)&1))%2==0)continue;
		cost[ci]+=bc[i];
	   }
	 }
	
    
    for(int j=0;j<2;j++){
	 if(dp[i][j]==-1)continue;
	 
	 if(j==0){
	   dp[i+1][0]=max(dp[i+1][0],dp[i][j]+max(cost[0],cost[1]));
	   continue;
	 }
	 
	 dp[i+1][1]=max(dp[i+1][1],dp[i][j]+cost[bi[i]]);

	 if(bi[i])dp[i+1][0]=max(dp[i+1][0],dp[i][j]+cost[0]);
    }
  }

  cout<<max(dp[45][0],dp[45][1])<<endl;
  
  /*
  for(int i=0;i<bi.size();i++){
    dbg(i);
    dbg(bi[i]);
    dbg(bc[i]);
  }
  //*/

  /*
  for(int i=0;i<bi.size();i++){
    dbg(i);
    for(int j=0;j<2;j++){
	 cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }
  //*/
  
  return 0;
}


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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  for(int i=a;i<=b;i++){
    if(i<=a+c-1||b-c+1<=i)cout<<i<<endl;
  }
  return 0;
}


Measured memory_bytes: 256