akhauriyash/Code-Regression huggingface dataset:
#if __has_include("noamoa_atcoder_lib.h")
#include "noamoa_atcoder_lib.h"
#else
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) (x).begin(),(x).end()
namespace atcoder {
	using namespace std;
	using ll = long long;
	using llv = vector<ll>;
	using intv = vector<int>;
	using charv = vector<char>;
	using boolv = vector<bool>;
	using floatv = vector<float>;
	using doublev = vector<double>;
	using stringv = vector<string>;

	constexpr ll MOD7 = 1000000007;
	constexpr ll MOD9 = 1000000009;

	void reverse(string& s){
		reverse(all(s));
	}

	template<typename T>
	void init(vector<T>& v, T initVal = T()){
		for(auto& e : v){
			e = initVal;
		}
	}

	template<typename T>
	void sort(vector<T>& v){
		sort(all(v));
	}
	template<typename T>
	void sortInv(vector<T>& v){
		sort(all(v), greater<T>());
	}

	template<typename T>
	void reverse(vector<T>& v){
		reverse(all(v));
	}

	template<typename T>
	T sum(const vector<T>& v){
		T ret = 0;
		for(const auto& e : v) ret += e;
		return ret;
	}

	template<typename T>
	inline vector<T>& operator+=(vector<T>& v, const T& e){
		v.push_back(e);
		return v;
	}

	template<typename T1, typename T2>
	inline vector<T1>& operator+=(vector<T1>& v1, const vector<T2>& v2){
		for(const auto& e : v2) v1.push_back(e);
		return v1;
	}

	template<typename T>
	void in(vector<T>& v){
		for(auto& e : v) cin >> e;
	}

	template<typename T1, typename T2>
	void in(vector<T1>& v1, vector<T2>& v2){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i];
	}
	template<typename T1, typename T2, typename T3>
	void in(vector<T1>& v1, vector<T2>& v2, vector<T3>& v3){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i] >> v3[i];
	}
	template<typename T1, typename T2, typename T3, typename T4>
	void in(vector<T1>& v1, vector<T2>& v2, vector<T3>& v3, vector<T4>& v4){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i] >> v3[i] >> v4[i];
	}

	template<typename T>
	istream& operator>>(istream &stream, vector<T>& v){
		for(auto& e : v) stream >> e;
		return stream;
	}

	template<typename T>
	void out(const vector<T>& v){
		for(const auto& e : v) cout << e << ' ';
		cout << endl;
	}

	template<typename T>
	void outln(const vector<T>& v){
		for(const auto& e : v) cout << e << endl;
	}

	template<typename T>
	inline set<T>& operator+=(set<T>& v, const T& e){
		v.insert(e);
		return v;
	}

	template<typename T1, typename T2>
	inline set<T1>& operator+=(set<T1>& v1, const set<T2>& v2){
		for(const auto& e : v2) v1.insert(e);
		return v1;
	}

	constexpr ll modPow(ll x, ll n, ll m){ // O(logn)
		if(n == 0) return 1;
		else if(n % 2 == 0) return modPow((x * x) % m, n / 2, m);
		else return x * modPow(x, n - 1, m) % m;
	}
}
using namespace atcoder;
#endif

int main(){
	cout << fixed << setprecision(15);
	
	
	ll N,A,B;cin>>N>>A>>B;

	cout << (N/(A+B)*A+min(A,N%(A+B)));
}

Measured memory_bytes: 256
import bisect
n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

cnt = 0
for b in B:
    index_a = bisect.bisect_left(A, b)
    index_c = bisect.bisect_right(C, b)
    cnt += index_a * (n - index_c)

print(cnt)


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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200) cout << s << '\n';
	else cout << "red" << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    int a[3*n];
    for (int i=0; i<3*n; i++){
        cin >> a[i];
    }
    priority_queue<int,vector<int>,greater<int>> q1;
    priority_queue<int> q2;
   
    ll sum1=0;
    ll sum2=0;
    vector<ll> pre;
    vector<ll> pos;
    for (int i=0; i<n; i++){
        q1.push(a[i]);
        sum1+=a[i];
        
        q2.push(a[3*n-i-1]);
        sum2+=a[3*n-i-1];
        
    }
    pre.push_back(sum1);
    pos.push_back(sum2);


    for (int k=n; k<2*n; k++){
        q1.push(a[k]);
        sum1+=a[k];
        sum1-=q1.top();
        q1.pop();
        pre.push_back(sum1);
    
        q2.push(a[3*n-k-1]);
        sum2+=a[3*n-k-1];
        sum2-=q2.top();
        q2.pop();
        pos.push_back(sum2);
    }
    ll ans=pre[0]-pos[n];
    for (int i=0; i<=n; i++){
        ans=max(pre[i]-pos[n-i],ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4720
from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)


Measured memory_bytes: 45268
#include <iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&a!=c)
        cout<<c;
    else if(a==c&&a!=b)
        cout<<b;
    else if(b==c&&b!=a)
        cout<<a;
    else
    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 sx = sc.nextInt(), sy  =sc.nextInt();
		int tx =sc.nextInt(), ty = sc.nextInt();
		
		for(int i=0;i<tx-sx;i++)
			System.out.print('R');
		for(int i=0;i<ty-sy;i++)
			System.out.print('U');
		for(int i=0;i<tx-sx;i++)
			System.out.print('L');
		for(int i=0;i<ty-sy;i++)
			System.out.print('D');
		
		System.out.print('D');
		for(int i=0;i<tx-sx+1;i++)
			System.out.print('R');
		for(int i=0;i<ty-sy+1;i++)
			System.out.print('U');
		System.out.print('L');
		System.out.print('U');
		
		for(int i=0;i<tx-sx+1;i++)
			System.out.print('L');
		for(int i=0;i<ty-sy+1;i++)
			System.out.print('D');
		System.out.print('R');
		
		
	}

}

Measured memory_bytes: 25476
#include <iostream>
using namespace std;
int main(){
	int H,W;
	while(1){
		cin>>H>>W;

		if(H==0&&W==0){
			break;
		}
		for(int i=0;i<H;i++){
			for(int ii=0;ii<W;ii++){
				cout<<"#";
			}
			cout<<endl;
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 1152
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<double,int> P;

static const double eps = 10e-6;

int dp[101][101];

int main(){
	int n;

	memset(dp,0x2,sizeof(dp));
	scanf("%d",&n);	
	for(int i=0;i<n;i++){
		int r,k,t;
		scanf("%d %d",&r,&k);
		for(int j=0;j<k;j++){
			scanf("%d",&t);
			dp[r][t] = 1;
		}
	}

	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				dp[j][k] = min(dp[j][i]+dp[i][k],dp[j][k]);
			}
		}
	}


	int p;
	scanf("%d",&p);
	for(int i=0;i<p;i++){
		int s,d,v;
		scanf("%d %d %d",&s,&d,&v);

		char buf[128];
		sprintf(buf,"%d",dp[s][d]+1);
		printf("%s\n", dp[s][d] >= v ? "NA" : buf);

	}
}

Measured memory_bytes: 0
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
int gogo[30] = {};
bool checking[30] = {};
int main() {
	iostream::sync_with_stdio(false);
	int n;
	scanf("%d", &n);
	vector<int> input;
	for (int i = 0; i < (1 << n); ++i) {
		int hoge;
		scanf("%d", &hoge);
		input.push_back(hoge);
	}
	int pre_ans = 0;
	for (int i = 1; i < (1 << n); ++i) {
		int now_itr = 0;
		int now_hoge = i;
		int geko = 1;
		while (now_hoge != 0) {
			if (now_hoge % 2 == 1) {
				gogo[now_itr] = geko;
				checking[now_itr] = 0;
				now_itr++;
			}
			geko *= 2;
			now_hoge /= 2;
		}
		int a = input[0], b = -1;
		int boa = (1 << now_itr);
		int gekoa = 0;
		for (int q = 1; q < boa; ++q) {
			for (int j = now_itr - 1; j >= 0; --j) {
				if (checking[j] == 0) {
					gekoa += gogo[j];
					checking[j] = 1;
					break;
				}
				else {
					checking[j] = 0;
					gekoa -= gogo[j];
				}
			}
			if (a < input[gekoa]) {
				b = a;
				a = input[gekoa];
			}
			else if (b < input[gekoa]) {
				b = input[gekoa];
			}
		}
		pre_ans = max(a + b, pre_ans);
		printf("%d\n", pre_ans);
	}
	return 0;
}

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

#define ll long long

inline ll read() {
    ll x = 0, f = 1; char ch = getchar();
    for(; ch < '0' || ch>'9'; ch = getchar())
        if(ch == '-') f = -f;
    for(; ch >= '0' && ch <= '9'; ch = getchar())
        x = x * 10 + ch - '0';
    return x * f;
}

inline void chkmin( int &a, int b ) { if(a > b) a = b; }

inline void chkmax( int &a, int b ) { if(a < b) a = b; }

#define _ read()

#define ln endl

int n, m, k, a[305][305], sum[305][305], vis[305][305], cnt, l[305 * 305], r[305 * 305], x[305 * 305];
char s[305][305];

int main()
{
	n = _; m = _; k = _;
	for( int i = 1; i <= n; i++ ) 
		scanf("%s", s[i] + 1);
	for( int i = 1; i <= n; i++ ) 
		for( int j = 1; j <= m; j++ ) 
			sum[i][j] = (s[i][j] == '#');
	for( int i = 1; i <= n; i++ ) 
		for( int j = 1; j <= m; j++ ) 
			sum[i][j] = sum[i - 1][j] + sum[i][j];
	for( int i = 1; i <= n; i++ ) 
		for( int j = 1; j <= m; j++ )
			if(s[i][j] == '#')
			{
				++cnt;
				vis[i][j] = cnt;
				x[cnt] = j;
				l[cnt] = i; 
				r[cnt] = i;
				for( int k = i - 1; k >= 1; k-- ) 
					if(!vis[k][j] && s[k][j] != '#')
						l[cnt] = k, vis[k][j] = cnt;
					else
						break;
				for( int k = i + 1; k <= n; k++ ) 
					if(!vis[k][j] && s[k][j] != '#')
						r[cnt] = k, vis[k][j] = cnt;
					else
						break;
			}
	// for( int i = 1; i <= n; i++, putchar('\n'))
	// 	for( int j = 1; j <= m; j++ )
	// 		cout << vis[i][j] << " ";
	for( int k = 1; k <= cnt; k++ ) 
	{
		// cout << l[k] << " " << r[k] << ln;
		// int j = x[k];
		for( int j = x[k] - 1; j >= 1; j -- ) 
		{
			int flag = 0;
			for( int i = l[k]; i <= r[k]; i++ ) 
				if(vis[i][j]) flag = 1;
			if(flag) break;
			for( int i = l[k]; i <= r[k]; i++ ) 
				vis[i][j] = k;		
		}
		for( int j = x[k] + 1; j <= m; j ++ ) 
		{
			int flag = 0;
			for( int i = l[k]; i <= r[k]; i++ ) 
				if(vis[i][j]) flag = 1;
			if(flag) break;
			for( int i = l[k]; i <= r[k]; i++ ) 
				vis[i][j] = k;		
		}
	// for( int i = 1; i <= n; i++, putchar('\n'))
	// 	for( int j = 1; j <= m; j++ )
	// 		cout << vis[i][j] << " ";
	// 	puts("===qwq===");
	}
	for( int i = 1; i <= n; i++, putchar('\n'))
		for( int j = 1; j <= m; j++ )
			cout << vis[i][j] << " ";
}


Measured memory_bytes: 2688
// AOJ 0641 Pencils
// 2018.3.28 bal4u

#include <stdio.h>

int main()
{
	int n, a, b, c, d, ma, mb;

	scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	ma = ((n-1)/a+1)*b;
	mb = ((n-1)/c+1)*d;
	if (ma > mb) ma = mb;
	printf("%d\n", ma);
	return 0;
}


Measured memory_bytes: 2048
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= 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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int N;
    cin >> N;

    vi a(N);
    vi cnt(N+1, 0);
    REP(i, N){ 
        cin >> a[i];
        cnt[a[i]]++;
    }

    ll sum = 0;
    for (int n : cnt) {
        sum += (n*(n-1))/2;
    }

    REP(i, N) {
        cout << sum - (cnt[a[i]]-1) << endl;
    }

    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int c[3][3];
  rep(i, 3) rep(j, 3) cin >> c[i][j];
  int a[3], b[3];
  a[0] = 0, b[0] = c[0][0], b[1] = c[0][1], b[2] = c[0][2];
  a[1] = c[1][0] - b[0], a[2] = c[2][0] - b[0];
  bool flag = true;
  rep(i, 3) rep(j, 3) {
    if (c[i][j] != a[i] + b[j]) flag = false;
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import Control.Applicative

main :: IO ()
main = do
  [dice1, dice2] <- map (roll . take 3 . map read . words) . lines <$> getContents :: IO [[Int]]
  putStrLn $ if dice1 == dice2 then "Yes" else "No" 

roll :: [Int] -> [Int]
roll xs@(a:b:c:_) = 
  let
    cnt = length $ filter (>= 4) xs
    dice = map (\x -> min x (7 - x)) $ if even cnt then xs else [a, c, b]
    (as, bs) = break (== 1) dice
  in
    bs ++ as

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

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



string s;

int main () {
  cin >> s;

  int n = s.size();

  string t = "";
  Rep(i, n/2) t = t + "p";
  Rep(i, (n-n/2)) t = "g" + t;

  int ans = 0;

  Rep(i, n) {
    if (t[i] == 'p' && s[i] == 'g') {
      ans++;
    } else if (t[i] == 'g' && s[i] == 'p') {
      ans--;
    }
  }

  cout << ans << "\n";
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;

@SuppressWarnings("unchecked")
public class Main {
    private static final long MOD = (int)1e9 + 7;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];

        int[] cnt = new int[n + 1];
        int[] cnt2 = new int[n + 1];

        int[] start = new int[n + 1];
        Arrays.fill(start, -1);

        for (int i = 0; i < n; ++i) {
            a[i] = in.nextInt();
            ++cnt2[a[i]];
        }
        for (int i = 0; i < n; ++i) {
            b[i] = in.nextInt();
            if (a[i] == b[i]) {
                ++cnt[a[i]];
                if (start[a[i]] == -1) start[a[i]] = i;
            }
            ++cnt2[b[i]];
        }
        // for (int i = 0; i <= n; ++i) {
        //     if (cnt2[i] > n) {
        //         System.out.println("No");
        //         return;
        //     }
        // }
        PriorityQueue<Pair> pq = new PriorityQueue<>();
        for (int i = 1; i <= n; ++i) {
            if (cnt[i] != 0) pq.add(new Pair(i, cnt[i]));
        }
        while (pq.size() > 1) {
            Pair p1 = pq.poll();
            Pair p2 = pq.poll();

            int i1 = start[p1.val];
            int i2 = start[p2.val];

            b[i1] = p2.val;
            b[i2] = p1.val;

            p1.cnt--;
            p2.cnt--;

            start[p1.val]++;
            start[p2.val]++;

            if (p1.cnt != 0) pq.add(p1);
            if (p2.cnt != 0) pq.add(p2);
        }
        if (!pq.isEmpty()) {
            Pair p = pq.poll();
            int x = p.val;
            int i = 0;
            while (i < n && p.cnt != 0) {
                if (b[i] != x && x != a[i]) {
                    int temp = b[i];
                    b[i] = x;
                    b[start[x]] = temp;
                    start[x]++;
                    p.cnt--;
                }
                ++i;
            }
        }
        for (int i = 0; i < n; ++i) {
            if (a[i] == b[i]) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
        for (int i = 0; i < n; ++i) {
            System.out.print(b[i] + " ");
        }
    }

    static class Pair implements Comparable<Pair> {
        int val, cnt;

        Pair(int val, int cnt) {
            this.val = val;
            this.cnt = cnt;
        }

        public int compareTo(Pair p) {
            return p.cnt - this.cnt;
        }
    }
}

Measured memory_bytes: 61260
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 1e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXM][MAXM];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>m>>a>>b;

    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            if(i<=b&&j<=a){
                A[i][j] = 1;
            }
            else if(i>b&&j>a)A[i][j] = 1;
    }

    for(int i=1;i<=n;i++,cout<<"\n")
        for(int j=1;j<=m;j++)
            cout<<A[i][j];

    return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> ordered_mset;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
/*.....................................................................................................................*/

    const ll mod=(ll)1e9+7;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;}
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const ll man=(ll)1e5+5;
/*........................................................................................................................*/

signed main()
{
    fast;
    string s;
    ll n;
    cin>>n;
    cin>>s;
    string a="ABC";
    ll ans=0;
    For(i,s.length()-2)
    {
        if(s.substr(i,3)==a)ans++;
    }
    cout<<ans<<endl;
}   


Measured memory_bytes: 3600
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	
	void solve()
	{
		int A = ni(), B = ni();
		if(A <= 5) {
			out.println(0);
		}
		else if(A >= 13) {
			out.println(B);
		}
		else out.println(B/2);
	}
	
		
	void run() throws Exception
	{
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
	}
	
	public static void main(String[] args) throws Exception { new Main().run(); }
	
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;
	
	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}
	
	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
	
	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }
	
	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}
	
	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}
	
	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}
	
	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;	ci(n);
  vll A(n);
  FOR(i,0,n){
	ci(A[i])
  }
  SORT(A);
  ll l=A[0];
  ll r=A[n-1];
  FOR(i,1,n-1){
    if(A[i]<0){
      r-=A[i];
    }
    else{
      l-=A[i];
    }
  }
  ll ans=(r-l);
  co(ans)
    
   ll a=A[0];
   ll b=A[n-1]; 
   FOR(i,1,n-1){
    if(A[i]<0){
      co(b<<" "<<A[i])
      b-=A[i];
    }
    else{
      co(a<<" "<<A[i])
      a-=A[i];
    }
  }
  co(b<<" "<<a)
}
  

Measured memory_bytes: 2688
h,w = map(int, input().split())
for _ in range(h):
    s = input()
    ans = []
    for i in range(len(s)):
        if s[i] == 'c':
            ans.append(0)
        elif i == 0:
            ans.append(-1)
        else:
            for j in range(1,i+1):
                if s[i-j] == 'c':
                    ans.append(j)
                    break
                if j == i:
                    ans.append(-1)
    print(' '.join(map(str, ans)))



Measured memory_bytes: 5612
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;

typedef pair<int, int> P;
typedef long long ll;

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

	int max_dist = 0;

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

		if (i != 0)
		{
			int dist = a[i] - a[i - 1];
			if (dist > max_dist)
			{
				max_dist = dist;
			}
		}
	}
	int dist = a[0] + (k - a[n - 1]);
	if (dist > max_dist)
	{
		max_dist = dist;
	}

	cout << k - max_dist << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<vector>
#define ll long long
#define ld long double
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rep2(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define vl vector< long >
#define vll vector< long long >
#define pll pair< long long, long long>
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

ll f(ll n, vll& dp, vll& h){
    if(dp[n]!=-1){
        return dp[n];
    }
    else{
        if(n==0) return dp[n] = 0;
        if(n==1) return dp[n] = abs(h[1]-h[0]);
        return dp[n] = min(abs(h[n]-h[n-2])+f(n-2,dp,h),abs(h[n]-h[n-1])+f(n-1,dp,h));
    }
}

using namespace std;
void solve(){
    ll n,k;
    vll h;
    cin>>n;
    rep(i,0,n){
        cin>>k;
        //cout<<k;
        h.pb(k);
    }
    vll dp(n,-1);
    ll ans = f(n-1,dp,h);
    cout<<ans<<endl;
}
int main()
{
    //Write code here
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 9716
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[55];
int n, k;
ll solve(int l,int r){
	vector<ll> v;
	for (int i=1;i<=l;i++)
		v.push_back(a[i]);
	for (int i=n-r+1;i<=n;i++)
		v.push_back(a[i]);
	int t=k-l-r;
	sort (v.begin(),v.end());
	ll ans=0; 
	for (int i=0;i<v.size();i++){
		if (v[i]<0&&t>0)
			t--;
		else
			ans+=v[i];	
	}
	return ans;
}
int main()
{
	cin >> n >> k;
	for (int i=1;i<=n;i++)
		cin >> a[i];
	ll ans=-1;
	for (int i=0;i<=k;i++)
		for (int j=0;j<=k;j++){
			if (i+j<=k&&i+j<=n){
				ans=max(ans,solve(i,j));
			}
				
		} 
	cout << ans;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define all(x) (x).begin(),(x).end()

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main()
{
    string s;
    cin >> s;
    ll ans = 0;
    vector<ll> cntl(s.size() + 1,0),cntr(s.size() + 1,0);
    rep1(i, s.size()){
        if(s[i - 1] == '<')cntl[i] = cntl[i - 1] + 1;
    }
    
    rrep0(i, s.size()){
        if(s[i] == '>')cntr[i] = cntr[i + 1] + 1;
    }
    
    rep0(i, s.size() + 1)ans += max(cntl[i], cntr[i]);
    pf(ans)
    return 0;
}


Measured memory_bytes: 8708
import java.awt.*;
import java.util.*;

import static java.lang.System.*;

// https://atcoder.jp/contests/abc088/submissions/4733059
public class Main {
    private static final int INF = 1000;
    private static final int[] dx = {0, 1, 0, -1};
    private static final int[] dy = {1, 0, -1, 0};

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();

        boolean[][] field = new boolean[H][W];
        int black = 0;
        for (int i = 0; i < H; i++) {
            String s = sc.next();
            for (int j = 0; j < W; j++) {
                field[i][j] = s.charAt(j) == '.';
                if (!field[i][j]) black++;
            }
        }

        // 幅優先探索(wfs)
        ArrayDeque<Point> queue = new ArrayDeque<>();
        queue.add(new Point(0, 0));

        int[][] dist = new int[H][W];
        for (int i = 0; i < H; i++) {
            Arrays.fill(dist[i], INF);
        }
        dist[0][0] = 0;

        while (!queue.isEmpty()) {
            Point p = queue.poll();
            int x = p.x;
            int y = p.y;

            if (x == H - 1 && y == W - 1) {
                break;
            }

            for (int i = 0; i < 4; i++) {
                int nx = x + dx[i];
                int ny = y + dy[i];

                if (0 <= nx && nx < H && 0 <= ny && ny < W && field[nx][ny] && dist[nx][ny] == INF) {
                    dist[nx][ny] = dist[x][y] + 1;
                    queue.add(new Point(nx, ny));
                }
            }

        }

        if (dist[H - 1][W - 1] == INF) {
            out.println(-1);
        } else {
            out.println(W * H - black - dist[H - 1][W - 1] - 1);
        }
    }
}

Measured memory_bytes: 24916
#include <cstdio>
using namespace std;

int main()
{
	int M,N;
	while(scanf("%d%d", &M,&N), (M||N))
	{
		int wid[100]={0}, swid=0;
		for(int i=0; i<N; i++)
		{
			scanf("%d", &wid[i]);
			swid+=wid[i];
		}
		
		int hi=swid, lo=0,mi;
		
		while(hi>lo)
		{
			mi=(hi+lo)/2;
			int cap=0, d=1;
			bool g=true;
			for(int i=0; i<N; i++)
			{
				if(mi < wid[i])
				{
					g=false;
					break;
				}
				if(cap+wid[i] > mi)
				{
					cap=wid[i];
					d++;
				}
				else
				{
					cap+=wid[i];
				}
			}
			
			if(!g||d>M) lo=mi+1;
			else hi=mi;
		}
		
		printf("%d\n", hi);
	}
}

Measured memory_bytes: 0
n = [int(n) for n in list(input())]

for op1 in ['+', '-']:
    if op1 == '+':
        s1 = n[0] + n[1]
    else:
        s1 = n[0] - n[1]

    for op2 in ['+', '-']:
        if op2 == '+':
            s2 = s1 + n[2]
        else:
            s2 = s1 - n[2]

        for op3 in ['+', '-']:
            if op3 == '+':
                s3 = s2 + n[3]
            else:
                s3 = s2 - n[3]
            
            if s3 == 7:
                print('{}{}{}{}{}{}{}=7'.format(n[0], op1, n[1], op2, n[2], op3, n[3]))
                break
            else:
                continue
        else:
            continue
        break
    else:
        continue
    break

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 文字列の入力
		String[] s = sc.next().split("");
        int ans = 0;
        for(String n : s) {
          if ("1".equals(n)) {
            ans++;
          }
        }
    
		// 出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    string w;
    cin>>w;
    
    int n=w.size();
    vector<int> l(26);
    rep(i,n) l.at(w.at(i)-'a')++;
    
    string ans="Yes";
    rep(i,26) if(l.at(i)%2==1) ans="No";
    cout<<ans<<endl;
}


Measured memory_bytes: 256
def prepare(k, n, MOD):
    def get_factorials(m):
        f = 1
        factorials = [1]
        for m in range(1, m + 1):
            f *= m
            f %= MOD
            factorials.append(f)
        inv = pow(f, MOD - 2, MOD)
        invs = [1] * (m + 1)
        invs[m] = inv
        for m in range(m, 1, -1):
            inv *= m
            inv %= MOD
            invs[m - 1] = inv

        return factorials, invs

    def solve(p):
        """Number of patterns where no pair of p appears when n dices are rolled"""
        if cache[p] > -1:
            return cache[p]

        ret = 0
        fp = factorials[p]
        for q in range(1, min(p, n // 2) + 1):
            tmp1 = (fp * invs[q] % MOD) * invs[p - q] % MOD
            tmp2 = (factorials[k + n - 2 * q - 1] * invs[n - 2 * q] % MOD) * ik % MOD
            if q % 2 == 1:
                ret += tmp1 * tmp2
            else:
                ret -= tmp1 * tmp2
            ret %= MOD

        cache[p] = ret = (all_patterns - ret) % MOD
        return ret

    factorials, invs = get_factorials(k + n)
    ik = invs[k - 1]
    all_patterns = factorials[k + n - 1] * invs[n] * ik % MOD
    cache = [-1] * (k // 2 + 2)

    return solve


MOD = 998244353
k, n = map(int, input().split())
if k == 1:
    print(0)
else:
    solve = prepare(k, n, MOD)
    ans = [solve(i // 2 - max(0, i - k - 1)) for i in range(2, k + 2)]
    print('\n'.join(map(str, ans)))
    print('\n'.join(map(str, ans[-2::-1])))


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

int main(){
    int n;
    cin>>n;
    vector<int>v[n];
    for(int i=0;i<n;i++){
	int a,b,c;
	cin>>a>>b>>c;
	v[i].push_back(a);
	v[i].push_back(b);
	v[i].push_back(c);
    }
    vector<int>d[n];
    for(int i=1;i<n;i++){
	d[i].push_back(0);
	d[i].push_back(0);
	d[i].push_back(0);
    }
    d[0].push_back(v[0][0]);
    d[0].push_back(v[0][1]);
    d[0].push_back(v[0][2]);

    for(int i=1;i<n;i++){
	for(int j=0;j<3;j++){
	    d[i][j] = max(v[i][j] + d[i-1][(j+1)%3],v[i][j]+d[i-1][(j+2)%3]);
	}
    }
    int r=0;
    for(int i=0;i<3;i++){
	if(d[n-1][i]>r)
	    r=d[n-1][i];
    }
    cout<<r<<endl;
}


    
	



Measured memory_bytes: 11136
#include<iostream>
using namespace std;
int main(void)
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b && b==c)
        cout << "No";
    else if(a!=b && b!=c && a!=c)
        cout << "No";
    else
        cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF_LL 1e18
#define INF 1e9

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

#define fst first
#define snd second

using namespace std;

using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
using PLLL = pair<ll, PLL >;

ll MOD = 1e9+7;
ll N, Nh, D, total = 0;
PLL tre[31];
vector<PLL> s;
vector<PLL> s1;
ll sz = 1;
vector<PLL> dat;

void set_val(int i, PLL x){
	i += sz-1;
	dat[i] = x;
	while(i > 0){
		i = (i-1)/2;
		if(dat[i*2+1].second < dat[i*2+2].second){
			dat[i] = dat[i*2+2];
		}else{
			dat[i] = dat[i*2+1];
		}
	}
}

ll query(int a, int b, int l, int r, int k){
	if(b <= l || r <= a) return -INF_LL;
	if(a <= l && r <= b){
		return dat[k].second;
	}else{
		ll res = max(query(a, b, l, (l+r)/2, k*2+1), query(a, b, (l+r)/2, r, k*2+2));
		return res;
	}
}

bool comp(PLL lhs, PLL rhs){
	return lhs.first < rhs.first;
}

void dfs1(int n, int lim, ll sum_ap, ll sum_ar, ll sum_bp, ll sum_br){
	if(n == lim){
		s.push_back({sum_bp-sum_ap, {sum_br-sum_ar}});
		return;
	}
	dfs1(n+1, lim, sum_ap, sum_ar, sum_bp, sum_br);
	dfs1(n+1, lim, sum_ap+tre[n].first, sum_ar+tre[n].second, sum_bp, sum_br);
	dfs1(n+1, lim, sum_ap, sum_ar, sum_bp+tre[n].first, sum_br+tre[n].second);
}


int main(void){
	cin >> N >> D;
	Nh = N/2;
	REP(i, N){
		cin >> tre[i].first >> tre[i].second;
	}
	dfs1(0, Nh, 0, 0, 0, 0);
	sort(all(s));
	REP(i, s.size()){
		int in = i;
		ll max_v = -INF_LL;
		while(s[in].first == s[i].first && in < s.size()){
			max_v = max(max_v, s[in].second);
			in++;
		}
		s1.push_back({s[i].first, max_v});
		i = in-1;
	}
	s1.push_back({INF_LL, 0});
	s = vector<PLL>();
	dfs1(Nh, N, 0, 0, 0, 0);
	sort(all(s));
	reverse(all(s));
	while(sz < s1.size()) sz *= 2;
	REP(i, sz*2-1){
		dat.push_back({INF_LL, 0});
	}

	REP(i, s1.size()){
		set_val(i, s1[i]);
	}

	ll res = -INF_LL;
	ll l = 0, r = 0;
	REP(i, s.size()){
		ll rare = s[i].second;
		ll price = s[i].first;
		l = lower_bound(all(s1), make_pair(-D-price, (ll)-INF_LL)) - s1.begin();
		r = upper_bound(all(s1), make_pair(D-price, (ll)INF_LL)) -s1.begin();

		res = max(res, query(l, r, 0, sz, 0) + rare);
	}
	cout << res << endl;
}

Measured memory_bytes: 975612
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#include <time.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
 
using namespace std;


int main(int argc, char* argv[])
{
    ll H;
    scanf("%lld", &H);

    ll cnt=0;
    ll sum=0;
    ll curr=1;
    while(H) {
        sum+=curr;
        H/=2;
        cnt++;
        curr*=2;
    }
    printf("%lld\n", sum);

    return 0;
}


Measured memory_bytes: 128
a = []
b = []

x,y = map(int,input().split())
a.append(x)
b.append(y)
x,y = map(int,input().split())
a.append(x)
b.append(y)
x,y = map(int,input().split())
a.append(x)
b.append(y)

for i in range(1,5):
    if a.count(i)+b.count(i)>= 2:
        continue
    if a.count(i)==1:
        k = b[a.index(i)]
        if a.count(k)+b.count(k)==2:
            print('YES')
            exit()
    if b.count(i)==1:
        k = a[b.index(i)]
        if a.count(k)+b.count(k)==2:
            print('YES')
            exit()
print('NO')

Measured memory_bytes: 3064
def a(n):
  return n//2
def b(n):
  return 3*n+1

s = int(input())
num = [s]

n = 0
while(True):
  if num[-1] % 2 == 0:
    ans = a(num[-1])
  else:
    ans = b(num[-1])
   
    
    
  if ans in num:
    break
  else:
    num.append(ans)
  n+=1
    
print(n+2)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int h,w;
char str[55][55];
int main()
{
	cin>>h>>w;
	for(int i=1;i<=h;i++)
	{
		scanf("%s",str[i]);
	}
	for(int i=1;i<=h;i++)
	  for(int j=1;j<=w;j++)
	  {
	  	 if(str[i][j]=='#'&&str[i][j]!=str[i][j-1]&&str[i][j]!=str[i][j+1]
		    &&str[i][j]!=str[i-1][j]&&str[i][j]!=str[i+1][j])
		    {
		    	cout<<"No"<<endl;
		    	return 0;
		    }
	  }
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


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


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };
int dx2[2] = { 1,0 };
int dy2[2] = { 0,1 };

/******************************************************************************************/

char mp[15][1005];

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);


	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
	return 0;
}



Measured memory_bytes: 384
#include"iostream"
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
#include<list>
#include<map>
#include<algorithm>
#include<string>
#include <queue> 
#include <sstream>
#include <fstream>
#include<cmath>
#define LL long long
using namespace std;
#define INF 1000000000

vector<string> v;



LL N,M,x[100000],xx[100000],B,W,ans;
string s;
int main() {
  
	cin>>N>>s;
	B=0;
	W=0;
	ans=INF;
	for(int i=0;i<s.size();i++){
		if(s[i]=='.')W++;
	}
	for(int i=0;i<s.size();i++){
		if(s[i]=='.')W--;
		ans=min(ans,B+W);
		if(s[i]=='#')B++;
	}
	
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

bool chk(int n)
{
    return (n >= 1 && n <= 9);
}

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

    if (chk(a) && chk(b)) ans = a * b;
    else ans = -1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
l, r = map(int, input().split())
ans = 2019
for i in range(l, r):
    for j in range(i+1, r+1):
        tmp = i*j % 2019
        if ans > tmp:
            ans = tmp
        if ans == 0:
            print(ans)
            exit(0)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
using namespace std; 
  
int main() {
int t;
	int count=0,count1=0,count2=0,count3=0;
cin>>t;
while(t--){
	string s;

	cin>>s;
	if(s=="AC"){
		count++;
	}
	if(s=="TLE"){
		count1++;
	}
	if(s=="WA"){
		count2++;
	}
	if(s=="RE"){
		count3++;
	}
	
}
cout<<"AC x"<<" "<<count<<endl;
cout<<"WA x"<<" "<<count2<<endl;
cout<<"TLE x"<<" "<<count1<<endl;
cout<<"RE x"<<" "<<count3<<endl;
return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    string s;
    cin >> s;

    ll ans = 0;
    int j = 0;
    rep(i, s.size()) {
        if(s[i] == 'W') {
            ans += i-j;
            j++;
        }
    }
    cout << ans << endl;
}

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

template<typename T, typename U> void cmax(T &a, U b) { if (a < b) a = b; }
template<typename T, typename U> void cmin(T &a, U b) { if (a > b) a = b; }

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  string S;
  cin >> S;
  long K;
  cin >> K;
  long N = S.size();
  for (long i = 0; i < N; i++) {
    if (S.at(i) == 'a') continue;
    long now = S.at(i) - 'a';
    if (26 - now <= K) S.at(i) = 'a', K -= 26 - now;
  }
  long last = S.at(N - 1) - 'a';
  last = (last + K) % 26;
  S.at(N - 1) = 'a' + last;
  cout << S << "\n";
}

Measured memory_bytes: 3776
import Control.Monad

concat_bonus::Int->Int->Int->Int
concat_bonus left_b right_a b_a = if b_a == 0 then min left_b  right_a
                                              else (b_a - 1) + case (left_b >= 1, right_a >= 1) of
                                                                (True,True) -> 1 + (min left_b right_a)
                                                                (True,False)-> 1
                                                                (False,True)-> 1
                                                                (False,False)->0
indep_appear::String->Int
indep_appear str = length (((filter (\ (c,d)-> c=='A' && d == 'B'))) (zip str (tail str)))

counter::(Int,Int,Int)->[String]->(Int,Int,Int)
counter (lb,ra,ba) []         = (lb,ra,ba)
counter (lb,ra,ba) (str:strs) = case (head str,last str) of
                                ('B','A') -> counter (lb,ra,ba+1) strs
                                ('B',_  ) -> counter (lb+1,ra,ba) strs
                                (_  ,'A') -> counter (lb,ra+1,ba) strs
                                otherwise -> counter (lb,ra,ba) strs

solver::[String]->Int
solver strs = let n = sum (map indep_appear strs) in
              let (lb,ra,ba) = counter (0,0,0) strs in
              n + (concat_bonus lb ra ba)

main::IO()
main=do
  n<-return.read=<<getLine
  strs<-forM [1..n] (\_-> getLine)
  print (solver strs)


Measured memory_bytes: 5500
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for(int i=0; i<n; i++) {
			a[i]=sc.nextInt();
		}
		ArrayList<Integer> arr = new ArrayList<>();
		for(int i=0; i<n; i++) {
			int j = lowerBound(arr, a[i]);
			if(j==0) {
				arr.add(j, a[i]);
			}else {
				arr.set(j-1, a[i]);
			}
		}
		System.out.println(arr.size());
		sc.close();
	}

	public int lowerBound(ArrayList<Integer> a, int v) {
		int l=-1;
		int r=a.size();
		while(l+1<r) {
			int m = (l+r)/2;
			if(a.get(m) < v) {
				l=m;
			}else {
				r=m;
			}
		}
		return l+1;
	}
}


Measured memory_bytes: 59340
#include<bits/stdc++.h>
using namespace std;
int main(){
    int s;
    cin>>s;
  if(s<3)
  {
   cout<<"0\n";
    return 0;
  }
    long long int mod=1e9+7;
    vector<long long int> dp(s+1,1);
    dp[0]=0;
    dp[1]=0;
    dp[2]=0;
    for(int i=3;i<=s;i++){
    	for(int j=3;j<=i;j++){
    		dp[i]=(dp[i]%mod+dp[i-j]%mod)%mod;
		}
	//	cout<<dp[i]<<"\n";
	}
	cout<<dp[s]<<"\n";
	return 0;
}
	

Measured memory_bytes: 3620
#include <bits/stdc++.h>
	using namespace std;
	
	typedef long long ll;
	#define pi 3.14159265 
	#define EPS 1e-8
	
	#define mod 5000000
	#define fi first
	#define se second
	#define mp make_pair
	#define pb push_back
	#define endl "\n"

	const ll INF=(ll)3e17;
	
	
	
	int main()
	{
		 ios_base::sync_with_stdio(false);
		 cin.tie(NULL);
		 
		ll n,m;
		cin>>n>>m;
		ll s=0;
		for(ll i=0;i<m;i++)
		{
			ll v;
			cin>>v;
			s+=v;
		}
		if(s>n)
			cout<<-1;
		else
			cout<<n-s;
	}


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

using namespace std;

int dp[100005];

vector<int> a;

int solve(int k)
{
    if (k < 0)
        return 0;
    if (~dp[k])
        return dp[k];
    dp[k] = 1;
    for (auto &x : a)
        dp[k] &= !solve(k-x);
    return dp[k];
}

int main()
{
    memset(dp, -1, sizeof dp);
    int n, k;
    scanf("%i%i", &n, &k);
    a.resize(n);
    for (auto &x : a)
        scanf("%i", &x);
    printf("%s\n", solve(k) ? "Second" : "First");
}


Measured memory_bytes: 5376