akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define OUT(s) cout << s << "\n";
using namespace std;

int N;
string s;
// https://atcoder.jp/contests/abc164
void Main()
{
    map<std::string, int> mp;    //  文字列 → 整数 の連想配列
    REP(i, N) {
        cin >> s;
        mp[s] = 1;
    }
    OUT(mp.size())
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    cin >> N;
    Main();
    return 0;
}

Measured memory_bytes: 19136
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
using namespace std;
using ll=long long;
#define MOD  1000000007

int main(int argc, char const *argv[]) {
  int a,b,c;
  std::cin >> a >> b >> c;
  if(a+b+c==17) std::cout << "YES" << '\n';
  else std::cout << "NO" << '\n';
  return 0;
}

Measured memory_bytes: 256
// D - Megalomania

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;

struct Work {
	int hour;
	int deadline;
};

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

	vector<Work> works(N);

	for (int i=0; i<N; i++) {
		cin >> works[i].hour >> works[i].deadline;
	}

	sort(works.begin(), works.end(), [](const Work &a, const Work &b) {
		return a.deadline < b.deadline;
	});

	int hour = 0;
	string ans = "Yes";
	for (int i=0; i<N; i++) {
		hour += works[i].hour;
		if (hour > works[i].deadline) {
			ans = "No";
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
  string  str, t;
  char temp[200];
  int m, h, l;
  cin >> str;
  while(str != "-"){
    cin >> m;
    l = str.length();
    for(int j=0; j<m; j++){
      cin >> h;
      for(int i=0; i<h; i++){
        temp[i] = str[i];
      }
      for(int i=0; i<l; i++){
        if(i<l-h)
          str[i] = str[i+h];
        else
          str[i] = temp[i-(l-h)];
      }
    }
    cout << str << endl;
    cin >> str;
  }
  return 0;
}


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

using namespace std;

int main(void){

  string helix;

  cin >> helix;

  if(helix == "A")
  cout << "T" << endl;

  else if (helix == "T")
  cout << "A" << endl;

  else if (helix == "G")
  cout << "C" << endl;

  else if (helix == "C")
  cout << "G" << endl;

  return 0;

  }


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

int main(){
    int flag=1;
    int n,a;
    int ans;
    int MIN=1000000001,MAX=0;

    cin >>n;

    for (int i = 0; i < n; i++){
        cin >> a;
        MAX=max(MAX,a);
        MIN=min(MIN,a);
    }
    
    cout << MAX-MIN <<endl;
    //cout <<fixed<<setprecision(16)<< ans <<endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    set<string> st;

    for (int bit = 0; bit < (1 << 4); bit++)
    {
        string tmp[4] = {"KIH", "B", "R", ""};
        for (int i = 0; i < 4; i++)
        {
            if (bit & (1 << i))
            {
                tmp[i] = "A" + tmp[i];
            }
        }
        string res = "";
        for (int i = 0; i < 4; i++)
        {
            res += tmp[i];
        }
        st.insert(res);
    }
    if (st.count(s))
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	ll n, i, x;
	cin >> n;
	bool ok = 0;
	rep(i,0,n){
		cin >> x;
		if(x%2==0){
			if(x%3 != 0 && x%5 != 0)ok = 1;
		}
	}
	if(ok)cout << "DENIED" << nl;
	else cout << "APPROVED" << nl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}



Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


// range sum query using fenwick tree
// note index starts at 1

class fenwick_tree {
	vector<long> t;
	long size;
public:
	fenwick_tree(long n) {
		t.assign(n + 1, 0);
		size = n + 1;
	}

	long LSOne(long k) {	// least significant 1-bit
		return k & (-k);
	}

	void update(long index, long val) {	// can go up or go down
		for (; index < size; index += LSOne(index)) t[index] += val;
	}

	long query_full(long a, long b) {		// range query
		return query(b) - ((a <= 1) ? 0 : query(a - 1));
	}

	long query(long b) {	// range query 1..b
		if (b < 1) return 0;

		long sum = 0;
		for (; b; b -= LSOne(b)) sum += t[b];
		return sum;
	}
};


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

	long long n, i, j, k, x, y, MOD = 1000000007, ans, f;
	cin >> n >> k;
	vector<pair<long long, long long>> a(n);
	for (i = 0; i < n; i++) {
		cin >> x;
		a[i] = { x, i + 1};
	}
	sort(a.begin(), a.end());

	fenwick_tree ft(n + 1);
	ans = 0;
	for (i = 0; i < n; i++) {
		x = ft.query_full(a[i].second, n);
		y = 0;
		for (j = 0; j < n; j++) {
			if (a[i].first > a[j].first) y++;
		}

		ans = (ans + x * k) % MOD;
		if (k > 1) {
			f = ((k - 1) * k / 2) % MOD;
			ans = (ans + y * f) % MOD;
		}

		ft.update(a[i].second, 1);
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long

using namespace std;
const ll Mod = 1e9 + 7;
ll n,k,fact[200100];

long long fastpower(long long a,long long b)
{
    if(b==0)
        return 1;
    if(b==1)
        return a;
    long long res = fastpower(a,b/2)%Mod;
    res = (res %Mod  * res % Mod )%Mod;
    if(b%2!=0)
        res*=a;
    return res % Mod;
}

ll C(ll n, ll k)
{
    if(k <= 0)  return 1;
    ll y = (fact[k] * fact[n - k])%Mod;
    return (fact[n] * fastpower(y, Mod - 2))%Mod;
}

void add_self(ll &x , ll y){
    x = (x + y)%Mod;
}

int main()
{
    cin >> n >> k;
    k = min(n , k + 1);
    fact[0] = 1;
    for(int i = 1; i<=200000; i++)  fact[i] = fact[i - 1] * i, fact[i]%=Mod;
    ll Ans = C(n - 1 , n - 1);
    for(int i = 1;i<k;i++)  add_self(Ans , C(n , i) * C(n - 1 , n - i - 1));
    cout << Ans;
    return 0;
}


Measured memory_bytes: 1920
N=int(input())
ans=""
if N==0:
    print(0)
    quit()
while(N):
    if (N-1)%(-2)==0:
        ans+="1"
        N-=1
        N//=(-2)

    else:
        ans+="0"
        N//=(-2)

print(ans[::-1])


Measured memory_bytes: 40304
l = int(input())
num_lis = list(input().split())
ans = 'YES'
for i in range(l):
    num_lis[i] = int(num_lis[i])
num_lis = sorted(num_lis)
for i in range(l-1):
    if num_lis[i] == num_lis[i+1]:
        ans = 'NO'
print(ans)  

Measured memory_bytes: 20432
#include<bits/stdc++.h>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vector<pii> vpii
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
bool ok(string s)
{
	rep(i,s.size()/2)
		if(s[i]!=s[s.size()-i-1])return 0;
	return 1;
}
int main()
{
	ios::sync_with_stdio(0);
	ld l;
	cin>>l;
	ld x=l/3;
	cout<<fixed<<setprecision(10)<<x*x*x<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ll a,b;
    cin>>a>>b;
    for(ll i=1;i<=1250;i++)
    {
        if((2*i)/25==a && i/10==b)
        {
            cout<<i;
            return 0;
        }
    }
    cout<<-1;
}

Measured memory_bytes: 256
import sys
import copy
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a, b, c = na()
l = a % b
li = [l]
if l == 0:
    print('NO')
else:
    while True:
        num = (li[-1] + l) % b
        if num == c:
            print('YES')
            break
        if num in li:
            print('NO')
            break
        li.append(num)



Measured memory_bytes: 3444
import math

def combinations(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n, k = map(int, input().split())
for i in range(k):
    if n-k+1 < i+1:
        print(0)
        continue
    else:
        print(combinations((n - k + 1), i+1) * combinations(k-1, i) % (10 ** 9 + 7))

Measured memory_bytes: 3316
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<string>
using namespace std;
#define gc getchar()
#define fup(i,a,b) for(int i=a,i##e=b;i<=i##e;++i)
#define fdn(i,a,b) for(int i=a,i##e=b;i>=i##e;--i)
#define mem(a,b) memset(a,b,sizeof(a))
#define hh putchar(10)
#define ll long long
struct zg{template<class T>inline zg&operator >>(T &x){T f=1;char a;while((a=gc)<48)
if(a==45)f=-1;for(x=a^48; (a=gc)>47; x=(x<<3)+(x<<1)+(a^48));x*=f;}}qin;void Main();
struct nnn{int x1,x2,x3;};int main(){Main();return 0;}

void Main()
{
    int a,b;
    qin>>a>>b;
    cout<<max(a-b,max(a*b,a+b));
}


Measured memory_bytes: 256
package main

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

var in = NewScanner(os.Stdin, 0)

/* this is port of top c++ answer to test go performance */
func main() {
	n, m := in.Int(), in.Int()
	a, b := in.ArrayInt(n), in.ArrayInt(m)
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	sort.Sort(sort.Reverse(sort.IntSlice(b)))
	a = append(a, 0)
	b = append(b, 0)
	ans, c := 1, 0
	for i, j, k := n*m, 0, 0; i > 0; i-- {
		if a[j] == i && b[k] == i {
			c += j + k
			j++
			k++
		} else if a[j] == i {
			ans = ans * k % M7
			c += k - 1
			j++
		} else if b[k] == i {
			ans = ans * j % M7
			c += j - 1
			k++
		} else {
			ans = ans * c % M7
			c--
		}
	}
	Pln(ans)
}

const M7 = 1000000007

type Scanner struct {
	*bufio.Scanner
}

func NewScanner(r io.Reader, max int) *Scanner {
	s := bufio.NewScanner(r)
	s.Split(scanWords)
	if max <= 0 {
		max = 1048576
	}
	s.Buffer([]byte{}, max)
	return &Scanner{s}
}
func (s *Scanner) Int() int {
	s.Scan()
	i, e := strconv.ParseInt(s.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}
func (s *Scanner) ArrayInt(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = s.Int()
	}
	return r
}
func isSpace(b byte) bool {
	return b == ' ' || b == '\n' || b == '\r' || b == '\t'
}
func scanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	start := 0
	for start < len(data) && isSpace(data[start]) {
		start++
	}
	for i := start; i < len(data); i++ {
		if isSpace(data[i]) {
			return i + 1, data[start:i], nil
		}
	}
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	return start, nil, nil
}
func Pln(s ...interface{}) {
	fmt.Println(s...)
}

type ByteSlice []byte
type IntSlice []byte


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
int main() 
{
  	int n;
  	cin >> n;
    string s;
    cin >> s;

    if(s.size()%2 == 1){
        cout << "No" << endl;
        return 0;
    }
        else{
            for(int i=0;i<s.size()/2;i++){
                if(s.at(i) != s.at(s.size()/2+i)){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    cout << "Yes" << endl;


}

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


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

    int h,w;
    cin >> h >> w;

    vector<vector<char>> chars(h,vector<char>(w));

    for(int i = 0 ; i < h; ++i)
    {
        for(int j = 0 ; j < w; ++j)
        {
            char c;
            cin >> c;
            chars[i][j] = c;
        }
    }

    vector<bool> dontTakeRow(h, 0);
    vector<bool> dontTakeCol(w, 0);
    for(int i = 0 ; i < h; ++i)
    {
        int count = 0;
        for(int j = 0 ; j < w; ++j)
        {
            if(chars[i][j] == '.') count++;
        }
        if(count == w) dontTakeRow[i] = 1;
    }

    for(int i = 0 ; i < w; ++i)
    {
        int count = 0;
        for(int j = 0 ; j < h; ++j)
        {
            if(chars[j][i] == '.') count++;
        }
        if(count == h) dontTakeCol[i] = 1;
    }

    for(int i = 0 ; i < h; ++i)
    {
        bool endline = false;
        for(int j = 0 ; j < w; ++j)
        {
            if(dontTakeRow[i]==0&&dontTakeCol[j]==0)
            {
                cout << chars[i][j];
                endline = true;
            }
        }
        if(endline)cout << endl;
    }

    return 0;
}


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

int main(void){
	int n,s[1010],i,b;
	double a=0,h=0;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		
		for(i=1;i<=n;i++){
			scanf("%d",&s[i]);
		}
		h=0;
		for(i=1;i<=n;i++){
			h+=s[i];
		}
		h=h/(double)n;
		a=0;
		for(i=1;i<=n;i++){
			a+=((double)s[i]-h)*((double)s[i]-h);
		}
		a=a/n;
		a=sqrt(a);
		printf("%f\n",a);
	}
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
signed main(){
  bool f=false;
  int n , m , x , y , z , a=1 , b=5 , c=10 , k , t;
  cin>>n>>m;
  m/=1000;
  for(int i=0;i<=n&&f==false;i++){
    for(int j=n-i;j>=0;j--){
      k=n-i-j;
      for(int l=0;l<3;l++){
	if(a*i+b*j+k*c == m){
	  f = true;
	  if(a==1){
	    x=i;
	  } else if(a==5){
	    y=i;
	  } else {
	    z=i;
	  }

	  if(b==1){
	    x=j;
	  } else if(b==5){
	    y=j;
	  } else {
	    z=j;
	  }

	  if(c==1){
	    x=k;
	  } else if(c==5){
	    y=k;
	  } else {
	    z=k;
	  }
	}

	else{
	  t=a;
	  a=b;
	  b=c;
	  c=t;
	}
      }
    }
  }
  if(f){
    cout<<z<<' '<<y<<' '<<x<<endl;
  } else {
    cout<<"-1 -1 -1\n";
  }
  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 repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    int n, m; cin >> n >> m;
    int all = 0; vector<int> a(n);
    rep(i, n){
        cin >> a[i]; all += a[i]; a[i] *= 4 * m;
    }

    int ans = 0;
    rep(i, n){
        if(a[i] >= all) ans ++;
    }
    if(ans >= m) out("Yes");
    else out("No");
}

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

const ll LIM = 1e6;
const ll INF = 4e18;
const ll BIG = 2e9 + 100;
ll mem[LIM + 10], a, b, c, d, n;
map<ll, ll> mem2;

ll dp(ll m) {
    if(m == 0)
        return 0;
    if(m < LIM && mem[m] != -1)
        return mem[m];
    if(mem2.count(m))
        return mem2[m];
    if(m == 1)
        return mem[1] = d;
    ll ans = INF;
    if(m <= BIG)
        ans = d * m;
    for(ll x = max(m - 1, 0LL); x <= m + 1; x++) {
        if(x % 2 == 0 && x / 2 < m)
            ans = min(ans, d*abs(x - m) + a + dp(x/2));
    }
    for(ll x = max(m - 1, 0LL); x <= m + 1; x++) {
        if(x % 3 == 0 && x / 3 < m)
            ans = min(ans, d*abs(x - m) + b + dp(x/3));
    }
    for(ll x = max(m - 2, 0LL); x <= m + 2; x++) {
        if(x % 5 == 0 && x / 5 < m)
            ans = min(ans, d*abs(x - m) + c + dp(x/5));
    }
    if(m < LIM)
        return mem[m] = ans;
    return mem2[m] = ans;
}

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

    int t;
    cin >> t;
    while(t--) {
        cin >> n >> a >> b >> c >> d;
        memset(mem, -1, sizeof mem);
        mem2.clear();
        for(int i = 0; i < LIM; i++)
            dp(i);
        cout << dp(n) << '\n';
    }
}

Measured memory_bytes: 11720
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    int res = 1;
    while(b > 0){
        if(b&1) res = m(m(res)*m(a));
        a = m(m(a)*m(a));
        b >>= 1;
    }
    return res;
} 
signed main(){
    fast();
    int r, g, b;
    cin >> r >> g >> b;
    int k;
    cin >> k;
    // int num = 0;
    while(g <= r){
        g *= 2;
        k--;
    }
    while(b <= g){
        b *= 2;
        k--;
    }
    if(k>=0)    cout << "Yes" << endl;
    else cout << "No" << endl;
    cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
}

Measured memory_bytes: 3608
N = int(input())
As = [int(input()) for i in range(N)]

if As[0] != 0:
    # 不可能
    print(-1)
    exit()

ans = 0
for i in reversed(range(1, N)):
    if As[i - 1] + 1 < As[i]:
        # 不可能
        ans = -1
        break
    elif As[i - 1] + 1 == As[i]:
        # X[i-1]→X[i]の、1回の操作で可能
        ans += 1
    else:
        # X[i-As[i]]から順に、As[i]回の操作が必要
        ans += As[i]

print(ans)


Measured memory_bytes: 11048
using System;

namespace ABC169A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] word = Console.ReadLine().Split(' ');
            int a = int.Parse(word[0]);
            int b = int.Parse(word[1]);

            int s = a * b;
            Console.WriteLine(s);
        }
    }
}

Measured memory_bytes: 27496
import sys
input = sys.stdin.readline

n = int(input())
s = list(input())
res = 10**6
ctw = 0
ctb = 0
w = [0]*n
b = [0]*n

for i in range(n):
     if s[i] == ".":
          ctw += 1
     else:
          ctb += 1
     w[i]= ctw
     b[i]= ctb
for i in range(n):
     res = min(res,b[i]+w[-1]-w[i])
res = min(res,w[-1],b[-1])
print(res)
      

Measured memory_bytes: 14184
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

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

  int N; cin >> N;
  mat m;
  vec v = {0, 0, 0};
  m.push_back(v);
  rep(i, N) {
    cin >> v[0] >> v[1] >> v[2];
    m.push_back(v);
  }

  int time, distance;
  rep(i, N) {
    time = m[i+1][0] - m[i][0];
    distance = abs(m[i+1][1]-m[i][1]) + abs(m[i+1][2]-m[i][2]);
    if(distance>time) {cout << "No" << endl; return 0;}
    else if (!((distance%2==0 && time%2==0) || (distance%2!=0 && time%2!=0))) {cout << "No" << endl; return 0;}
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 6196
#include<stdio.h>
#include<string.h>
int main(){
  char s[11],a[]="ACGT";
  scanf("%s",s);
  int l=0,t=0,i=0;
  for(;i<strlen(s);i++){
    if(strchr(a,s[i])){
      t++;
    }else {
      t=0;
    }
    l= l>t?l:t;
  }
  printf("%d\n",l);
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))
A = [0] + A + [0]
D = [0] * (N+1)
TD = [0] * N

TD[0] = abs(A[2]-A[0])
for i in range(N):
    D[i] = D[i-1]+abs(A[i+1]-A[i])
    TD[i] = abs(A[i+2]-A[i])
D[N] = D[N-1]+abs(A[N+1]-A[N])

for j in range(N):
    if j == 0:
        print(TD[j]+D[N]-D[j+1])
    elif j == N-1:
        print(D[j-1]+TD[j])
    else:
        print(D[j-1]+TD[j]+D[N]-D[j+1])


Measured memory_bytes: 16024
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int ans[105][105];
int h,w;
void nxt(int &x,int &y)
{
    if(y==w&&(x&1)) x++;
    else if(y==1&&x%2==0) x++;
    else if(x&1) y++;
    else y--;
}
int main()
{
    cin>>h>>w;
    int n;
    cin>>n;
    vi a(n+1);
    for(int i=1;i<=n;i++) cin>>a[i];
    int x=1,y=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<a[i];j++)
        {
            ans[x][y]=i;
            nxt(x,y);
        }
    }
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
            cout<<ans[i][j]<<(j==w?'\n':' ');
    }
}

Measured memory_bytes: 384
/*
 *  author : Atul Anand   
 *  created on : Wed Apr 01 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int A = in.nextInt();
        int B = in.nextInt();
        int C = in.nextInt();

        if((A == B && A != C) || (A == C && A != B) || (B == C && A != C)){
            println("Yes");
        }
        else{
            println("No");
        }

        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl a,b,c,d;
    cin >> a >> b >> c;
    cout << max(0,c-(a-b)) << endl;
    return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
wv = []
for _ in range(N):
  wv += list(map(int, input().split()))
dp = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(N):
  for w in range(W+1):  
    if w-wv[2*i] >= 0:
      dp[i+1][w] = max(dp[i+1][w], dp[i][w-wv[2*i]]+wv[2*i+1])
    dp[i+1][w] = max(dp[i+1][w], dp[i][w])
print(dp[N][W])

Measured memory_bytes: 173832
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

void rec(vector<int> &pre, vector<int> &in, vector<int> &post, int *posIndex, int l, int r)
{
    if (l >= r)
    {
        return;
    }

    int root = pre[*posIndex];
    *posIndex = *posIndex + 1;

    int m = distance(in.begin(), find(in.begin(), in.end(), root));

    rec(pre, in, post, posIndex, l, m);
    rec(pre, in, post, posIndex, m+1, r);

    post.push_back(root);
}

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

    vector<int> pre(N);
    vector<int> in(N);
    vector<int> post(0);

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

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

/*
    for (int i = 0; i < N; i++)
    {
        cout << pre[i];
    }
*/
    int *pos = new int;
    *pos = 0;

    rec(pre, in, post, pos, 0, pre.size());

    for (int i = 0; i < N; i++)
    {
        if (i != 0)
        {
            cout << " ";
        }

        cout << post[i];
    }
    cout << endl;

    return 0;
}



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

using namespace std;

const int N = 1001;
const int mod = 1e9 + 7;

int h, w;
string arr[N];
int dp[N][N];
int dx[] = {1, 0};
int dy[] = {0, 1};

inline int add(int a, int b) {
  a += b;
  if(a >= mod) a -= mod;
  if(a < 0) a += mod;
  return a;
}

bool valid(int x, int y) {
  return (x >= 0) && (x < h) && (y >= 0) && (y < w);
}

int rec(int cx, int cy){
  if(cx == h - 1 && cy == w - 1) return 1;
  int& cxy = dp[cx][cy];
  if(cxy != -1) return cxy;
  cxy = 0;
  for(int i = 0; i < 2; ++i) {
    int p = cx + dx[i]; 
    int q = cy + dy[i];
    if(valid(p, q) && arr[p][q] != '#') {
      cxy = add(cxy, rec(p, q));
    }
  }
  return cxy;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> h >> w;
  memset(dp, -1, sizeof dp);
  for(int i = 0; i < h; ++i){
    cin >> arr[i];
  }
  cout << rec(0, 0) << "\n";
}

Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  string s; cin >> s;
  rep(i,s.size()) {
    if(s[i] == ',') s[i] = ' ';
  }
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int n;
    cin >> n;
    int x = n;
    int y = 0;
    while(x){
        y += x % 10;
        x /= 10;
    }
    cout << (n % y ? "No" : "Yes") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  string S,T;
  cin>>S>>T;
  int ans=T.size();
  REP(i,S.size()-T.size()+1){
    int temp=0;
    REP(j,T.size()){
      if(T[j]!=S[i+j])temp++;
    }
    ans=min(ans,temp);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main() {
  long long n;
  for (;;) {
    cin >> n;
    if (!n) return 0;
    long long r = 0, x = 1;
    for (int i = 0; i < 15; i++) {
      x *= 5;
      r += n / x;
    }
    cout << r << endl;
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=200010;
int a[N],n;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    reverse(a,a+n);
    ll res=0;
    for(int i=1;i<n;i++) res+=a[i/2];
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 4404
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}

ll a,b,c;

double f(double t){
  return a*t + b*sin(c*t*acos((long double)(-1)));
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  string s;cin>>s;
  ll n = s.size();
  if(((int)(s[0] == s[n-1]) + n%2) % 2 == 0){
    cout<<"Second"<<endl;
  }else{
    cout<<"First"<<endl;
  }
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    int t=0;
    set<string> s;
    rep(i,N){
        int num;
        cin >> num;
        if(0<num&&num<400){
            s.insert("gray");
        }else if(400<=num&&num<800){
            s.insert("brown");
        }else if(800<=num&&num<1200){
            s.insert("green");
        }else if(1200<=num&&num<1600){
            s.insert("cyan");
        }else if(1600<=num&&num<2000){
            s.insert("blue");
        }else if(2000<=num&&num<2400){
            s.insert("yellow");
        }else if(2400<=num&&num<2800){
            s.insert("orange");
        }else if(2800<=num&&num<3200){
            s.insert("red");
        }else{
            ++t;
        }
    }
    int m = s.size();
    cout << max(m,1) << " " << s.size()+t << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
 int N;
 int P[9]={};
 string S[9]={};
 for(int i=0;i<3;i++){
     cin>>P[i];
 }
 for(int i=0;i<3;i++){
     cin>>P[i+3];
 }
 for(int i=0;i<3;i++){
     cin>>P[i+6];
 }
 cin>>N;
 for(int i=0;i<N;i++){
     int b;
     cin>>b;
     for(int j=0;j<9;j++){
         if(P[j]==b){
             S[j]="a";
         }
     }
 }
 for(int i=0;i<3;i++){
     if(S[i]=="a" &S[i+3]=="a" & S[i+6]=="a"){
         cout<<"Yes"<<endl;
         return 0;
     }
     else if(S[3*i]=="a" & S[3*i+1]=="a" & S[3*i+2]=="a"){
         cout<<"Yes"<<endl;
         return 0;
     }
 }
 if(S[0]=="a" & S[4]=="a" & S[8]=="a"){
     cout<<"Yes"<<endl;
     return 0;
 }
 else if(S[2]=="a" & S[4]=="a" & S[6]=="a"){
     cout<<"Yes"<<endl;
     return 0;
 }
 else{
     cout<<"No"<<endl;
 }
}


Measured memory_bytes: 256
A=map(int,raw_input().split(" "))
vec=A[0]
col=A[1]

def zero(n):
	zerolist=list()
	for i in range(n):
		zerolist+=[0]
	return(zerolist)
A=list()
for i in range(vec):
	A+=[zero(col)]



for i in range(vec):
	k=map(int,raw_input().split(" "))
	for j in range(col):
		A[i][j]=k[j]

#ok

v=zero(col)

for i in range(col):
	v[i]=int(raw_input())

k=0
for i in range(vec):
	for j in range(col):
		k+=A[i][j]*v[j]
	print k
	k=0

Measured memory_bytes: 6556
#include <iostream>

using namespace std;

int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

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

int main()
{
   int a;
   cin >> a;
   cout << lcm(a,360)/a << endl;
   return 0;
}

Measured memory_bytes: 3612
from collections import Counter
n=int(input())
a=input()
b=input()
c=input()
i=0
ans=""
while i<len(a):
  tmp=[]
  tmp.append(a[i])
  tmp.append(b[i])
  tmp.append(c[i])
  tmp=Counter(tmp)
  ans+=tmp.most_common()[0][0]
  i+=1
diff=0
i=0
while i<len(a):
  if a[i]!=ans[i]:
    diff+=1
  if b[i]!=ans[i]:
    diff+=1
  if c[i]!=ans[i]:
    diff+=1
  i+=1
print(diff)

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int A, B; cin >> A >> B;
  if(A > B) swap(A,B);
  if(A == 1 && B == 2) {
    cout << 3 << endl;
  } else if(A == 1 && B == 3) {
    cout << 2 << endl;
  } else {
    cout << 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n,m= map(int,input().split())
l=[]
for i in range(n):
  l1= list(map(int,input().split()))
  del l1[0]
  l=l+l1
ans=0
l2=list(set(l))
for j in range(len(l2)):
  if l.count(l2[j])==n:
    ans+=1
print(ans)

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

void show_array(int *array, int &N){

	for(int i=0; i<N; ++i){
		cout << array[i];
		if(i < N-1){
			cout << " ";
		}
	}	
	cout << endl;
}

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

	int A[N]; // define a static array

	// Input values in the array
	for(int i=0; i<N; i++){
   scanf("%d", &A[i]);
	}

	// Insertion Sort
	int v, j;
	show_array(A, N);
	for(int i=1; i<=N-1; ++i){
		v = A[i];
		j = i - 1;

		while(j >= 0 && A[j] > v){
			A[j+1] = A[j];
			j -= 1;
		}
		A[j+1] = v;

		// Show sorted values
		show_array(A, N);
	}

	return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  vector <ll> red(a);
  vector <ll> green(b);
  vector <ll> colorless;
  vector <ll> v;
  for(int i = 0; i < a; i++){
    cin >> red[i];
  }
  for(int i = 0; i < b; i++){
    cin >> green[i];
  }
  for(int i = 0; i < c; i++){
    ll t;
    cin >> t;
    colorless.push_back(t);
  }
  sort(red.rbegin(),red.rend());
  sort(green.rbegin(),green.rend());
  sort(colorless.rbegin(),colorless.rend());
  ll ans = 0;
  for(int i = 0; i < x; i++){
    colorless.push_back(red[i]);
  }
  for(int i = 0; i < y; i++){
    colorless.push_back(green[i]);
  }
  sort(colorless.rbegin(),colorless.rend());
  for(int i = 0; i < x+y; i++){
    ans += colorless[i];
  }
  cout << ans;
}
         

Measured memory_bytes: 8048
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int vis[100005]={0};
vector<int> g[100005];
void dfs(int cu){
	vis[cu]=1;
	for(auto u:g[cu]){
		if(vis[u])continue;
		dfs(u);
	}
}
int main(){
	int n,m;cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y,z;cin>>x>>y>>z;
		g[x].pb(y);
		g[y].pb(x);
	}
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			cnt++;
			dfs(i);
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 9216
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        
        int ans = -1;
        for(int i = 1; i <= 1250; i++){
            if(i * 2 / 25 == a && i / 10 == b){
                ans = i;
                break;
            }
        }
        System.out.println(ans);
    }
}

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

using namespace std;

void outStr(vector<int>& ary) {

	string aryStr = "";
	for (int i = 0; i < ary.size(); i++)
	{
		aryStr = aryStr + to_string(ary[i]);
		if (i < ary.size() - 1) aryStr = aryStr + " ";
	}

	cout << aryStr << endl;
	return;
}

int selectionSort(vector<int>& ary) {

	int swt = 0;
	for ( int i = 0; i < ary.size() ; i++)
	{
		int minj = i;
		bool needSw = false;
		for (int j = i; j < ary.size(); j++) {
			if (ary[j] < ary[minj]) {
				minj = j;
				needSw = true;
			}
		}
		if (needSw) {
			int sw = ary[i];
			ary[i] = ary[minj];
			ary[minj] = sw;

			swt++;
		}
	}

	return swt;
}


int main() {

	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	int swt = selectionSort(A);
	outStr(A);

	cout << swt << endl;


	return 0;
}



Measured memory_bytes: 3260
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

int a(void);

int main(void) {
	a();
	return 0;
}

int a(void) {
	int N;
	std::cin >> N;
	if (N % 2 == 0) {
		std::cout << static_cast<int>((N / 2) - 1);
	}
	else {
		std::cout << static_cast<int> (((N - 1) / 2));
	}
	return 0;
}

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

using namespace std;

#ifdef Lin1043
    #define DEBUG(msg, ...) printf("(%s #%d) " msg, __FUNCTION__, __LINE__, __VA_ARGS__)
    #define massert(...) assert(...)
#else
    #define DEBUG(...)
    #define massert(...)
#endif

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i )
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i )

struct iopener
{
    iopener()
    {
#ifdef Lin1043
        freopen("./in" , "r" , stdin);
#endif
    }
} iop;

typedef long long LL;

template<typename T>inline bool chkmin(T &x , const T &y) { return x > y ? (x = y , 1) : 0; }
template<typename T>inline bool chkmax(T &x , const T &y) { return x < y ? (x = y , 1) : 0; }

template<typename T>inline T read(T &f)
{
    f = 0; int x = 1 ; char c = getchar();
    while(!isdigit(c)) x = (c == '-' ? -1 : 1) , c = getchar();
    while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
    return f = x * f;
}

const int N = 2000 + 5 , L = 4000000;

int n , k ;
LL fac[L+10] , inv[L+10];

const int KCZ = 1e9 + 7;

LL mp(LL x , LL y = KCZ - 2)
{
    LL res = 1;
    while(y)
    {
        if(y & 1)
            res = res * x % KCZ;
        x = x * x % KCZ;
        y >>= 1;
    }
    return res;
}

void init()
{
    fac[0] = 1;
    rep(i , 1 , L) fac[i] = fac[i - 1] * i % KCZ;
    inv[L] = mp(fac[L]);
    per(i , L - 1 , 1) inv[i] = inv[i + 1] * (i + 1) % KCZ;
    inv[0] = 1;
}

LL C(int n , int m)
{
    if(n < m) return 0;
    return fac[n] * inv[m] % KCZ * inv[n - m] % KCZ;
}

LL f[N][N];

void add(LL &x , const LL &y)
{
    x += y; if(x >= KCZ) x -= KCZ;
}

int main()
{
    read(n) , read(k) , init();
    if(k == 1)
        return puts("1") , 0;
    f[0][0] = 1;
    rep(i , 1 , n)
    {
        per(j , i , 0)
        {
            f[i][j] = f[i][j + 1]; 
            if(j >= 1)
                add(f[i][j] , f[i - 1][j - 1] * C(i * k - j - 1 , k - 2) % KCZ);
        }
    }
    printf("%lld\n" , f[n][0] * fac[n] % KCZ);
    return 0;
}



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

int main()
{
  int N;
  cin >> N;
  int prev = -1;
  int cnt = 0;
  for (int i = 1000; 0 < i; i /= 10)
  {
    if (N/i == prev)
    {
      ++cnt;
      if (3 == cnt)
        break;
    }
    else
      cnt = 1;
    prev = N/i;
    N -= prev*i;
  }
  cout << ((3 == cnt) ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
//#define REPR(i, n) for(int i = n; i >= 0; i--)
//#define FOR(i, m, n) for(int i = m; i < n; i++)
//#define INF 1e9
// template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
// template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;

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

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

    string s, ans;
    cin >> s;

    if (s == "AAA" || s == "BBB"){
        ans = "No";
    } else {
        ans = "Yes";
    }

    cout << ans;
   
}


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

int EO[2][100000];//[e|o][value]<count>
int eoV[2],eo1[2],eo2[2];//[e|o]

int main(){
	int N; cin>>N;
	for(int i=0; i<N; ++i){
		int n,v; scanf("%d",&v); v--,n=i&1;
		EO[n][v]++;
		if(EO[n][v] > eo1[n]){ eo1[n] = EO[n][v]; eoV[n] = v+1; }
		else if(EO[n][v] > eo2[n]) eo2[n] = EO[n][v];
	}
	cout<< N - (eoV[0]!=eoV[1]? eo1[0]+eo1[1]: max(eo1[0]+eo2[1], eo2[0]+eo1[1])) <<endl;
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))
sum = 0
neg = 0
neg_sum = 0
min = float('inf')
max = -float('inf')
for i in range(N):
	sum += A[i]
	if A[i] < 0:
		neg += 1
		neg_sum += A[i]
		if A[i] > max:
			max = A[i]
	else:
		if A[i] < min:
			min = A[i]
if neg % 2 == 1:
	if max + min < 0:
		neg_sum += min
	else:
		neg_sum -= max
print(sum - neg_sum * 2)

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

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  int n;
  string s;
  cin >> n >> s;
  int count = 0;
  for(int i = 0; i < n; ++i) {
    if(s[i] == 'A')
      if(s[i+1] == 'B')
        if(s[i+2] == 'C') count++;
  }
  cout << count << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3576