akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) std::begin(x), std::end(x)
using namespace std;
template <class T, class U> inline void chmin(T & a, U const & b) { a = min<T>(a, b); }

double solve(int n, int m, const vector<vector<int> > & g) {
    vector<double> e(n, INFINITY);
    e[n - 1] = 0;
    REP_R (i, n - 1) {
        double acc = 0;
        for (int j : g[i]) {
            acc += e[j];
        }
        e[i] = 1 + acc / g[i].size();
    }

    vector<double> cnt(n, 0.0);
    cnt[0] = 1;
    REP (i, n - 1) {
        for (int j : g[i]) {
            cnt[j] += cnt[i] / g[i].size();
        }
    }

    double answer = e[0];
    REP (i, n - 1) if (g[i].size() >= 2) {
        double acc = (e[i] - 1) * g[i].size();
        for (int j : g[i]) {
            double updated_e_i = 1 + (acc - e[j]) / (g[i].size() - 1);
            chmin(answer, e[0] - cnt[i] * e[i] + cnt[i] * updated_e_i);
        }
    }
    return answer;
}

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int> > g(n);
    REP (i, m) {
        int s, t; cin >> s >> t;
        -- s;
        -- t;
        g[s].push_back(t);
    }
    cout << setprecision(12) << solve(n, m, g) << endl;
    return 0;
}


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

typedef long long ll;
const int MAX = 2000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  ll X,Y;
  cin >> X >> Y;
  
  // 前処理
  COMinit();
  ll A,B;
  A = 2 * X - Y;
  B = 2 * Y - X;
  ll ans = 0;
  if( A >= 0 && A % 3 == 0 && B >= 0 && B % 3 == 0){
    A = A / 3;
    B = B / 3;
    ans = COM(A+B,A);
  } else { 
    ans = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 47104
#include <iostream>
using namespace std;
#include <cstdio>
#include <cmath>

class Dice{
public:
    int face[6], facetmp[6];

    Dice(void){
        for (int i = 0; i < 6; i++){
            face[i] = 0;
            facetmp[i] = 0;
        }
    }

    void move(char ch){
        for (int i = 0; i < 6; i++) {
            facetmp[i] = face[i];
        }

        if (ch == 'E') {
            facetmp[0] = face[3];
            facetmp[2] = face[0];
            facetmp[3] = face[5];
            facetmp[5] = face[2];
        }

        else if (ch == 'W') {
            facetmp[0] = face[2];
            facetmp[2] = face[5];
            facetmp[3] = face[0];
            facetmp[5] = face[3];
        }

        else if (ch == 'N') {
            facetmp[0] = face[1];
            facetmp[1] = face[5];
            facetmp[4] = face[0];
            facetmp[5] = face[4];
        }

        else if (ch == 'S') {
            facetmp[0] = face[4];
            facetmp[1] = face[0];
            facetmp[4] = face[5];
            facetmp[5] = face[1];
        }

        else if (ch == 'Z'){
            facetmp[1] = face[3];
            facetmp[2] = face[1];
            facetmp[3] = face[4];
            facetmp[4] = face[2];
        }

        for (int i = 0; i < 6; i++){
            face[i] = facetmp[i];
        }

    }

    void print(){
        cout << face[0] << endl;
    }

};

bool equal(Dice d1, Dice d2, int num1[6]){
    for (int j = 0; j <= 3; j++){
        for (int k = 0; k <= 3; k++){
            for (int n = 0; n <= 3; n++){
                string order = "";
                order.append(j,'E');
                order.append(k,'S');
                order.append(n,'Z');

                for (int i = 0; i < 6; i++){
                    d1.face[i] = num1[i];
                }

                for (int m = 0; m < order.size(); m++){
                    d1.move(order[m]);
                }
                if (d1.face[0] == d2.face[0] &&
                    d1.face[1] == d2.face[1] &&
                    d1.face[2] == d2.face[2] &&
                    d1.face[3] == d2.face[3] &&
                    d1.face[4] == d2.face[4] &&
                    d1.face[5] == d2.face[5]){

                    return true;
                }
            }

        }
    }
    return false;
}

int main() { ;
    int n, flag = 0;
    cin >> n;
    string order = "";
    int num[n][6];
    Dice d[100];

    for (int i = 0; i < n; i++){
        for (int j = 0; j < 6; j++){
            cin >> num[i][j];
            d[i].face[j] = num[i][j];
        }
    }

    for (int i = 0; i < n-1; i++){
        for (int j = i+1; j < n; j++){
            if (equal(d[i],d[j],num[i])) flag = 1;
        }
    }


    if (flag == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3184
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   string s, t, u;
   int a,b;
   cin >> s >> t >> a >> b >> u;

   if(s == u)
      a--;
   else
      b--;
   cout << a << " " << b << 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)
# define PER(i,n) for (int i=(N-1);i>=0;--i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

const ll longinf = 1LL << 60 ;

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

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

    ll ans = longinf;
    int m1 = 1, m2 = 3;
    for(int x = 2; x <= N - 2; x++){

        bool flg1 = true;
        while(flg1) {
            ll g1 = abs((a[x] - a[m1]) - a[m1]);
            ll g2 = abs((a[x] - a[m1 + 1]) - a[m1 + 1]);

            if(g1 <= g2) flg1 = false;
            else m1++;
        }

        bool flg2 = true;
        while(flg2) {
            ll g1 = abs((a[N] - a[m2]) - (a[m2] - a[x]));
            ll g2 = abs((a[N] - a[m2 + 1]) - (a[m2 + 1] - a[x]));

            if(g1 <= g2) flg2 = false;
            else m2++;
        }

        ll s1 = a[m1];
        ll s2 = a[x] - a[m1];
        ll s3 = a[m2] - a[x];
        ll s4 = a[N] - a[m2];

        chmin(ans, max({s1, s2, s3, s4}) - min({s1, s2, s3, s4}));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M,K;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>K;
	
	
	for(i=0;i<=N;i++) {
		for(j=0;j<=M;j++) {
			if(i*j+(N-i)*(M-j)==K) return _P("Yes\n");
			
		}
	}
	 _P("No\n");
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdio.h>

int main(void)
{
    long int n, k, i=0;
    scanf("%ld %ld", &n, &k);
    while(n!=0)
    {
        n/=k;
        i++;
    }
    printf("%d", i);
	return 0;
}



Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n=int(input())
    
    if n%2==1:
        print(0)
    else:
        N=n//2
        cnt=0
        while N>=5:
            cnt+=N//5
            N//=5
        print(int(cnt))
        



    
resolve()

Measured memory_bytes: 38384
def gcd(a, b):
    while b: a, b = b, a % b
    return a


def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2, 7, 61] if n < 1 << 32 else [2, 3, 5, 7, 11, 13, 17] if n < 1 << 48 else [2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
                                                                                     31, 37]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = y * y % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1


def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g):
                return g
            elif isPrimeMR(n // g):
                return n // g
            return findFactorRho(g)


def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i * i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += i % 2 + (3 if i % 3 == 1 else 1)
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret


def divisors(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p] + 1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return sorted(ret)


N = int(input())
A = list(map(int, input().split()))
ma = max(A)

X = [0] * (ma + 1)
Ans = [True] * (ma + 1)
ans = 0
A.sort()

for a in A:
    X[a] += 1
for a in A:
    if X[a] > 1:
        continue
    for d in divisors(a)[:-1]:
        if X[d]:
            break
    else:
        ans += 1
print(ans)


Measured memory_bytes: 129740
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100009;
string s;
int k,n;
int dp[103][4][2];
int solve(int pos,int cnt,int is_sml)
{
    if(cnt>k)return 0;
    if(pos>=n)
    {
        if(cnt==k)return 1;
        else return 0;
    }
    int &ret=dp[pos][cnt][is_sml];
    if(ret!=(-1))return ret;
    ret=0;
    if(is_sml)
    {
        ret+=solve(pos+1,cnt,is_sml);
        int x=solve(pos+1,cnt+1,is_sml);
        x=9*x;
        ret+=x;
    }
    else
    {
         int dg=s[pos]-'0';
         f(i,0,dg-1)
         {
             if(i==0)ret+=solve(pos+1,cnt,1);
             else ret+=solve(pos+1,cnt+1,1);
         }
         if(dg==0)ret+=solve(pos+1,cnt,is_sml);
         else ret+=solve(pos+1,cnt+1,is_sml);
    }
    return ret;
}
 main()

{
    fast
    memset(dp,-1,sizeof dp);
    cin>>s>>k;
    n=s.size();
    cout<<solve(0,0,0)<<endl;
    return 0;

}





































Measured memory_bytes: 256
fun main(args: Array<String>)
{
    val n = readInt()
    val p = readNInts()

    var ans = 0
    for (i in 1..n-2) {
        val ptn1 = (p[i+1] - p[i] > 0) && (p[i] - p[i-1] > 0)
        val ptn2 = (p[i-1] - p[i] > 0) && (p[i] - p[i+1] > 0)
        ans += if (ptn1 || ptn2) 1 else 0
    }

    println(ans)
}


// Read an integer
// Usage: val a = readInt()
private fun readInt() = readLine()!!.toInt()

// Read N integers separated by " "
// Usage: val (a, b, c) = readNInts()
private fun readNInts() = readLine()!!.split(" ").map(String::toInt)

// Read a string
// Usage: val a = readString()
private fun readString() = readLine()!!


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

int main() {
  int N, M, A, sum=0;
  cin >> N >>M;
  
  for (int i=0; i<M; i++) {
    cin >> A;
    sum+=A;
  }
  
  if (N-sum>=0) cout << N-sum << endl;
  else cout << "-1" << endl;
}


Measured memory_bytes: 3580
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define VMAX 1002
#define EMAX 2002
#define INF (long long )1e18

//コメントアウトするとdebug()を実行しない
// #define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	std::fill( (T*)array, (T*)(array+N), val );
}

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

struct edge{
	ll from,to,cost;
};
edge es[EMAX];
ll V,E,r,ans,d[VMAX],nat;
string S;
static const ll dx[8] = {0,1,1,1,0,-1,-1,-1},
dy[8] = {1,1,0,-1,-1,-1,0,1};
bool shortest_path(){
	Fill(d,-INF);
	d[1] = 0;
	bool	update = false;
	int j = 0;
	do{
		update = false;
		for (ll i = 0; i < E; ++i)
		{
			edge e = es[i];
			if(d[e.from] != -INF && d[e.to] < d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if(j == V-2){
			nat = d[V];
		}
		if(j > 2*V && update){
			if(nat != d[V]){
				return true;
			}
			return false;
		}
		j++;
	}while(update);
	return false;
}

void solve(){
	if(shortest_path()){
		ans = INF;
	}
}

void debug(){
	for (ll i = 0; i < V; ++i)
	{
		cout << d[i] << " ";
	}
	cout << "\n";
}

void answer(){
	if(ans == INF){
		cout << "inf\n";
	}else{
		cout << d[V] << "\n";
		
	}
}

int main(){
	cin >> V >> E;
	for (ll i = 0; i < E; ++i)
	{
		ll a,b,c;
		cin >> a >> b >> c;
		es[i] = (edge){a,b,c};
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

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

int main() {
    bool first = true;
    int n;
    int p[4] = {10, 50, 100, 500};
    int c[4];
    int a[4];

    while(true) {
        cin >> n;
        if(n == 0) break;
        if(!first) { cout << endl; }
        for(int i = 0; i < 4; ++i) { 
            cin >> c[i];
        }

        int change = inner_product(c, c + 4, p, 0) - n;


        for(int i = 3; i >= 0; --i) {
            a[i] = change / p[i];
            change %= p[i];
        }

        for(int i = 0; i < 4; ++i) {
            if(c[i] - a[i] > 0) {
                cout << p[i] << ' ' << c[i] - a[i] << endl;
            }
        }

        first = false;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
    using namespace std;
    #define inp(k)           ll k;cin>>k;
    #define in2(n,k)       ll n, k; cin>>n;cin>>k;
    #define in3(n,k,r)       ll n, k,r; cin>>n;cin>>k;cin>>r;
    #define ll long long
    #define dl double
    #define ch char
    #define f(i,a,b) for(ll i=a;i<b;i++)
    #define rf(i,a,b) for(ll i=a-1;i>=b;i--)
    #define Godspeed                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define vpl vector< pair<ll,ll> >
    #define vpi vector< pair<int,int> >
    #define vi vector<int>
    #define vl vector<ll>
    #define vdl vector<dl>
    #define vch vector<char>
    #define pll pair<ll,ll>
    #define pb push_back
    #define mp make_pair
    #define fr first
    #define se second
    #define PI 3.14159265
    /*vl v[10005];
    ll cnt=0;
    ll a[51][51]={0};
    bool visited[10005]={0};
    void dfs(ll u)
    {
        visited[u]=1;
        f(i,0,v[u].size())
        {
            ll f=v[u][i];
            if(!visited[f])
            {
                dfs(f);
            }
        }
    }*/
    ll dp[105][100005];
    ll weight[105],value[105];
    ll KS(ll n,ll c)
    {
        ll result;
        if(dp[n][c]!=-1)return dp[n][c];
        if(n==0 || c==0)result=0;
        else if (weight[n]>c)
            result=KS(n-1,c);
        else
        {
            ll temp1=KS(n-1,c);
            ll temp2=value[n]+KS(n-1,c-weight[n]);
            result= max(temp1,temp2);
        }
        dp[n][c]=result;
        return result;
    }
    const int INF=1e9+5;
    void solve()
    {
        in2(n,w);
        f(i,1,n+1)cin>>weight[i]>>value[i];
        f(i,0,n+1)
        {
            f(j,0,w+1)dp[i][j]=-1;
        }

        ll ans=KS(n,w);
        cout<<ans;
    }

    int32_t main(void)
    {
        Godspeed;
        int q;
        q=1;
        //cin>>q;
        while (q--)
        {
            solve();cout<<endl;
        }
        return 0;
    }


Measured memory_bytes: 82448
n = int(input())
a = [int(i) for i in input().split()]
c = [0] * n
ma = max(a)

ans = 0
while max(c) != ma:
    ing = False
    for i in range(n):
        if a[i] == c[i]:
            ing = False
            continue
        else:
            if not ing:
                ing = True
                ans += 1
            c[i] += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <cstdio>
#include <map>
#define F first
#define S second

using namespace std;
typedef pair<int, int> P;

int main()
{
    P v[100010];

    int h, w, d, m[350][350], q, x, y, sum[100010], ant;

    scanf("%d %d %d", &h, &w, &d);

    for(int i = 0; i < h; i++)
        for(int j = 0; j < w; j++)
        {
            scanf("%d", &m[i][j]);
            v[m[i][j]] = P(i, j);
        }
    sum[0] = 0;
    for(int i = d + 1; i <= h * w; i++)
    {
        sum[i] = sum[i - d] + abs(v[i].F - v[i - d].F) + abs(v[i].S - v[i - d].S);
    }

    scanf("%d", &q);

    while(q--)
    {
        scanf("%d %d", &x, &y);
        printf("%d\n", sum[y] - sum[x]);
    }
    return 0;
}


Measured memory_bytes: 2688
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

const int DIGIT=14;
const ll INF=1e10;
ll mx[DIGIT+1][1<<DIGIT];
ll Mx(int l,int r){ //[l,r]
  if(l==r)return mx[DIGIT][l];
  int d=__builtin_clz(l^r)+DIGIT-31;
  return min(mx[d][l],mx[d][r]);
}
void buildRMQ(vector<ll> &v){
  fill(mx[DIGIT],mx[DIGIT]+(1<<DIGIT),INF);
  rep(i,v.size()) mx[DIGIT][i]=v[i];
  rrep(i,DIGIT)rep(j,1<<DIGIT){
    int b=(j>>(DIGIT-i)|1)<<(DIGIT-i);
    mx[i][j]=j>>(DIGIT-i)&1?Mx(b,j):Mx(j,b-1);
  }
}

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  cin>>n;
  ll x;
  cin>>x;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  rep(hoge,2) rep(i,n) a.pb(a[i]);
  buildRMQ(a);
  ll re=1e16;
  rep(i,n){
    ll sum=x*i;
    rep(j,n) sum+=Mx(n+j-i,n+j);
    //    cout<<i<<":"<<sum<<endl;
    MN(re,sum);
  }
  cout<<re<<endl;
  return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
const int64_t INF=9999999999999999;
int main() {
 int r,D,x;
 cin>>r>>D>>x;
 vector<int>X(100);X[0]=x;
 for(int i=1;i<=10;i++){
  X[i]=r*X[i-1]-D;
  cout<<X[i]<<endl;
 }
 return 0;}

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

#define FOR(x,to) for(int x=0;x<(to);x++)
#define F0R(x,in,to) for(int x=(in);x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))

typedef long long ll;
using namespace std;
ll MOD = 998244353;

typedef pair<int,int> ii;
typedef struct {int a,b,c;}iii;
typedef vector<int> vi;

void mosA(vector<int> a){
	for(int i=0; i<a.size(); i++) printf("%d ",a[i]);
	printf("\n");
}
void mosP(vector<ii> a){
	for(int i=0; i<a.size(); i++) printf("%d %d\n",a[i].first,a[i].second);
	printf("\n");
}

ll min_especial(ll a, ll b){
  if(a!=-1 && b!=-1) return min(a,b);
  else return max(a,b);
}
/*
bool ord(ii a, ii b){
	if(a.first == b.first){
		return a.second < b.second;
	}
	return a.first < b.first;
}*/

bool ord(ll a, ll b){
	return a>b;
}

int ans = 0;
int a,n,w,t,k,m,z,q,l,r,x,b,y;
char S[1005][1005];
ii A[10000];

queue<iii> Q;

int main(){
	scanf("%d%d",&n,&m);
	FOR(i,n) scanf("%s",S[i]);
	FOR(i,n) FOR(j,m)
	if(S[i][j]=='#')
		Q.push({i,j,0});

	
	while(!Q.empty()){

		iii x = Q.front();
		Q.pop();
		ans = x.c;
		int i = x.a, j = x.b;

		if(i<(n-1) && S[i+1][j]=='.'){
			S[i+1][j]='#';
			Q.push({i+1,j,ans+1});}

		if(j<(m-1) && S[i][j+1]=='.'){
			S[i][j+1]='#';
			Q.push({i,j+1,ans+1});}

		if(i>0 && S[i-1][j]=='.'){
			S[i-1][j]='#';
			Q.push({i-1,j,ans+1});}

		if(j>0 && S[i][j-1]=='.'){
			S[i][j-1]='#';
			Q.push({i,j-1,ans+1});}

	}

	printf("%d\n", ans);
	
}




// REVISATE ESTO:
// - memset(A,-1,SIZEOF()*n)
// - (x-y+MOD)%MOD
// - int o ll?

Measured memory_bytes: 13328
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,K,x; cin>>N>>K;
	vector<int> neg, pos;
	bool zero=false;
	for (int i=0; i<N; i++) {
		cin>>x;
		if(!x) zero=true;
		else if(x<0) neg.push_back(x);
		else pos.push_back(x);
	}
	if(zero) K--;

	if(!K) {
		cout<<0<<"\n";
		return 0;
	}

	if(!neg.empty())
		sort(neg.rbegin(), neg.rend());
	if(!pos.empty())
		sort(pos.begin(), pos.end());
	int ret=INT_MAX;
	if(neg.size()>=K)
		ret=min(ret,abs(neg[K-1]));
	if(pos.size()>=K)
		ret=min(ret,abs(pos[K-1]));

	for (int x=0; x<min((int) neg.size(),K); x++) {
		int y=K-x-2;
		if(y<0||y>=pos.size())
			continue;
		int p=abs(neg[x]), q=abs(pos[y]);
		ret=min(ret,p+q+min(p,q));
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
      int n,k;
      cin>>n>>k;
      int arr[n];
      for(int i=0;i<n;i++)
      {
        cin>>arr[i];
      }
      vector<int>dp(n,INT_MAX);
      dp[0]=0;
	  dp[1]=abs(arr[0]-arr[1]);
      for(int i=2;i<n;i++)
      {
        for(int j=1;j<=k;j++)
        {
          if(i-j>=0)
          dp[i]=min(dp[i],abs(arr[i-j]-arr[i])+dp[i-j]);
        }
      }
      cout<< dp[n-1]<<endl;
    }

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<deque>
#define LiangJiaJun main
using namespace std;
int a[200004];
int n,t;
deque<int>q;
int LiangJiaJun(){
    scanf("%d",&n);
    t=1;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(t)q.push_back(a[i]);
        else q.push_front(a[i]);
        t^=1;
    }
    if(t){
        while(!q.empty()){
            printf("%d ",q.front());
            q.pop_front();
        }
    }
    else{
        while(!q.empty()){
            printf("%d ",q.back());
            q.pop_back();
        }
    }
    puts("");
    return 0;
}





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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(2*M);
  for (int i= 0; i < 2*M; i++) {
    cin >> a.at(i);
  }
  
  vector<int> count(N);
  for (int i = 0; i < N; i++) {
    count.at(i) = 0;
  }
  for (int i = 0; i < 2*M; i++) {
    for (int j = 0; j < N; j++) {
      if (a.at(i) == j+1) count.at(j)++;
    }
  }
  for (int i = 0; i < N; i++) {
    cout << count.at(i) << endl;
  }
}

Measured memory_bytes: 256
// AOJ 	2302: On or Off
// 2018.1.31 bal4u

#include <stdio.h>
#include <string.h>

typedef struct { int r, c, t; } Q;
Q q[2600]; int top, end;

char map[53][53];
char pr[53][53], prev[53][53][2];		// prev (r,c)
int tbl[3][53][53];
int cost[53][53];
int visited[53][53];
char mk[53][53];
int mv[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int R, C, M, i, k, r, c, t, nr, nc, sr, sc, gr, gc, tm, ans;
	
	R = in(), C = in(), M = in();
	for (r = 0; r < R; r++) fgets(map[r], 53, stdin);
	for (k = 0; k < 3; k++) {
		for (r = 0; r < R; r++) for (c = 0; c < C; c++) tbl[k][r][c] = in();
	}

	tm = 1;
	sr = in(), sc = in();
	visited[sr][sc] = tm, cost[sr][sc] = tbl[1][sr][sc];
	while (--M) {
		gr = in(), gc = in();
		memset(mk, 0, sizeof(mk));
		q[0].r = sr, q[0].c = sc, q[0].t = tm, top = 0, end = 1;
		while (top != end) {
			r = q[top].r, c = q[top].c, t = q[top++].t;
			if (r == gr && c == gc) break;
			if (mk[r][c]) continue;
			mk[r][c] = 1;
			for (i = 0; i < 4; i++) {
				nr = r+mv[i][0], nc = c+mv[i][1];
				if (nr < 0 || nr >= R || nc < 0 || nc >= C ||
					map[nr][nc] == '#' || mk[nr][nc]) continue;
				prev[nr][nc][0] = r, prev[nr][nc][1] = c;
				q[end].r = nr, q[end].c = nc, q[end++].t = t+1;
			}
		}
		nr = gr, nc = gc, tm = t;
		while (nr != sr || nc != sc) {
			if (!visited[nr][nc]) cost[nr][nc] = tbl[1][nr][nc];
			else {
				k = (t - visited[nr][nc])*tbl[0][nr][nc];
				if (k > tbl[1][nr][nc]+tbl[2][nr][nc]) k = tbl[1][nr][nc]+tbl[2][nr][nc];
				cost[nr][nc] += k;
			}
			visited[nr][nc] = t;
			r = prev[nr][nc][0], c = prev[nr][nc][1], t--;
			nr = r, nc = c;
		}
		sr = gr, sc = gc;
	}

	ans = 0;
	for (r = 0; r < R; r++) for (c = 0; c < C; c++) {
		if (visited[r][c]) ans += cost[r][c] + tbl[2][r][c];
	}
	printf("%d\n", ans);
	return 0;
}


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

using i64 = int64_t;

int main(){
    string s;
    cin >> s;
    set<char> st;
    for(auto c: s)st.insert(c);
    cout << (st.size() > 1 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
s = input()
dp = [1] + [0] * 12
for c in s:
    newdp = [0] * 13
    for d in range(10) if c == '?' else [int(c)]:
        for m in range(13):
            m2 = (m * 10 + d) % 13
            newdp[m2] = (newdp[m2] + dp[m]) % 1000000007
    dp = newdp
print(dp[5])

Measured memory_bytes: 43828
/* ex 9_2
series2 */
#include <stdio.h>
#include <stdlib.h>

//リストのノード（スタック内の各データ）の定義
typedef struct node {
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem) {
    //追加する分の領域を確保
    node *newnode = (node *)calloc(1, sizeof(node));
    if (newnode == NULL) exit(1);
    newnode->elem = elem;
    newnode->next = *first;
    *first = newnode;
}

//スタックからデータを取り出す
char pop(node **first) {
    char elem;
    node *tmp = *first;
    if (tmp == NULL) {
        elem = '\0';
    } else {
        elem = tmp->elem;
        *first = tmp->next;
        //取り出したノードのメモリを解放
        free(tmp);
    }

    return elem;
}

int main(void) {
    int count = 0;
    //最初のノードの指す先
    node *first = NULL;
    char inp;
    scanf("%c", &inp);
    while (inp != '\n') {  //入力文字が終了するまで読み取る
        char under = pop(&first);  //読み込みをしている一つ前の文字を取り出す
        if (under == '\0') {  //取り出せない時、入力文字を追加する
            push(&first, inp);
        } else if (
            under ==
            inp) {  //取り出せる時で文字が一致する時、取り出した文字を戻し、入力文字も追加
            push(&first, under);
            push(&first, inp);
        } else {  //文字が不一致の時、削除
            count += 2;
        }
        scanf("%c", &inp);
    }
    printf("%d\n", count);
    return 0;
}


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

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    int nb,s=0,sb=0;
    for(int i=1;i<=n;i++){
        nb=i;
        while(nb){
            sb+=nb%10;
            nb/=10;
        }
        if(sb>=a && sb<=b) s+=i;
        sb=0;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n;
string s;
int a[50];
int ans[50];
int main(void){
    cin>>n;
    for(int i=0;i<50;i++){
        ans[i]=1000000000;
    }
    for(int i=0;i<n;i++){
        cin>>s;
        for(int j=0;j<50;j++){
            a[j]=0;
        }
        for(int j=0;j<s.size();j++){
            a[s[j]-'a']++;
        }
        for(int j=0;j<50;j++){
            ans[j]=min(ans[j],a[j]);
        }
    }
    for(int i=0;i<50;i++){
        for(int j=0;j<ans[i];j++){
            char t='a'+i;
            cout<<t;
        }
    }
    cout<<endl;

}


Measured memory_bytes: 3644
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	N := readInt()
	S := readString()

	result := 0
	for i := N - 1; i > 0; i-- {
		if i <= result {
			break
		}
		t := 0
		for j := 0; j < N-i; j++ {
			if S[j] == S[j+i] {
				t++
				result = max(result, t)
				if result == i {
					break
				}
			} else {
				t = 0
			}
		}
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 640
import copy
import sys

sys.setrecursionlimit(100000)
N, M, Q = map(int, input().split())
kumi = list()
max_score = 0

def dfs(a):
    global N
    global Q
    global max_score
    global kumi
    if len(a) == N:
        # print(a)
        score = 0
        for k in kumi:
           if a[k[1]-1] - a[k[0]-1] == k[2]:
               score += k[3]
        max_score = max(max_score, score)
        return

    for i in range(a[-1], M+1):
        next = copy.copy(a)
        next.append(i)
        dfs(next)

for i in range(Q):
    kumi.append(list(map(int, input().split())))

dfs([1])
print(max_score)

Measured memory_bytes: 9352
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
const ll MOD = 1000000007;
//const ll MOD = 998244353;

int main() {
	ll H, N, al = 0, A;
	cin >> H >> N;
	for (int i = 0;i < N;i++) {
		cin >> A;
		al += A;
	}
	if (al < H) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

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


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

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



Measured memory_bytes: 1972
#include<bits/stdc++.h>
using namespace std;
int main()
{char a[50],b[50];
 cin>>a;
 cin>>b;
 for(int i=0;i<strlen(b);i++)
    cout<<a[i]<<b[i];
 if(strlen(a)==strlen(b))
   cout<<endl;
 else
   cout<<a[strlen(a)-1]<<endl;
}

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

using namespace std;

#define endl "\n"
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define f first
#define se second
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007

typedef long long ll;

void solve(){
    int W,a,b;
    cin>>W>>a>>b;
    int firstL=a;
    int firstR=a+W;
    int secondL=b;
    int secondR=b+W;
    if(firstL>secondR){
        cout<<firstL-secondR<<endl;
    }
    else if(firstR<secondL){
        cout<<secondL-firstR<<endl;
    }
    else cout<<0<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //int t;
    //cin>>t;
    //while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 256
def resolve():
    a, b, m = map(int, input().split())
    a_list = list(map(int, input().split()))
    b_list = list(map(int, input().split()))
    ans = min(a_list) + min(b_list)
    for _ in range(m):
        x, y, c = map(int, input().split())
        ans = min(ans, a_list[x-1]+b_list[y-1]-c)
    print(ans)
resolve()

Measured memory_bytes: 24740
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int l;
int tui[20],jie[20];
char s[20];
int hh()
{
	int ans1,i,j,h,k;
	if(l==1) ans1=0;
	else ans1=1;
	for(i=1;i<=l/2;i++)
	{
		h=0;
		for(j=0;j<=9;j++)
		for(k=0;k<=9;k++)
		{
			if(i==1&&k==0) continue;
			if(j-k-tui[i]+jie[i]*10==s[i]-'0'&&k-j-tui[l+1-i]+jie[l+1-i]*10==s[l+1-i]-'0')
			{
				//cout<<j<<"  "<<k<<endl;
				 h++;
			 }
		}
		ans1*=h;
	}
	if(l%2==1)
	{
		h=0;
		for(k=0;k<=9;k++)
		{
			j=k;
			if(j-k-tui[l/2+1]+jie[l/2+1]*10==s[l/2+1]-'0') h++;
		}
		ans1*=h;
	}
	return ans1;
}
int main()
{
	int i,j,mark,mark2=1,back,up,ans=0;
	while(~scanf("%s",s+1))
	{
		ans=0;
		l=strlen(s+1);
	int ii=l;
	for(l=ii;l<=18;l++)
	{
		mark2=1;
		if(l!=ii)
		{
			for(i=l;i>=2;i--)
			s[i]=s[i-1];
			s[1]='0';
		}
		//if(l==3) cout<<s+1<<endl;
		tui[0]=0;
	jie[l+1]=0;
	for(i=1;i<=l/2;i++)
	{
			mark=s[i]+s[l+1-i]-'0'-'0';
			if(mark%10==0)
			{
				back=0;
				up=0;
			}
			else if(mark%10==8)
			{
				back=2;
				up=1;
			}
			else if(mark%10==9)
			{
				back=1;
				up=1;
			}
			up+=mark/10;
			if(!(mark==0||mark==8||mark==9||mark==20||mark==19||mark==18||mark==10))mark2=0;
			jie[i]=tui[i-1];
			tui[l+1-i]=jie[l+1-i+1];
			jie[l+1-i]=up-jie[i];
			tui[i]=back-tui[l+1-i];
			if(tui[i]<0||tui[i]>1||jie[l+1-i]<0||jie[l+1-i]>1) mark2=0;
	}
	//cout<<tui[1]<<tui[2]<<endl;
	//cout<<jie[1]<<jie[2]<<endl;
	if(l%2==1)
	{
		jie[l/2+1]=tui[l/2];
		tui[l/2+1]=jie[l/2+2];
	}
	for(i=2;i<=l;i++)
	if(jie[i]!=tui[i-1]) mark2=0;
	if(mark2==1) ans+=hh();
	//cout<<l<<" "<<ans<<" "<<mark2<<endl;
	}
	//cout<<mark2<<endl;
	printf("%d\n",ans);
	}
	
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<pair<ll, int>> C(2*N);
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        C[i] = {A, 1};
    }
    for (int i = 0; i < N; i++) {
        int B;
        cin >> B;
        C[i+N] = {B, -1};
    }
    sort(C.begin(), C.end());
    
    ll mod = 1e9+7;
    ll ans = 1;
    ll cnt = 0;
    for (int i = 0; i < 2*N; i++) {
        if (cnt*C[i].second < 0) {
            ans *= abs(cnt);
            ans %= mod;
        }
        cnt += C[i].second;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6436
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N;

  long long a[3333], s = 0;
  
  std::cin >> N;

  for (int i = 0; i < N; i ++) {
    std::cin >> a[i];

    s += a[i] - 1;
  }

  std::cout << s << std::endl;

  return 0;
}


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

using namespace std;

#define ll long long 
#define REPL(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 10010;
static const ll INFTY = 1e12;
static const int NUMMAX = 300;
static const ll MOD = 1000000007;


int main() {

  int ans = 0;
  string S;

  cin >> S;

  if( S == "SUN" ){
    ans = 7;
  } else if( S == "MON" ){
    ans = 6;
  }else if( S == "TUE" ){
    ans = 5;
  }else if( S == "WED" ){
    ans = 4;
  } else if( S == "THU" ){
    ans = 3;
  } else if( S == "FRI" ){
    ans = 2;
  }else if( S == "SAT" ){
    ans = 1;
  }



  cout << ans << endl;

  return 0;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 256
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

n,x=gi
m = []
rep n do |variable|
  m << gif
end
m.sort!
sum = m.inject :+
puts n+(x-sum)/m[0]


Measured memory_bytes: 4348
#include <iostream>
#include <math.h>
using namespace std;

int main(){
  
  int n;

  while(cin >> n){
    bool Prime[1000000] = {};
    int i,j;
  
    for(i = 2; i <= sqrt(n) ; i++){
      if(Prime[i] == false){
        
	for(j = 2; i*j <= n ; j++){
	  Prime[i*j] = true;
	}
      }
    }
    int count = 0;
    for(i = 2 ; i <= n ; i++){
      if(Prime[i] == false){
	count++;
      }
    }
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 2140
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

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

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> field(H);
    for (int i = 0; i < H; i++) {
        cin >> field[i];
    }

    vector<string> field2;
    for (int i = 0; i < H; i++) {
        bool w = true;
        for (int j = 0; j < W; j++) {
            if (field[i][j] == '#') {
                w = false;
                break;
            }
        }

        if (!w) {
            field2.push_back(field[i]);
        }
    }

    H = field2.size();
    vector<string> field3(H);
    for (int i = 0; i < W; i++) {
        bool w = true;
        for (int j = 0; j < H; j++) {
            if (field2[j][i] == '#') {
                w = false;
                break;
            }
        }

        if (!w) {
            for (int j = 0; j < H; j++) {
                field3[j].push_back(field2[j][i]);
            }
        }
    }

    for (auto e : field3) {
        cout << e << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>

int main()
{
    int N;
    scanf("%d", &N);
    int dig = 0;
    int num = N;
    while (num > 0)
    {
        ++dig;
        num /= 10;
    }
    int m = dig % 2 == 0 ? dig - 1 : dig;
    int ans = 0;
    constexpr int cnt[3] = {1, 100, 10000};
    for (int i = 1; i <= m; i += 2)
    {
        if (i == m && m == dig)
        {
            ans += N - cnt[(m - 1) / 2] + 1;
        }
        else
        {
            ans += 9 * cnt[(i - 1) / 2];
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#define N 200010
using namespace std;
long long l[N], r[N], a[N], c[N], h[N];
int main()
{
	int n, m, i;
	long long now, cnt;
	long long ans;
	scanf("%d%d", &n, &m);
	ans = 0;
	for(i = 1; i <= n; ++i) scanf("%lld", &a[i]);
    for(i = 2; i <= n; ++i)
    {
    	if(a[i - 1] < a[i])
    	{
    		l[a[i - 1]]++;
    		r[a[i]]++;
    		h[a[i]] += a[i] - a[i - 1] - 1;
    		ans += a[i] - a[i - 1];
    	}else
    	{
    		l[a[i - 1]]++;
    		r[a[i] + m]++;
    		ans += a[i] - a[i - 1] + m;
    		h[a[i] + m] += a[i] - a[i - 1] + m - 1;
    	}
    }
    now = 0;
    cnt = 0;
    for(i = 1; i <= 2 * m; ++i)
    {
    	now += cnt;
    	c[i] = now;
    	cnt += l[i - 1];
    	cnt -= r[i];
    	now -= h[i];
    }
    long long t = 0;
    for(i = 1; i <= m; ++i) t = max(t, c[i] + c[i + m]);
    printf("%lld\n", ans - t);
	return 0;
}
/*
2 7
3 7
*/


Measured memory_bytes: 6528
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.card", "r", stdin);
	string str = "";
	while (getline (cin, str ) ){
		if (str.empty() ){
			break;
		} // end if
		vector <bool> used (11, false );
		int C1, C2, C3;
		stringstream ss(str);
		ss >> C1 >> C2 >> C3;
		int sum = C1 + C2;
		used[C1] = used[C2] = used[C3] = true;
		int enable = 0;
		int all = 0;
		int i;

		for (i = 1; i <= 10; ++i){
			if (!used[i]){
				++all;
				if (sum + i <= 20){
					++enable;
				} // end if
			} // end if
		} // end for
		double prob = (double)enable/(double)all*100.;
		if (prob >= 50.){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		} // end if
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0