akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } 
template <typename A>
string to_string(A v) {
    bool first = true; 
    string res = "{";
    for (const auto &x : v) {
        if (!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}"; 
    return res;
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    dbg_out(T...);
}
#ifdef LOCAL
    #define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", dbg_out(__VA_ARGS__)
#else
    #define dbg(...) 42
#endif

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define MP make_pair
#define sz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)
#define nl "\n"
typedef pair<int, int> pii;
typedef vector <int> vi;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

const int inf = (1LL << 60), mod = 1e9+7, nn = 2e5+5;

void solve(){
    int a, b;
    string s, t, u;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    map <string, int> mp;
    mp[s] = a;
    mp[t] = b;
    mp[u]--;
    cout << mp[s] << ' ' << mp[t] << nl;
}

int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
n,a,b = map(int,input().split())
s = input()
ans = 0
pass_b = 0
for i in range(n):
  if s[i] == 'a' and ans < (a+b):
    ans += 1
    print('Yes')
  elif s[i] == 'b':
    pass_b += 1
    if ans < (a+b) and pass_b <= b:
      ans += 1
      print('Yes')
    else:
      print('No')
  else:
    print('No')


Measured memory_bytes: 4016
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;

long long a[3], m[3], k[3];
long long gcd(int a, int b) {
    if (b == 0) { return a; }
    return gcd(b, a%b);
}
int main() {
    while (true) {
        cin >> a[0] >> m[0] >> a[1] >> m[1] >> a[2] >> m[2];
        if (a[0] == 0 && m[0] == 0 && a[1] == 0 && m[1] == 0 && a[2] == 0 && m[2] == 0) { break; }
        for (int i = 0; i < 3; i++) {
            long long cnt = 0, x = 1;
            while (true) {
                if (x == 1 && cnt >= 1) { break; }
                x *= a[i]; x %= m[i]; cnt++;
            }
            k[i] = cnt;
        }
        int LCM = k[0] * k[1] / gcd(k[0], k[1]);
        cout << LCM*k[2] / gcd(LCM, k[2]) << endl;
    }
    return 0;
}


Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
int main(){
	int x[3]={};
	int a,b,c;
	scanf("%d%d%d",&x[0],&x[1],&x[2]);
	std::sort(x,x+3);
	a=x[0];
	b=x[1];
	c=x[2];
	int ans=c-b;
	a=a+c-b;
	b=c;
	int p=b-a;
	if(p%2==0)ans+=p/2;
	else ans+=p/2+2;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long int 
int lucas[100];
void cal()
{
    lucas[0]=2;
    lucas[1]=1;
    for(int i=2;i<=100;i++)
    lucas[i]=lucas[i-1]+lucas[i-2];
}
int32_t main()
{
    cal();
    int n;
    cin>>n;
    cout<<lucas[n]<<endl;
}

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

int main(){
    int n;
    cin >> n;
    int c=n/4;
    int d=n/7;
    bool flag=false;
    for(int i=0;i<=c;i++){
        int sum=0;
        for(int j=0;j<=d;j++){
            sum=i*4+j*7;
            if(sum==n) {
                flag=true;
                break;
            }
        }
    }
    if(flag) cout << "Yes" <<endl;
    else cout << "No" <<endl;

    return 0;
}


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

//#define int long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

int main()
{
    int n;
    cin>>n;
    vector<int> h(n-1);
     vector<int> a(n);
	for (int i = 0; i < n-1; ++i){
		cin >> h[i];
    }
    a[0]=h[0];
    a[n-1]=h[n-2];
    for (int i=1; i<n-1; i++){
        a[i]=min(h[i-1],h[i]);
    }
    int sum=0;
    for (int i=0; i<n; i++){
        sum+=a[i];
    }
    cout<<sum<<endl;

    
}

Measured memory_bytes: 256
n=int(input())
s=input()
s=list(s)

x=[]

for i in range(n):
    a=s[:i]
    b=s[i:]
    cnt=0
    c=set(a)
    d=set(b)
    c=list(c)
    d=list(d)
    for j in range(len(c)):
        for k in range(len(d)):
            if c[j]==d[k]:
                cnt+=1
                break
    x.append(cnt)

print(max(x))

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

int main () {
int N;
cin >> N;
vector<int> A(N-1);
int i,a;
for (i = 0;i < N-1;i++){
cin >> a;
A[a-1]+=1;
}
for (i = 0;i < N-1;i++){
cout << A[i] << endl;
}
cout << 0 << endl;
}




Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int W,H,x,y,r;
  int min,mid,max;
  vector<int> li;
  
  cin >> W >> H >> x >> y >> r;

if(W < x + r || x - r < 0 || H < y + r || y - r < 0){
  cout << "No" << endl;
} else {
  cout << "Yes" << endl;
}
  
}


Measured memory_bytes: 3112
#include<cstdio>
using namespace std;
int sai[1001][1001],hy[1001][1001],t[1001],a[1001],b[1001],c[1001];
int main(void)
{
	int i,j,d,n,sa=0,mm=-1,k;
	scanf("%d %d",&d,&n);
	for(i=1;i<=d;i++){
		scanf("%d",&t[i]);
	}
	for(i=1;i<=n;i++){
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
	}
	for(i=1;i<=d;i++){
		for(j=1;j<=n;j++){
			hy[i][j]=0;
		}
	}
	for(i=1;i<=d;i++){
		for(j=1;j<=n;j++){
			if(a[j]<=t[i] && t[i]<=b[j]){
				for(k=1;k<=n;k++){
					if(a[k]<=t[i+1] && t[i+1]<=b[k]){
						sa=c[j]-c[k];
						if(sa<=0) sa=sa*-1;
						if(hy[i+1][k]<sa+hy[i][j])hy[i+1][k]=sa+hy[i][j];
					}
				}
			}
		}
	}
	mm=-1;
	for(i=1;i<=n;i++){
		if(mm<hy[d][i]){
			mm=hy[d][i];
		}
	}
	printf("%d\n",mm);
	return 0;
}

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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
typedef pair<LL,LL> P;    
int main(){
    int N;
    cin>>N;
    LL X,Y;
    cin>>X>>Y;
    vector<vector<P>> xy(5,vector<P>(1,P(0,0)));
    REP(i,N){
        int t;LL x,y;
        cin>>t>>x>>y;
        xy[t-1].pb(P(x,y));
    }
    vector<P> A,B;
    for(auto &a:xy[0])
        for(auto &b:xy[1])
            for(auto &c:xy[2])A.pb(P(a.fi+b.fi+c.fi,a.se+b.se+c.se));
    for(auto &d:xy[3])
        for(auto &e:xy[4])B.pb(P(d.fi+e.fi,d.se+e.se));
    sort(ALL(A));
    sort(ALL(B));
    reverse(ALL(B));
    
    int M=B.size();
    multiset<LL> exist;
    int bg=0,ed=0;
    for(auto &a:A){
        while(ed<M&&a.fi+B[ed].fi>=X){
            exist.insert(B[ed].se);
            ed++;
        }
        while(bg<ed&&a.fi+B[bg].fi>Y){
            auto it = exist.find(B[bg].se);
            exist.erase(it);
            bg++;
        }
        auto it = exist.lower_bound(X-a.se);
        if(it!=exist.end()&&a.se+*it<=Y){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 19468
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(), M = sc.nextInt();
        
        List<List<Integer>> to = new ArrayList<>();
        for(int i = 0; i < N; i++) {
            to.add(new ArrayList<Integer>());
        }
        
        for(int i = 0; i < M; i++) {
            int A = sc.nextInt()-1;
            int B = sc.nextInt()-1;
            to.get(A).add(B);
            to.get(B).add(A);
        }
        
        int[] dist = new int[N];
        int[] pre = new int[N];
        for(int i = 0; i < N; i++) {
            dist[i] = Integer.MAX_VALUE;
            pre[i] = -1;
        }
        Queue<Integer> queue = new LinkedList<>();
        queue.add(0);
        dist[0] = 0;
        
        while(!queue.isEmpty()) {
            int q = queue.poll();
            for(int p : to.get(q)) {
                if(dist[p] != Integer.MAX_VALUE) continue;
                dist[p] = dist[q] + 1;
                pre[p] = q;
                queue.add(p);
            }
        }
        
        System.out.println("Yes");
        for(int i = 1; i < N; i++) {
            System.out.println(pre[i]+1);
        }
    }
}


Measured memory_bytes: 77984
#ifdef _MSC_VER
#  define _CRT_SECURE_NO_WARNINGS
#  define _USE_MATH_DEFINES
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double;
using u32 = unsigned int; using u64 = unsigned long long int; using str = string;
template <typename T> using vec = vector<T>; void in() { }
template <typename T, typename...TS> void in(T &&x, TS &&...xs) { cin >> x; in(move(xs)...); }
template <typename T> void out(T &&x) { cout << x << "\n"; }
template <typename T, typename...TS> void out(T &&x, TS &&...xs) { cout << x << " "; out(move(xs)...); }
#define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
#define get(t) []{ t x; cin >> x; return x; }()
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define even(x) ((abs(x) & 1) == 0)
#define odd(x) ((abs(x) & 1) == 1)
#define bit(x, i) (((x) >> i) & 1)
#define append emplace_back
#define bisect_left lower_bound
#define bisect_right upper_bound
#define bound(a, x, b) (a <= x && x <= b)
const i64 MOD = 1000000007ll;
const f64 EPS = 1e-10;

void solve() {
    indef(i32, n, m);
    vec<pair<i32, i32>> v;
    times(m, i) {
        indef(i32, a, b);
        v.append(make_pair(a, b));
        v.append(make_pair(b, a));
    }
    sortall(v);
    set<pair<i32, i32>> s;
    s.insert(make_pair(0, 1));
    bool fp[200001] = {};
    while (s.size()) {
        i32 d = s.begin()->first;
        i32 i = s.begin()->second;
        s.erase(s.begin());
        if (fp[i]) continue;
        fp[i] = true;
        if (d > 1) continue;

        auto it = bisect_left(all(v), make_pair(i, 0));
        while (it != v.end() && (*it).first == i) {
            i32 j = (*it).second;
            if (fp[j]) { 
                it++;
                continue;
            }
            s.insert(make_pair(d+1, j));
            it++;
        }
    }

    out(fp[n] ? "POSSIBLE" : "IMPOSSIBLE");
}

i32 main()
{
    ios::sync_with_stdio(false);

#ifdef _MSC_VER
    /**
    ifstream fin("input.txt"); cin.rdbuf(fin.rdbuf()); assert(fin);
    ofstream fout("output.txt"); cout.rdbuf(fout.rdbuf()); assert(fout);
    /**/
#endif

    //cout << fixed << setprecision(9);
    solve();
    return 0;
}

Measured memory_bytes: 9068
#include <bits/stdc++.h>
#define int llint
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int H, W;
int c[10][10];
int A[210][210];
int d[10][10];


void warshallFloyd(){
	rep(i, 0, 10) fill(RNG(d[i], 0, 10), INF);
	rep(i, 0, 10)
		rep(j, 0, 10) d[i][j] = c[i][j];
	rep(k, 0, 10)
		rep(i, 0, 10)
			rep(j, 0, 10) chmin(d[i][j], d[i][k]+d[k][j]);
}


int solve(){
	int ans = 0;
	rep(i, 0, H)
		rep(j, 0, W)
			if(A[i][j] != -1) ans += d[A[i][j]][1];
	return ans;
}


signed main(){
	cin >> H >> W;
	rep(i, 0, 10)
		rep(j, 0, 10) cin >> c[i][j];
	rep(i, 0, H)
		rep(j, 0, W) cin >> A[i][j];

	warshallFloyd();

	cout << solve() << endl;

	return 0;
}

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


int main(){

    int N;
    string S;
    cin >> N >> S;
    int cnt=0;

    for(int i=0; i<N-2; i++){
        if(S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C'){
            cnt++;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

k, n = load_list()
A = load_list()


def dist(a, b):
    if b > a:
        return b - a
    else:
        return (k-a) + b

ds = []
for i in range(n):
    if i == n-1:
        ds.append(dist(A[i], A[0]))
    else: 
        ds.append(dist(A[i], A[i+1]))

print(sum(ds) - max(ds))


Measured memory_bytes: 25428
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll n; cin >> n;
  cout << n*n*n << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<map>
using namespace std;
struct Rank {
	int i;
	int rank;
};
map<int, int> mp;
int main()
{
	int n;
	Rank a[100005];
	while (cin >> n) {
		for (int i = 1; i <= n; i++) {
			cin >> a[i].rank;//编号为i的学生进去时，教室中共有a[i]个学生
			a[i].i = i;
			mp[a[i].rank] = i;
		}
		for (int i = 1; i <= n; i++) {
			cout << mp[i] << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
#define ran 101111
int n;
vector<pair<int,int> > e[ran];
bool vis[ran];
int pos[ran];
bool dfs(int x){
	vis[x] = true;
	for(auto p : e[x]){
		int y = p.first;
		int dif = p.second;
		if(!vis[y]){
			pos[y] = pos[x] + dif;
			if(!dfs(y))return false;
		}else{
			if(pos[y] != pos[x] + dif)return false;
		}
	}
	return true;
}
int main(){
	int m;
	scanf("%d%d",&n,&m);
	while(m--){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		e[x].push_back({y, z});
		e[y].push_back({x, -z});
	}
	for(int i=1; i<=n; i++)
		if(!vis[i]){
			pos[i] = 0;
			if(!dfs(i)){
				puts("No");
				return 0;
			}
		}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define N 500005
#define ll long long
#define For(i,x,y) for(int i=(x);i<=(y);++i)
#define Rof(i,x,y) for(int i=(x);i>=(y);--i)
#define Edge(x) for(int i=head[x];i;i=e[i].nxt)
#define mset(x,y) memset(x,y,sizeof(x))
#define mod 998244353
using namespace std;
int fac[N],invf[N];
int C(int x,int y){ return x>=y?1ll*fac[x]*invf[y]%mod*invf[x-y]%mod:0; }
int main(){
	int n,k,ans=0;
	scanf("%d%d",&n,&k);
	fac[0]=fac[1]=1,invf[0]=invf[1]=1;
	For(i,2,k){
		fac[i]=1ll*fac[i-1]*i%mod;
		invf[i]=1ll*(1ll*mod-mod/i)*invf[mod%i]%mod;
	}
	For(i,2,k) invf[i]=1ll*invf[i-1]*invf[i]%mod;
	For(i,n,k) (ans+=C(k-1,i-1))%=mod;
	cout<<ans;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> vv(200200);
    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        vv[a].push_back(b);
        vv[b].push_back(a);
    }
    
    string ans = "IMPOSSIBLE";
    for(int i=0; i<vv[1].size(); i++){

        for(int j=0; j<vv[vv[1][i]].size(); j++){
            if(vv[vv[1][i]][j] == n){
                ans = "POSSIBLE";
                break;
            }
        }

    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12016
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for ( ulli i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for ( slli i = n - 1; i >= 0; --i )

bool check(const std::vector<ulli> &A)
{
  unsigned odd_count = 0;
  N_TIMES(n, A.size()) {
    if (A[n] % 2 == 1) {
      ++odd_count;
    }
  }

  if (odd_count % 2 == 1) return false;

  return true;
}

int main()
{
  unsigned N;
  std::cin >> N;

  std::vector<ulli> A(N);
  N_TIMES(n, N) {
    std::cin >> A[n];
  }

  std::cout << (check(A) ? "YES" : "NO") << std::endl;

  return 0;
}

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

int main() {
    int r,g,b,n;
    cin >> r >> g >> b >> n ;
    int ans = 0;
    for(int i = 0 ; i*r <= n; i++){
        for(int j = 0; j*g <= (n-i*r); j++){
            /*for(int k = 0; k*b <= (n-i*r-j*g) ;k++){
                //cout << i << j << k << endl;
                int ri = r*i;
                int gj = g*j;
                int bk = b*k;
                ll clac = ri+gj+bk;
                if(n == clac){
                    ans++;
                }*/
                if((n-(i*r+j*g)) % b == 0){
                    ans++;
                }
        }
    }
    cout << ans << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

OK = ["A", "C", "G", "T"]
s = input()[:-1]
l = 0
r = 0
ans = 0
N = len(s)
while l < N and r < N:
    if s[r] in OK:
        ans = max(ans, r-l+1)
        r += 1
    else:
        l = r+1
        r += 1
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char s;
  cin >> s;
  
  if (s=='a'||s=='i'||s=='u'||s=='e'||s=='o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 3592
program ABC_090_B_PalindromicNumbers
   implicit none
   integer A, B, c, i, j, k, countN
   read(*, *) A, B
   countN = 0
   do k = 1, 9
       do j = 0, 9
	       do i = 0, 9
		       c =1d4 * k + 1d3 * j + 1d2 * i + 1d1 * j + 1d0 * k
			   if(c >= A .and. c <= B) then
			      countN = countN + 1
			   end if
		   end do
	   end do
   end do
   write(*, *) countN
end program ABC_090_B_PalindromicNumbers

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
lli n, m, k;

int main(void){
    cin >> n >> m >> k;
    vector<lli> a(m), b(m), c(k), d(k), f(n);
    rep(i, m){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        f[a[i]]++;
        f[b[i]]++;
    }
    rep(i, k){
        cin >> c[i] >> d[i];
        c[i]--;
        d[i]--;
    }
    UnionFind u(n);
    vector<lli> uc(n);
    rep(i, m){
        u.unite(a[i], b[i]);
    }
    rep(i, n) uc[u.root(i)]++;
    vector<lli> ans(n);
    rep(i, n){
        ans[i] = uc[u.root(i)]-f[i]-1;
    }
    rep(i, k){
        if(u.same(c[i], d[i])){
            ans[c[i]]--;
            ans[d[i]]--;
        }
    }
    rep(i, n) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 10316
#include <stdio.h>

void trace(int A[],int N){
  int i;
  for(i=0;i<N;i++){
    if(i>0) printf(" ");
    
    printf("%d",A[i]);
  }
  printf("\n");
}

void insertionSort(int A[],int N){
  int i,j,v;
    
  for(i=1;i<=N-1;i++){
    v=A[i];
    j=i-1;
    while((j>=0) && (A[j]>v)){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    trace(A,N);
    
  }
     
}

int main()
{
  int N,i,j;
  int A[1000];
  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);
  trace(A,N);
  insertionSort(A,N);
 

  return 0;
}




Measured memory_bytes: 2144
#include<iostream>

int main(){
	int N;
	std::cin >> N;
	int H[N];
	for(int i = 0;i < N;i++){
		std::cin >> H[i];
		//std::cout << H[i] << ",";
	}
	for(int i = 1;i < N-1;i++){
		//std::cout << H[i];
		if(H[i-1] < H[i]){
			H[i] -= 1;
		}
		if(H[i] > H[i+1]){
			std::cout << "No";
			return 0;
		}
	}
	std::cout << "Yes";

	return 0;
}

Measured memory_bytes: 640
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    s = S()
    for i in range(len(s) - 1):
        if s[i] == s[i+1]:
            print(i + 1, i + 2)
            return
    for i in range(len(s) - 2):
        if s[i] == s[i + 2]:
            print(i + 1, i + 3)
            return
    print(-1, -1)

    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 49648
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>v;
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
			/*brownsands IIITA*/

signed main(){
  		
                boost
		int n;
  cin>>n;
  int dp[n+2][3],A[3];
 // dp[n+2][3]={0};
  inz(dp);
  //cout<<dp[n][0]<<endl;
  for(int i=0;i<n;i++){
    cin>>A[0]>>A[1]>>A[2];
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(k!=j)
          dp[i+1][k]=max(dp[i+1][k],dp[i][j]+A[k]);
      }
     
			}
    //cout<<dp[i+1][0]<<" "<<dp[i+1][1]<<" "<<dp[i+1][2]<<endl;
  }
  cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
  }
 

				
		
		





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

namespace ConsoleApp2
{
    public class Program
    {
        public static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long A = long.Parse(Console.ReadLine());
            long B = long.Parse(Console.ReadLine());
            long C = long.Parse(Console.ReadLine());
            long D = long.Parse(Console.ReadLine());
            long E = long.Parse(Console.ReadLine());

            long[] carryNum = new long[5] { A, B, C, D, E };
            long slow = carryNum.Min();

            if(N%slow==0) Console.WriteLine(N / slow + 4);
            else Console.WriteLine(N / slow + 5);

        }



        private static long[] Read(string input)
        {
            string[] inputs = input.Split(' ');
            long num = inputs.Length;
            long[] longs = new long[num];
            for (long i = 0; i < num; i++)
            {
                longs[i] = long.Parse(inputs[i]);
            }
            
            return longs;
        }


    }
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());
            int[] temp = Console.ReadLine().Split(" ").Select(s => int.Parse(s)).ToArray();
            int a = temp[0];
            int b = temp[1];
            string ans = "NG";
            for (int i = a; i <= b; i++)
            {
                if(i % k == 0)
                {
                    ans = "OK";
                    break;
                }
            }
            System.Console.WriteLine(ans);
        }
    }
}

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

#define UN unsigned
#define ll long long
#define mod 1000000007
#define pii pair<int, int>
#define pb push_back
//~ #define x first
//~ #define y second
const int N = 500000;

int main(void) {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	
	ll a=0, b=0;
	cin >> a >> b;
	cout << a*b << endl;
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stdio.h>
#include <cmath>

using namespace std;

typedef unsigned long long ull;
typedef unsigned int uint;
typedef unsigned char uchar;
#define umap unordered_map
const static ull INVALID_DIGIT = ~(ull)0;

static const ull MEMO_MAX_SIZE = 100001;

umap<int, umap<bool, ull>> memo;
ull possiblePatternMemo[MEMO_MAX_SIZE];

static const ull DIVIDER = 1000000007l;

int bitCount;
int valueIn2Bit[100001]{ 0 };

ull findPossibleCount(int currentIdx, bool possibleToOver)
{
    if (currentIdx + 1 == bitCount) {
        // final bit
        if (!possibleToOver) {
            // no warry to be over
            // (0,1) and (1,0) and (0,0) are possible
            return 3;
        }
        else {
            // lower digits are over than L. thus we cannot take (0,1) and (1,0)
            // only (0,0)
            return 1;
        }
    }

    auto it1 = memo.find(currentIdx);
    if (it1 != memo.end()) {
        auto it2 = it1->second.find(possibleToOver);
        if (it2 != it1->second.end()) {
            return it2->second;
        }
    }

    int v = valueIn2Bit[currentIdx];
    ull wayCount = 0;
    if (v == 0) {
        // (0,0) => ok and no possible to be over
        // (0,1) and (1,0) => ok but posible to be over
        wayCount += findPossibleCount(currentIdx + 1, possibleToOver) % DIVIDER;
        wayCount += (findPossibleCount(currentIdx + 1, true) * 2) % DIVIDER;
    }
    else {
        // (0,0) => ok and no possible to be over
        // (0,1) and (1,0) => ok and no possible to be over if lower digits has no possibility
        wayCount += findPossibleCount(currentIdx + 1, false) % DIVIDER;
        wayCount += (findPossibleCount(currentIdx + 1, possibleToOver) * 2) % DIVIDER;
    }
    wayCount %= DIVIDER;

    memo[currentIdx][possibleToOver] = wayCount;

    return wayCount;

}

int main()
{
    string s;
    cin >> s;

    int idx2bit = 0;
    bitCount = s.size();
    for (int i = bitCount - 1; i >= 0; i--) {
        valueIn2Bit[idx2bit] = s[i] - '0';
        idx2bit++;
    }

    ull wayCount = 0;
    wayCount = findPossibleCount(0, false);

    cout << wayCount << endl;


    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll r,g,b,n;
    cin>>r>>g>>b>>n;

    ll ans = 0;

    REP(i,0,3000/r+1)REP(j,0,3000/g+1){
        ll s = r*i+g*j;
        ll x = n-s;
        if(x>=0 && x%b==0)ans++;
    }
    cout<<ans<<endl;
    return  0;
}


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

using namespace std;

int main()
{

  string S;
  cin >> S;

  int r = 0;
  int s = 0;
  int t = 1;

  for (int i = 0; i < S.size()-1; ++i) t *= 10;

  for (int i =0; i < S.size() ; i++) {
    int x = (int)(S.at(i) - '0');
    r += x;
    s += x * t;
    t /= 10;
  }

  cout << ((s%r==0) ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 256
N,*as=$<.read.split.map(&:to_i)

n = 0
as.each do |a|
    n = a - n
end

n = n / 2
ret = [n*2]
as[0..-2].each do |a|
    n = a - n
    ret << n*2
end

puts ret.join(' ')

Measured memory_bytes: 15228
#include<iostream>
#include<vector>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;

int main(){
  int N,a[100010],ans =0;
  
  cin >> N;
  
  for(int i=1;i<=N;i++)
    cin >> a[i];
  
  
  for(int i=1;i<=N;i++){
    
    if(a[i] == i){
      
      if(a[i+1] == i+1){
      ans ++;
      i++;
      }
      
      else{
        ans ++;
      }
      
    }
    
  }
    cout << ans << endl;
    
  }
    
    
      
    
        
    
      
        
      
      
      
      
  
 


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y, int m) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y, int m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int k;
int ans = 0, p = 1;

int f(int x) {
	int res = 0;
	while (x) {
		res += x % 10;
		x /= 10;
	}
	return res;
}

signed main() {
	cin >> k;
	for (int i = 0; i < k; i++) {
		ans += p;
		cout << ans << endl;
		long double c = (long double)(ans + p) / f(ans + p);
		long double d = (long double)(ans + 2 * p) / f(ans + 2 * p);
		if (c > d)p *= 10;
	}
}


Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    a, b, c = i_map()

    print('Yes' if a + b >= c else 'No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 77184
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;


int main() {
  int d, g;
  cin >> d;
  cin >> g;

  vector<int> p(d);
  vector<int> c(d);
  int totalProblems = 0;
  for (int i = 0; i < d; i++) {
    int t;
    cin >> t;
    p[i] = t;
    totalProblems += t;

    cin >> t;
    c[i] = t;
  }

  int result = totalProblems;
  for (int pat = 0; pat < (1 << d); pat++) {
    // cout << pat << endl;
    int score = 0;
    int problems = 0;
    int rest_max = -1;
    for (int i = 0; i < d; i++) {
      if (!(pat & (1 << i))) {
	rest_max = i;
	continue;
      }

      problems += p[i];
      score += p[i] * 100 * (i + 1) + c[i];
    }

    // cout << score << endl;
    if (score < g) {
      int rest = g - score;
      if (100 * (rest_max + 1) * (p[rest_max] - 1) < rest) {
	continue;
      }
      int need = ceil((float)rest / (100 * (rest_max + 1)));
      problems += need;
    }
    result = min(result, problems);
  }

  cout << result << endl;
}



Measured memory_bytes: 256
def knapsack(w, ts)
  ms = [0] * (w + 1)

  for t in ts
    vi, wi = t

    ms0 = []

    for j in (0..w)
      ms0[j] = (wi <= j) ? [ms[j], ms[j - wi] + vi].max : ms[j]
    end

    ms = ms0
  end

  return ms[w], (0..w).map.select{|k| ms[k] == ms[w]}.min
end

### main

dn = 1

while true
  w = gets.chomp.to_i
  break if w == 0

  n = gets.chomp.to_i
  ts = n.times.map{gets.chomp.split(",").map{|s| s.to_i}}

  puts "Case #{dn}:"
  puts knapsack(w, ts)

  dn += 1
end

Measured memory_bytes: 6144
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define MOD 998244353
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
#define X first
#define Y second
typedef long long ll; 
char str[200005]; 
int dp[200005][3][3][2]; 
int main()
{
	// freopen("ARC094-F.in", "r", stdin);
	scanf("%s", str); 
	int n = strlen(str), cnt = 0, sum = 0; 
	for (int i = 0; i < n; i++)
	{
		cnt += i && str[i - 1] != str[i]; 
		(sum += str[i] - 'a') %= 3; 
	}
	if (!cnt)
	{
		puts("1"); 
		return 0; 
	}
	if (n <= 3)
	{
		if (n == 2)
			puts("2"); 
		else
		{
			if (cnt != n - 1)
				puts("6"); 
			else if (str[0] == str[2])
				puts("7"); 
			else
				puts("3"); 
		}
		return 0; 
	}
	dp[1][0][0][0] = dp[1][1][1][0] = dp[1][2][2][0] = 1; 
	for (int i = 1; i < n; i++)
	{
		for (int x = 0; x < 3; x++)
		{
			for (int y = 0; y < 3; y++)
			{
				for (int f = 0; f < 2; f++)
				{
					for (int z = 0; z < 3; z++)
						(dp[i + 1][z][(y + z) % 3][f | (x == z)] += dp[i][x][y][f]) %= MOD; 
				}
			}
		}
	}
	int ans = cnt == n - 1; 
	for (int i = 0; i < 3; i++)
		(ans += dp[n][i][sum][1]) %= MOD; 
	printf("%d\n", ans);
	return 0; 
}


Measured memory_bytes: 14464
N = int(input())
a = list(map(int,input().split()))

dic = {}
for i in a:
    dic[i] = 0

for val in a:
    dic[val] += 1

ans = 0
for key,val in dic.items():
    if key < val:
        ans += val - key
    elif key >val:
        ans += val


print(ans)


Measured memory_bytes: 17780
#include <iostream>
using namespace std;
int main()
{
    int n,h,m=0,co=0;
    int i=0;
    cin >> n;
    while(i<n){
        i++;
        cin >> h;
        if(m<=h){
            co++;
            m=h;
        }
    }
    cout << co << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
drink = []
for _ in range(N):
    A, B = map(int, input().split())
    drink.append([A, B])

drink.sort()
money = 0
for a, b in drink:
    if b > M:
        money += a * M
        break
    else:
        money += a * b
        M -= b
print(money)

Measured memory_bytes: 20064
def InputData():
    
    # [weight_len, track_num] = map(int, input().split())
    # weight_data_str = [input() for i in range(weight_len)]
    # weight_data = list(map(int, weight_data_str))

    weight_len, track_num = [int(s) for s in input().split(" ")]
    weight_data = [int(input()) for _ in range(weight_len)]

    return weight_len, track_num, weight_data

def check(track_num, weight_len, weight_data, key):
    i = 0
    for j in range(track_num):
        s = 0
        while (s + weight_data[i]) <= key:
            s += weight_data[i]
            i += 1
            if i == weight_len:
                return weight_len

    return i

def binarySearch(right, weight_len, track_num, weight_data):

    left = 0

    while((right - left) > 1):
        mid = (left + right) // 2
        v = check(track_num, weight_len, weight_data, mid)
        if v >= weight_len:
            right = mid
        else:
            left = mid

    return right

def PrintOut(right):
    print(right)

def main():
    
    [weight_len, track_num, weight_data] = InputData()
    right = 100000 * 10000
    right = binarySearch(right, weight_len, track_num, weight_data)
    PrintOut(right)

if __name__ == '__main__':
    main()
    


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

int main() {
    int N;
    cin >> N;
    set<int> S;
    for(int i = 0; i < N; i++) {
        int a;
        cin >> a; 
        S.insert(a);
    }
    int Q;
    cin >> Q;
    vector<int> T(Q);
    for(int i = 0; i < Q; i++) {
        cin >> T[i];
    }
    int count = 0;
    for(int i = 0; i < Q; i++) {
        count += S.count(T[i]);
    }
    cout << count << endl;
    return 0;
}


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

struct Node{
    int key;
    Node *parent, *left, *right;
};
Node *root;

void insert(int k){
    Node *x = root;
    Node *y = nullptr;
    Node *z;
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = nullptr;
    z->right = nullptr;

    while(x != nullptr){
        y = x;
        if(z->key < x->key) x = x->left;
        else x = x->right;
    }

    z->parent = y;
    if(y == nullptr) root = z;
    else if(z->key < y->key) y->left = z;
    else y->right = z;
    return;
}

void inorder(Node* n){
    if(n == nullptr) return;
    inorder(n->left);
    cout << ' ' << n->key;
    inorder(n->right);
    return;
}

void preorder(Node* n){
    if(n == nullptr) return;
    cout << ' ' << n->key;
    preorder(n->left);
    preorder(n->right);
    return;
}

Node* find(int k){
    Node *n = root;
    while(n != nullptr && k != n->key)
        (n->key < k) ? n = n->right : n = n->left;
    return n;
}

Node* tree_min(Node* z){
    while(z->left != nullptr) z = z->left;
    return z;
}

Node* next(Node* z){
    if(z->right != nullptr) return tree_min(z->right);
    Node *y = z->parent;
    while(y != nullptr && z == y->right){
        z = y;
        y = y->parent;
    }
    return y;
}

void del(Node* z){
    Node *x, *y;
    if(z->left == nullptr || z->right == nullptr) y = z;
    else y = next(z);

    (y->left == nullptr) ? x = y->right : x = y->left;
    if(x != nullptr) x->parent = y->parent;

    if(y->parent == nullptr) root = x;
    else (y->parent->left == y) ? y->parent->left = x : y->parent->right = x;

    if(y != z) z->key = y->key;
    free(y);
    return;
}

int main(){
    int n; cin >> n;
    rep(i, 0, n){
        string com; cin >> com;
        int k;
        if(com[0] == 'i'){
            cin >> k;
            insert(k);
        } else if(com[0] == 'f'){
            cin >> k;
            cout << (find(k) ? "yes" : "no") << endl;
        } else if(com[0] == 'd'){
            cin >> k;
            Node *z = find(k);
            if(z) del(z);
        } else {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        };
    }
    return 0;
}


Measured memory_bytes: 21960
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

std::vector<int> pre(1001*1001, -1);
//-------------------------------------------------------------------
int MAX_V = 1001*1001;
vvi G = vv(MAX_V, 0, 0, int);
vvi rG = vv(MAX_V, 0, 0, int);
vector<bool> used(MAX_V);
vector<int> cmp(MAX_V);
vector<int> vs;

void add_edge(int from, int to){ G[from].push_back(to), rG[to].push_back(from);}
void dfs(int v){
  used[v] = true;
  for(int i=0;i<G[v].size();i++) if(!used[G[v][i]]) dfs(G[v][i]);
  vs.push_back(v);
}
void rdfs(int v, int k){
  used[v] = true;
  cmp[v] = k;
  for(int i=0;i<rG[v].size();i++) if(!used[rG[v][i]]) rdfs(rG[v][i], k);
}
int scc(int V){
  for(int i=0;i<MAX_V;i++) used[i] = false;
  vs.clear();
  for(int i=0;i<=V;i++) if(!used[i]) dfs(i);
  for(int i=0;i<MAX_V;i++) used[i] = false;
  int k = 0;
  for(int i=vs.size()-1;i>=0;i--) if(!used[vs[i]]) rdfs(vs[i], k++);
  return k;
}
std::vector<int> mpath(1001*1001, -1);

int f(int now){
  if(mpath[now]!=-1) return mpath[now];
  int d = 0;
  for(int i=0;i<G[now].size();i++) d = max(d, f(G[now][i]));
  d++;
  mpath[now] = d;
  return d;
}
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  vvi A = vv(N+1, N, 0, int);
  vector<int> nyu(1001*1001, 1);
  for(int i=1;i<=N;i++) for(int j=1;j<=N-1;j++) std::cin >> A[i][j];
  for(int i=1;i<=N;i++) {
    for(int j=1;j<=N-2;j++) {
      add_edge(min(i,A[i][j])*1001+max(i,A[i][j]), min(i,A[i][j+1])*1001+max(i,A[i][j+1]));
      nyu[min(i,A[i][j+1])*1001+max(i,A[i][j+1])] = 0;
    }
  }
  scc(1001*1001);
  bool flag = true;
  set<int> dt;
  for(int i=1;i<=N;i++) {
    for(int j=1;j<i;j++) {
      if(dt.find(cmp[j*1001+i])!=dt.end()) flag = false;
      else dt.insert(cmp[j*1001+i]);
    }
  }
  if(!flag){
    std::cout << -1 << '\n';
    return 0;
  }
  int ans = 0;
  for(int i=0;i<1001*1001;i++) if(nyu[i]==1) ans = max(f(i), ans);
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 125680