akhauriyash/Code-Regression huggingface dataset:
def operate( cmd, text, cur ):
    lentxt = len(text)
    if cmd == "forward char":
        if cur < lentxt: cur += 1
    elif cmd == "backward char":
        if cur > 0: cur -= 1
    elif cmd == "forward word":
        while cur < lentxt and text[cur] == ' ': cur += 1
        while cur < lentxt and text[cur] != ' ': cur += 1
    elif cmd == "backward word":
        while cur > 0 and text[cur - 1] == ' ': cur -= 1
        while cur > 0 and text[cur - 1] != ' ': cur -= 1
    elif cmd == "delete char":
        text = text[:cur] + text[cur + 1:]
    elif cmd == "delete word":
        d = 0
        while cur + d < lentxt and text[cur + d] == ' ': d += 1
        if cur + d != lentxt:
            while cur + d < lentxt and text[cur + d] != ' ': d += 1
            text = text[:cur] + text[cur + d:]
    else:
        ins = cmd[8:-1]
        text = text[:cur] + ins + text[cur:]
        cur += len(ins)
    return cur, text

if __name__ == "__main__":
    a = int(raw_input())
    for i in range(a):
        text = raw_input()
        cnt = int(raw_input())
        cursor = 0
        for j in range(cnt):
            command = raw_input()
            cursor, text = operate( command, text, cursor )
        print (text[:cursor] + '^' + text[cursor:])

Measured memory_bytes: 4312
#include <stdio.h>

int main(){
  int a,b,c,k;
  scanf("%d %d %d\n%d",&a,&b,&c,&k);
  int answer;
  answer = a;
  if(a < b) answer = b;
  if(a < c && b < c) answer = c;
  int answer0 = answer;
  for(int i = 0; i < k; ++i) answer *= 2;
  answer += a + b + c - answer0;
  printf("%d\n",answer);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>

using namespace std;

static const int MAX = 200010;

const int MAX_NAME = 16;

int main() {
	int R[MAX], n;

	cin >> n;
	for (int i = 0; i < n; ++i) cin >> R[i];

	int maxv = -2000000000;
	int minv = R[0];

	for (int i = 1; i < n; ++i) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
		//printf("maxv = %d : minv = %d\n", maxv, minv);
	}

	cout << maxv << endl;

	return 0;
}


Measured memory_bytes: 3900
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto ab = readints;
    int a = ab[0], b = ab[1];
    writeln((a - 1) * (b - 1));
}


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

#define pi 2 * acos(0.00)
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl '\n'
#define nll '\0'
#define mx 1000007
#define bdyptb return 0;
#define testcase ll t,tt; cin>>tt; for(t=1;t<=tt;t++)
   
#define mod 142857

using namespace std;


struct level
{
    int a;
    int b;
};

bool acp(level lhs,level rhs)
{return lhs.a<rhs.a;}

int main()
{
    fastio;
    int x,y;

    for(int i=0;i<5;i++)
    {
        cin>>x;
        if(x==0)
        y=i+1;
    }
    cout<<y<<nl;
    
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,c=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=1;i<n;i++){
    if(a[i]==a[i-1]){
      c++;
      i++;
    }
  }
  cout<<c;
}

Measured memory_bytes: 256
N = int(input())
card_list = input().rstrip().split()
card_list = [int(s) for s in card_list]
sort_card_list = sorted(card_list, reverse = True)
alice_point = 0
bob_point = 0

for i, x in enumerate(sort_card_list):
    if i%2 == 0:
        alice_point = alice_point + x
    else:
        bob_point = bob_point + x

print(alice_point-bob_point)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

typedef struct {
	int index;string s; int p;
}rest;

bool compare(rest r1, rest r2) {
	int tmp = r1.s.compare(r2.s.c_str());
	if (tmp < 0) {
		return true;
	}
	else if(tmp==0){
		if (r1.p > r2.p) return true;
	}
	return false;
}

int main()
{
	int n;
	vector<rest> r;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s; int p;
		cin >> s >> p;
		r.push_back({ i + 1,s,p });
	}
	sort(r.begin(), r.end(), compare);
	for (int i = 0; i < n; i++) {
		cout << r[i].index << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <string>

int main() {
  std::string a;
  std::getline(std::cin, a);
  std::cin >> a;
  for (int i = 0; i < a.size(); i++)
  {
    int code_diff = 'a' - 'A';
    if (std::islower(a[i]))
    {
      a[i] = std::toupper(a[i]);
    }
    else if (std::isupper(a[i]))
    {
      a[i] = std::tolower(a[i]);
    }
  }
  std::cout << a << "\n";
}


Measured memory_bytes: 3156
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Name        : Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define SZ(c) int(c.size())
#define ff first
#define ss second
#define INF 1e9 + 1
#define _INF INT32_MIN
#define PQ priority_queue
#define MM multimap
#define PB push_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	LL c;
	while (a != 0) {
		c = a;
		a = b % a;
		b = c;
	}
	return b;
}
int LCM(int a, int b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		printf("%d ", 2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			printf("%d ", i);
			n /= i;
		}
	}
	if (n > 2)printf("%d ", n);
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
void dijjkstra(int src, int n) {
	list<ipair>adj[1000005];
	vector<bool>visited(1000005, false);
	vector<int>dis(1000005, 1e9);
	PQ<ipair, vector<ipair>, greater<ipair>>pq;
	pq.push(MP(0, 1));
	dis[src] = 0;
	while (!pq.empty())
	{
		int u = pq.top().ss;
		visited[u] = true;
		pq.pop();
		list<ipair>::iterator i;
		for (i = adj[u].begin(); i != adj[u].end(); i++)
		{
			int v = i->ff;
			int we = i->ss;
			if (!visited[v] && dis[v] > dis[u] + we)
			{
				dis[v] = dis[u] + we;
				pq.push(MP(dis[v], v));
			}
		}
	}
}
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	int n;
	cin >> n;
	PQ<int>q;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		q.push(x);
	}
	int mx = q.top();
	q.pop();
	int sum = 0;
	while (!q.empty())
	{
		sum += q.top();
		q.pop();
	}
	if (mx < sum)cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
x, N = list(map(int, input().split()))
p = list(map(int, input().split()))
dif = 0

while(dif <= x):
    if x - dif not in p:
        print(x - dif)
        break
    if x + dif not in p:
        print(x + dif)
        break
    dif += 1

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

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

ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll N;
    cin >> N;
    map<pair<ll, ll>, ll> X;
    ll A0 = 0, B0 = 0, AB0 = 0;
    REP(i,N){
        ll a, b;
        cin >> a >> b;
        if(a == 0 && b == 0)
            AB0++;
        else if(a == 0)
            A0++;
        else if(b == 0)
            B0++;
        else{
            ll g = gcd(abs(a), abs(b));
            ll aa = a / g;
            ll bb = b / g;
            pair<ll, ll> p1;
            if(bb < 0){
                p1 = make_pair(-aa, -bb);
            }
            else{
                p1 = make_pair(aa, bb);
            }

            X[p1]++;
        }

    }

    ll ans = 1;
    X[make_pair(-1, 0)] = A0;
    X[make_pair(0, 1)] = B0;
    for(auto&& p : X){
        pair<ll, ll> ab = p.first;
        ll a = ab.first;
        ll b = ab.second;
        ll num = p.second;
        if(num == 0) continue;

        ll t;
        if(a < 0){
            t = X[make_pair(b, -a)];
            X[make_pair(b, -a)] = 0;
        }
        else{
            t = X[make_pair(-b, a)];
            X[make_pair(-b, a)] = 0;
        }

        ll y1 = mod_pow(2, num, MOD);
        ll y2 = mod_pow(2, t, MOD);
        y1 %= MOD;
        y2 %= MOD;
        ans *= (y1 + y2 - 1);
        ans %= MOD;
    }

    ans += MOD - 1 + AB0;
    ans %= MOD;

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


Measured memory_bytes: 28412
N,M=map(int,input().split())
a=[int(input()) for _ in range(M)]
dp=[0]*N
id=0
p=10**9+7
id=0
for i in range(N):
    if (i==0):
        dp[i]=1
    elif (i==1):
        dp[i]=dp[i-1]+1
    else:
        dp[i]=dp[i-1]+dp[i-2]
    if len(a)>0:
        if a[id]==i+1:
            dp[i]=0
            if id<len(a)-1:
                id=id+1
print(dp[N-1]%p)





Measured memory_bytes: 470264
#include<bits/stdc++.h>
using namespace std;
int main(){

     long long int a,b,vl,vl2;
     double c,d,e,f,i,j,t=0,u=0;
     string x,y;
     vector<int> v;
     vector<int> v1;
     vector<int> v2;
     cin>>a>>b;
     for(i=1;i<10000;i++){
        c=floor(double(i)*.08);
        d=floor(double(i)*.1);
        if(c==a && d==b){
            t++;
            vl=i;

            break;
        }


     }
if(t>0)
    cout<<vl<<endl;
else cout<<-1<<endl;


    return 0;
}



Measured memory_bytes: 256
//****************************//
/**********  main *************/
//****************************//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<b;i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000


int main() {

	std::cin.tie(0);

	string s ;
	cin >> s ;

	(s[0]==s[1] && s[1]==s[2]) ? (cout << "No") : (cout << "Yes") << endl;

    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10

bool isMon(int x) {
	return (x > 0 && x < 13);
}

int main() {
	int s; cin >> s;
	int bef = s / 100;
	int aft = s % 100;

	if (isMon(bef)&&isMon(aft))cout << "AMBIGUOUS" << endl;
	else if (isMon(bef)) cout << "MMYY" << endl;
	else if (isMon(aft)) cout << "YYMM" << endl;
	else cout << "NA" << endl;

	return 0;
}


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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define int ll
#define tcase int t; cin>> t; for( ; t; --t)
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;

int n;

int32_t main(){
	fastio;
	cin>> n;

	cout<< n*n*n<< endl;
	return 0;
}


Measured memory_bytes: 256
s = str(input())
#s = 'ATCODER'

count = 0
count_max = 0
for i in s:
    if i == 'A' or i == 'T' or i == 'G' or i == 'C':
        count += 1
    else:
        if count_max < count:
            count_max = count
            count = 0

if count_max < count:
    count_max = count

print(count_max)

Measured memory_bytes: 3060
#include <stdio.h>

int main() {
	int a, b, c, k;
	scanf("%d%d%d%d", &a, &b, &c, &k);
	k += 1;
	while (k--) {
		if (b <= a) b <<= 1;
		else if (c <= b) c <<= 1;
		else {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
}


Measured memory_bytes: 1656
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

n,k = map(int,input().split())
x = len(str(Base_10_to_n(n,k)))
print(x)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long w, h, x, y; cin >> w >> h >> x >> y;
    printf("%.12f ", (double) w * h / 2);
    if (x * 2 == w && y * 2 == h) {
        cout << 1 << endl;
    } else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
import fractions
a,b,c,d=map(int,input().split())

ac=(a-1)//c
bc=b//c
ad=(a-1)//d
bd=b//d


f=fractions.gcd(c,d)
f=c*d//f

af=(a-1)//f
bf=b//f



print((b-a+1)-(bc-ac)-(bd-ad)+(bf-af))

Measured memory_bytes: 5304
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

#include <atcoder/all>
using namespace atcoder;
using namespace std;
#define rep(i, s, t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i, s, t) for(ll i = (ll)(s - 1); (ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max() / 4;
constexpr ll n_max = 2e5 + 10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {
    return '"' + s + '"';
}
string to_string(const char *c) {
    return to_string((string)c);
}
string to_string(bool b) {
    return (b ? "true" : "false");
}
template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
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;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

void debug_out() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n, d;
    cin >> n >> d;

    atcoder::two_sat ts(n);
    vector<ll> x(n), y(n);
    rep(i, 0, n) {
        cin >> x[i] >> y[i];
    }

    rep(i, 0, n) {
        rep(j, i + 1, n) {
            if(abs(x[i] - x[j]) < d) {
                ts.add_clause(i, false, j, false);
            }
            if(abs(x[i] - y[j]) < d) {
                ts.add_clause(i, false, j, true);
            }
            if(abs(y[i] - x[j]) < d) {
                ts.add_clause(i, true, j, false);
            }
            if(abs(y[i] - y[j]) < d) {
                ts.add_clause(i, true, j, true);
            }
        }
    }

    if(!ts.satisfiable()) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    auto v = ts.answer();
    rep(i, 0, n) {
        if(v[i]) {
            cout << x[i] << "\n";
        } else {
            cout << y[i] << "\n";
        }
    }
}

Measured memory_bytes: 3816
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;
    vector<int> bs(n + 1);
    for(int i = 0; i < n; i++){
        bs[i + 1] = bs[i] + (s[i] == '#');
    }
    int ws = 0;
    int ans = bs.back();
    printde(ans);
    for(int i = n - 1; i >= 0; i--){
        ws += s[i] == '.';
        ans = min(ans, ws + bs[i]);
        printde(i, ans, ws, bs[i]);
    }
    cout << ans << '\n';
}


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

int main(int argc, char *argv[]){
  long long N,M;
  cin>>N>>M;
  long long count=0;
  if(N==1 && M==1){
    cout<<1<<endl;
    return 0;
  }
  if((N==1 || M==1) && (N==2 || M==2)){
    cout<<0<<endl;
    return 0;
  }
  else if(N==1 || M==1){
    if(N!=1) count=N-2;
    else     count=M-2;
    cout<<count<<endl;
    return 0;
  }
  else{
    count=(N-2)*(M-2);
    cout<<count<<endl;
  }
}


Measured memory_bytes: 256
#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 n,m,a=0,b;
  cin >> n >> m;
  
  for(int i=0;i<m;i++){
    cin >> b;
    a+=b;
  }
  
  if(a>n)cout << -1 << endl;
  else cout << n-a << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
  int a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  int res=v*t;
  int res1=w*t;
  int d1=a+res;
  int d2=b+res1;
  int x=res-res1;
  int y=abs(a-b);
  if(x>=y)
  {
    cout<<"YES";
  }
  else
  {
    cout<<"NO";
  }
}

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

int ans;
string s;


int main(){
  cin >> s;
  int tmpans = 0;
  rep(i, s.size()){
    if(s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'G' || s.at(i) == 'T'){
      tmpans++;
    }
    else{
      ans = max(ans, tmpans); 
      tmpans = 0;
    } 
  }
  ans = max(ans, tmpans);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int main(){
    vector<int> cnt(5, 0);
    for(int i=0; i<6; i++){
        int x; cin>>x;
        cnt[x]++;
    }
    sort(cnt.begin(), cnt.end(), greater<int>());

    if(cnt[0]==2 && cnt[1]==2 && cnt[2]==1 && cnt[3]==1){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		char c=scan.next().charAt(0);
		if(c=='A') System.out.println("T");
		else if(c=='T') System.out.println("A");
		else if(c=='G') System.out.println("C");
		else System.out.println("G");

	}

}


Measured memory_bytes: 26980
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()

typedef long long ll;

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

ll gcd(ll x, ll y){
    if(x<y) swap(x,y);
    return (y ? gcd(y,x%y) : x);
}

ll lcm(ll x,ll y){
    return (x/gcd(x,y))*y;
}

int main(){
    int n; cin >> n;
    
    ll t[n];
    rep(i,n) cin >> t[i];
    
    sort(t,t+n);
    
    ll ans = t[0];
    
    rep(i,n-1){
        ans = lcm(ans , t[i+1]);
    }
    
    cout << ans << endl;
    
}














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

using namespace std;

int cnt = 0;

void mulspl(int n) {
	int place = 0, tmp = n, i = 0;
	vector<int> sp(10);
	while (tmp > 0) {
		sp[i] = tmp % 10;
		tmp /= 10;
		place++, i++;
	}
	if (place > 1) {
		int maxi = 0;
		for (int i = 1; i < place; ++i) {
			int x = (n / (int)pow(10, i)) * (n % (int)pow(10, i));
			maxi = max(maxi, x);
		}
		cnt++;
		mulspl(maxi);
	}
}

int main() {
	int q;
	cin >> q;
	int n;
	for (int i = 0; i < q; ++i) {
		cin >> n;
		mulspl(n);
		cout << cnt << endl;
		cnt = 0;
	}

	return 0;
}


Measured memory_bytes: 3268
s = input()
n = len(s)
dp = [ [0,0] for i in range(n) ]
dp[0][0] = ord(s[0])-ord('0')
dp[0][1] = 11-(ord(s[0])-ord('0'))
for i in range(n-1):
  d = ord(s[i+1])-ord('0')
  dp[i+1][0] = min(dp[i][0], dp[i][1]) + d
  dp[i+1][1] = min(dp[i][0]+11-d, dp[i][1]+9-d)
print(min(dp[n-1][0],dp[n-1][1]))

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

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    for ( int i = 0; i < N; ++i){
        cin >> S[i];
    }
    
    int ac = 0, wa = 0, tle = 0, re = 0;
    
    for ( int i = 0; i < N; ++i){
        if ( S[i] == "AC" ) ++ac;
        else if ( S[i] == "WA" ) ++wa;
        else if ( S[i] == "TLE" ) ++tle;
        else ++re;
    }
    
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    
    return 0;
}



Measured memory_bytes: 6424
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define ins insert
#define er erase
#define f(i,a,b) for(i=a;i<b;++i)
#define rf(i,a,b) for(i=a;i>=b;--i)
#define tc int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int> 
#define vll vector<ll> 
#define vull vector<ull>
#define vc vector<char>
#define vst vector<string>
#define bs bitset
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b) 
#define lb lower_bound
#define ub upper_bound
#define nl "\n" 
#define sp " "
using namespace std;

//LET'S PLAY THE GAME!!

int main(){
    fast;
    
    int n,i;ll a,b;cin>>n;
    vector<pll>v;
    
    f(i,0,n){
        cin>>a>>b;
        v.pb(mp(b,a));
    }
    
    sort(all(v));
    
    ll t=0;
    
    f(i,0,n){
        ll f=v[i].ff, s=v[i].ss;
        t+=s;
        if(t>f){
            cout<<"No";return 0;
        }
    }
    
    cout<<"Yes";
    
    return 0;
}
// AND THE GAME IS OVER!!

Measured memory_bytes: 6572
#include <bits/stdc++.h>
using namespace std;
using Graph= vector<vector<int>>;
const int Ndig= 10;

void solve(const Graph &weights, int g, vector<int> *dists){
  using path= pair<int, int>;

  priority_queue<path, vector<path>, greater<path>> search;
  search.push(make_pair(0, g));
  while( !search.empty() ){
    int d_tmp, to_tmp;
    tie(d_tmp, to_tmp)= search.top();
    search.pop();
    if(dists->at(to_tmp) <= d_tmp){ continue; }
    else{
      dists->at(to_tmp)= d_tmp;
      for(int from=0; from<Ndig; from++){
        search.push(make_pair(d_tmp+ weights.at(from).at(to_tmp), from));
      }
    }
  }
}

int main(){
  int H,W,buf;
  cin >> H >> W;

  Graph weights(Ndig, vector<int>(Ndig));
  vector<int> freq(Ndig);
  for(int i=0; i<Ndig; i++){
    for(int j=0; j<Ndig; j++){
      cin >> weights.at(i).at(j);
    }
  }
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> buf;

      if(buf != -1){ freq.at(buf)++; }
    }
  }

  vector<int> dists(Ndig, INT_MAX);
  solve(weights, 1, &dists);

  int ans= 0;
  for(int i=0; i<Ndig; i++){
    ans+= freq.at(i)* dists.at(i);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG    //空コンテナ操作禁止　Clang環境では#define _LIBCPP_DEBUG 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  for( int i=0; i<N; i++ ) cin >> P.at(i);
  
  int cnt = 0;
  for( int i=0; i<N; i++ )   if( P.at(i) != i+1 ) cnt++;
  
  if( cnt == 2 || cnt == 0 )   cout << "YES";
  else     cout << "NO";

  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

	int A[100], B[99];

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

	int ans = 0;

	for (int i = 0; i < N; i++) {
		if (i == 0) {
			A[i] = B[i];
			continue;
		}
		if (i == N - 1) {
			A[i] = B[i - 1];
			continue;
		}
		if (B[i] > B[i - 1]) {
			A[i] = B[i-1];
		}
		else {
			A[i] = B[i];
		}
	}
	
	for (int i = 0; i < N; i++) {
		ans += A[i];
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main() {
    int a, b;
    double x;
    scanf("%d %d", &a, &b);
    x = (a+b)/2.0;
    printf("%d\n", (int)(x+0.5));
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    unordered_map<char,int> map;
    string s;
    cin>>s;
    for(char ch:s)
    map[ch]++;
    if(map.size()!=2)cout<<"No";
    else
    {
        cout<<"Yes";
    }
    return 0;
}

Measured memory_bytes: 256
import sys
lines = sys.stdin.readlines()
for linea in lines:
    c = linea.split()
    c = list(map(int,c))
list(c)
x = c[0]*c[1]
v =c[2]*c[3]
if x>v:
  print(x)
if x<v:
  print(v)
if x==v:
  print(x)    

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

int main() {

    int n;
    long long int a,b;

    cin >> n >> a >> b;

    long long int x[n];

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

    long long int ans = 0;

    long long int pos =x[0];

    for(int i=1; i<n; i++){
        ans += min((x[i]-pos)*a,b);
        pos = x[i];
    }

    cout << ans << endl;

    return 0;
}

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

#define debug(x) cerr << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}


const int maxn = 2505 + 5;
ll fat[maxn], inv[maxn];

ll C(int n, int k)
{
  if(n < k) 
    return 0;
  if(n < 0 || k < 0) 
    return 0;
  return (((fat[n] * inv[k]) % mod) * inv[n - k]) % mod;
}

void initFactorials()
{
  fat[0] = 1;
  inv[0] = 1;
  for(int i = 1; i < maxn; i++)
  {
    fat[i] = (i * fat[i-1]) % mod;
    inv[i] = exp(fat[i], mod - 2);
  }
}

int main()
{
  initFactorials();
  ios::sync_with_stdio(0);
  int n,k;
  cin >> n >> k;
  for(int i = 1 ; i <= k; i++)
  {
    ll ans = (C(n - k + 1, i) * C(k - 1, i - 1)) % mod;
    cout << ans << endl;
  }


  return 0;
}

Measured memory_bytes: 3680
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		long a = stdIn.nextInt();
		long b = stdIn.nextInt();
		long c = stdIn.nextInt();
		long d = stdIn.nextInt();
		
		System.out.println(Math.max(a * c, Math.max(a * d, Math.max(b * c, b * d))));
	}
}

Measured memory_bytes: 35576
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < N; i++){
        if (i%2 == 0) ans += a.at(i);
        else ans -= a.at(i);
    }
    cout << ans << endl;
}

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

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

    char prevColor = colors[0] == '0' ? '1' : '0';
    int count = 0;
    for (auto& color : colors)
    {
        if (color == prevColor)
        {
            color = prevColor == '0' ? '1' : '0';
            count++;
        }
        prevColor = color;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);


		double[][] mawasi=new double[1001][2];
		mawasi[0][0]=0;
		mawasi[0][1]=0;
		mawasi[1][0]=1.0d;
		mawasi[1][1]=0.0d;
		double now_cyouhen=0;

		double[][] matrix=new double[2][2];
		for(int i=2; i<=1000; i++) {
			now_cyouhen=Math.sqrt(i);
			matrix[0][0]=Math.sqrt(i-1)/now_cyouhen*now_cyouhen/Math.sqrt(i-1);
			matrix[0][1]=1/now_cyouhen*now_cyouhen/Math.sqrt(i-1);
			matrix[1][0]=-matrix[0][1];
			matrix[1][1]=matrix[0][0];

			mawasi[i][0]=mawasi[i-1][0]*matrix[0][0]+mawasi[i-1][1]*matrix[1][0];
			mawasi[i][1]=mawasi[i-1][0]*matrix[0][1]+mawasi[i-1][1]*matrix[1][1];
		}

		while(sc.hasNext()) {
			int tmp=sc.nextInt();
			if(tmp==-1) {
				System.exit(0);
			}
			System.out.println(mawasi[tmp][0]);
			System.out.println(mawasi[tmp][1]);
		}
	}
}


Measured memory_bytes: 26332
from bisect import bisect_right
from bisect import bisect_left

n = int(input())
s = list(input())
q = int(input())

ind_list = [[] for _ in range(26)]

for i, x in enumerate(s):
    ind_list[ord(x)-97].append(i)

for _ in range(q):
    _type, val1, val2 = input().split()
    if _type == '1':
        i = int(val1)-1
        c = val2
        if s[i] == c:
            continue
        ind_list[ord(s[i])-97].remove(i)
        p = bisect_right(ind_list[ord(c)-97], i)
        ind_list[ord(c)-97].insert(p, i)
        s[i] = c
    elif _type == '2':
        l = int(val1)-1
        r = int(val2)-1
        ans = 0
        for i in range(26):
            if bisect_right(ind_list[i], r) - bisect_left(ind_list[i], l) > 0:
                ans += 1
        print(ans)
    else:
        print('Exception caught!')
        exit()


Measured memory_bytes: 99840
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef vector<int> vi;
typedef long double D;

int d[12][11][11][11][55]; //d[curh][curw][l][r][oxy]

int main(){
  int w,h;
  while(cin >> w >> h, w){
    int f, m, o;
    cin >> f >> m >> o;

    vector<vi> c(h, vi(w,0));
    rep(i,h)rep(j,w)cin >> c[i][j];

    if(o<=1){
      cout << "NA" << endl;
      continue;
    }

    memset(d,-1,sizeof(d));
    priority_queue< vi, vector<vi>, greater<vi> > q;

    rep(i,w){
      int no = o-1, nv = 0;
      if(c[0][i] > 0)no = min(m, no+c[0][i]);
      else nv = -c[0][i];
      d[0][i][i][i][no] = nv;
      q.push( {nv,0,i,i,i,no} );
    }

    int ans = 1e9;
    while(q.size()){
      vi s = q.top(); q.pop();
      int v = s[0], y = s[1], x = s[2], l = s[3], r = s[4], o = s[5];
      if(y==h-1){
	ans = v;
	break;
      }
      if(d[y][x][l][r][o] < v || o<=1)continue;

      rep(k,3){
	int nx = x, ny = y, nl = l, nr = r, no = o-1, nv = v;

	if(k==0 && x-1>=0){
	  nx--;
	  if(nx < nl)nl--;
	}
	if(k==1 && x+1<w){
	  nx++;
	  if(nx > nr)nr++;
	}
	if(k==2 && y+1<h){
	  ny++; nl = nr = nx;
	}

	if(c[ny][nx] > 0)no = min(m, no+c[ny][nx]);
	else nv -= c[ny][nx];

	if(d[ny][nx][nl][nr][no] < 0 || d[ny][nx][nl][nr][no] > nv){
	  d[ny][nx][nl][nr][no] = nv;
	  q.push( {nv,ny,nx,nl,nr,no} );
	}
      }
    }

    if(ans > f)cout << "NA" << endl;
    else cout << ans << endl;
  }
}

Measured memory_bytes: 6620
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   cout << (n+1)/2 << '\n';
   return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX



 
void solve()
{
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    double d1 = (h*30);
    double d2 = m*6;
    double pi = 3.141592653589793238462643383279502884197169399375105820;
    d1 += (double)m/2;
    double ang = min(abs(d1-d2), 360-abs(d1-d2));
    double  x1 = 0, y1 = a;
    double x2,y2;





    if(ang <= 90)
    {
        ang = 90-ang;
        ang *= pi;
        ang /=180;
        x2 = (double)b*(double)cos(ang);
        y2 = (double)b*sin(ang);
    }
    else
    {
                ang = ang - 90;

        ang = (ang*pi)/180;
        x2 = b*cos(ang);
        y2 = -b*sin(ang);
    }
    cout << setprecision(25);
    cout << sqrt(((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2))) << endl;
}   


signed main()
{
    
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 4056
#include<iostream>

using namespace std;

int add(int x){
	int total=0;
    while(x>0){
	    total+=x%10;
		x/=10;
	}
	return total;
}

int main(){
	int n,a,b,ans=0;
	cin >> n >> a >> b;
	for(int i=1; i<=n; i++){
	    int sum=add(i);
		if(sum >= a && sum <= b)
			ans+=i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string str;
  cin>>str;
  int n = str.length();
  vector<char> ans;
  for(int i=0;i<n;i++){
    ans.push_back(str[i]);
  }
  if(ans[n-1]=='s'){
    ans.push_back('e');
    ans.push_back('s');
  }
  else
    ans.push_back('s');
  for(int i=0;i<ans.size();i++){
    cout<<ans[i] ;
  }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int d;
  cin >> d;
  cout<<"Christmas";
  rep(i,25-d) cout<<" Eve";
  cout<<endl;
}



Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

    string s; cin>>s;
    int ans = 0;
    for(int i=0; i<s.size(); i++){
        ans += (s[i] == '2');
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  for (int i = 0; i < N; ++i)
    cin >> P[i];
  int min_P = 1000000000, ans = 0;
  for (int i = 0; i < N; ++i)
    if (P[i] < min_P)
      min_P = min(P[i], min_P), ++ans;
  cout << ans << endl;
}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}

const ll mDivisor = 1000000;

int main(){
    ll A,B;
    cin >> A>>B;
    ll num = gcd(A,B);
    // cerr << num << endl;
    ll i=2;
    vector<ll> s;
    while(num != 1){
        if(i>mDivisor){
            s.push_back(num);
            // cerr << "break" << endl;
            break;
        }
        bool found = false;
        while(num%i ==0){
            num /= i;
            if(!found){
                s.push_back(i);
            }
            found = true;
        }
        i ++;
    }
    cout << 1 + s.size() << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;

int main(){
    ll n,x;
    cin>>n>>x;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll cnt=0;
    rep(i,n-1){
        if(a[i]+a[i+1]>x){
            if(a[i]<=x){
                cnt+=a[i+1]-(x-a[i]);
                a[i+1]=x-a[i];
            }else{
                cnt+=a[i+1]+(a[i]-x);
                a[i+1]=0;
                a[i]=x;
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = tuple(map(int,input().split()))

if(n <= 3):
    print(max(a))
    exit()

left = [0] * (n+1)
right = [0] * (n+1)

left[1] = a[0]
left[2] = max(a[0],a[1])
for i in range(3,n+1):
    if(i%2==0):
        left[i]  = max(left[i-3] + max(a[i-2], a[i-1]),
                        left[i-2] + a[i-1])
    else:
        left[i] = left[i-2] + a[i-1]

right[-2] = a[-1]
right[-3] = max(a[-1],a[-2])
for i in range(n-3,-1,-1):
    if((n-i)%2==0):
        right[i]  = max(right[i+3] + max(a[i+1], a[i]),
                        right[i+2] + a[i])
    else:
        right[i] = right[i+2] + a[i]

ans = left[-1]
for i in range(0,n-1 ):
    ans = max(ans, left[i] + right[i+2])

if(n%2==0):
    print(left[-1])
else:
    print(ans)

Measured memory_bytes: 99028
#include <bits/stdc++.h>
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int n;
     cin>>n;
     int A[n+1];
     A[0]=0;
     for(int i=1;i<n+1;i++)
     {
         cin>>A[i];
     }
     int count=0;
     for(int i=1;i<n+1;i++)
     {
         if(i%2!=0 && A[i]%2!=0)
         {
             count++;
         }
     }
     cout<<count<<endl;
}

Measured memory_bytes: 3580
N = int(input())
A = [int(x) for x in input().split()]
B = [int(y) for y in input().split()]
C = 0
B.append(0)
ans = 0
for i in range(N+1):
    if A[i]<=B[i]+C:
        ans = ans + A[i]
        if C >= A[i]:
            C = B[i]
        else:
            C = B[i] + C - A[i]
    else:
        ans = ans + B[i] + C
        C = 0
print(ans)

Measured memory_bytes: 19156
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=3e5+5;
const int mod=1e9+7;
void Inc(int &x,int y){
	x+=y;x>=mod?x-=mod:x;
}
/*
  0: 0
  1: 00
  2: 01
  3: 1
  4: 10
  5: 100
  6: 11
 */
int ls[]={1,0,0,4,5,4,6};
int rs[]={2,0,3,6,3,4,6};
char str[N];int n,f[N][7];
int main(){
	scanf("%s",str+1);n=strlen(str+1);
	if(str[1]!='1')f[1][0]=1;
	if(str[1]!='0')f[1][3]=1;
	for(int i=1;i<n;++i){
		if(str[i+1]!='1')
			for(int j=0;j<7;++j)
				Inc(f[i+1][ls[j]],f[i][j]);
		if(str[i+1]!='0')
			for(int j=0;j<7;++j)
				Inc(f[i+1][rs[j]],f[i][j]);
	}
	printf("%d\n",(f[n][3]+f[n][6])%mod);
	return 0;
}


Measured memory_bytes: 8704
f:: Int->Int->Int->Int->String
f a b c d
    |a-d<=c && c<=a+d="Yes"
    |(a-d<=b && b<=a+d) && (b-d<=c && c<=b+d)="Yes"
    |otherwise="No"

main = do
      x<-getLine
      let (a:b:c:d:[])=map read (words x)::[Int]
      putStrLn $ f a b c d

Measured memory_bytes: 508
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

string s;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>s;
    for(int i=0;i<s.size();++i){
        if(s[i]=='?') s[i]='D';
    }
    cout<<s<<endl;

    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;

int main()
{
    int K, A, B;
    cin >> K >> A >> B;
    for (int i = A; i <= B; i++)
    {
        if (i % K == 0)
        {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

    return 0;
}

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

using namespace std;
#define sz(x) (int)((x).size())
#define forn(i,n) for (int i=0; i < n; i++)
#define forse(i,s,e) for (int i=s; i < e; i++)
#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define time() ((double)clock() / CLOCKS_PER_SEC)

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

double PI=3.141592653589793;


void solve(){
	ll n;
	cin >> n;
	int ans=0;
	for(ll i=2;i*i<=n;i++){
		if(n%i) continue;
		int cnt=0;
		while(n%i==0){
			cnt++;
			n/=i;
		}
		int mx=0;
		while(((mx+1)*(mx+2))>>1<=cnt) mx++;
		ans+=mx;
	}
	if(n>1) ans++;
	cout << ans;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); 
	int T=1;
//	cin >> T;
	forse(c,1,T+1){
	//	cout << "Case #" << cid << ": ";
		solve();
	}
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      long n,a,b,c=0,ans=0;
      cin>>n;
      for(long i=1;i<=n;i++)
      {
        long temp=i,c=0;
        while(temp>0)
        {
          temp/=10;
          c++;
        }
        if(c & 1)
        {
          ans++;
        }
      }
      
      cout<<ans<<endl;
    }

Measured memory_bytes: 256