akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int p[210000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	std::sort(p,p+a);
reverse(p,p+a);
	long long ret=0;
	for(int i=0;i<a;i++){
		if(i<b);
		else ret+=p[i];
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 896
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
b=int(input())
print(a[b-1])

Measured memory_bytes: 38384
#include <algorithm>
#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()
#define ll long long
#define INF 1000000000000000000

long long GCD(long long a, long long b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

// LCM
long long LCM(long long a, long long b) { return a / GCD(a, b) * b; }

int main() {
    int N;
    cin >> N;
    ll lcm;
    rep(i, N) {
        ll a;
        cin >> a;
        if (i == 0)
            lcm = a;
        else
            lcm = LCM(lcm, a);
    }

    cout << lcm << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion


int32_t main() {
    make(double, a);
    cout << fixed << setprecision(10) << pow(a/3, 3);
    return 0;
}

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

int main(){
	vector<string>s(3);
	for(int i=0;i<3;++i){
		cin>>s.at(i);
		reverse(s.at(i).begin(),s.at(i).end());
	}
	char t='a';
	for(char t2;;){t2=t;
		if(s.at(t-'a').size()==0)break;
		t=s.at(t-'a').back();
		s.at(t2-'a').pop_back();
	}
	cout<<static_cast<char>(t-'a'+'A')<<"\n"s;
}

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

using std::cout;
using std::cin;
using std::endl;
using std::string;

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

    int op_num;
    cin >> op_num;

    string op;
    int first, last;
    while (op_num--) {
        cin >> op >> first >> last;
        int char_num = last - first + 1;

        if (op == "print") {
            cout << str.substr(first, char_num) << endl;
        } else if (op == "reverse") {
            string reversed;
            reversed.resize(char_num);
            for (int i = 0; i < char_num; i++) {
                reversed.at(i) = str.at(last - i);
            }
            str.replace(first, char_num, reversed);
        } else if (op == "replace") {
            string p;
            cin >> p;
            str.replace(first, char_num, p);
        } else {
            cout << "ERROR!" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;



int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,small=-1,big=0;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=0,start=0;
    //vector <int> v;
    //float f,g,h;
    char now,pre;
    //string a;
    cin>>m>>n;
    while(1)
    {
        if(m*2>n) break;
        else
        {
            sum++;
            m*=2;
        }
    }
    cout<<sum+1;
    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if ((N / 10)% 111 == 0 || (N % 1000)% 111 == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    puts(s == "abc" ? "Yes" : "No");
}

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

#define rep(i, a, b) for (int i = a, i##end = b; i <= i##end; ++i)
#define per(i, a, b) for (int i = a, i##end = b; i >= i##end; --i)
#define rep0(i, a) for (int i = 0, i##end = a; i < i##end; ++i)
#define per0(i, a) for (int i = (int)a-1; ~i; --i)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define chkmax(a, b) a = max(a, b)
#define chkmin(a, b) a = min(a, b)
#define x first
#define y second
#define enter putchar('\n')

typedef long long ll;
typedef double DB;

const DB eps = 1e-12;

int sgn(DB x) { return fabs(x) < eps ? 0 : (x > 0 ? 1 : -1); }

struct Point {
	DB x, y;
	Point(DB x = 0, DB y = 0) : x(x), y(y) {}
	Point operator + (Point a) { return Point(x + a.x, y + a.y); }
	Point operator - (Point a) { return Point(x - a.x, y - a.y); }
	Point operator - () { return Point(-x, -y); }
	friend Point operator * (DB k, Point a) { return Point(k * a.x, k * a.y); }
	DB operator % (Point a) { return x * a.x + y * a.y; }
	DB operator / (Point a) { return x * a.y - y * a.x; }
	operator DB() { return sqrt(x*x + y*y); }
};

Point gp() { Point a; scanf("%lf%lf", &a.x, &a.y); return a; }
void wp(Point a) { printf("%.10lf %.10lf ", a.x, a.y); }

struct Poly {
	std::vector<Point> a;
	Poly(int n = 0) { a.resize(n); rep0(i, n) a[i] = gp(); }
	Point &operator [] (int i) { int n = a.size(); return a[i >= n ? i-n : i]; }
};

Point Proj(Point P, Point P1, Point P2) { // Projection
	Point v = P2-P1; DB t = (P-P1)%v / (v%v);
	return P1 + t*v;
}

int Direct(Point P, Point P1, Point P2) { return sgn((P1-P)/(P2-P)); }

bool IsSegInter(Point P1, Point P2, Point Q1, Point Q2) {
	if (min(P1.x, P2.x) <= max(Q1.x, Q2.x) && max(P1.x, P2.x) >= min(Q1.x, Q2.x) && min(P1.y, P2.y) <= max(Q1.y, Q2.y) && max(P1.y, P2.y) >= min(Q1.y, Q2.y))
		if (Direct(P1, P2, Q1) * Direct(P1, P2, Q2) <= 0 && Direct(Q1, Q2, P1) * Direct(Q1, Q2, P2) <= 0) return 1;
	return 0;
}

Point GetSegInter(Point P1, Point P2, Point Q1, Point Q2) {
	Point v = P2-P1, w = Q2-Q1; DB t = (Q1-P1)/w / (v/w);
	return P1 + t*v;
}

int q;

int main() {
	scanf("%d", &q);
	while (q--) {
		Point P1 = gp(), P2 = gp(), Q1 = gp(), Q2 = gp();
		wp(GetSegInter(P1, P2, Q1, Q2)); enter;
		//printf("%d\n", IsInter(P1, P2, Q1, Q2));
		//wp(Proj(P, P1, P2)); enter;
	}
	return 0;
}


Measured memory_bytes: 3260
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
// typedef struct {
//     ll a;
//     ll b;
//     ll idx;
// } P;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll a[100010], b[100010];
    vector<lpair> tree[100010];
    rep(i,0,N-1){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        tree[a[i]].push_back({b[i], i});
        tree[b[i]].push_back({a[i], i});
    }
    ll K = 0;
    rep(i,0,N){
        K = max(K, (ll)tree[i].size());
    }
    print(K);
    ll used[100010] = {};
    map<ll,ll> mp[100010];
    ll colors[100010] = {};
    rep(i,0,N){
        ll color = 1;
        for(auto &e: tree[i]){
            if(used[e.second]) continue;
            used[e.second] = true;
            while(1){
                if(mp[i][color] == 0 && mp[e.first][color] == 0) break;
                color++;
            }
            mp[i][color]++;
            mp[e.first][color]++;
            colors[e.second] = color;
            color++;
        }
    }
    rep(i,0,N-1) print(colors[i]);






    

}

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

#define all(v) v.begin(),v.end()
#define pb push_back
#define ll long long
#define N 100007

vector<pair<int, int>> edges;
ll parent[N];
ll size[N];
vector<ll> ans;

int rootf(int x) {
    while(x!=parent[x]) {
        parent[x] = parent[parent[x]];
        x = parent[x];
    }
    return x;
}

ll fun(ll x) {
    return (x * (x - 1))/2;
}

ll unionf(int u, int v) {
    int p_u = rootf(u);
    int p_v = rootf(v);
    if(p_u == p_v) {
        return 0;
    } else {
        parent[p_v] = p_u;
        ll tmp = (size[p_u] * size[p_v]);
        size[p_u]+=size[p_v];
        return tmp;
    }
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    
    ll n, m, u, v;
    cin >> n >> m;

    for(int i=1; i<=n; i++) {
        parent[i] = i;
        size[i] = 1;
    }

    for(int i=1; i<=m; i++) {
        cin >> u  >> v;
        edges.push_back({u, v});
    }

    ll prev = fun(n);
    ans.pb(prev);
    reverse(all(edges));
    for(auto e : edges) {
        u = e.first;
        v = e.second;
        prev = prev - unionf(u, v);
        
        ans.pb(prev);
    }

    reverse(all(ans));
    ans.erase(ans.begin());
    for(auto i : ans) {
        cout << i << "\n";
    }

    return 0;
}


Measured memory_bytes: 4596
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
int BinarySearch(int key,int n,int S[]){
  int l=0,r=n;
  while(r-l>1){
    int mid=(l+r)/2;
    if(S[mid]>key)r=mid;
    else l=mid;
  }
  return S[l]==(key?1:0);
}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
  ll N,M,X,Y,x,y;
  cin >> N >>  M >> X >>Y;
  rep(i,N){
    cin >> x;
    X=max(x,X);
  }
  rep(i,M){
    cin >> y;
    Y=min(y,Y);
  }
  cout << (Y<=X ? "War" : "No War") <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n;
    cin >> n;
    if(n % 2 == 1)
    {
        cout << 0 << endl;
    }
    else
    {
        ll ans = 0;
        ll div = 10;
        while(n >= div)
        {
            ans += n/div;
            div *= 5;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010

int main(){
	IOS;
	ll n,m;cin>>n>>m;
	set<ll>s;rep(i,0,m){ll x;cin>>x;s.insert(x);}
	ll ans[n+1]={0};
	ans[0]=1;
	if(s.count(1))ans[1]=0;
	else ans[1]=1;
	rep(i,2,n+1){
		if(s.count(i))ans[i]=0;
		else ans[i]=(ans[i-1]+ans[i-2])%md;
	}
	cout<<ans[n]%md;
	
	return 0;
	
}



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

namespace AtConderBeginnerContest054
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            string szLine = Console.ReadLine();
            string[] szSplittedLine = szLine.Split(' ');
            int a = int.Parse(szSplittedLine[0]);
            int b = int.Parse(szSplittedLine[1]);

            // 1 を一番強くするためにオフセット
            const int kOffset = 13;
            if( a == 1) { a += kOffset; }
            if( b == 1) { b += kOffset; }

            string result = null;
            if( a == b)
            {
                result = "Draw";
            }else if( a > b)
            {
                result = "Alice";
            }else
            {
                result = "Bob";
            }
            Console.WriteLine(result);
        }
    }


}


Measured memory_bytes: 13140
s=input()

ans=0
while s!="":
    
    if s[-6:] =="eraser":
        s=s[:-6]
        
    elif s[-5:]=="dream":
        s=s[:-5]
        
    elif s[-7:]=="dreamer":
        s=s[:-7]
        
    elif s[-5:]=="erase":
        s=s[:-5]
        
    else:
        ans=1
        print("NO")
        break

if ans==0:
    print("YES")


Measured memory_bytes: 9180
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		long k = stdIn.nextLong();
		
		Map<Integer,Long> map = new TreeMap<>();
		
		for(int i = 0; i < n; i++) {
			int a = stdIn.nextInt();
			long b = stdIn.nextLong();
			if(!map.containsKey(a)) {
				map.put(a,b);
			}else {
				map.put(a,map.get(a)+b);
			}
		}
		
		long sum = 0;
		for(Integer key: map.keySet()) {
			if(sum + map.get(key) < k) {
				sum += map.get(key);
			}else {
				System.out.println(key);
				return;
			}
			
			
			
		}
		
		
		
	}

}


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int inf = 1e9;
const int maxn = 12;
const int maxm = 1e3+3;
int n,m, W[maxm], V[maxm], dp[maxm][1<<maxn];

int dfs(const int i, const int mask)
{
    if (i == m) 
        return mask+1 == (1<<n) ? 0 : inf;
    int& ans = dp[i][mask];
    if (-1 == ans) {
        ans = inf;
        ans = min(ans, W[i]+dfs(i+1,mask|V[i]));
        ans = min(ans, dfs(i+1,mask));
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    while (cin >> n >> m) {
        memset(dp,-1,sizeof(dp));
        FOR(i,0,m) {
            int a,b; cin >> a >> b;
            int value = 0;
            FOR(_,0,b) {
                int c; cin >> c; c--; value |= (1<<c);
            }
            V[i] = value;
            W[i] = a;
        }
        const int ans = dfs(0,0);
        cout << (ans < inf ? ans : -1) << endl;
    }
    return 0;
}


Measured memory_bytes: 16384
// #include <bits/stdc++.h>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<string>
#include<tuple>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline void                             in(T &p){cin>>p;}
template<class T1,class T2>inline void                   in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void          in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T>inline void                             ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
template<class T>inline void                             outs(T p){for_each(all(p),out<decltype(p[0])>);}
string N;
inline void solve(void){
  in(N);
  out(count(all(N),'2'));
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include<stdio.h>	

int main() {
	int a, b;
	scanf("%d %d", &a, &b);

	if (a < b)
		printf("a < b\n");
	else if (a == b)
		printf("a == b\n");
	else
		printf("a > b\n");
	return 0;
}

Measured memory_bytes: 580
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007
 
ll d[210][210];
 
int main(){
	ll n;
	cin>>n;
	clr(d,-1);
	rep(i,0,40){
		string s;
		rep(j,0,200){
			s += "0";
		}
		rep(j,i*5,i*5+5){
			s[j] = '1';
		}
		cout << "?" << " " << s << endl;
		ll ans1;
		cin>>ans1;
		if(ans1==0){
			rep(j,i*5,i*5+5){
				rep(k,i*5+1,i*5+5){
					d[j][k] = 0;
				}
			}
		}
	}
	rep(i,0,n){
		rep(j,i+1,n){
			if(d[i][j]!=-1)continue;
			string s1;
			rep(l,0,n){
				if(l==i||l==j)s1+="1";
				else s1+="0";
			}
			cout << "?" << " " << s1 << endl;
			ll ans1;
			cin>>ans1;
			if(ans1==1){
				d[i][j] = 1;
			}
			else{
				d[i][j] = 0;
			}
		}
	}
	cout << "! ";
	vector<pair<ll,ll> > v;
	rep(i,0,200){
		rep(j,i+1,200){
			if(d[i][j] == 1){
				v.pb(mp(i,j));
			}
		}
	}
	rep(i,0,v.sz){
		cout << "(" << v[i].fi << "," << v[i].se << ")";
		if(i!=v.sz-1)cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1236
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g;
    cin>>n;
    cout<<"ABC"<<n<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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 int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    string s;
    cin >> n >> s;
    n%=26;
    for(int i = 0; i < (int)s.size(); i++) {
        int now = s[i]-'A';
        if(now+n>=26){
            s[i] = (char)(s[i]+n-26);
        }else{
            s[i] = (char)(s[i]+n);
        }
    }
    cout << s << endl;
}

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

int main() {
	vector<int> p(5);
	for (int i = 0; i < 5; i++) cin >> p.at(i);
	
	for (int j = 0; j < 5; j++) {
		if (p.at(j) == 0) {
			cout << j + 1 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3520
#include <iostream>
#include <vector>

using namespace std;

typedef vector<int> V;

int main() {
    int n;
    cin >> n;
    V v = V(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    int q;
    cin >> q;
    int c = 0;
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        for (int j : v) {
            if (t == j) {
                c++;
                break;
            }
        }
    }
    cout << c << "\n";
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
     
     
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
#define pld(x) printf("%lld\n",x)
#define pd(x) printf("%d\n",x)
     
     
int main(){
            
    int n , k;
    sd(n); sd(k);

    pd(n-k+1); 
     
        
    return 0;
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int H, W;

int main(void) {
    cin >> H >> W;
    vector<vector<int>> g(H, vector<int>(W));

    int N;
    cin >> N;
    vector<int> a(N + 1);
    REP(i, 1, N + 1) {
        cin >> a[i];
    }

    int px = 0;
    int py = 0;
    int dx = 1;
    int dy = 0;
    int col = 1;
    int col_c = 0;
    while (px < W && py < H) {

        g[py][px] = col;
        col_c++;
        if (col_c >= a[col]) {
            col++;
            col_c = 0;
        }

        // 方向転換
        int tried = 0;
        while (px + dx >= W || py + dy >= H || px + dx < 0 || py + dy < 0 || g[py + dy][px + dx] != 0) {
                if (tried >= 4) break;
                if (dx == 1) {
                    dx = 0; dy = 1;
                }
                else if (dy == 1) {
                    dx = -1; dy = 0;
                }
                else if (dx == -1) {
                    dx = 0; dy = -1;
                }
                else if (dy == -1) {
                    dx = 1; dy = 0;
                }

                tried++;
        }

        if (tried >= 4) break;
        px += dx; py += dy;
    }

    rep(y, H) {
        rep(x, W) {
            cout << g[y][x];
            if (x < W - 1) cout << " ";
        }

        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

// author:Swastik Banerjee

using namespace std;

typedef long long ll;
#define MOD 1000000007

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



  string s;
  cin >> s;

  string s1, s2;

  for (int i = 0; i < s.size() / 2; i++) {
    s1 += s[i];
  }

  for (int i = s.size() / 2 + 1; i < s.size(); i++) {
    s2 += s[i];
  }

  string check1 = s;
  reverse(s.begin(), s.end());
  string check2 = s1;
  reverse(s1.begin(), s1.end());
  string check3 = s2;
  reverse(s2.begin(), s2.end());

  if (check1 == s && check2 == s1 && check3 == s2)
    cout << "Yes";
  else
    cout << "No";
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define int          long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define repr(i,x,m)  for(int i=x;i>=m;i--)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define pi           pair<int,int>
#define sz(x)       (int)x.size()
#define pq           priority_queue<int>
#define pqs          priority_queue<int,vi,greater<int> >
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define FIO         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int fac[2000005]={0};
void factorial(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=((i%MOD)*(fac[i-1]%MOD))%MOD;}
int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}
int ncr(int n,int r){return ((fac[n]*power(fac[r],MOD-2))%MOD*power(fac[n-r],MOD-2))%MOD;}

void ram5564()
{
     int r,g,b,k;
     cin>>r>>g>>b;
     cin>>k;
     int cnt=0;
     while(g<=r)
     {
     	g*=2;++cnt;
     }
     while(b<=g)
     {
     	b*=2;++cnt;
     }
     if(cnt<=k)
     {
     	cout<<"Yes";return;
     }
     cout<<"No";

}

signed main()
{
        FIO
        
        
        int t=1;
        //cin>>t;
        while(t--)
        ram5564();
        cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;

        return 0;
}

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

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

  int N;
  long double ans = 0;
  
  cin >> N;
  for(int i = 0; i < N; ++i){
    long double a;
    cin >> a;
    ans += 1/a;
  }
  
  cout << 1/ans <<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {

	int fnit[10];
	int i = 0;

	int top = 0;
	int second = 0;
	int third = 0;

	for(i = 0; i < 10; i++) {
		scanf("%d", &fnit[i]);
	}

	/* トップを求める処理 */

	top = fnit[0];

	for(i = 1; i <= 9; i++) {

		if( top < fnit[i] ) {
			third = second;
			second = top;
			top = fnit[i];
		}
		else if (second < fnit[i]) {
			third = second;
			second = fnit[i];
		}
		else if(third < fnit[i]) {
			third = fnit[i];
		}
	}

	/* --- */

	printf("%d\n", top);
	printf("%d\n", second);
	printf("%d\n", third);


	return 0;
}

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

using namespace std;
using ll = long long;


//x番目のゴーレムを落とせるかを考える
bool checkLeft(int x, int k, string &s, vector<char> &t, vector<char> &d) {
	for (int i = 0; i < t.size(); i++)
	{
		if (t[i] == s[x])
		{
			x += (d[i] == 'L' ? -1 : 1);
		}

		if (s[x] == '_')
		{
			return x == k;
		}
	}
	return false;
}

int main() {
	int N, Q;
	string s;
	cin >> N >> Q;
	cin >> s;
	vector<char> t(Q);
	vector<vector<char>> d(2, vector<char>(Q));

	s = '_' + s + '_';

	for (int i = 0; i < Q; i++)
	{
		cin >> t[i] >> d[0][i];
		d[1][i] = (d[0][i] == 'L' ? 'R' : 'L');
	}

	int golem = N;
	for (int i = 0; i < 2; i++)
	{
		int lb = 0, m, ub = N + 1;
		while (ub - lb > 1) {
			m = (ub + lb) / 2;
			(checkLeft(m, 0, s, t, d[i]) ? lb : ub) = m;
		}

		golem -= lb;

		reverse(s.begin(), s.end());
	}

	cout << golem << endl;

	return 0;
}

Measured memory_bytes: 1284
#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    int N, A, B;
    cin >> N;
    cin >> A;
    cin >> B;
    
    int densya = N * A;
    if (densya > B) {
        cout << B << endl;
    }else {
        cout << densya << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n, minv, maxv = -1000000000, r;
    cin >> n;
    cin >> minv;
    for(int i = 1; i < n; ++i){
        cin >> r;
        maxv = max(maxv, r-minv);
        minv = min(minv, r);
    }
    cout << maxv << endl;
}



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

#define ll long long
int n,k,l[50],ans = 0;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>l[i];
	}
	sort(l, l+n, greater<int>());
	for(int i=0;i<k;i++){
		ans += l[i];
	}
	cout<<ans;
	return 0;
}

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

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

  if ("Sunny" == S) {
    cout << "Cloudy" << endl;
  }
  if ("Cloudy" == S) {
    cout << "Rainy" << endl;
  }
  if ("Rainy" == S) {
    cout << "Sunny" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 100000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,K;
vector<int> g[4010];
int dist[4010];
void add_edge(int a,int b){
	g[a].pb(b);
	g[b].pb(a);
}
void dfs(int v,int p,int d){
	dist[v]=d;
	for(int i=0;i<g[v].size();i++){
		if(g[v][i]==p)continue;
		dfs(g[v][i],v,d+1);
	}
}
int main(){
	cin >> N >> K;
	for(int i=0;i<N-1;i++){
		int A,B;
		cin >> A >> B;
		A--;B--;
		add_edge(A,N+i);
		add_edge(N+i,B);
	}
	int ans = N;
	for(int i=0;i<=2*N-2;i++){
		memset(dist,0,sizeof(dist));
		dfs(i,-1,0);
		int cnt = 0;
		for(int j=0;j<N;j++){
			if(dist[j]>K)cnt++;
		}
		ans = min(ans,cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>

int main(void) {
  int H, W;
  char **s;
  scanf("%d%d", &H, &W);
  s = (char**)malloc(sizeof(char*) * H);
  for (int i = 0; i < H; i++) {
    getchar();
    s[i] = (char*)malloc(sizeof(char) * W);
    for (int j = 0; j < W; j++) {
      scanf("%c", &s[i][j]);
    }
  }

  for (int j = 0; j < H; j++) {
    for (int i = 0; i < W; i++) {
      int cnt = 0;
      if (s[j][i] != '#') continue;
      if (i >= 1 && s[j][i-1] == '#') cnt++;
      if (j >= 1 && s[j-1][i] == '#') cnt++;
      if (i <= W-2 && s[j][i+1] == '#') cnt++;
      if (j <= H-2 && s[j+1][i] == '#') cnt++;
      if (cnt == 0) {
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<queue>
#include<vector>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
bool is_returns(string s){
    string t(s.rbegin(),s.rend());
    return s==t;
}

int main(){
    string s;
    
    cin >> s;
    int n=s.size();
    if(is_returns(s) && is_returns(s.substr(0,(n-1)/2)) && is_returns(s.substr((n+1)/2))){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
return 0;
}

Measured memory_bytes: 256
from sys import setrecursionlimit

def find(par,i):
    if par[i]<0:
        return i
    par[i] = find(par,par[i])
    return par[i]

def unite(par,i,j):
    ri = find(par,i)
    rj = find(par, j)
    if ri==rj:
        return
    par[rj] += par[ri]
    par[ri] = rj
    
setrecursionlimit(10**6)
n,m = map(int,input().split())

parent = [-1]*n
for _ in range(m):
    a,b = map(lambda x:int(x)-1,input().split())
    unite(parent,a,b)
    
print(-min(parent))

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

typedef vector<int> vi;

int M,T,P,R;
int m,t,p,j;
vi team[60];
int pena[60][20];

int main(){
  while(cin >> M >> T >> P >> R,M){
    for(int i=0;i<T;i++){
      team[i].resize(3);
      team[i][0] = team[i][1] = 0; team[i][2] = -i-1;
      for(int j=0;j<P;j++)pena[i][j] = 0;
    }

    for(int i=0;i<R;i++){
      cin >> m >> t >> p >> j;
      t--; p--;
      if(j==0){
	team[t][0]--;
	team[t][1] += pena[t][p]*20 + m;
      }else pena[t][p]++;
    }

    sort(team,team+T);

    for(int i=0;i<T;i++){
      cout << -team[i][2];
      if(i==T-1)cout << endl;
      else{
	if(team[i][0] == team[i+1][0] && team[i][1] == team[i+1][1])
	  cout << "=";
	else
	  cout << ",";
      }
    }
  }
}

Measured memory_bytes: 1228
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		while(true) {
			String str = sc.next();
			if(str.equals("-")) {
				break;
			}
			int m = sc.nextInt();
			for(int i = 0;i < m;i++) {
				int h = sc.nextInt();
				str = str.substring(h) + str.substring(0,h);
			}
			System.out.println(str);
		}
    }
}


Measured memory_bytes: 26352
import std.stdio, std.string, std.conv, std.range, std.algorithm;

void main() {
  auto w = readln.chomp;
  int[char] char_count;
  foreach (c; w) {
    char_count[c]++;
  }

  if (char_count.values.all!"a % 2 == 0") {
    "Yes".writeln;
  } else {
    "No".writeln;
  }
}

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

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

    string s,ar[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    cin>>s;
    for(int i=0;i<7;i++){
        if(s==ar[i]){
            cout<<7-i<<endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 764
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main(){

	int N, a[3000], s = 0;
	scanf("%d", &N);
	REP(i, N){
		scanf(" %d", &a[i]);
		s += (a[i] - 1);
	}
	printf("%d\n", s);

	return 0;
}

Measured memory_bytes: 256
n = int(input())
B = list(map(int,input().split()))

ans = []
while B:
    for i,v in enumerate(B[::-1]):
        if len(B)-i == v:
            a = B.pop(len(B)-i-1)
            ans.append(a)
            break
    else:
        break
if not B:
    print(*ans[::-1],sep='\n')
else:
    print(-1)

Measured memory_bytes: 63976
#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, K = getlist()
	A = getlist()
	for i in range(N):
		A[i] -= 1

	B = [0]
	for i in range(N):
		B.append(B[-1] + A[i])
	for i in range(N + 1):
		B[i] %= K

	ans = 0
	D = defaultdict(int)
	x = min(N + 1, K)
	for i in range(x):
		ans += D[B[i]]
		D[B[i]] += 1
	for i in range(x, N + 1):
		D[B[i - K]] -= 1
		ans += D[B[i]]
		D[B[i]] += 1
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 111524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
int n = 10;
int a,b,c;
vector<int> L(n);
int ans = INF;

void dfs(int i,int ca,int cb,int cc,int la,int lb,int lc,vector<int> used){
  if(i == n){
    if(ca == 0 || cb == 0 || cc == 0) return;
    ans = min(ans,abs(la-a)+abs(lb-b)+abs(lc-c)+10*(ca+cb+cc-3));
  }else{
    dfs(i+1,ca,cb,cc,la,lb,lc,used);
    used.at(i) = 1;
    dfs(i+1,ca+1,cb,cc,la+L.at(i),lb,lc,used);
    dfs(i+1,ca,cb+1,cc,la,lb+L.at(i),lc,used);
    dfs(i+1,ca,cb,cc+1,la,lb,lc+L.at(i),used);
    
  }
}

int main() {
  cin >> n >> a >> b >> c;
  rep(i,n) cin >> L.at(i);
  vector<int> used(n,0);
  dfs(0,0,0,0,0,0,0,used);
  cout << ans << endl;
  return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef  long long ll;
int main(void){
    string S;
    cin >> S;
    ll cnt[2]={};
    rep(i,S.length()){
        cnt[S[i]%2]++;
    }
    cout << min(cnt[1],cnt[0])*2 << endl;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int n;
int p[125252];
int ans[125252];

map<int,queue<int>> Q;

int data[125252];
void init(){REP(i,n)data[i]=-1;}
int next(int x){return data[x]<0?x:data[x]=next(data[x]);}
void unite(int x){
  int y = (x+1)%n;
  y = next(y);
  data[y] += data[x];
  data[x] = y;
}

int main(){
  scanf("%d",&n);
  init();
  REP(i,n){
    scanf("%d",p+i);
    --p[i];
    Q[p[i]].push(i);
  }
  REP(i,n)ans[i]=-1;
  int rest = n;

  priority_queue<pii> S;
  for(auto &P : Q){
    S.push(pii(-0, -P.first));
  }
  while(!S.empty()){
    pii P = S.top(); S.pop();
    int id = -P.second;
    int shft = -P.first;
    int pos = (id+shft)%n;
    if(ans[pos]==-1){
      ans[pos] = Q[id].front(); Q[id].pop();
      --rest;
      if(rest)unite(pos);
    }
    if(Q[id].size()){
      int to = next(pos);
      int nsft = (to-id+n)%n;
      S.push(pii(-nsft,-id));
    }
  }
  REP(i,n)printf("%d\n",ans[i]+1);

  return 0;
}

Measured memory_bytes: 50036
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define MOD 1000000007
typedef long long ll;
using namespace std;

vector<ll> to[200005];
vector<ll> ans;

void dfs(ll v, ll p=-1)
{
	for (ll u : to[v]) {
    	if (u == p) continue;
      	ans[u] += ans[v];
      	dfs(u, v);
    }
}

int main()
{
	ll N, Q; cin >> N >> Q;
  	for (ll i = 0; i < N - 1; i++) {
      	ll a, b; cin >> a >> b;
      	a--; b--;
      	to[a].push_back(b);
      	to[b].push_back(a);
    }
  	ans.resize(N);
  	for (ll i = 0; i < Q; i++) {
    	ll p, x; cin >> p >> x;
      	p--;
      	ans[p] += x;
    }
  	dfs(0);
  	for (ll i = 0; i < N; i++) {
    	cout << ans[i] << " ";
    }
}

Measured memory_bytes: 24320
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
using namespace std;

int main() {
  int N;
  cin>>N;
  vector<int> V(N);
  for(int i = 0; i < N; i++) cin>>V[i];
  vector<int> C(N);
  for(int i = 0; i < N; i++) cin>>C[i];
  int sum; sum = 0;
  for(int i = 0; i < N; i++) if(V[i]-C[i] > 0) sum += V[i]-C[i];
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int n;
int main()
{
    cin>>n;
    for(int i=sqrt(n);i>=1;i--)
    {
        if(n%i==0)
		{
            int t=i,l=n/i;
            int s=1;
            while(l>=10)
			{
                s++;
                l/=10;
            }
        cout<<s;
        return 0;
        }
    }
}

Measured memory_bytes: 256
solve :: [Int] -> Int
solve (d:n:_) =
    let li = filter (\x -> x `mod` 100^d == 0 && x `mod` 100^(d + 1) > 0) [1..1010000]
    in li !! (n - 1)

main :: IO ()
main = do
    n <- fmap (read :: String -> Int) . words <$> getLine
    (putStrLn . show . solve) n

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

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;

bool custom1 (pii a, pii b) {
  return a.first < b.first;
}

bool custom2 (pii a, pii b) {
  return a.second < b.second;
}

const int MOD = 1000000007;

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

  if(a == b) {
    for(int i=0;i<a;i++) {
      cout << b;
    }
    cout << endl;
  } else if( a > b ) {
    rep(i, a) cout << b;
    cout << endl;
  } else {
    rep(i, b) cout << a;
    cout << endl;
  }
}

Measured memory_bytes: 256