akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    string s, t;
    while(cin >> s, s != ".") {
        cin >> t;

        if(s == t) {
            cout << "IDENTICAL" << endl;
        }
        else {
            int cnt1 = 0, cnt2 = 0;
            for(auto c : s) cnt1 += (c == '"');
            for(auto c : t) cnt2 += (c == '"');

            if(cnt1 != cnt2) {
                cout << "DIFFERENT" << endl;
            }
            else {
                int pari = 0, diff = 0, ng = false;
                auto i1 = s.begin(), i2 = t.begin();
                while(i1 != s.end()) {
                    auto j1 = find(i1, s.end(), '"');
                    auto j2 = find(i2, t.end(), '"');
                    
                    {
                        int l1 = j1 - i1, l2 = j2 - i2;
                        int k1 = i1 - s.begin();
                        int k2 = i2 - t.begin();
                        // fprintf(stderr, "k1 = %lld, k2 = %lld\n", k1, k2);

                        // cerr << "# " << s.substr(k1, l1) << " " << t.substr(k2, l2) << endl;
                        if(s.substr(k1, l1) != t.substr(k2, l2)) {
                            if(pari == 1) diff++;
                            else ng = true;
                        }
                    }
                    i1 = j1, i2 = j2;
                    if(i1 != s.end()) i1++;
                    if(i2 != t.end()) i2++;
                    (pari += 1) %= 2;
                }

                ng |= (diff > 1);
                if(ng) cout << "DIFFERENT" << endl;
                else cout << "CLOSE" << endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3116
package main

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

func main() {
	sc := newScanner()
	S := sc.next()
	if strings.HasPrefix(S, "YAKI") {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) nextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) nextInt() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) nextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}
	return result
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
using namespace std;
class dice {
public:
	int a[6];
	int b;
	void moveN() {
		b = a[0];
		a[0] = a[1];
		a[1] = a[5];
		a[5] = a[4];
		a[4] = b;
	}
	void moveS() {
		b = a[0];
		a[0] = a[4];
		a[4] = a[5];
		a[5] = a[1];
		a[1] = b;
	}
	void moveE() {
		b = a[0];
		a[0] = a[3];
		a[3] = a[5];
		a[5] = a[2];
		a[2] = b;
	}
	void moveW() {
		b = a[0];
		a[0] = a[2];
		a[2] = a[5];
		a[5] = a[3];
		a[3] = b;
	}
	void moveR() {
		b = a[1];
		a[1] = a[2];
		a[2] = a[4];
		a[4] = a[3];
		a[3] = b;
	}
	void moveL() {
		b = a[1];
		a[1] = a[3];
		a[3] = a[4];
		a[4] = a[2];
		a[2] = b;
	}
};
int main() {
	dice dice1, dice2;
	for (int i = 0; i < 6; i++) {
		cin >> dice1.a[i];
	}
	for (int i = 0; i < 6; i++) {
		cin >> dice2.a[i];
	}

	if (dice1.a[2] == dice2.a[2] && dice1.a[3] == dice2.a[3] && dice1.a[4] == dice2.a[4] && dice1.a[0] == dice2.a[0] && dice1.a[1] == dice2.a[1] && dice1.a[5] == dice2.a[5]) {
		cout << "Yes" << endl;
		return 0;
	}
	
	for (int i = 0; i < 4; i++) {
		dice2.moveR();
		for (int j = 0; j < 4; j++) {
			dice2.moveN();
			if (dice1.a[2] == dice2.a[2] && dice1.a[3] == dice2.a[3] && dice1.a[4] == dice2.a[4] && dice1.a[0] == dice2.a[0] && dice1.a[1] == dice2.a[1] && dice1.a[5] == dice2.a[5]) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	for (int i = 0; i < 4; i++) {
		dice2.moveE();
		for (int j = 0; j < 4; j++) {
			dice2.moveN();
			if (dice1.a[2] == dice2.a[2] && dice1.a[3] == dice2.a[3] && dice1.a[4] == dice2.a[4] && dice1.a[0] == dice2.a[0] && dice1.a[1] == dice2.a[1] && dice1.a[5] == dice2.a[5]) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;
}


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

typedef long long ll;
const int INF = 1 << 30;

vector<int> a, b;
vector<pair<int, int>> pa, pb;

int n;

int main(){
    cin >> n;

    for (int i = 0; i < n; i++){
        int temp;
        if (i % 2 == 0){
            cin >> temp;
            a.push_back(temp);
        } else {
            cin >> temp;
            b.push_back(temp);
        }
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    
    pa.push_back(make_pair(a[0], 1));  
    for (int i = 1; i < a.size(); i++){
        if (pa.back().first != a[i]){
            pa.push_back(make_pair(a[i], 1));
        } else {
            pa.back().second++;
        }
    }

    sort(pa.begin(), pa.end(), [](pair<int, int> s, pair<int, int> t) {
        return s.second < t.second;
    });


    pb.push_back(make_pair(b[0], 1));
    for (int i = 1; i < b.size(); i++){
        if (pb.back().first != b[i]){
            pb.push_back(make_pair(b[i], 1));
        }else{
            pb.back().second++;
        }
    }

    sort(pb.begin(), pb.end(), [](pair<int, int> s, pair<int ,int> t) {
        return s.second < t.second;
    });

///////////////////////////////////////////////////////////

/*
    for (int i = 0; i < pa.size(); i++){
        cout << pa[i].first << ", " << pa[i].second << endl;
    }
    for (int i = 0; i < pb.size(); i++)
    {
        cout << pb[i].first << ", " << pb[i].second << endl;
    }
    */

///////////////////////////////////////////////////////////

    int res = 0;
    if (pa.back().first != pb.back().first){
        for (int i = 0; i < pa.size()-1; i++){
            res += pa[i].second;
        }
        for (int i = 0; i < pb.size()-1; i++){
            res += pb[i].second;
        }
    } else {
        int ma1=0;
        int ma2=0;
            for (int i = 0; i < pa.size() - 1; i++){
                ma1 += pa[i].second;
            }
            if (pb.size()>1){
            for (int i = 0; i < pb.size() - 2; i++){
                ma1 += pb[i].second;
            }
            }
            ma1 += pb.back().second;
        
            if(pa.size()>1 ){
            for (int i = 0; i < pa.size() - 2; i++){
                ma2 += pa[i].second;
            }
            }
            for (int i = 0; i < pb.size() - 1; i++){
                ma2 += pb[i].second;
            }
            ma2 += pa.back().second;
        res = min(ma1, ma2);
    }
    cout << res << endl;
}

Measured memory_bytes: 1784
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  ll N ; cin >> N;
  vector<ll > a;

  rep(i,N){
    ll inp; cin >> inp;
    a.pb(inp);
  }
  sort(rall(a));
  ll A=0,B=0;
  rep(i,N){
    if(i%2 == 0) A+=a[i];
    else B+=a[i];
  }

  cout << A-B << endl;
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[]) {
  /* code */
  int n; //H,N
  int i; //for用
  long int h, sum;
  sum=0;
  scanf("%ld %d\n", &h, &n);
  int a[n];
  for(i=0; i<n; i++){
    scanf("%d", &a[n]);
    sum += a[n];
  }

  if (sum>=h) {
    printf("Yes");
  }else{
    printf("No");
  }


  return 0;
}


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

int main(){
  string s;std::cin>>s;
  long n=0;

  for (int i=0;i<s.size();++i){
    if(s[i]=='B'&&s[i+1]=='C'){
      s.erase(i+1,1);
      s.replace(i,1,"D");
    }
  }
  long a_count=0;
  for (int c=0;c<s.size();++c){
    if (s[c]=='A') ++a_count;
    else if(s[c]=='D') n +=a_count;
    else a_count=0;
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//


int main() {
  int n, p;
  cin >> n >> p;
  vi a(n);
  rep(i, n) cin >> a[i];
  bool even = true;
  rep(i, n) if (a[i]%2) even = false;
  ll ans = 1;
  if (even) {
    if (p) ans = 0;
    else {
      rep(i, n) ans *= 2;
    }
  } else {
    rep(i, n-1) ans *= 2;
  }
  cout << ans << endl;
}

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

int main()
{
  int i;
  int flag=0;
  char str[5];
  scanf("%s", str);
  i=0;
  for(i=1;i<4;i++){
    if(str[i]==str[i-1]) flag=1;
  }
  if(flag){
    printf("Bad\n");
  }else{
    printf("Good\n");
  }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define vpii vector< pair<int,int> >
#define mii map<int,int>
#define MOD 1000000007
#define fr(i,k,n) for(int i=k;i<n;i++)
#define fl(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
typedef long long ll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long double a,b;
cin>>a>>b;
ll x=a*b;
cout<<x;
return 0;
}
// Problem : C - Multiplication 3
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)



Measured memory_bytes: 3804
#include <stdio.h>
#include <iostream>
using namespace std;

main(void) {
	int n, m, temp;
	int t[100001], p[100001], x[100001];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> p[i] >> x[i];
	}

	for (int i = 0; i < m; i++) {
		int lap = 0;
		temp = t[p[i] - 1];
		t[p[i] - 1] = x[i];
		for (int j = 0; j < n; j++) {
			lap += t[j];
		}
		cout << lap << endl;
		t[p[i] - 1] = temp;
	}
	return 0;
}

Measured memory_bytes: 256
s=input()
for i in range(len(s)//5+1):
    if s[-5:]=="dream" or s[-5:]=="erase":
        s=s[:-5]
    elif s[-6:]=="eraser":
        s=s[:-6]
    elif s[-7:]=="dreamer":
        s=s[:-7]
    if len(s)==0:
        print('YES')
        exit()
print('NO')

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

using Picture_Frame = std::vector<std::vector<char>>;

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

	uint32_t height = 0;
	uint32_t width = 0;

	std::cin >> height;
	std::cin >> width;

	Picture_Frame frame;
	frame.resize(height + 2);
	char current;
	int line_count = 0;
	for (int i = 0; i < height + 2; i++) {
		auto &line = frame[i];
		line.resize(width + 2);
		if (i == 0 || i == height + 1) {
			for (int j = 0; j < width + 2; j++) {
				line[j] = '#';
			}
		} else {
			for (int k = 0; k < width + 2; k++) {
				if (k == 0 || k == width + 1) {
					line[k] = '#';
				} else {
					std::cin >> current; 
					line[k] = current;
				}
			}
		}
	}

	for (int l = 0; l < frame.size(); l++) {
		auto &output_line = frame[l]; 	
		for (int m = 0; m < output_line.size(); m++) {
			std::cout << output_line[m];
		}
 		std::cout << std::endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner in = new Scanner(System.in);
    int A = in.nextInt(), B = in.nextInt();
    int c = (A + B);
    if (c % 2 == 0) {
      System.out.println(c / 2);
    } else {
      System.out.println("IMPOSSIBLE");
    }
  }
}


Measured memory_bytes: 21844
if_ t f True = t
if_ t f False = f

main = do
  [s, t] <- words <$> getLine
  [a, b] <- map read . words <$> getLine
  u <- getLine
  putStrLn . unwords . (map show) $ if_ [a - 1, b] [a, b - 1] $ u == s


Measured memory_bytes: 3924
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mx 100000000
#define pb push_back
#define mp make_pair
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()


ll md=1e9+7;
ll __gcd(ll a, ll b) {if(b==0) return a; return __gcd(b, a%b);}
ll poww(ll a, ll b) {ll res=1;while(b) {if(b&1){res*=a;res%=md;}a*=a;a%=md;b>>=1;}return res;}
void ainp(int arr[], int n) {for(int i=0;i<n;i++) cin>>arr[i];}

const ll N=3e5+5;

void fun()
{ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}


signed main()
{  
fun();
int t;
//cin>>t;
t=1;
while(t--)
{
	int n,i,j;
	ll sum=0,csum=0,p=0;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		csum+=a[i];
		csum%=md;
	}
	for(i=0;i<n;i++)
	{
		csum-=a[i];
		if(csum<0)
		csum+=md;
	sum+=((a[i]%md)*(csum%md)%md);
		sum%=md;
	}
	cout<<sum;
}
}



Measured memory_bytes: 4424
#include <stdio.h>
int main(void){
    int n;
    scanf("%d", &n);

    int a[111];
    int i;
    for(i=0;i<n;i++) scanf("%d",a+i);
    
    int flg = 1, cnt = 0;
    while(flg){
        flg = 0;
        int j;
        for(j = n - 1; j > 0; j--){
        if(a[j] < a[j - 1]){
            int tmp = a[j - 1];
            a[j - 1] = a[j];
            a[j] = tmp;
            flg = 1;
            cnt = cnt + 1;
        }
        }
       
    }
    for(i=0;i < n;i++) printf("%d%c",a[i]," \n"[i==n - 1]);
    printf("%d\n", cnt);
}



Measured memory_bytes: 2076
S = input()
S1 = int(S[:2])
S2 = int(S[2:])
s_dic = {'1':'YYMM', '2':'MMYY', '3':'AMBIGUOUS', '4':'NA'}
if (S1 == 0 and S2 > 12) or (S1 > 12 and S2 == 0) or (S1 > 12 and S2 > 12) or (S1 == 0 and S2 == 0):
    print(s_dic['4'])
elif (S1 > 12 or S1 == 0) and S2 <= 12:
    print(s_dic['1'])
elif (S2 > 12 or S2 == 0) and S1 <= 12:
    print(s_dic['2'])
elif S1 <= 12 and S2 <= 12:
    print(s_dic['3'])
    


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

void Main() {
  int N, K;
  cin >> N >> K;

  if (K == 0) {
    cout << (long long)N * (long long)N << endl;
    return;
  }
  long long ans = 0;
  for(int b = K + 1; b <= N; b++) {
    //cout << b << " " << (N / b) * (b - K) + max(0, (N % b) - (K - 1)) << endl;
    ans += (N / b) * (b - K) + max(0, (N % b) - (K - 1));
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;



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

	long long ans;
	if (n == 1) {
		if (m == 1) {
			ans = 1;
		
		}
		else {

			ans = m - 2;
		}

	}
	else {
		if (m == 1) {
			ans = n - 2;
		}
		else {
			ans = (n - 2)* (m - 2);
		}

	}


	cout << ans << endl;
}

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

int N,K,S[100];

int main() {
  while(true) {
    scanf("%d %d", &N, &K);
    if (N == 0 && K == 0) break;
    for (int i = 0; i < K; ++i) {
      scanf("%d", S+i);
    }
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < K; ++j) {
	int B;
	scanf("%d", &B);
	S[j]-=B;
      }
    }
    cout << (*min_element(S, S+K) >= 0 ? "Yes" : "No") << endl;
  }
  return 0;
}

Measured memory_bytes: 876
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    if(s[1] == 'B')
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

int main(){
  int i,j;
  string n;
  cin>>n;
  n='0'+n;
  int m=n.size();
  VVI dp(m,VI(2));
  dp[0][0]=0;
  dp[0][1]=1;
  for(i=1;i<m;i++){
    dp[i][0]=min(dp[i-1][0]+n[i]-'0',dp[i-1][1]+1+'9'-n[i]);
    dp[i][1]=min(dp[i-1][0]+n[i]-'0'+1,dp[i-1][1]+'9'-n[i]);
  }
  cout<<min(dp[m-1][0],dp[m-1][1]+1)<<endl;

}
  


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  string S;
  cin >> S;

  cout << S.substr(0, 4) << " " << S.substr(4, 8) << endl;

  return 0;
}


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

int main(){
  string s;
  cin>>s;
  int sum,n=s.size();
  for(int i = 0;i<n;i++){
    if (i%2==0){
      if (s.at(i) == '1'){
        sum++;
      }
    }
    else {
      if (s.at(i) == '0'){
        sum++;
      }
    }
  }
  
  int num = max(sum,n-sum);
  int ans = s.size() - num;
  cout << ans << endl;
}

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

int main(){
    int n; cin>>n;
    vector<int> a(n);
    int t=1,c=1;
    for(int i=0;i<n;i++){
        cin>>a[i];
        t*=3;
        if(a[i]%2==0) c*=2;
    }
    
    cout<<t-c<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

int main() {
	int a, b;
	cin >> a >> b;
	for (int i = 0; i < 1100; i++) {
		int per8 = i * 8 / 100;
		int per10 = i * 10 / 100;
		if (per8 == a && per10 == b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

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

using namespace std;

int main() {
    int h, r;
    cin >> h >> r;
    if(h + r < 0){
        cout << -1 << endl;
    }
    else if (h + r > 0){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
    
    return 0;
}

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

const int N = 1e5 + 10 , M = 5e5+10 ,  MOD = 1e9+7;
const int OO = 0x3f3f3f3f;
const double EPS = 1e-3;

#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 

int r ,d ,x;


int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
	

    cin >> r >> d >> x;
    
    vi v(11);
    v[1] = (r*x) - d;
    range(i , 2 , 10)
        v[i] = (r*v[i-1]) - d;

    range( i , 1 , 10)
        cout << v[i] << "\n";

    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n)     for (ll i = 0; i < (n); ++i)
#define rep2(i, a, b) for (ll i = (a); i < (b); ++i)
#define repin(a, n)  \
    vector<ll> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repins(a, n)     \
    vector<string> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repind(a, n)     \
    vector<double> a(n); \
    rep(i, n) { cin >> a[i]; }
#define in(a) \
    ll a;     \
    cin >> a;
#define ins(a) \
    string a;  \
    cin >> a;
#define ind(a) \
    double a;  \
    cin >> a;
template <class T>
inline void out(T a) {
    cout << a << endl;
}
inline void out(double a) { printf("%.10f\n", a); }
#define all(x)  (x).begin(), (x).end()    //昇順
#define rall(x) (x).rbegin(), (x).rend()  //降順
#define yes     out("Yes");
#define no      out("No");

int main() {
    in(x);
    if (x == 1) {
        out(0);
    } else {
        out(1);
    }
}

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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

map<long long,int> prime_factorize(long long a){
	map<long long,int> res;
	if(a%2==0){
		int cnt=0;
		do{ cnt++; a/=2; }while(a%2==0);
		res.emplace(2,cnt);
	}
	for(long long p=3;p*p<=a;p+=2) if(a%p==0) {
		int cnt=0;
		do{ cnt++; a/=p; }while(a%p==0);
		res.emplace(p,cnt);
	}
	if(a>1) res.emplace(a,1);
	return res;
}

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	auto pf=prime_factorize(1);
	rep(i,n){
		for(auto q:prime_factorize(a[i])){
			pf[q.first]=max(pf[q.first],q.second);
		}
	}

	mint L=1;
	for(auto q:pf) L*=pow(mint(q.first),q.second);

	mint ans=0;
	rep(i,n) ans+=L/a[i];
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;
typedef pair<int, int> P;
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = { 0, 1, 0, -1 };

int main() {

	int n, k;
	cin >> n >> k;
	int num = 1;
	int cnt = 1;

	while (1) {
		num = num * k;
		if (n < num) {
			cout << cnt << endl;
			break;
		}
		cnt++;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String[][] s = new String[h][w];
        String[][] ans = new String[h][w];
        for (int i = 0; i < h; i++) {
            s[i] = sc.next().split("");
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                int count = 0;
                if (s[i][j].equals("#")) {
                    ans[i][j] = "#";
                } else {
                    try {
                        if (s[i - 1][j - 1].equals("#"))
                            count++;
                    } catch (Exception e) {
                    }
                    try {
                        if (s[i - 1][j].equals("#"))
                            count++;
                    } catch (Exception e) {
                    }
                    try {
                        if (s[i - 1][j + 1].equals("#"))
                            count++;
                    } catch (Exception e) {
                    }
                    try {
                        if (s[i][j - 1].equals("#"))
                            count++;
                    } catch (Exception e) {
                    }
                    try {
                        if (s[i][j + 1].equals("#"))
                            count++;
                    } catch (Exception e) {
                    }
                    try {
                        if (s[i + 1][j - 1].equals("#"))
                            count++;
                    } catch (Exception e) {
                    }
                    try {
                        if (s[i + 1][j].equals("#"))
                            count++;
                    } catch (Exception e) {
                    }
                    try {
                        if (s[i + 1][j + 1].equals("#"))
                            count++;
                    } catch (Exception e) {
                    }
                    ans[i][j] = String.valueOf(count);
                }
            }
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                System.out.print(ans[i][j]);
            }
            System.out.println();
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N = 1e5+50;
const int M = 1e6;
const ll oo = 1e18;
const int mod = 1e9+7;

vector<int> g[N];
int in[N],dp[N];

int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		g[u].push_back(v);
		in[v]++;
	}
	queue<int> q;
	int ans=0;
	for(int i=1;i<=n;i++)
		if(!in[i])
			q.push(i);
	while(q.size()){
		int u = q.front();
		q.pop();
		for(int v : g[u]){
			dp[v] = max(dp[v],dp[u] + 1);
			in[v]--;
			if(!in[v])q.push(v);
		}
		ans = max(ans,dp[u]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 6528
#include<stdio.h>

int main (void){
	
	int n,b,f,r,v,i,x,y,z;
	int array[4][3][10]={0};
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		
		array[b-1][f-1][r-1] += v;
		
	}
	for(x=0;x<4;x++){
		for(y=0;y<3;y++){
			for(z=0;z<10;z++){
				
				printf(" %d",array[x][y][z]);
							}
			printf("\n");
			
		}
		if(x != 3){
			printf("####################\n");
		}
	}
return 0;
}

Measured memory_bytes: 612
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <memory>        // unique_ptr, shared_ptr, weak_ptr
#include <cstring>
#include <cmath>

using namespace std;

using ll = long long int;
using vi = vector<int>;
using vvi = vector<vi>;

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

int main() {
	long long N, a, ans=0, cnt=0;
	cin >> N;

	vector<long long> v(3*N, 0);

	for (size_t i = 0; i < 3*N; i++) cin >> v.at(i);

	sort(v.begin(), v.end());
	for (size_t i=N; i<v.size(); i++) {
		if (cnt%2 == 0) ans += v.at(i);
		cnt++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5120
#include <stdio.h>

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

int lcm(int x, int y){
    double ans;
    ans = (double)x * (double)y / (double)gcd(x, y);
    return (int)ans;
}

int main(void)
{
    long a, b;
    while (scanf("%d %d", &a, &b) == 2) {
        printf("%d %d\n",gcd(a, b), lcm(a, b));
    }
    return 0;
}

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

using namespace std;

#define rep(i, a) for (int (i) = 0; (i) < (a); (i)++)
#define reps(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define MP(a, b) make_pair((a), (b))
#define pb(a) push_back((a))

string s;

bool komoji(char c)
{
	return c >= 'a' && c <= 'z';
}

int main()
{
	cin >> s;
	bool f = s[0] == 'A';
	int l = s.length();
	if (!komoji(s[1])) f = false;
	int cnt = 0;
	reps(i, 2, l-1) {
		if (s[i] == 'C') cnt++;
	}
	if (cnt != 1) f = false;
	reps(i, 2, l) {
		if (s[i] != 'C' && !komoji(s[i])) f = false;
	}
	if (f) cout << "AC" << endl;
	else cout << "WA" << endl;
}

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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h,w;
  cin >> h >> w;
  string board[h];
  rep(i,h) cin >> board[i];
  
  ll b[4][h][w];
  rep(i,4) rep(j,h) rep(k,w) b[i][j][k] = 0;

  rep(i,h) {
    int cnt = 0;
    rep(j,w){
      b[0][i][j] = cnt;
      if(board[i][j] == '#') cnt = 0;
      else{
        cnt++;
      }
    }
  }

  rep(i,h) {
    int cnt = 0;
    for(ll j= w-1; j>= 0; j--){
      b[1][i][j] = cnt;
      if(board[i][j] == '#') cnt = 0;
      else{
        cnt++;
      }
    }
  }

  rep(j,w){
    int cnt = 0;
    rep(i,h){
      b[2][i][j] = cnt;
      if(board[i][j] == '#') cnt = 0;
      else{
        cnt++;
      }
    }
  }

  rep(j,w){
    int cnt = 0;
    for(ll i= h-1; i>= 0; i--){
      b[3][i][j] = cnt;
      if(board[i][j] == '#') cnt = 0;
      else{
        cnt++;
      }
    }
  }
  ll ans = 0;
  rep(i,h)rep(j,w){
    if(board[i][j] == '#') continue; 
    ll tmp = 1;
    rep(k,4) tmp += b[k][i][j];
    ans = max<ll>(ans,tmp);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int x ,y;
  cin >> x >> y;
  if (x == 2 || y == 2) {
    cout << "No" << endl;
  }
  else {
    bool xg ,yg;
    if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 ||
        x == 10 || x == 12) {
      xg = true;
    }
    else {
      xg = false;
    }
    if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 ||
        y == 10 || y == 12) {
      yg = true;
    }
    else {
      yg = false;
    }
    if (xg == yg) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}


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

int main(){
  long n ;
  cin >> n;
  long ans = 0;
  long a = 0 , b = 0 , ab = 0;
  string str;
  for(long i = 0;  i < n ; i++){
      cin >> str;
      if(str[0] == 'B' && str[str.length()-1] == 'A'){
          ab += 1;
      }else if(str[str.length()-1] == 'A'){
          a += 1;
      }else if(str[0] == 'B'){
          b += 1;
      }
      for(long j = 0 ; j < str.length() - 1 ; j++ ){
          if(str[j] == 'A' && str[j+1] == 'B'){
              ans += 1;
          }
      }
  }
  if(ab > 0){
      ans += ab -1;
      if(a > 0){
          a -= 1;
          ans += 1;
      }
      if(b > 0){
          b -= 1;
          ans += 1;
      }
  }
  ans = ans + min(a , b);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
	int n, c[510], s[510], f[510];
	scanf("%d", &n);
	for(int i = 0, *pc = c, *ps = s, *pf = f; i < n - 1; ++i, ++pc, ++ps, ++pf) scanf("%d%d%d", pc, ps, pf);
	++(f[n - 1] = s[n - 1] = c[n - 1] = 0);
	for(int i = 0; i < n; i++){
		int ans = 0;
		for(int j = i; j < n; j++) ans = c[j] + (ans < s[j] ? s[j] : (ans / f[j] + (ans % f[j] != 0)) * f[j]);
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 128
n=int(input())
x=list(map(int,input().split()))

health = 10**9
p_min = min(x)
p_max = max(x)
for p in range(p_min,p_max+1):
  tmp = 0
  for i in range(n):
    tmp += (x[i]-p)**2
    
  health = min(health, tmp)
print(health)

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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e18;
const int MOD = 1e9 + 7;
const int MB = 60;

int dp[3000][3000];
int a[3000];
int n;

int rec(int l, int r) {
	if (l == r) return n % 2 ? a[l] : -a[l];
	if (dp[l][r] != INF) return dp[l][r];
	if ((r - l + 1) % 2 == n % 2) {
		dp[l][r] = max(a[l] + rec(l + 1, r), a[r] + rec(l, r - 1));
	}
	else {
		dp[l][r] = min(-a[l] + rec(l + 1, r), -a[r] + rec(l, r - 1));
	}
	return dp[l][r];
}

void solve() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			dp[i][j] = INF;
		}
	}
	cout << rec(0, n - 1);
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}


Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
char a[1005][1005];

int main(){
   int n,k;
   cin>>n>>k;
   int ans=k*pow(k-1,n-1);
   cout<<ans<<endl;
}

   


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

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

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

    map<long long, int>::reverse_iterator i = mp.rbegin();
    bool f = true;
    long long i1;
    for(; i != mp.rend(); ++i){
        long long x = i -> first;
        int y = i -> second;
        if(y >= 4){
            if(!f) cout << i1 * x << endl;
            else cout << x * x << endl;
            return 0;
        }else if(y >= 2){
            if(f){
                i1 = x;
                f = false;
            }else{
                cout << i1 * x << endl;
                return 0;
            }
        }
    }

    cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,m;
  cin >> n >> m;
  vec num(n,1);
  vec red(n,false);
  red[0]=true;
  for(ll i=0;i<m;i++) {
    ll x,y;
    cin >> x >> y;
    x--;
    y--;
    if(red[x]) red[y]=true;
    num[x]--;
    num[y]++;
    if(num[x]==0) red[x]=false;
  }
  ll ans=0;
  for(ll i=0;i<n;i++) {
    ans+=red[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        Map<Character, Integer> map1 = new HashMap<>();
        Map<Character, Integer> map2 = new HashMap<>();
        for (int i = 0; i < S.length(); i++) {
            int value = 1;
            if (map1.containsKey(S.charAt(i))) {
                value += map1.get(S.charAt(i));
            }
            map1.put(S.charAt(i), value);
            value = 1;
            if (map2.containsKey(T.charAt(i))) {
                value += map2.get(T.charAt(i));
            }
            map2.put(T.charAt(i), value);
        }
        int[] num1 = new int[Math.max(map1.size(), map2.size())];
        int[] num2 = new int[Math.max(map1.size(), map2.size())];
        int i = 0;
        for (int value : map1.values()) {
            num1[i] = value;
            i++;
        }
        i = 0;
        for (int value : map2.values()) {
            num2[i] = value;
            i++;
        }
        Arrays.sort(num1);
        Arrays.sort(num2);
        boolean ok = true;;
        for (int j = 0; j < num1.length; j++) {
            if (num1[j] != num2[j]) {
                ok = false;
            }
        }
        if (ok) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 33488
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


int visitTime = 1;
int d[101]={},f[101]={},n[101],v[101][101],id;


void dfs(int cur) { // cur????¨????
	d[cur] = visitTime;// cur????¨??????????????¨????
	visitTime += 1;
	rep(i,n[cur]){ // ??¨????????? v[cur][i] ????????????
		if(d[v[cur][i]]==0){ // v[cur][i] ???????¨??????????
			dfs(v[cur][i]);
		}
	}
	f[cur] = visitTime;// cur ????¨????????????????????¨????
	visitTime += 1;
	// ??¢??°??????????????§???????????? (?????¢??°)
}

int main(void){
	int N;
	cin>>N;
	rep(i,N){
		cin>>id;
		cin>>n[id];
		rep(j,n[id])cin>>v[id][j];
	}
	reg(i,1,N){
		if(d[i]==0){
			dfs(i);
		}
	}
	reg(i,1,N)cout<<i<<" "<<d[i]<<" "<<f[i]<<endl;
	return 0;
}

Measured memory_bytes: 3108
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}

module Main where

import qualified Data.ByteString.Char8 as B8
import Data.Maybe (fromJust)
import Data.Char (toUpper,isDigit)
import Data.List
import qualified Data.Map as M
import Data.Array.IO
import Data.IORef
import Data.Ix (range)
import Control.Monad
import Control.Applicative
import Text.Printf
import Data.Time.Calendar
import Debug.Trace

readDigits = map read <$> words <$> getLine :: IO [Int]
readDigits' = map read <$> lines <$> getContents :: IO [Int]

--
main :: IO ()
main = do
    inBounds <$> readDigits
    >>= putStrLn 
    where
    inBounds [w,h,x,y,r]
        | 0 <= (x-r) && (x+r) <= w
        && 0 <= (y-r) && (y+r) <=h = "Yes"
        | otherwise = "No"

Measured memory_bytes: 3632
n,m=map(int,input().split())
a=set(int(input()) for _ in range(m))
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-2]+dp[i-1])%1000000007
    if i in a:
        dp[i]=0
print(dp[n])

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

int main(){
    int N,M,C,i,j,sum,count=0;
    int A,B[20];
    cin >> N >> M >> C;
    for(i=0;i<M;i++){
        cin >> B[i];
    }
    for(j=0;j<N;j++){
        int sum = C;
        for(i=0;i<M;i++){
            cin >> A;
            sum += A*B[i];
        }
    if(sum > 0){ ++count; }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [0 for _ in range(N)]

max1 = 0
max2 = 0

for i in range(len(A)):
    A[i] = int(input())

    if max1 < A[i]:
        max2 = max1
        max1 = A[i]

    elif max2 < A[i]:
        max2 = A[i]

for a in A:
    if a == max1:
        print(max2)
    else:
        print(max1)


Measured memory_bytes: 12528
//include <bits/stdc++.h>
// Headder {{{
#pragma GCC optimize("O3")
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
// }}}
using namespace std;
#define int long long
#define read cin >>
#define echo cout <<
#define fin << '\n'
#define _ << ' ' <<

bool isAC[100100];
int wa_cnt[100100];

signed main ( ) {

    int wa = 0;
    int ac = 0;

    int n, m;
    read n >> m;
    for ( int i = 0; i < m; i++ ) {
        int p;
        string s;
        read p >> s;
        if ( s == "AC" ) {
            if ( !isAC[p] ) {
                wa += wa_cnt[p];
                ac++;
                isAC[p] = true;
            }
        }
        else {
            wa_cnt[p] += !isAC[p];
        }
    }

    echo ac _ wa fin;
    return 0;
}

Measured memory_bytes: 1152
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    vector<int> m;
    int m_all = 0;
    for (int i = 0; i < n; i++) {
        int mi;
        cin >> mi;
        m.push_back(mi);
        m_all += mi;
    }
    x -= m_all;

    sort(m.begin(), m.end());

    cout << n + x / m[0] << endl;

    return 0;
}


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

typedef long long ll;
typedef tuple<ll, ll, ll> mytuple;
const ll INF = 1e9;
const ll MOD = 1000000007;
const double pi = 3.141592653589793238;

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) { if (b == 0) {return a;} else {return GCD(b, a % b);} }
// a と b の最小公倍数を返す関数
long long LCM(long long a, long long b) { return a/GCD(a,b)*b; }

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

int main() {
  string S; cin >> S;
  string T; cin >> T;

  if(S+T.at(T.size()-1) == T) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;

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

    vector<int> tow;
    tow.push_back(1);
    for (int i = 1; tow[i - 1] < 100000; ++i) {
        tow.push_back(tow[i - 1] * 2);
    }

    double ans = 0;
    for (int i = 1; i <= n; ++i) {
        int coin = 0;
        while (i * tow[coin] < k) coin++;

        double p = 1.0 / n;
        for (int j = 0; j < coin; ++j) {
            p *= 1.0 / 2.0;
        }
        ans += p;
    }

    cout.precision(10);
    cout << ans << endl;

    return 0;
}


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

bool f(int x,int y,string s){
    for(int i=x;i<y-2;i++){
        if(s[i]=='#' && s[i+1]=='#'){
            return false;
        }
    }
    return true;
}
bool g(int x,int y,string s){      //すぬけ君がふぬけ君を抜けるか判定
    for(int i=x-1;i<y;i++){
        if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.'){
            return true;
        }
    }
    return false;
}
int main(){
    int n,a,b,c,d;
    string s;
    cin >> n >>a >> b >> c >> d;
    cin >> s;
    if(c<d){
        if(f(b,d,s) && f(a,c,s)){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else{
        if(g(b,d,s)){
            if(f(b,d,s) && f(a,c,s)){
                cout << "Yes" << endl;
            }
            else{
                cout << "No" <<endl;
            }
        }
        else{
            cout << "No" <<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 900