akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int n, x;
  cin >> n >> x;
  vector<int> m(n);
  REP(i, n) cin >> m[i];
  sort(ALL(m));
  int ans = n;
  REP(i, n) x -= m[i];
  ans += x / m[0];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
	string str;
	cin >> str;
	for (int i = 0; i < str.length(); i += 2) {
		cout << str[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 512
n,k = gets.chomp.split.map(&:to_i)
hs = gets.chomp.split.map(&:to_i)
dp = Array.new(n,10**18)
dp[0] = 0
0.upto(n-1) do|i|
  1.upto(k) do |j|
    if i+j < n && dp[i+j] > dp[i] + (hs[i] - hs[i+j]).abs
      dp[i+j] = dp[i] + (hs[i] - hs[i+j]).abs
    end
  end
end
puts dp[n-1]

Measured memory_bytes: 9484
import java.math.BigDecimal;
import java.util.*;
import java.util.regex.Pattern;
public class Main {
  public static void main(String[] args){
    new Main().run();
  }

  void run() {
    Scanner sc = new Scanner(System.in);
    BigDecimal A = new BigDecimal(sc.next());
    BigDecimal B = new BigDecimal(sc.next().replace(".", ""));
    BigDecimal mul = A.multiply(B);
    String ans = A.multiply(B).toPlainString();
    if (mul.compareTo(new BigDecimal(100)) < 0) {
      ans = "0";
    }
    int len = ans.length();
    if (2 < len) {
      ans = ans.substring(0, ans.length() - 2);
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 36008
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//227
	string a,b;
	cin>>a>>b;
	vector<string> v;
	REP(i,0,(int)a.length()-(int)b.length()) {
		bool h = true;
		REP(j,0,(int)b.length()-1) {
			if(b[j]!=a[i+j]&&a[i+j]!='?') {
				h=0;
				break;
			}
		}
		if(h) {
			string tem = a;
			REP(j,0,(int)b.length()-1) {
				tem[i+j]=b[j];
			}
			REP(j,0,(int)a.length()-1){
				if(tem[j]=='?')tem[j]='a';
			}
			v.PUB(tem);
		}
	}
	if(v.size()>0){
		sort(v.begin(),v.end());
		cout<<v[0];
	} else
	cout<<"UNRESTORABLE";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3672
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;

LL n,m,h,w;
LL val[505][505] = {0};

int main(){
	cin >> n >> m >> h >> w;
	if(!(n % h || m % w)){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	for(LL i = h;i <= n;i += h)
		for(LL j = w;j <= m;j += w)
			val[i][j] = - (h * w * 1000 - 999);
	for(LL i = 1;i <= n;i ++)
		for(LL j = 1;j <= m;j ++)
			cout << (val[i][j] ? val[i][j] : 1000) << (j == m ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
char s[5];
int main(){
    cin>>s+1;
    int x=0;
    for(int i=1;i<=2;++i){
        x*=10;
        x+=s[i]-'0';
    }
    int y=0;
    for(int i=3;i<=4;++i){
        y*=10;
        y+=s[i]-'0';
    }
    int flag=0;
    int flag2=0;
    if(x>=1&&x<=12)
        flag=1;
    if(y>=1&&y<=12)
        flag2=1;
    if(flag&&flag2)
        cout<<"AMBIGUOUS";
    else if(flag&&!flag2)
        cout<<"MMYY";
    else if(!flag&&flag2)
        cout<<"YYMM";
    else if(!flag&&!flag2)
        cout<<"NA";
    return 0;
}



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

s=0
if(A[0]>x):
    s+=A[0]-x
    A[0]=x

for i in range(N-1):
    if(A[i+1]>x):
        s+=A[i+1]-x
        A[i+1]=x
    if(A[i]+A[i+1]>x):
        t=A[i]+A[i+1]-x
        s+=t
        A[i+1]-=t

print(s)

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    int n,k; cin >> n >> k;
    vector<int> p(n), c(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> c[i];
    rep(i,n) p[i]--;
    ll ans = -INF;
    rep(si,n) { //スタート位置全探索
        int x = si;
        vector<int> s; //サイクルの得られるスコアを格納
        ll tot = 0; //サイクルの総和
        while (1) {
            x = p[x];
            s.push_back(c[x]);
            tot += c[x];
            if (x == si) break; //始点に戻ってきたら終了
        }
        int l = sz(s); //周期の長さ
        ll t = 0;
        rep(i,l) { //サイクルを回っていく
            t += s[i];
            if (i+1>k) break;
            ll now = t;
            if (tot>0) { //サイクル総和正なら足せるサイクル分足す
                ll e = (k-(i+1))/l;
                now += tot*e;
            }
            chmax(ans,now);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3696
#include "bits/stdc++.h"

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;
const long double PI = (acos(-1));
const ull MOD = 1000000007;


struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

vector<vector<ll>> C(10, vector<ll>(10));
void warshall_floyed(int n){
    for(int k = 0; k < n; k++){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++) C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
        }
    }
}
int main() {
    int H, W;
    cin >> H >> W;
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++) cin >> C[i][j];
    }
    ll res = 0;
    warshall_floyed(10);
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            int A;
            cin >> A;
            if(A >= 0) res += C[A][1];
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
#define int long long

signed main(){
        int a;
        while( scanf("%lld", &a) != EOF ){
                int ans = 0;
                for(int i=0;i<10;i++)
                        for(int j=0;j<10;j++)
                                for(int k=0;k<10;k++)
                                        for(int l=0;l<10;l++)
                                                if(i+j+k+l==a) ans++;

                printf("%lld\n",ans);
        }
        return 0;
}

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

const int MAX = 100005;

int main() {
    string S, T;
    int q, a, b, c, d;
    int s[MAX], t[MAX];

    cin >> S >> T >> q;
    s[0] = t[0] = 0;
    for (int i = 1; i <= S.size(); i++) {
        if (S[i-1] == 'A') s[i] = s[i-1] + 1;
        else s[i] = s[i-1] + 2;
    }
    for (int i = 1; i <= T.size(); i++) {
        if (T[i-1] == 'A') t[i] = t[i-1] + 1;
        else t[i] = t[i-1] + 2;
    }

    for (int i = 0; i < q; i++) {
        cin >> a >> b >> c >> d;
        if ((s[b] - s[a-1]) % 3 ==  (t[d] - t[c-1]) % 3) {
            printf("%s\n", "YES");
        } else {
            printf("%s\n", "NO");
        }
    }

    return 0;
}

Measured memory_bytes: 1664
a = [0,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]

print(a[int(input())])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;

int n;
ll a[310][310];
int ok[310][310];

int main(){
    bool flag = true;
    cin>>n;
    for(int i=0;i<n;i++){
        for (int j = 0; j < n;j++)
        {
            cin>>a[i][j];
            if(i<j)ok[i][j] = 1;
        }  
    }

    for (int k = 0; k < n; k++)
    {
        for (int i = 0; i < n-1; i++)
        {
            for (int j = i+1; j < n; j++)
            {
                if(a[i][j] == a[i][k]+a[k][j]&&k!=i&&k!=j) {ok[i][j]=0;}
                else if(a[i][j] > a[i][k]+a[k][j]) {flag = false;break;}
            }       
        }
    }
    if(!flag){cout<<-1<<endl;return 0;}
    ll sum=0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if(ok[i][j])sum += a[i][j];
        }    
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1280
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int dm = 1400000;
char dn[dm], * di = dn;
const int MAX = 20000;
class unko {
public:
	char C[MAX * 7 + 10], *K[MAX + 10];
	constexpr unko() : C(), K() {
		auto di = C + 3;
		C[0] = '0';
		C[0] = ' ';
		C[0] = '\n';
		K[0] = C;
		K[1] = di;
		rep1(i, MAX) {
			int X = i;
			int keta = 0;
			char c[10] = {};
			while (X) {
				*(c + keta) = '0' + X % 10;
				X /= 10;
				keta++;
			}
			for (int j = keta - 1; j >= 0; j--)* di++ = (*(c + j));
			*di++ = ' ';
			*di++ = '\n';
			K[i + 1] = di;
		}
	}
};
constexpr unko f;
inline void putint(int X) {
	if (X > 20000) {
		int ue = X / 10;
		for (auto i = f.K[ue]; *i != ' '; i++) *di++ = *i;
		*di++ = '0' + X % 10;
		*di++ = ' ';
	}
	else for (auto i = f.K[X]; *i != '\n'; i++)* di++ = *i;
}

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


	int N = getint(), K = getint();

	int A[200001];
	rep(i, N) A[i] = getint();
	ll owa = ll(N) * N;

	rep(p, K) {
		int B[200001] = {};
		rep(i, N) {
			B[max(0, i - A[i])]++;
			B[min(N, i + A[i] + 1)]--;
		}
		ll kei = B[0];
		A[0] = B[0];
		rep1(i, N - 1) {
			kei += (A[i] = A[i - 1] + B[i]);
		}
		if (kei == owa) break;
	}

	rep(i, N) putint(A[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 6240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 1e5+5;
struct dao{
	int a,b;	
}ss[N];

vector<int>bb;
bool cmp(dao x,dao y)
{
	return x.a>y.a;
}
int main()
{
	//int a,b,c;
	int n,h;
	scanf("%d%d",&n,&h);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&ss[i].a,&ss[i].b);
		bb.pb(ss[i].b);
	}
	sort(ss+1,ss+1+n,cmp);
	sort(bb.begin(),bb.end());
	int st=-1;
	for(int i=bb.size()-1;i>=0;i--)
	{
		if(ss[1].a>bb[i])
		{
			st=i;
			break;
		}
	}
	//de(st);
	int ans=0;
	int topb=bb.size()-1;
	while(h>0)
	{
	//	de(topb);
		if(topb>st)
		{
			h-=bb[topb];
		//	de(topb);
		//	de(bb[topb]); 
			topb--;
			ans++;
			if(h<=0) break;
		}
		else
		{
			int tmp=h/ss[1].a;
			if(h%ss[1].a!=0) tmp++;
			ans+=tmp;
			break;
		}
	}
	cout<<ans<<endl;
	
	return 0;
} 

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    bool use[26] = {};
    REP(i,s.length()){
        if(use[s[i] - 'a'] == true){
            cout << "no" << endl;
            return 0;
        }
        use[s[i] - 'a'] = true;
    }
    cout << "yes" << endl;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	int A, B, C;
	cin >> A >> B >> C;

	if (A != B && B != C && C != A || A == B && B == C)cout << "No" << "\n";
	else cout << "Yes" << "\n";

	return 0;
}

Measured memory_bytes: 256
// AtCoder Group Contest
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int N;
    long long int su = 0;
    cin >> N;
    vector<int> a(3*N);
    for (int i = 0; i < 3*N; i++) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());

    for (int i = 1; i < 2*N; i=i+2) {
        su += a[i];
    }
    cout << su << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	int a,b,c,d;
	a=s[0]-'0';
	b=s[1]-'0';
	c=s[2]-'0';
	d=s[3]-'0';
//	int res=a+b+c+d;
	if (a+b+c+d==7)
	{
		cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7";
		return 0;
	}
	if (a+b+c-d==7)
	{
		cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7";
		return 0;
	}
	if (a+b-c+d==7)
	{
		cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7";
		return 0;
	}
	if (a+b-c-d==7)
	{
		cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7";
		return 0;
	}
	if (a+b+c-d==7)
	{
		cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7";
		return 0;
	}
	if (a-b+c+d==7)
	{
		cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7";
		return 0;
	}
	if (a-b+c-d==7)
	{
		cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7";
		return 0;
	}
	if (a-b-c+d==7)
	{
		cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7";
		return 0;
	}
	if (a-b-c-d==7)
	{
		cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7";
		return 0;
	}
	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;
using P = pair<int, int>;

int main() {

    int N;
    cin >> N;

    int ans = 0;

    for (int i = 1; i <= N; ++i)
    {
        if (to_string(i).size() % 2 == 1)
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    double ans = 0;
    rep(i, N) {
        double num;
        string s;
        cin >> num >> s;
        if(s == "BTC") {
            num *= 380000;
        }
        ans += num;
    }

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

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

int main(){
	string n,m; cin>>n;
	m=n;
	reverse(n.begin(),n.end());
	if(n==m) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 3588
from collections import deque

S = deque(input())
Q = int(input())
rev = False
for _ in range(Q):
    s = input().split()
    if len(s) == 1:
        rev = not rev
        continue
    if not rev:
        if s[1] == '1':
            S.appendleft(s[2])
        else:
            S.append(s[2])
    else:
        if s[1] == '1':
            S.append(s[2])
        else:
            S.appendleft(s[2])
if rev:
    print(''.join(reversed(S)))
else:
    print(''.join(S))

Measured memory_bytes: 8692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
const int N=100;
const int W=10000;
int n,w,v[N],wi[N];
int dp[N+1][W+1];


int rec(int i,int j){
	if(dp[i][j]!=-1){
		return dp[i][j];
	}
	int res;
	if(i==n){
		res=0;
	}else if(j<wi[i]){
		res=rec(i+1,j);
	}else{
		res=max(rec(i+1,j),rec(i+1,j-wi[i])+v[i]);
	}
	return dp[i][j]=res;
}



int main(){
	FOR(i,0,N+1)FOR(j,0,W+1)dp[i][j]=-1;
	cin>>n>>w;
	FOR(i,0,n){
		cin>>v[i]>>wi[i];
	}
	cout<<rec(0,w)<<endl;
	return 0;
}


Measured memory_bytes: 7056
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin>>s;
  if(((s[0]==s.back())+sz(s))%2==0)
    cout<<"Second"<<endl;
  else
    cout<<"First"<<endl;
  return 0;
}


Measured memory_bytes: 512
n=input()
if n=="SUN":
    print(7)
elif n=="MON":
    print(6)
elif n=="TUE":
    print(5)
elif n=="WED":
    print(4)
elif n=="THU":
    print(3)
elif n=="FRI":
    print(2)
elif n=="SAT":
    print(1)

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  double ans = 0;
  for(int i = 1; i <= N; i++){
    int num = i;
    double cnt = 1;
    while(num < K){
      num *= 2;
      cnt = cnt / 2.0;
    }
    ans += 1.0/N*cnt;
  }
  printf("%.10f\n",ans);
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;

ll power(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) {
            res = (res * a) % mod;
        }
        a = (a * a) % mod;
        n /= 2;
    }
    return res;
}

ll inv(ll x) {
    return power(x, mod - 2);
}

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<ll> pr(n + 1);
    pr[0] = 0;
    for (int i = 1; i <= n; ++i) {
        pr[i] = (pr[i - 1] + inv(i)) % mod;
    }
    ll res = 0;
    for (int i = 0; i < n; ++i) {
        res = (res + a[i] * (pr[i + 1] + pr[n - i] - 1 + mod)) % mod;
    }
    for (int i = 0; i < n; ++i) {
        res = (res * (i + 1)) % mod;
    }
    cout << res << endl;
}

//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void) {
  string s;
  string ans;
  cin >> s;
  if('S' == s[0]) {
    ans = "Cloudy";

  } else if('C' == s[0]) {
    ans = "Rainy";
  } else {
    ans = "Sunny";
  }
  cout << ans;
  return 0;
}

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

int main() {
  int N;
  int cnt = 0;
  string S;
  cin >> N >> S;

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void  main(String[]  args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();
		int sum = a+b;
		if(x <= sum && x >= a){
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 21844
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

a,b,k = i2()
if b - (a-1) <= 2*k:
	for i in range(a,b+1):
		print(i)
else:
	for i in range(k):
		print(a+i)
	for i in range(-k+1,1):
		print(b+i)

Measured memory_bytes: 9204
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(X: int, Y: int):
    if X % Y == 0:
        print(-1)
        return
    else:
        print(X)
        return
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 

// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }

const ll mod = 1e9+7;

ll dp[100005][13];

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
 
    string s; cin >> s;
    int slen = s.size();

    vector<int> mod13(100005, 0);
    mod13[0] = 1;
    for(int i=1; i<100005; ++i){
        mod13[i] = mod13[i-1]*10%13;
    }

    if(s[slen-1] == '?'){
        for(int i=0; i<10; ++i) dp[0][i] = 1;
    }
    else dp[0][s[slen-1]-'0'] = 1;

    for(int i=1; i<slen; ++i){
        if(s[slen-1-i] == '?'){
            for(int d=0; d<10; ++d){
                ll add = d*mod13[i]%13;
                for(int j=0; j<13; ++j){
                    dp[i][(add+j)%13] += dp[i-1][j];
                    dp[i][(add+j)%13] %= mod;
                }
            }
        }
        else{
            ll d = (s[slen-1-i]-'0')*mod13[i]%13;
            for(int j=0; j<13; ++j){
                dp[i][(j+d)%13] = dp[i-1][j];
            }
        }
    }


    
    cout << dp[slen-1][5] << endl;

    return 0;
}

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

int main()
{
    int total = 0 ;
    int hold, n ;
    int s[100] ;
    while(cin >> n)
    {
        total = 0 ;
        for(int i=0; i<n; i++)
        {
            cin >> s[i] ;
        }
        for(int i=0; i<n; i++)
        {
            for(int j=i+1; j<n; j++)
            {
                total += s[i]*s[j] ;
            }
        }
        cout << total << '\n' ;
    }
}


Measured memory_bytes: 256
fun main(args: Array<String>) {

    val num = readLine()!!.split(" ").map { it.toString() }
    val spc = readLine()!!.split(" ").map { it.toString() }

    var hp = num[0].toInt()
    var sum = 0

    for(a in spc) {
        sum += a.toInt()
    }

    val res = if(hp - sum <= 0) "Yes" else "No"

    print(res)
}

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

int main(){
  
int n,t;
  cin>>n>>t;
  
  vector<int> cost(n);
  vector<int> time(n);
  
  for (int i=0;i<n;i++){
    cin>>cost.at(i)>>time.at(i);
  }
  
  vector<int> tmp;
  
  for (int i=0;i<n;i++){
    if (time.at(i)<=t){
      tmp.push_back(i);
    }
  }
  
  if (int(tmp.size())==0){
    cout<<"TLE"<<endl;
  }
  
  else {
    int answer=cost.at(tmp.at(0));
    
    for (int x:tmp){
      if (cost.at(x)<answer){
        answer=cost.at(x);
      }
    }
    cout<<answer<<endl;
  }
  
  
}
  













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

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000001;
using namespace std;
typedef long long ll;

int n;
int v[100100];
// int e[100100], o[100100];
std::vector<int> e(100100,0);
std::vector<int> o(100100,0);

ll sum(std::vector<int> v){
  ll ret = 0;
  rep(i,0,v.size())ret+=v[i];
  return ret;
}
ll max_arg(std::vector<int> v){
  ll tmp = v[0];
  ll ret = 0;
  rep(i,1, v.size()){
    if(v[i] > tmp){
      ret = i;
      tmp = v[i];
    }
  }
  return ret;
}

int main(){

  std::cin >> n;
  rep(i,1,(n/2)+1){
    int tmp_o,tmp_e;
    std::cin >> tmp_o;
    std::cin >> tmp_e;
    e[tmp_e]++;
    o[tmp_o]++;
  }
  int E_1 = max_arg(e);
  int O_1 = max_arg(o);
  // std::cout << E_1 <<' '<< O_1 << '\n';
  ll res;
  if(E_1 != O_1){
    res = sum(e) - e[E_1];
    res += sum(o) - o[O_1];
  }else{
    int temp_E_1 = e[E_1];
    int temp_O_1 = o[O_1];
    e[E_1] = 0; o[O_1] = 0;
    int E_2 = max_arg(e);
    int O_2 = max_arg(o);
    // std::cout << E_2<<' '<<O_2 << '\n';
    e[E_1] = temp_E_1; o[O_1] = temp_O_1;
    res = sum(e) - e[E_2];
    res += sum(o) - o[O_1];
    ll tmp = sum(e) - e[E_1];
    tmp += sum(o) -o[O_2];
    // std::cout << res << ' '<< tmp << '\n';
    res = min(res,tmp);
  }
  std::cout << res << '\n';
  // std::cout << res << '\n';
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <stack>
#define endl    '\n'
using namespace std;
typedef long long ll;

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

    int x;
    cin >> x;

    if(x >= 1800)
        cout << 1 << "\n";
    else if(x >= 1600)
        cout << 2 << "\n";
    else if(x >= 1400)
        cout << 3 << "\n";
    else if(x >= 1200)
        cout << 4 << "\n";
    else if(x >= 1000)
        cout << 5 << "\n";
    else if(x >= 800)
        cout << 6 << "\n";
    else if(x >= 600)
        cout << 7 << "\n";
    else if(x >= 400)
        cout << 8 << "\n";

    return 0;
}

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

int main()
{
	//freopen("1.in","r",stdin);
	int a,b;
	cin>>a>>b;
	if(a<=0&&b>=0)puts("Zero"); else
	if(a>0||(min(-1,b)-a+1)%2==0) puts("Positive");
	else puts("Negative"); 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  cout<<n*(n-1)/2<<endl;
  return 0;
}


Measured memory_bytes: 256
import itertools

N, M, Q = map(int, input().split())

L = []
for _ in range(Q):
    L.append(list(map(int, input().split())))

C = itertools.combinations_with_replacement(range(1, M + 1), N)
ans = 0

for c in C:
    tmp = 0
    for l in L:
        if c[l[1] - 1] - c[l[0] - 1] == l[2]:
           tmp += l[3]
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
int main(){
    int n,m;cin >> n >> m;
    int ans=0;
    vector<P> p(m);
    for(int i=0; i<m; i++){
        int a,b;cin >> a >> b;
        p[i]={b,a};
    }
    sort(p.begin(),p.end());
    int fall=0;
    for(int i=0; i<m; i++){
        if(p[i].second<=fall&&fall<p[i].first) continue;
        fall=p[i].first-1;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

    Int n;
    cin >> n;
    string s;
    cin >> s;

    Int r = 0;
    Int w = 0;
    for (Int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            r++;
        } else {
            w++;
        }
    }

    int t = 0;
    Int rr = r;
    while (s[t] == 'R' && t < n) {
        rr--;
        t++;
    }

    Int ans = min(w, rr);

    Int tem = 0;
    for (Int i = 0; i < r; i++) {
        if (s[i] == 'R') {
            tem++;
        }
    }

    ans = min(ans, r - tem);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3764
n = int(input())
top_val = 0
top_idx = set()
semi_top = 0

for i in range(n):
  a = int(input())
  if a > top_val:
    semi_top = top_val
    top_val = a
    top_idx.clear()
    top_idx.add(i)
  elif a == top_val:
    top_idx.add(i)
  elif a > semi_top:
    semi_top = a

if len(top_idx) > 1:
  semi_top = top_val

semi_top = str(semi_top)
top_val = str(top_val)

print("\n".join([semi_top if i in top_idx else top_val for i in range(n)]))

Measured memory_bytes: 21860
#include <iostream>
#include <cstring>
#include <map>

using namespace std;
map <string,bool> ds;
int ans=0;
string s;
int n;
int main(){
    cin>>n;
    while(n--){
        cin>>s;
        if(!ds[s]){ans++;ds[s]=1;}
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 19204
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let a: Vec<i64> = sc.vec(n);
    let b: Vec<i64> = sc.vec(n);

    let mut ans = 0;
    for i in 1..30 {
        let mask = (1 << i) - 1;
        let mut b = b.iter().map(|&a| a & mask).collect::<Vec<_>>();
        b.sort();

        let mut total_count = 0;
        for &v in a.iter() {
            let v = v & mask;
            let sum1 = (mask + 1) >> 1;
            let sum2 = mask + 1;
            let sum3 = sum1 + sum2;
            let sum4 = (mask << 1) + 1;

            let pos1 = b.lower_bound(sum1 - v);
            let pos2 = b.lower_bound(sum2 - v);
            let pos3 = b.lower_bound(sum3 - v);
            let pos4 = b.lower_bound(sum4 - v);

            let count = pos2 - pos1 + pos4 - pos3;
            total_count += count;
        }
        ans |= (total_count as i64 % 2) << (i - 1);
    }

    println!("{}", ans);
}

trait LowerBound {
    fn lower_bound(&self, v: i64) -> usize;
}

impl LowerBound for Vec<i64> {
    fn lower_bound(&self, v: i64) -> usize {
        self.binary_search_by_key(&(v * 2), |&t| 2 * t + 1)
            .err()
            .unwrap()
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 13336
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  ll a[N];
  ll sum[N + 1];
  ll sumxor[N + 1];
  sum[0] = 0;
  sumxor[0] = 0;
  for(int i = 0; i < N; i++){
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
    sumxor[i + 1] = sumxor[i] ^ a[i];
  }

  //しゃくとりちっくに
  ll ans = 0;
  int l = 0, r = 0;
  while(r < N){
    if(sum[r + 1] - sum[l] == (sumxor[r + 1] ^ sumxor[l])){
      ans += r - l + 1;
      r++;
    } else {
      l++;
    }
  }

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

Measured memory_bytes: 4992
N=int(input())
xyh=[list(map(int,input().split()))for i in range(N)]
xyh.sort(reverse=True,key=lambda x:x[2])
for cx in range(101):
  for cy in range(101):
    H=0
    flag=False
    for i,tmp in enumerate(xyh):
      x,y,h=tmp
   
      if h != 0:
        tmp= h+abs(x-cx)+abs(y-cy)
      else:
        if H-abs(x-cx)-abs(y-cy) <=0:
          if i == N-1:
            flag=True
          continue
      if H!=0:
        if H==tmp:
         
          if i==N-1:
            flag=True
          continue
        else:
          break
      else:
        H=tmp
        

    if flag:
      print(cx,cy,H)
      exit(0)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

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

    ll N;
    string S, T;
    cin >> N >> S >> T;
    Rep (i, N) {
        cout << S[i] << T[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
///complexity O( sqrt(N).Q + n*sqrt(N) )
/// for Q query and N size of Array
#include<bits/stdc++.h>
#define ll  long long int
#define scll(x) scanf("%lld",&x)
using namespace std;
ll freq[100000000];
struct boo
{
    ll l;
    ll r;
    ll index;
};
ll result[10000000];
ll n;
bool comp(boo A,boo B)
{
    ll blocksize=(ll)sqrt(n*1.0);

    if(A.l/blocksize!=B.l/blocksize)
        return A.l/blocksize<B.l/blocksize;
    else
        return A.r<B.r;
}
int main()
{
    ll i,j,m;
    scll(n);
    scll(m);
    ll a[n];
    for(j=0; j<n; j++)
    {
        scll(a[j]);
    }
    ll l1,r1;
    struct boo st[m];
    for(i=0; i<m; i++)
    {
        scll(st[i].l);
        scll(st[i].r);
        st[i].l--;
        st[i].r--;
        st[i].index=i;
    }
    sort(st,st+m,comp);
    ll currL=0;
    ll currR=-1;
    ll distinct=0;
    for(i=0; i<m; i++)
    {
        ll le=st[i].l;
        ll ri=st[i].r;
        while(currL>le)
        {
            currL--;
            freq[a[currL]]++;
            if(freq[a[currL]]==1)
                distinct++;
        }
        while(currR<ri)
        {
            currR++;
            freq[a[currR]]++;
            if(freq[a[currR]]==1)
                distinct++;
        }
        while(currL<le)
        {
            freq[a[currL]]--;
            if(freq[a[currL]]==0)
                distinct--;
            currL++;
        }
        while(currR>ri)
        {
            freq[a[currR]]--;
            if(freq[a[currR]]==0)
                distinct--;
            currR--;
        }
        result[st[i].index]=distinct;
    }
    for(i=0; i<m; i++)
        printf("%lld\n",result[i]);

    return 0;
}



Measured memory_bytes: 27244
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;



int main()
{
  fastio();

ll int T=1;
//cin>>T;
while(T--)
{
  ll int n,m,k,ans,cnt;
  ans=0;cnt=0;
  cin>>n;

  string s;
  map<string,ll int> mp;
  for(ll int i=0;i<n;i++)
  {
      cin>>s;
      mp[s]++;
      ans=max(ans,mp[s]);
  }

  for(auto it : mp)
  {
     if(it.second==ans)
        cout<<it.first<<endl;
  }

}}     






Measured memory_bytes: 23936
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    string s;cin>>s;
    int n=s.size();
    vll a(n+1),ab(n+1),abc(n+1);
    ll res=1;//res=3^(そこまでの?の数)=そこまでの文字列の場合の数
    rep(i,n){
        a[i+1]=a[i];
        if(s[i]=='?')a[i+1]*=3;
        if(s[i]=='A'||s[i]=='?')a[i+1]+=res;
        a[i+1]%=inf;
        ab[i+1]=ab[i];
        if(s[i]=='?')ab[i+1]*=3;
        if(s[i]=='B'||s[i]=='?')ab[i+1]+=a[i];
        ab[i+1]%=inf;
        abc[i+1]=abc[i];
        if(s[i]=='?')abc[i+1]*=3;
        if(s[i]=='C'||s[i]=='?')abc[i+1]+=ab[i];
        abc[i+1]%=inf;
        if(s[i]=='?'){
            res*=3;
            res%=inf;
        }
    }
    cout<<abc[n]<<endl;
}

Measured memory_bytes: 5820
n=int(input())
a=[int(i) for i in input().split()]

def p(a, n):
  for i in range(n):
    if i==n-1: 
      print(a[i],end='')
    else :
      print(a[i], end=' ')

def f(a, n):
  for i in range(n):
    v = a[i]
    j = i-1
    while (a[j] > v) & (j>=0):
      a[j+1] = a[j]
      j-=1
    a[j+1] = v
    p(a, n)
    print()
f(a, n)



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

int main() {
	int n;
	cin >> n;
	int min = 1E+9 + 100;
	int mncount = 0;
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		ans += abs(a);
		if (abs(min) > abs(a)) min = a;
		if (a < 0) mncount++;
	}
	if (mncount & 1) cout << ans - 2 * abs(min) << endl;
	else cout << ans << endl;
}

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

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

  int cnt = 0, ans;
  for (int i = min(a, b); i >= 1; i --) {
    if (a % i == 0 && b % i == 0) cnt ++;

    if (cnt == k) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;
}


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

typedef long long ll;


int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  deque <char> dq;
  char c;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    c = s[i];
    dq.push_back(c);
  }
  int q;
  cin >> q;
  int t, f;
  bool normal = true;
  while (q--) {
    cin >> t;
    if (t == 1) normal = !normal;
    else {
      cin >> f >> c;
      if (f == 1) {
        if (normal) dq.push_front(c);
        else dq.push_back(c);
      }else {
        if (normal) dq.push_back(c);
        else dq.push_front(c);
      }
    }
  }
  if (normal) {
    while (dq.size() > 0) {
      cout << dq.front();
      dq.pop_front();
    }
  } else {
    while (dq.size() > 0) {
      cout << dq.back();
      dq.pop_back();
    }
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 976
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <cstdio>
#include <math.h>
#include <utility>
#include <list>
#include <functional>
#include <queue>
using namespace std;

#define ll long long
#define vecint vector<int>
#define Pii pair<int, int>

#define REP(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define print(a) cout << a << endl

#define MOD 1000000007
#define NIL -1

int N,T;
ll ans=0;
int t[200000];

void solve(){
    int lft=0;
    int now=0;
    int ncnt=0;

//    while(ncnt<N||lft!=0){
//        if(t[ncnt]==now){
//            lft=T;
//            ncnt++;
//        }
//        if(lft>0){
//            ans++;
//            lft--;
//        }
//        now++;
//    }
    for(ncnt=0;ncnt<N;ncnt++){
        if(ncnt==N-1){
            ans+=T;
        }else {
            ans += (ll) min(T, t[ncnt + 1] - t[ncnt]);
        }
    }
    print(ans);
    return;
}



int main(){
    cin>>N>>T;
    rep(i,N){
        cin>>t[i];
    }
    solve();
    return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

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

	Vi A(n);
	rep(i, n)  cin >> A[i];

	if (n == 1) {
		if (A[0] == 0)  cout << 1 << endl;
		else  cout << 0 << endl;
		return 0;
	}

	Vi J(n, 0);
	rep(i, n) {
		J[A[i]]++;
	}

	/*rep(i, n) {
		cout << J[i] << endl;
	}*/
	if (n % 2 == 1) {
		bool f = true;
		for (int i = 0; i < n; i++) {
			if (i == 0) {
				if (J[i] != 1) {
					f = false;
					break;
				}
			}
			else if (i % 2 == 0) {
				if (J[i] != 2) {
					f = false;
					break;
				}
			}
			else {
				if (J[i] != 0) {
					f = false;
					break;
				}
			}
		}

		if (f) {
			ll ans = 1;
			rep(k, n / 2) {
				ans *= 2;
				ans %= Mod;
			}
			cout << ans << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
	else {
		bool f = true;
		for (int i = 0; i < n; i++) {
			if (i % 2 == 1) {
				if (J[i] != 2) {
					f = false;
					break;
				}
			}
			else {
				if (J[i] != 0) {
					f = false;
					break;
				}
			}
		}
		if (f) {
			ll ans = 1;
			rep(k, n / 2) {
				ans *= 2;
				ans %= Mod;
			}
			cout << ans << endl;
		}
		else {
			cout << 0 << endl;
		}
	}

}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        if (a.equals("H") && b.equals("H")
                || a.equals("D") && b.equals("D")) {
            System.out.println("H");
            return;
        }
        System.out.println("D");
    }

}


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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

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

ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}

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

    ll fac = modpow(2, n, MOD) - 1;;

    ll fac_a, fac_b;
    fac_a = fac_b = 1;
    for(ll i = 1; i <= max(a, b); ++i){
        if(i <= a)fac_a = (fac_a*i)%MOD;
        if(i <= b)fac_b = (fac_b*i)%MOD;
    }

    ll n2a, n2b;
    n2a = n2b = n;
    for(ll i = n-1; i >= min(n-a+1, n-b+1); --i){
        if(i >= n-a+1)n2a = (n2a*i)%MOD; 
        if(i >= n-b+1)n2b = (n2b*i)%MOD; 
    }

    ll minus = n2a*modinv(fac_a, MOD) + n2b*modinv(fac_b, MOD);
    minus %= MOD;

    cout << (fac-minus + MOD)%MOD << endl;

}


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

constexpr int MAX_N = 200;
constexpr int MAX_R = 8;
constexpr int INF = 1 << 29;

int N, M, R;
int costs[MAX_N][MAX_N] = {};
std::vector<int> order;

int main(){

    std::cin >> N >> M >> R;

    for(int i = 0; i < R; ++i){
        int input;
        std::cin >> input;
        order.push_back(input - 1);
    }

    std::sort(order.begin(), order.end());

    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
            costs[i][j] = INF;
        }
        costs[i][i] = 0;
    }

    for(int i = 0; i < M; ++i){
        int a, b, c;
        std::cin >> a >> b >> c;
        --a, --b;
        costs[a][b] = std::min(c, costs[a][b]);
        costs[b][a] = std::min(c, costs[b][a]);
    }

    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
            for(int k = 0; k < N; ++k){
                costs[j][k] = std::min(costs[j][k], costs[j][i] + costs[i][k]);
            }
        }
    }

    int ans = INF;
    do{
        int sum = 0;
        for(int i = 1; i < R; ++i){
            sum += costs[order[i]][order[i - 1]];
        }

        ans = std::min(ans, sum);
    } while(std::next_permutation(order.begin(), order.end()));

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 384