akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    if(abs(a-b)%2==1)
        cout<<"IMPOSSIBLE";
    else cout<<abs(a-b)/2+min(a,b);
    return 0;
}


Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let S = get!(String);

    let mut A = S.chars().collect::<Vec<_>>();
    A.sort();
    let ans = if A[0] == A[1] && A[1] != A[2] && A[2] == A[3] {
        "Yes"
    } else {
        "No"
    };

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

Measured memory_bytes: 4352
//
// Created by yuki on 2018/9/10.
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;
const int maxn = 100005;
int num[maxn];
int dist[maxn];
int n, x;

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

int main() {
    cin >> n >> x;
    for (int i = 1; i <= n; i++) cin >> num[i];
    for (int i = 1; i <= n; i++) dist[i] = abs(num[i] - x);
    int ans = dist[1];
    for (int i = 1; i <= n; i++) {
        ans = gcd(ans, dist[i]);
    }
    cout << ans << endl;
}

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

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

vector<int> graph[20];

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

    rep(i, N)
    {
        int x, y;
        cin >> x >> y;

        x--;
        y--;

        graph[x].push_back(y);
    }

    vector<int> indeg(M);
    stack<int> s;

    for (auto edges : graph)
        for (auto v : edges)
            indeg[v]++;

    rep(i, M) if(indeg[i] == 0) s.push(i);

    vector<int> ans;

    while(s.size() > 0)
    {
        int u = s.top();
        s.pop();

        ans.emplace_back(u);

        for(auto v : graph[u])
        {
            indeg[v]--;
            if(indeg[v] == 0) s.push(v);
        }
    }

    rep(i, M) cout << ans[i] + 1 << endl;

    return 0;
}


Measured memory_bytes: 3160
def main(): 
    n = int(input())
    v = list(map(int, input().split()))
    a = [0]*(10**5+7)
    b = [0]*(10**5+7)
    for i in v[::2]:
        a[i]+=1
    for i in v[1::2]:
        b[i]+=1
    ama = max(a)
    bma = max(b)
    
    if a.index(ama)!=b.index(bma):
        print(n-ama-bma)
    else:
        a[a.index(ama)] = 0
        ama2 = max(a)
        b[b.index(bma)] = 0
        bma2 = max(b)
        print(min(n-ama-bma2, n-ama2-bma))
    
    
    
    

    
main()

Measured memory_bytes: 85440
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=10000;
const ll INF=1000000010;
const int MAX=100001;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int m,f,b;
    cin>>m>>f>>b;
    if(m+f<b){
        cout<<"NA"<<endl;
    }else{
        cout<<max(0,b-m)<<endl;
    }
    return 0;
}



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

const int N = 200010;
const int moder = 200003;
const int rt = 2;

const double PI = acos(-1.0);
const int MAX = 20;
typedef long long ll;

struct comp{
    double real, imag;

    comp(double real = 0, double imag = 0):real(real), imag(imag){}

    comp operator +(const comp &c)const{
        return comp(real + c.real, imag + c.imag);
    }

    comp operator -(const comp &c)const{
        return comp(real - c.real, imag - c.imag);
    }

    comp operator *(const comp &c)const{
        return comp(real * c.real - imag * c.imag, real * c.imag + imag * c.real);
    }

    comp operator *(const double &c)const{
        return comp(real * c, imag * c);
    }
};

comp w[2][1 << MAX];

void init(){
    for (int i = 0; i < 1 << MAX; ++i){
        double angle = 1.0 * i / (1 << (MAX - 1)) * PI;
        for (int type = -1; type <= 1; type += 2){
            w[!~type][i] = comp(std::cos(angle), type * std::sin(angle));
        }
    }
}

void FFT(std::vector <comp> &a, int len, int type){
    for (int i = 1, j = 0; i < len - 1; ++i){
        for (int s = len; j ^= s >>= 1, ~j & s; )
            ;
        if (i < j){
            std::swap(a[i], a[j]);
        }
    }
    for (int i = 2, d = 1; i <= len; i <<= 1, ++d){
        for (int j = 0; j < len; j += i){
            auto u = a.begin() + j;
            for (int k = 0; k < i / 2; ++k){
                comp s = u[k], t = w[type][k << (MAX - d)] * u[k + i / 2];
                u[k] = s + t, u[k + i / 2] = s - t;
            }
        }
    }
    if (type == 0) return;
    double inv = 1.0 / len;
    for (int i = 0; i < len; ++i){
        a[i] = a[i] * inv;
    }
}

const int M = 1 << 19;

ll cnt[M], cnt1[M];
int logarithm[N], power[N];

int main(){
    init();
    /*for (int i = 1; i <= moder; ++ i){
        if (moder % i == 0){
            printf("%d\n", i);
        }
    }*/
    memset(logarithm, -1, sizeof(logarithm));
    int prod = 1, cur = 0;
    while (true){
        logarithm[prod] = cur;
        power[cur] = prod;
        prod = 1ll * prod * rt % moder;
        ++ cur;
        if (prod == 1){
            break;
        }
    }
    /*for (int i = 1; i < moder; ++ i){
        if (logarithm[i] == -1){
            printf("%d\n", i);
            fflush(stdout);
        }
    }*/
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++ i){
        int x;
        scanf("%d", &x);
        if (x == 0){
            continue;
        }
        ++ cnt[logarithm[x]];
        int y = 2 * logarithm[x] % (moder - 1);
        ++ cnt1[y];
    }
    std::vector<comp> aux(M);
    for (int i = 0; i < M; ++ i){
        aux[i].real = cnt[i];
    }
    FFT(aux, M, 0);
    for (int i = 0; i < M; ++ i){
        aux[i] = aux[i] * aux[i];
    }
    FFT(aux, M, 1);
    ll ans = 0;
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < M; ++ i){
        ll num = ll(std::round(aux[i].real));
        cnt[i % (moder - 1)] += num;
    }
    for (int i = 0; i < moder - 1; ++ i){
        ans += (cnt[i] - cnt1[i]) / 2 * power[i];
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main(void){
    while(true){
        int n, min=10000, max=-1, sum=0;
        cin >> n;
        if(n==0) break;
        for(int i=0;i<n;++i){
            int s;
            cin >> s;
            sum += s;
            max = (max > s)? max: s;
            min = (min < s)? min: s;
        }
        cout << (sum-max-min)/(n-2) << endl;
    }
}


Measured memory_bytes: 3004
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;
static const int N = 1000;


int lcs(string X, string Y) {
	int m = X.size();
	int n = Y.size();
	int c[N + 1][N + 1];
	for ( int i = 1; i <= m; ++i ) c[i][0] = 0;
    for ( int i = 1; i <= n; ++i ) c[0][i] = 0;
    int max1=0;
    X = ' ' + X;
    Y = ' ' + Y;
    for(int i = 1; i <= m; ++i )	
    	for( int j = 1; j <= n; ++j) {
    		if ( X[i] == Y[j]) {
    			c[i][j] = c[i-1][j-1] + 1;
    		} else {
    			c[i][j] = max( c[i-1][j], c[i][j-1]);
    		}
    		max1 = max (max1, c[i][j]);
    	}
	return max1;

}
int main() {

	int n;
    string X, Y;

    cin >> n;
    while ( n-- ) {
    	cin >> X >> Y;
    	cout << lcs(X, Y) << endl;
    }
	return 0;
}


Measured memory_bytes: 7064
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  ll X,Y;
  cin >> X >> Y;
  if(Y==1)
  {
    cout << -1 << endl;
    return 0;
  }
  if(X%Y!=0)
  {
    cout << X << endl;
  }
  else
  {
    cout << -1 << endl;
  }
  return 0;
}


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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0;i<n;i++)cin >> a[i];
	sort(a.begin(),a.end());
	int cnt = 1,ans=0;
	for(int i = 0;i<n-1;i++)
	{
		if(a[i]!=a[i+1])
		{
			if(cnt%2==1)ans++;
			cnt=1;
		}
		else
		{
			cnt++;
		}	
	}
	if(cnt%2==1)ans++;
cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;



int main()
{
	ll n,m,a[200005]={},b;
	cin>>n;
	for(ll i=1;i<n;i++)
	{
		cin>>b;
		a[b]++;
	}
	for(ll i=1;i<=n;i++)
	{
		cout<<a[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 5196
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mod = 998244353;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

int main(){
    ll a,p; cin >> a >> p;
    p += a*3;
    cout << p/2 << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int x = stdIn.nextInt();
        int y = stdIn.nextInt();
        
        
        if(x == 1 & y == 1){
            System.out.println(1000000);
        }else if(x <= 3 & y <= 3){
            System.out.println(400000 - (x * 100000) + 400000 - (y * 100000));
        }else if(x > 3 & y <= 3){
            System.out.println(400000 - (y * 100000));
        }else if(x <= 3 & y > 3){
            System.out.println(400000 - (x * 100000));
        }else{
            System.out.println(0);
        }
        
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 2e5 + 5;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
 
int fac[MAX_N], inv[MAX_N];
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b, bool usemod = true) {ll c = 1LL; while (b > 0) {if (b & 1LL) {if(!usemod)c*=a;else c = a * c%mod;}if (!usemod) a*=a;else a = a * a%mod; b >>= 1LL;}return c;}
void _nCr() {fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) {fac[i] = fac[i - 1LL] * i%mod;}for (int i = 0; i < MAX_N; i++) {inv[i] = POW(fac[i], mod - 2);}}
ll nCr(ll n, ll r) {return (fac[n] * inv[r] % mod)*inv[n - r] % mod;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}

class Warshall_Floyd {
public:
	vector<vector<int>> d;
	int nodecnt = -1;

	Warshall_Floyd(int n) {
		d = vector<vector<int>>(n,vector<int>(n,INF));
		nodecnt = n;
	}

	void add(int s,int e,int cost) {
		d[s][e] = cost;
	}

	bool wf() {
		for (int k = 0;k < nodecnt;k++) {
			for (int i = 0;i < nodecnt;i++) {
				for (int j = 0;j < nodecnt;j++) {
					//k経由でi->j
					d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
				}
			}
		}
	}
};

bool solve() {
	int h,w; cin >> h >> w;
	Warshall_Floyd wf(10);
	REP (i,10) {
		REP (j,10) {
			int x; cin >> x;
			wf.add(i,j,x);
		}
	}
	wf.wf();
	int ans = 0;
	REP (i,h) {
		REP (j,w) {
			int x; cin >> x;
			if (x == -1) {
				continue;
			} else {
				ans += wf.d[x][1];
			}
		}
	}
	cout << ans << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

Measured memory_bytes: 256
n = int(input())
ab = [[int(ii) for ii in input().split()] for i in range(n)]
ab = sorted(ab, key=lambda x: x[1])

time = 0
flag = True
for a, b in ab:
    time += a
    if time > b:
        print("No")
        flag = False
        break
        
if flag:
    print("Yes")

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

int main(){
  int N;
  cin >> N;
  vector<long long> X(N);
  vector<long long> Xc(N);
  int loop;
  for(loop=0;loop<N;loop++){
    cin >> X[loop];
  }
  Xc=X;
  sort(Xc.begin(),Xc.end());
  long long gre=Xc[(N/2)-1],lea=Xc[(N/2)];
  for(loop=0;loop<N;loop++){
    if(X[loop]<=gre){
      cout << lea << endl;
    }else{
      cout << gre << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 5376
/*
	In the name of ALLAH
	Author : Raashid Anwar
*/

#include <bits/stdc++.h>
using namespace std;

#define int int64_t
#define mod 1000000007


int power(int a,int b) {
	int r=1;
	while(b) {
		if(b&1)
			r=(r*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return r;
}

int dp[20][20][20][20];
int n,m;
string s[20];

void bfs(int x,int y,int i,int j,int d) {
	if(i<0||j<0||i>=n||j>=m)
		return ;
	if(s[i][j]=='#')
		return ;
	if(dp[x][y][i][j]!=-1&&dp[x][y][i][j]<=d)
		return ;
	dp[x][y][i][j]=d;
	bfs(x,y,i-1,j,d+1);
	bfs(x,y,i+1,j,d+1);
	bfs(x,y,i,j-1,d+1);
	bfs(x,y,i,j+1,d+1);
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int ans=0;
	cin>>n>>m;
	for(int i=0;i<n;i++) {
		cin>>s[i];
	}
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++) {
		for(int j=0;j<m;j++) {
			bfs(i,j,i,j,0);
		}
	}
	for(int i=0;i<n;i++) {
		for(int j=0;j<m;j++) {
			for(int x=0;x<n;x++) {
				for(int y=0;y<m;y++) {
						ans=max(ans,dp[i][j][x][y]);
				}
			}
		}
	}
	cout<<ans<<"\n";
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
static const ll MOD = 1000000007;

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> p(N);
  for(int i = 0; i < N; i++){
    cin >> p[i];
  }
  vector<double> E(N);
  for(int i = 0; i < N; i++){
    E[i] = (double) (p[i] + 1) / 2;
  }
  double sum = 0;
  for(int i = 0; i < K; i++){
    sum += E[i];
  }
  double sumMax = sum;
  for(int i = 1; i + K <= N; i++){
    sum = sum - E[i-1] + E[i+K-1];
    sumMax = max(sumMax, sum);
  }
  cout << fixed << setprecision(10) << sumMax << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
long double arr[3005],dp[3005][3005];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long n,i,j,k,x,y,z;
    long double ans=0.0;
    cin>>n;
    for (i=1;i<=n;i++)
    {
    	cin>>arr[i];
	}
	dp[1][0]=1-arr[1];
	dp[1][1]=arr[1];
	for (i=2;i<=n;i++)
	{
		for (j=0;j<=(n-1);j++)
		{
			dp[i][j+1]+=(dp[i-1][j]*arr[i]);
		}
		for (j=0;j<=(n-1);j++)
		{
			dp[i][j]+=(dp[i-1][j]*(1-arr[i]));
		}
	}
	for (i=n;i>(n/2);i--)
	{
		ans+=dp[n][i];
	}
	cout<<setprecision(15)<<ans<<endl;
}

Measured memory_bytes: 141056
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

ll k,a,b;
int main(){
    cin>>k>>a>>b;
    if(a+1>=b||k<=a){
        cout<<k+1<<endl;
        return 0;
    }
    ll cnt=(k+1-a)/2;
    ll ans=(b-a)*cnt+a+((k+1-a)&1);
    cout<<ans<<endl;
    return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    short X; cin >> X;
    if (X >= 30) cout << "Yes" << "\n";
    else cout << "No" << "\n";
    return EXIT_SUCCESS;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll n,h[30],c=0,d=0;
  cin >> n;
  rep(i,n)cin >> h[i];
  rep(i,n){
    if(d<=h[i]){
      d=h[i];
      c++;
    }
  }
  printf("%lld",c);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
int main() {
	string a;
	string d[10] = { "",".,!? ","abc","def","ghi","jkl","mno",
		"pqrs","tuv","wxyz" };
	int m;
	cin >> m;
	for (int z = 0; z < m; z++) {
		cin >> a;
		string c = "";
		for (int i = 0; i < a.length();) {
			while (a[i] == '0'&&i < a.length())i++;
			if (i == a.length()) break;
			int j = i;
			while (a[j] == a[i] && i < a.length()) {
				i++;
			}
			int sum = i - j - 1;
			sum %= d[(int)a[j] - '0'].length();
			if (i < a.length() && a[i] == '0')c += d[(int)a[j] - '0'][sum];
		}
		if (c != "") cout << c << endl;
	}
}

Measured memory_bytes: 3140
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		String[] coordinates = input().split(" ");
		double x1 = Double.parseDouble(coordinates[0]);
		double y1 = Double.parseDouble(coordinates[1]);
		double x2 = Double.parseDouble(coordinates[2]);
		double y2 = Double.parseDouble(coordinates[3]);

		System.out.println(Math.sqrt(Math.abs(Math.pow((x2 - x1), 2)) + Math.abs(Math.pow((y2 - y1), 2))));

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 26332
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main(void){
    long N,K;
    long ans=0;
    cin>>N>>K;
    vector<pair<long,long> > pairs(N);
    for(long i=0;i<N;i++){
        cin>>pairs[i].first>>pairs[i].second;
    }
    sort(pairs.begin(),pairs.end());
    for(long i=0;i<N;i++){
        K=K-pairs[i].second;
        if(K<=0) {ans=pairs[i].first; break;}
    }
    cout<<ans;
    return 0;
}


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

#define datatype int

typedef enum{
	false,
	true
}Boolean;

typedef struct node_sub{
	datatype data;
	struct node_sub *next;
}node;

typedef struct {
	node *fst;
	int num;
}stack;

stack *make_stack(){
	stack *s = (stack *)malloc(sizeof(stack));
	s->fst = NULL;
	s->num = 0;
	return s;
}

Boolean stack_is_empty(stack *s){
	if(s->num == 0){
		return true;
	}
	else{
		return false;
	}
}

void stack_add_data(datatype val, stack *s){
	node *fst = (node *)malloc(sizeof(node));
	fst->data = val;
	fst->next = s->fst;
	s->fst = fst;
	s->num++;
}

datatype stack_take_data(stack *s){
	if(s->num == 0){
		printf("no data in the stack\n");
	}
	datatype ans = s->fst->data;
	node *fst = s->fst;
	s->fst = fst->next;
	free(fst);
	s->num--;
	return ans;
}

datatype stack_look_data(stack *q){
	if(q->num == 0){
		printf("no data in the stack\n");
	}
	else{
		return q->fst->data;
	}
}

typedef struct {
	node *fst;
	node *last;
	int num;
}queue;

queue *make_queue(){
	queue *q = (queue *)malloc(sizeof(queue));
	q->fst = NULL;
	q->last = NULL;
	q->num = 0;
	return q;
}

Boolean queue_is_empty(queue *q){
	if(q->num == 0){
		return true;
	}
	else{
		return false;
	}
}

void queue_add_data(datatype val, queue *q){
	node *last = (node *)malloc(sizeof(node));
	last->data = val;
	last->next = NULL;
	if(queue_is_empty(q) == true){
		q->fst = last;
	}
	else{
		q->last->next = last;
	}
	q->last = last;
	q->num++;
}

datatype queue_take_data(queue *q){
	if(q->num == 0){
		printf("no data in the queue\n");
	}
	datatype ans = q->fst->data;
	node *fst = q->fst;
	if(q->num == 1){
		q->fst = NULL;
		q->last = NULL;
	}
	else{
		q->fst = fst->next;
	}
	free(fst);
	q->num--;
	return ans;
}

datatype queue_look_data(queue *q){
	if(q->num == 0){
		printf("no data in the queue\n");
	}
	else{
		return q->fst->data;
	}
}

void insert_node(int val, node **v){
	node *new = (node *)malloc(sizeof(node));
	new->data = val;
	new->next = *v;
	*v = new;
}

int main(){
	int N, a, b, v, i;
	node *n;
	scanf("%d", &N);
	node **relative = (node **)malloc(sizeof(node *) * N);
	int *parent = (int *)malloc(sizeof(int) * N);
	Boolean *exist = (Boolean *)malloc(sizeof(Boolean) * N);
	for(i = 0; i < N; i++){
		relative[i] = NULL;
		exist[i] = true;
	}
	for(i = 1; i < N; i++){
		scanf("%d%d", &a, &b);
		a--;
		b--;
		insert_node(a, &relative[b]);
		insert_node(b, &relative[a]);
	}
	stack *s = make_stack();
	queue *q = make_queue();
	queue_add_data(0, q);
	stack_add_data(0, s);
	parent[0] = -1;
	while(queue_is_empty(q) == false){
		v = queue_take_data(q);
		for(n = relative[v]; n != NULL; n = n->next){
			if(n->data != parent[v]){
				queue_add_data(n->data, q);
				stack_add_data(n->data, s);
				parent[n->data] = v;
			}
		}
	}
	while(stack_is_empty(s) == false){
		v = stack_take_data(s);
		if(exist[v] == true){
			if(exist[parent[v]] == true){
				exist[parent[v]] = false;
			}
			else{
				printf("First\n");
				return 0;
			}
		}
	}
	printf("Second\n");
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    if (a <= b) {
        cout << "unsafe\n";
    }
    else {
        cout << "safe\n";
    }
}


Measured memory_bytes: 3660
def main():
    n = int(input())
    hs = list(map(int, input().split()))
    result = 0
    tmp = 0
    for i, h in enumerate(hs):
        if i == len(hs) - 1:
            result = max(tmp, result)
        elif hs[i + 1] <= h:
            tmp += 1
            result = max(tmp, result)
        else:
            tmp = 0
    print(result)


main()


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

string s, t;
int cnt;

int main() {
	
	ios_base::sync_with_stdio(false);
	cin >> s >> t;
	cnt = 0;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] != t[i]) cnt++;
	}
	cout << cnt;
}

Measured memory_bytes: 3868
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#define MN 100000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int main()
{
    long long n;scanf("%lld",&n);
    long long ans=n/11*2;n%=11;
    if(n>0) ++ans;if(n>6) ++ans;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
string S;int X,Y,d=0,x,y=0;cin>>S>>X>>Y;S+="T";vector<int> dx,dy;
for(auto s:S) if(s=='F') d++; else{ (dx.size()==dy.size()? dx:dy).push_back(d); d = 0; }
sort(dx.rbegin(), dx.rend());sort(dy.rbegin(), dy.rend());x=dx.back();dx.erase(dx.end()-1);
for(auto d:dx) x+=d*(x<X? 1:-1);
for(auto d:dy) y+=d*(y<Y? 1:-1);
cout<<(x==X&&y==Y? "Yes":"No")<<endl;
}


Measured memory_bytes: 3612
;; #!/usr/bin/env sbcl --script

;; (declaim (optimize (speed 3) (safety 0) (debug 0)))

(deftype int32 () '(signed-byte 32))

(defun main ()
  (let* ((n (read))
         (k (read))
         (a (make-array n :element-type 'int32))
         (dp (make-array n :element-type 'int32 :initial-element (+ (expt 10 9) 100))))
    ;; (let ((stream (make-string-input-stream (read-line))))
    ;;   (loop for i from 0
    ;;      for j = (read stream nil) until (null j)
    ;;      do (setf (aref a i) j))
    (loop for i of-type int32 from 0 below n do (setf (aref a i) (read)))
    (setf (aref dp 0) 0)
    (loop for i of-type int32 from 0 below n do
      (loop with from-val of-type int32 = (aref dp i)
         for j of-type int32 from (1+ i) to (+ i k)
         while (< j n)
         do
           (let ((nval (+ from-val (abs (- (aref a i) (aref a j))))))
             (setf (aref dp j) (min (aref dp j) nval)))))
    (format t "~a~%" (aref dp (- n 1)))))

(main)


Measured memory_bytes: 59752
class Main{
  void doIt(){
    for(int i = 1;i <= 9;i++){
      for(int k = 1;k <= 9;k++){
        System.out.printf("%dx%d=%d\n",i,k,(i*k));
      }
    }
  }
  public static void main(String[] args){
    new Main().doIt();
  }
}

Measured memory_bytes: 24776
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>=r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(a-1)),y(b){}_RX(int a):_RX(up?0:a,up?a:0){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef int64_t i64;
typedef uint64_t u64;
// const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

using namespace std;

int main() {

	const i64 h = read_item();
	const i64 w = read_item();

	if(h == 1 || w == 1) {
		printf("1\n");
		return 0;
	}
	const i64 a = (h * w + 1) / 2;
	printf("%lld\n", a);

	return 0;
}

/* wafdayo~~~ */


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a[4],i,j,t=0;
	for(i=0;i<3;i++) scanf("%d",&a[i]);
	for(i=0;i<2;i++){
		for(j=i+1;j<3;j++){
			if(a[i]>a[j]){
				t=a[i]; a[i]=a[j]; a[j]=t;
			}
		}
	}
	printf("%d ",a[0]);
	for(i=1;i<3;i++){
		printf("%d",a[i]);
		if(i<2) printf(" ");
	}	
	printf("\n");
	return 0;
}

Measured memory_bytes: 2700
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize m:usize)(h_list:[i64]){m;ab_list:(@,@)});
    let mut goods = Vec::with_capacity(n);
    goods.resize(n, true);
    for (a, b) in ab_list {
        let ah = h_list[a];
        let bh = h_list[b];
        if ah >= bh {
            goods[b] = false;
        }

        if ah <= bh {
            goods[a] = false;
        }
    }
    goods.into_iter().filter(|x| *x).count().to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "4 3\n1 2 3 4\n1 3\n2 3\n2 4\n" => "2\n",
    test2: "6 5\n8 6 9 1 2 1\n1 3\n4 2\n4 3\n4 6\n4 6\n" => "3\n",
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

vector<int> x(10), y(10);

double distance(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx*dx+dy*dy, 0.5);
}

int main() {
    int N; cin >> N;
    for (int i = 1; i <= N; ++i) {
        cin >> x[i] >> y[i];
    }

    // 点（町）の順番の配列を0〜N-1番まで作成
    vector<int> v(N);
    for (int i = 0; i < N; ++i) {
        v[i] = i + 1;
    }
 
    // 階乗の計算
    int cnt=1;
    for (int i = 1; i <= N; ++i) {
        cnt *= i;
    }

    // 今いる町v[i]から、次の町v[i+1]までの距離を求め、総和（dis_sum）を計算。
    // next_permutation()で順列の総数分（vの組み合わせを変え、trueを返すので）繰り返す。
    double dis_sum= 0.0;
    do {
        for (int i = 0; i < N - 1; ++i) {
            dis_sum += distance(v[i], v[i+1]);
        }
    } while (next_permutation(v.begin(), v.end()));

    // 浮動小数点10桁までの精度で「距離の平均」を出力。
    cout << setprecision(10) << dis_sum / cnt << endl;
    return 0;
}

Measured memory_bytes: 256
function Main(input) {
  input = input.trim().split(" ");
  var A = parseInt(input[0], 10);
  var B = parseInt(input[1], 10);
  var N = parseInt(input[2], 10);

  var x = Math.min(B - 1, N);
  var f = Math.floor((A * x) / B) - A * Math.floor(x / B);
  console.log(f);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29420
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc179
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
            solve_abc179A();
            Console.Out.Flush();
        }

        public static void solve_abc179B()
        {
        }

        public static void solve_abc179A()
        {
            string s = Console.ReadLine();
            Console.WriteLine(s.EndsWith('s') ? s + "es" : s + "s");
        }
    }
}

Measured memory_bytes: 26700
#include <stdio.h>
int main(void){
    int n;
    int s;
    int S=0;
    int m=100;
    int i=0;
    
    for(;~scanf("%d",&s);){
        i&&s%10&&(m=fmin(m,s));
        i++&&(S+=s);
    }
    m>99&&(S=m);
    printf("%d",S%10?S:S-m);
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#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,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    string s; cin >> s;
    unordered_map<string, int> m;
    m["SUN"]=7;m["MON"]=6;m["TUE"]=5;m["WED"]=4;
    m["THU"]=3;m["FRI"]=2;m["SAT"]=1;

    cout << m[s] << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define mp make_pair
#define r0 return 0

/* const */
const int inf = 1e9 + 7;
const int dxl[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dyl[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dxs[4] = {1, 0, -1, 0};
const int dys[4] = {0, 1, 0, -1};

/* main */
signed main(void)
{
    int a, p;
    cin >> a >> p;
    cout << ((a * 3) + p) / 2 << endl;
    return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

    ll n; std::cin >> n;
    vl cnt(n+1, 1);
    srep(i, 2, n+1) {
        for (int j = i; j <= n; j+=i) {
            cnt[j]++;
        }
    }

    ll ans = 0;
    rrep(k, n) {
        ans += cnt[k] * k;
    }
    std::cout << ans << "\n";
}


Measured memory_bytes: 81336
pnum,mtime = map(int,input().split(" "))

total = [list(input().split(" ")) for _ in range(pnum)]

cnt=0
tcnt=0
while len(total) > 0:
	ztime = int(total[0][1]) - mtime
	if ztime <= 0:
		tcnt += int(total[0][1])
		print(total[0][0],int(tcnt))
		total.pop(0)
	else:
		total.append([total[0][0],ztime])
		total.pop(0)
		tcnt += mtime
	cnt += 1



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

using namespace std;
typedef long long ll;
const int N = 3010;
const int mod = 998244353;
int n, s;
ll arr[N], dp[N][N];
bool vis[N][N];

ll fun(int pos, int rem) {
  if (pos > n) {
    if (rem == 0) return 1;
    return 0;
  }
  ll &ret = dp[pos][rem];
  if (vis[pos][rem]) return ret;
  vis[pos][rem] = true;
  ret = 0;
  if (rem >= arr[pos]) {
    ret = (ret + fun(pos + 1, rem - arr[pos])) % mod;
  }
  ret = (ret + 2LL*fun(pos + 1, rem)) % mod;
  return ret;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> s;
  for (int i = 1; i <= n; ++i) cin >> arr[i];
  cout << fun(1, s) << '\n';
}

Measured memory_bytes: 83160
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,flag1=0,flag2=0,ta=0,yo=0;
  vector<long long> a;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>ta;
    a.push_back(ta);
  }
  ta=0;
  sort(a.begin(),a.end(),greater<long long>());
  for(int i=0;i<n;i++){
    if(flag1==0 && a[i]==a[i+1]){
      ta=a[i];
      i++;  
      flag1=1;
    }
    else if(a[i]==a[i+1]){
      yo=a[i];
      break;
    }
  }
  if(yo==0 || ta==0)
    cout<<0<<'\n';
  else
    cout<<ta*yo<<'\n';
  return(0);
}

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

using namespace std;

int main()
{

        int a;
        double sum=1,sum1=0,n;
        double d;

        cin>>a;
        while(a--){
            cin>>n;
            sum1+=1.0/n;


        }
        d=(1./sum1);

        printf("%lf\n",d);




}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = INT_MAX;
const ll LLINF = LLONG_MAX;
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
  
#define DIV 1000000007
typedef vector<ll> Array;
typedef vector<Array> matrix;
typedef tuple<int,int,int> tiii;
#define mt make_tuple
ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if(n&1==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}

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


Measured memory_bytes: 512
//@uthor: _|EE|_RB30

#include<bits/stdc++.h>
using namespace std;
#define int long long

#define vi vector<int>
#define vpi vector<pair<int,int>>
#define pb push_back

#define pii pair<int,int>
#define mii map<int,int>
#define mpi map<pair<int,int>,int>

#define M 1000000009
#define pi 3.141592653589793238
#define endl "\n"
#define brisk ios_base::sync_with_stdio(false);cin.tie(NULL);

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

    	string s[n];
    	map<string,int> mm;

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

    	cout<<"AC x "<<mm["AC"]<<endl;
    	cout<<"WA x "<<mm["WA"]<<endl;
    	cout<<"TLE x "<<mm["TLE"]<<endl;
    	cout<<"RE x "<<mm["RE"]<<endl;
}


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

bool isPalindrome(string s){
	int len=s.length();
	int l=0,r=len-1;
	while(l<r){
		if(s[l]!=s[r]) return false;
		l++,r--;
	}
	return true;
}

int main(){
	string s;
	cin >> s;
	int len=s.length();
	string t="";
	for(int i=0;i<len;i++) if(s[i]!='x') t+=s[i];
	if(!isPalindrome(t)){
		cout << "-1\n";
		return 0;
	}
	int l=0,r=len-1;
	int cnt=0;
	while(l<r){
		if(s[l]==s[r]) l++,r--;
		else if(s[l]=='x') cnt++,l++;
		else if(s[r]=='x') cnt++,r--;
	}
	
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  string S, T;
  cin >> S >> T;
  reverse(S.begin(), S.end());
  reverse(T.begin(), T.end());

  int S_size = S.size();

  vector<int> Ans_S(S_size+3, 0);
  rep(i, S_size) {
    Ans_S[i] = (S[i]-'0')*(T[0]-'0');
  }
  srep(i, 1, S_size+1) {
    Ans_S[i] += (S[i-1]-'0')*(T[1]-'0');
  }
  srep(i, 2, S_size+2) {
    Ans_S[i] += (S[i-2]-'0')*(T[3]-'0');
  }

  rep(i, S_size+2) {
    if (Ans_S[i] >= 10) {
      Ans_S[i+1] += Ans_S[i]/10;
      Ans_S[i] %= 10;
    }
  }
  reverse(Ans_S.begin(), Ans_S.end());

//  for (const auto& e : Ans_S) {
//    cout << e << '\n';
//  }
  bool is_first = true;
  rep(i, S_size+1) {
    if (is_first == true && Ans_S[i] == 0) {
    } else if (is_first == true) {
      cout << Ans_S[i];
      is_first = false;
    } else {
      cout << Ans_S[i];
    }
  }
  if (is_first == true) cout << '0';
  cout << '\n';
}


Measured memory_bytes: 3676