akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
using namespace std;
 
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;
			
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);
int sub(int,int);
template<typename A> ostream& operator<<(ostream&,vector<A>&);
 
const int N=1000001;

void solve(){
	int n;
	cin>>n;
	vi a(n);
	cin>>a;
	multiset<int>st;
	for(int i=0;i<n;i++){
		st.insert(a[i]);
	}
	for(int i=0;i<n;i++){
		st.erase(st.find(a[i]));
		auto it=st.end();
		it--;
		cout<<*it<<"\n";
		st.insert(a[i]);
	}
	
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;
}


Measured memory_bytes: 11776
import math
n = int(input())
if math.floor(math.ceil((n*100)/108) * 1.08) == n:
    print(math.ceil((n*100)/108))
  
else:
    print(":(")

# print(math.ceil(((n*100)/108) * 1.08))
# print((((n*100)/108) * 1.08))

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

const int INF = 1 << 29;
const long long int Mod = 1000000007;
using ll = long long int;
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; ++i)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)

ll a[200010];

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


	rep(i, n) cin >> a[i];

	ll ans = 0;
	ll l = 0;

	rep(i, n) {
		l += a[i];
		l %= Mod;
	}

	for (int i = 0; i < n - 1; ++i) {
		l -= a[i];
		if (l < 0) l += Mod;
		ans += a[i] * l;
		ans %= Mod;
	}

	cout << ans % Mod << endl;
}

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

int a[50], b[50], c[50], d[50];
int n, m, q;
int mx = 0;
vector<int> t;

int check()
{
	int curr = 0;
	for(int i = 0; i<q; i++)
	{
		if(t[b[i]] - t[a[i]] == c[i]) curr += d[i];
	}
	return curr;
}

void dfs(int i, int cur)
{
	if(i>=n)
	{
		mx = max(mx, check());
		return ;
	}
	for(int j = cur; j<=m; j++)
	{
		t.push_back(j);
		dfs(i+1, j);
		t.pop_back();
	}
}

void solve()
{
	cin >> n >> m >> q;
	
	for(int i = 0; i<q; i++) 
	{
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--; b[i]--;
	}
	
	dfs(0, 1);
	cout << mx << "\n";			
}

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


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=1;i<=n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
using namespace std;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
typedef pair<ll,ll> P;

const ll MOD = 998244353;
int main(){
    int n; cin >> n;
    ll num[n];
    rep(i,n+1) num[i]=0;
    int d[n];
    rep(i,n){
        cin >> d[i];
        num[d[i]]++;
        if(i!=0 && d[i]==0){
            cout << 0;
            return 0;
        }
    }
    if(d[0]!=0){
        cout << 0 << endl;
        return 0;
    }
    ll ans = (ll)1;
    for(int i=1;i<n;i++){
        ll res = (ll)1;
        if(num[i]>0){
            rep(j,num[i+1]){
                res *= num[i];
                if(res>0) res%=MOD;
            }
        }
        if(res!=0){
            ans *= res;
            ans %= MOD;
        }
        if(num[i]==0 && num[i+1]!=0){
            cout << 0 << endl;
            return 0;
        }
    }
    ans%=MOD;
    cout << ans << endl;
}



Measured memory_bytes: 1408
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main() {
  int n = in();
  vector<int> s(n), l(n), p(n);
  rep(i, n) cin >> s[i] >> l[i] >> p[i];
  auto dp = vectors(n + 1, 394, 0LL);
  loop(i, 1, n + 1) rep(j, 394) {
    dp[i][j] = dp[i - 1][j];
    loop(k, s[i - 1], l[i - 1] + 1) {
      if (j - k >= 0) cmax(dp[i][j], dp[i][j - k] + p[i - 1]);
    }
  }
  int m = in();
  vector<int> ans;
  ans.reserve(m);
  while (m--) {
    int w = in();
    if (dp[n][w] == 0) {
      cout << -1 << endl;
      return 0;
    }
    ans.emplace_back(dp[n][w]);
  }
  for (auto &x : ans) cout << x << endl;
}



Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
#define reps(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(i, n) reps(i, 0, n)
#define deps(i, a, n) for (int i = (a); i >= (n); --i)
#define dep(i, n) deps(i, n, 0)
#define inf 2147483647
#define int long long

signed main(void)
{
	int tmp = 0;
	char c;
	while ((c = fgetc(stdin)) != '\n')
	{
		tmp += c - '0';
		tmp %= 9;
	}
	if (tmp) cout << "No" << endl;
	else cout << "Yes" << endl;
}


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

int main(){
    int A,B,C,D;
    cin >> A>>B>>C>>D;
    int de,ba;
    if(A<=B){
        de=A;
    }
    else{
        de=B;
    }
    if(C<=D){
        ba = C;
    }
    else{
        ba = D;
    }

    cout << de+ba << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<map>
#include<array>
#include<cstring>
#include<numeric>
#include<string>
#include<set>
#include<cstdio>
#include<cmath>
#include<unordered_map>
#include<bitset>
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> x;
    while(n--){
        int tmp;
        cin>>tmp;
        x.push_back(tmp);
    }
    int res = 1;
    for(int i=0; i<x.size()-1; i++){
        if(x[i]>x[i+1]) res++;
        else x[i+1] = x[i];
    }
    cout<<res<<"\n";
    return 0;
}


Measured memory_bytes: 4320
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int l,r,d;
    cin>>l>>r>>d;
    int x=l%d;
    if(x!=0)
        l+=(d-x);
    l=l/d;
    r=r/d;
    //cout<<l<<"  "<<r<<"\n";
    int c=(r-l)+1;
    cout<<c;
    return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int dp[1100];
int dp2[2][5100];

const int INF = 1<<29;


int N;
vector<int> tree[1100];
int X[1100];


void rec(int v, int p) {
    for (auto to : tree[v]) {
        if (to == p) continue;
        rec(to, v);
    }
    for (int i = 0; i < 2; ++i) for (int j = 0; j < 5100; ++j) dp2[i][j] = INF;
    dp2[0][0] = 0;
    for (int i = 0; i < tree[v].size(); ++i) {
        int ch = tree[v][i];
        for (int num = 0; num <= X[v]; ++num) {
            if (num + X[ch] < 5100) chmin(dp2[(i+1)%2][num + X[ch]], dp2[i%2][num] + dp[ch]);
            if (num + dp[ch] < 5100) chmin(dp2[(i+1)%2][num + dp[ch]], dp2[i%2][num] + X[ch]);
        }
        for (int num = 0; num < 5100; ++num) dp2[i%2][num] = INF;
    }
    for (int num = 0; num <= X[v]; ++num) chmin(dp[v], dp2[tree[v].size()%2][num]);
}


int main() {
    while (cin >> N) {
        for (int i = 0; i < 1100; ++i) tree[i].clear();
        for (int i = 0; i < N-1; ++i) {
            int p;
            cin >> p;
            --p;
            tree[p].push_back(i+1);
        }
        for (int i = 0; i < N; ++i) cin >> X[i];
        for (int i = 0; i < 1100; ++i) dp[i] = INF;
        rec(0, -1);
        if (dp[0] < INF) puts("POSSIBLE");
        else puts("IMPOSSIBLE");
    }
}











Measured memory_bytes: 384
from collections import Counter

def print_cnt(l):
    counter = Counter(l)
    max_cnt = counter.most_common(1)[0][1]
    ret = [v for v,c in counter.most_common() if c == max_cnt] # 最多２個以上にするなら ～if c > 1 and c == max_cnt
    ret=sorted(ret)
    for a in ret:
        print(a)


n = int(input())
print_cnt([input()for i in range(n)]) 

Measured memory_bytes: 45032
import sys
def input():
    return sys.stdin.readline()
X, Y, Z, K = map(int, input().split())
*A, = map(int, input().split())
*B, = map(int, input().split())
*C, = map(int, input().split())
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

abl = sorted([a + b for a in A for b in B], reverse=True)[:K]
abcl = sorted([ab + c for ab in abl for c in C], reverse=True)[:K]
for abc in abcl:
    print(abc)

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

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	
	if (a < 10 && b < 10)
	{
		cout << a*b;
	}
	else
	{
		cout << -1;
	}

	
	
	return 0;
}


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

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(0);    
    cin.tie(0);
		
	ll int a,b;
  cin>>a>>b;
  cout<<(a*b);

			 
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

ll a, b, n;

ll func(ll x) {
    return (a * x) / b - x / b * a;
}

int main() {
//	cout << fixed << setprecision(15);
    cin >> a >> b >> n;
    if(n < b - 1) cout << func(n) << endl;
    else cout << func(b - 1) << endl;
}


Measured memory_bytes: 3580
N, M = map(int, input().split())
H = list(map(int, input().split()))
result = [1 for _ in range(N)]

for m in range(M):
    A, B = map(int, input().split())
    if H[A-1] <= H[B-1]:
        result[A-1] = 0
    if H[A-1] >= H[B-1]:
        result[B-1] = 0

print(sum(result))

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

int main() {
  int N;
  cin >> N;
  string W[N];
  for (int i = 0; i < N; i++) cin >> W[i];
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i >= j) continue;
      if (W[i] == W[j]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  
  for (int i = 1; i < N; i++) {
    if (W[i][0] != W[i - 1].back()) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
}


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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

int main()
{
    // Fast_IO();
    ll a, b, n; cin >> a >> b >> n;
    ll ans = max((a*(n))/b - a*((n)/b),(a*(n-1))/b - a*((n-1)/b));
    if(b <= n) ans = max(ans,(a*(b))/b - a*((b)/b));
    if(b-1 <= n) ans = max(ans,(a*(b-1))/b - a*((b-1)/b));
    cout << ans;
    return 0;
}

Measured memory_bytes: 3596
using System;
class Program
{
    static void Main(string[] args)
    {
        // 整数の入力

        //// スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int Y = int.Parse(input[1]);


        //出力
        Console.WriteLine(NewMethod(N, Y).ToString());
    }

    private static string NewMethod(int N, int Y)
    {
        for (int i = 0; i <= N; i++)
        {
            for (int j = 0; j <= N; j++)
            {
                var k = N - i - j;
                if (k < 0)
                {
                    continue;
                }
                if (i * 10000 + j * 5000 + k * 1000 == Y && i + j + k == N)
                {
                    return i.ToString() + " " + j.ToString() + " " + k.ToString();
                }
            }
        }
        return "-1 -1 -1";
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e6+3;
ll fac[mod+10];
ll n,q,x,d;
ll pw(ll x,ll p){
	ll ret=1;
	while(p){
		if(p&1)ret=ret*x%mod;
		x=x*x%mod;
		p>>=1;
	}
	return ret;
}
int main(){
	scanf("%lld",&q);
	fac[0]=1;for(int i=1;i<=mod;i++)fac[i]=fac[i-1]*i%mod;
	while(q--){
		scanf("%lld%lld%lld",&x,&d,&n);
		if(!d)
			printf("%lld\n",pw(x,n));
		else{
			ll t=x*pw(d,mod-2)%mod;
			if(t+n-1>=mod||!t)
				puts("0");
			else{
				ll ret=pw(d,n)*fac[t+n-1]%mod*pw(fac[t-1],mod-2)%mod;
				ret=(ret%mod+mod)%mod;
				printf("%lld\n",ret);
			}
		}
	}
	return 0;
}

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

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

	int count = 0;

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

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 10

struct Point{
	Point(double arg_x,double arg_y){
		x = arg_x;
		y = arg_y;
	}

	Point(){
		x = y = 0.0;
	}

	Point operator + (Point p){ return Point(x+p.x,y+p.y); }
	Point operator - (Point p){ return Point(x-p.x,y-p.y);}
	Point operator * (double a){ return Point(a*x,a*y); }
	Point operator / (double a){ return Point(x/a,y/a); }

	double abs(){ return sqrt(norm()); }
	double norm(){ return x*x + y*y; }

	bool operator<(const Point &p) const{
		return x != p.x? x < p.x: y < p.y;
	}

	bool operator == (const Point &p) const{
		return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
	}

	double x,y;
};

typedef Point Vector;
typedef vector<Point> Polygon;

int N,M;

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

double dot(Vector a,Vector b){
    return a.x*b.x + a.y*b.y;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -1;
static const int ON_SEGMENT = 0;

int ccw(Point p0,Point p1,Point p2){

	Vector a = p1 - p0;
	Vector b = p2 - p0;

	if(cross(a,b) > EPS)return COUNTER_CLOCKWISE;
	if(cross(a,b) < -EPS)return CLOCKWISE;
	if(dot(a,b) < -EPS)return ONLINE_BACK;
	if(a.norm() < b.norm())return ONLINE_FRONT;

	return ON_SEGMENT;
}

Point calc_Cross_Point(double x1,double x2,double x3,double x4,double y1,double y2,double y3,double y4){
	Point ret;
	ret.x = ((x2-x1)*(y3*(x4-x3)+x3*(y3-y4))-(x4-x3)*(y1*(x2-x1)+x1*(y1-y2)))/((y2-y1)*(x4-x3)-(y4-y3)*(x2-x1));
	if(x1 != x2){
		ret.y = ((y2-y1)*ret.x+y1*(x2-x1)+x1*(y1-y2))/(x2-x1);
	}else{
		ret.y = ((y4-y3)*ret.x+y3*(x4-x3)+x3*(y3-y4))/(x4-x3);
	}
	return ret;
}

Point calc_Cross_Point(Point a,Point b,Point c,Point d){
	return calc_Cross_Point(a.x,b.x,c.x,d.x,a.y,b.y,c.y,d.y);
}

Polygon ConvexCut(Polygon g,Point a,Point b){

	Polygon ret;
	int N = g.size();

	for(int i = 0; i < g.size(); i++){
		Point A = g[i], B = g[(i+1)%N];
		if(ccw(a,b,A) != -1)ret.push_back(A);
		if(ccw(a,b,A)*ccw(a,b,B) == -1)ret.push_back(calc_Cross_Point(a,b,A,B));
	}

	return ret;
}

double calc_S(Polygon g){

	int N = g.size();
	double ret = 0;

	for(int i = 0; i < g.size(); i++){
		ret += cross(g[i],g[(i+1)%N]);
	}
	return ret/2.0;
}

void func(){

	Point C[NUM];
	Polygon L;

	double tmp_x,tmp_y;

	for(int i = 0; i < N; i++){
		scanf("%lf %lf",&tmp_x,&tmp_y);
		L.push_back(Point(tmp_x,tmp_y));
	}

	for(int i = 0; i < M; i++){
		scanf("%lf %lf",&C[i].x,&C[i].y);
	}

	for(int i = 0; i < M; i++){
		Polygon p = L;
		for(int k = 0; k < M; k++){
			if(k == i)continue;

			Point from = (C[i]+C[k])/2;
			Vector v1 = C[k]-C[i];
			Vector v2 = Vector(-v1.y,v1.x);
			Point to = from+v2;
			p = ConvexCut(p,from,to);
		}
		printf("%.10lf\n",calc_S(p));
	}
}

int main(){

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}

	return 0;
}



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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll k;
	cin>>k;
	vector<ll> vl;
	string s = "~abcdefghijklmnopqrstuvwxyz";
	if(k<=26)
	{
		cout<<s[k]<<endl;
		return 0;
	}
	while(k>=26)
	{
		ll yu = k%26;
		k/=26;
		if(yu == 0)
		{
			yu = 26;
			k--;
		}
		vl.pb(yu);
	}
	if(k>0)
		vl.pb(k);
	reverse(all(vl));
	FOR(i,0,vl.size())
	{
		if(vl[i]>0)cout<<s[vl[i]];
		else cout<<"z";
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3628
from sys import stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
dp = [1 for i in range(N+1)]
MOD = 1000000007
for _ in range(M):
  a = int(stdin.readline().rstrip())
  dp[a] = 0
for i in range(2, N+1):
    if dp[i] == 0:
        continue
    dp[i] = dp[i-1]+dp[i-2]
print(dp[N] % MOD)

Measured memory_bytes: 460056
#define M 32768
n,D[15],S[15],P[15][M],R[15][M],Q[15*M];E(c,p,I){int r,s,J;if(~P[p][I]){if(r=P[p][I],E(c+1,s=r/M,J=r%M),s-p&&printf("Move to room %d.\n",p+1),J-I){for(r=0;J^I^1<<r;r++);printf("Switch o%s room %d.\n",I&1<<r?"n":"ff",r+1);}}else printf("You can go home in %d steps.\n",c);}J,q,m,s,r,e;main(p,I){for(;scanf("%d%d",&n,&m),n;P[n][1<<n]?E(0,n,1<<n):puts(e?"You can not switch off all lights.":"Help me!")){for(memset(D,e=0,60);m--;D[--r]|=1<<--s,D[s]|=1<<r)scanf("%d%d",&r,&s);for(memset(P,I=r=0,60*M);r<n;I|=s<<r++)scanf("%d",&s);for(memset(Q,r=0,60*M);r<n;r++)for(S[r]=!scanf("%d",&m);m--;S[r]|=1<<--s)scanf("%d",&s);I[*P]=-1;I[*R]=*S;n--;for(q=I;I&&!P[n][1<<n];I=Q[p*M+I]){p=I/M,I%=M;for(s=R[p][I];r=-s&s;J&1<<p&&!P[p][J]?q=Q[P[p][J]=p*M+I,R[p][J]=s,q]=p*M+J:0)J=I^r,s^=r;for(r=n+1;r--;)I&D[p]&1<<r&&!P[r][I]?q=Q[P[r][I]=p*M+I,R[r][I]=S[r],e|=r==n,q]=r*M+I:0;}}exit(0);}

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

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

Measured memory_bytes: 7196
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 958585860497

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

ll csum[2][200005];
int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);


	while(cin >> n >> m >> k)
	{
		for(i = 1; i <= n; i++)
		{
			slld(input);

			csum[0][i] = input + csum[0][i - 1];
		}

		for(i = 1; i <= m; i++)
		{
			slld(input);

			csum[1][i] = input + csum[1][i - 1];
		}
		ans = 0;

		for(i = 1; i <= n && csum[0][i] <= k; i++)
		{
			ll lft = k - csum[0][i];

			ll pabo = 0;
			ll lo = 1;
			ll hi = m;

			while(lo <= hi)
			{
				ll mid = (lo + hi) / 2;

				if(csum[1][mid] <= lft)
				{
					pabo = mid;
					lo = mid + 1;
				}
				else
				{
					hi = mid - 1;
				}
			}

//			cout << i << " " << pabo << " " << lft << endl;

			ans = max(ans, pabo + i);
		}

		for(i = 1; i <= m && csum[1][i] <= k; i++)
		{
			ll lft = k - csum[1][i];

			ll pabo = 0;
			ll lo = 1;
			ll hi = n;

			while(lo <= hi)
			{
				ll mid = (lo + hi) / 2;

				if(csum[0][mid] <= lft)
				{
					pabo = mid;
					lo = mid + 1;
				}
				else
				{
					hi = mid - 1;
				}
			}

			ans = max(ans, pabo + i);
		}

		cout << ans << '\n';
	}


}






Measured memory_bytes: 6752
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>

#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(long (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(long (i)=(a)-1;(i)>=(b);(i)--)
#define MOD 1000000007
#define PI acos(-1.0)
#define DEBUG(C) cout<<C<<endl;
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<long,long>
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).begin(),(a).end(),greater<int>())
#define MP(a,b) make_pair(a,b)
#define FORE(a,b) for(auto &&a:b)

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;

int main(void){
	int a,b; cin>>a>>b;
	if(a==b) cout<<"a == b";
	else if(a<b) cout<<"a < b";
	else cout<<"a > b";
	cout<<endl;
}

Measured memory_bytes: 3112
#include <stdio.h>
#include <stdlib.h>
#define Mod 1000000007

int **g;
int used[100000] = {};
int in[100000] = {};
int k;

long long ans;

long long P(long long a, long long b){
  long long r =  1;
  if(a < b) return 0;
  for(int i = 0; (long long)i < b; i++){
    r = r * a % Mod;
    a--;
  }
  return r;
}



void dfs(int u){
  used[u] = 1; int cnt = 0;
  for(int i = 0; i < in[u]; i++){
    if(used[g[u][i]] == 0) cnt++;
   
  }
  
  ans = ans * P((long long)k - 2, (long long)cnt) % Mod;
  for(int i = 0; i < in[u]; i++){
    if(used[g[u][i]] == 0){
      used[g[u][i]] = 1;
      dfs(g[u][i]);
    }
  }
  return;
}
      
  

int
main(int argc, char *atgv[])
{
  g = malloc(sizeof(int *) * 100000);
  for(int i = 0; i < 100000; i++){
    g[i] = (int *)malloc(sizeof(int) * 100000);
  }
  
  int n;
  used[0] = 1;
  int a, b;
  scanf("%d %d", &n, &k);
  for(int i = 0; i < n - 1; i++){
    scanf("%d %d", &a, &b);
    a--; b--;
    g[a][in[a]] = b; in[a]++;
    g[b][in[b]] = a; in[b]++;
  }
 
    
  ans = (long long)k * P((long long)k - 1, (long long)in[0]) % Mod;

  for(int i = 0; i < in[0]; i++){
    dfs(g[0][i]);
  }

  printf("%lld\n", ans);

  for(int i = 0; i < 100000; i++){
    free(g[i]);
  }
  free(g);

  return 0;
}

  
  


Measured memory_bytes: 407788
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

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

  int ans=0;
  REP(i,s.size()/2){
    if(s[i]!=s[s.size()-1-i]) ans++;
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int maxLength = scan.nextInt();
		int otherLength = maxLength;
		for(int i = 1;i <= n-1;i++) {
			int currentLength = scan.nextInt();
			otherLength = otherLength + currentLength;
			if(maxLength <= currentLength) {
				maxLength = currentLength;
			}
		}
		otherLength = otherLength- maxLength;
		if(maxLength < otherLength) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 23508
#include <iostream>
#include<stdio.h>
#define MAXSIZE 10000
#define PI 3.141592653589
using namespace std;
int main(){
  while(1){
    int H,W;
    std::cin >> H>>W;
    if(0==H&&0==W){
      return 0;
    }

    for(int i=0;i<H;i++){
      if(i%2==0){
        for(int j=0;j<W;j++){
          if(j%2==0){
            std::cout << "#";
          }else{
            std::cout << ".";
          }
        }
        std::cout  << '\n';
      }else{
        for(int j=0;j<W;j++){
          if(j%2==0){
            std::cout << ".";
          }else{
            std::cout << "#";
          }
        }
        std::cout  << '\n';
      }

    }
    std::cout  << '\n';
  }

}

Measured memory_bytes: 3100
# from math import ceil,sqrt,log,gcd,pi
# def ii():return int(input())
# def si():return input()
# def mi():return map(int,input().split())
# def li():return list(mi())

# for _ in range(ii()):
a,b=map(int,input().split())
s=(a+b)
if(s==0 or s%2):
    print("IMPOSSIBLE")
else:
    x=0
    if(s!=0):
        x=abs(s)//2
    print(x)

Measured memory_bytes: 38256
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

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

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

int main() {
    int n = read();
    vector<pair<int, int> > seg(n);
    generate_n(seg.begin(), n, []() -> pair<int, int> {
        return {read(), read()};
    });
    sort(seg.begin(), seg.end());

    set<int> sr1, sr2;
    for (int i = 0; i < n - 1; ++i) {
        sr1.emplace(seg[i].second);
    }
    sr2.emplace(seg.back().second);

    int ans = 0;
    for (int i = n - 2; i >= 0; --i) {
        int l1 = seg[i].first;
        int l2 = seg.back().first;
        int r1 = seg[i].second;
        int r2 = *sr2.begin();
        int rr1 = sr1.empty() ? INT_MAX : *sr1.begin();
        int rr2 = INT_MAX;

        ans = max(ans, max(min(rr1, r1) - l1 + 1, 0) + max(min(rr2, r2) - l2 + 1, 0));
        swap(rr1, rr2);
        ans = max(ans, max(min(rr1, r1) - l1 + 1, 0) + max(min(rr2, r2) - l2 + 1, 0));

        sr1.erase(seg[i].second);
        sr2.emplace(seg[i].second);
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N; cin >> N;
  ll M; cin >> M;
  
  vector<int> A(N);
  for (auto& a : A) { cin >> a; }
  
  set<int> s{};
  ll t{1};
  ll ans{};
  ll r{-1};
  for (const auto& a : A) {
    int l = 1;
    int b = a / 2;
    while (b % 2 == 0) { b /= 2; ++l; }
    s.emplace(l);
    t = boost::lcm(t, (ll)a/2);
    if (t > M) {
      goto err;
    }
  }
  if (s.size() != 1) {
    goto err;
  }
  r = t;
  while (r <= M) {
    r += t * 2;
    ++ans;
  }

err:
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int num[5];
	int sum=0,cut=0;
	for(int i=0;i<5;i++){
		cin >> num[i];
	}
	for(int i=0;i<5;i++){
		if((num[i]%10)==0){
			sum += num[i];
		}else{
		sum += 10*((num[i]/10)+1);
			if((10-(num[i]%10))>cut){
				cut=(10-(num[i]%10));
			}
		}
	}
	int ans = sum-cut;
	cout <<ans;
	
	return 0;
}



Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let X: usize = read();
    let Y: usize = read();
    let A: usize = read();
    let B: usize = read();
    let C: usize = read();
    let mut As: Vec<usize> = (0..A).map(|_| read()).collect();
    As.sort();
    As.reverse();
    let mut Bs: Vec<usize> = (0..B).map(|_| read()).collect();
    Bs.sort();
    Bs.reverse();
    let Cs: Vec<usize> = (0..C).map(|_| read()).collect();
    let mut all: Vec<usize> = Cs;
    all.extend_from_slice(&As[0..X]);
    all.extend_from_slice(&Bs[0..Y]);
    all.sort();
    all.reverse();
    let ans: usize = all[0..X + Y].iter().sum();
    println!("{}", ans)
}


Measured memory_bytes: 7084
x, y = map(int, input().split())

g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]

if (x in g1 and y in g1) or (x in g2 and y in g2):
    print('Yes')
else:
    print('No')


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

using namespace std;

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

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

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

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

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

char s[2521];
int n,k;

int dpx[2521][2521][2];
int dpy[2521][2521][2];
int ansx[2521], ansy[2521];

void calc(int dp[2521][2521][2],int ans[2521], string s,int k){
  // dp[i][j][x] := pos i, used j, [min, max]
  int n = s.size();
  REP(i,n+1)REP(j,k+1)dp[i][j][0] = 1e9, dp[i][j][1] = -1e9;
  dp[0][0][0] = dp[0][0][1] = 0;
  REP(i,n)REP(j,k+1){
    if(dp[i][j][0] > dp[i][j][1])continue;
    char c = s[i];
    int way = 1;
    if(c=='R' && j%2==1)way = -1;
    if(c=='L' && j%2==0)way = -1;
    CHMIN(dp[i+1][j][0],dp[i][j][0]+way);
    CHMAX(dp[i+1][j][1],dp[i][j][1]+way);
    // use magic
    CHMIN(dp[i+1][j+1][0],dp[i][j][0]-way);
    CHMAX(dp[i+1][j+1][1],dp[i][j][1]-way);
  }
  // calc ans
  ans[0] = max(abs(dp[n][0][1]),abs(dp[n][0][0]));
  FOR(j,1,k+1){
    ans[j] = ans[j-1];
    if(dp[n][j][0] > dp[n][j][1])continue;
    CHMAX(ans[j], abs(dp[n][j][1]));
    CHMAX(ans[j], abs(dp[n][j][0]));
  }
}

int main(){
  scanf("%s",s);
  scanf("%d",&k);
  n = strlen(s);
  string x,y;
  REP(i,n){
    if(s[i]=='L'||s[i]=='R'){
      x += s[i];
    }else{
      y += s[i]=='U' ? 'L' : 'R';
    }
  }
  calc(dpx,ansx,x,k);
  calc(dpy,ansy,y,k);
  int ans = 0;
  REP(i,k+1)CHMAX(ans, ansx[i]+ansy[k-i]);
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 42528
# include <algorithm>
# include <cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<cstdlib>
using namespace std;
namespace fastio{
	template<typename tn> void read(tn &a){
	    tn x=0,f=1;char c=' ';
	    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	    for(;isdigit(c);c=getchar() ) x=x*10+c-'0';
	    a=x*f;
	}
	template<typename tn> void print(tn a){
	    if(a<0) putchar('-'),a=-a;
	    if(a>9) print(a/10);
	    putchar(a%10+'0');
	}
};
using namespace fastio;
string c; 
int main(){
	cin>>c;
	if(c=="SUN"){puts("7");return 0;}
	if(c=="MON"){puts("6");return 0;}
	if(c=="TUE"){puts("5");return 0;}
	if(c=="WED"){puts("4");return 0;}
	if(c=="THU"){puts("3");return 0;}
	if(c=="FRI"){puts("2");return 0;}
	if(c=="SAT"){puts("1");return 0;}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int cnt[69];

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

	ll N; cin >> N;
	for (int i = 0; i < N; i++) {
		ll A; cin >> A;
		for (int i = 0; A > 0; i++) {
			cnt[i] += A % 2;
			A /= 2;
		}
	}

	ll sum = 0;
	ll num = 1;
	for (int i = 0; i < 63; i++) {
		ll tmp = cnt[i] * (N - cnt[i]); tmp %= MOD;
		tmp *= num; tmp %= MOD;
		sum += tmp; sum %= MOD;

		num *= 2; num %= MOD;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
A={int(input()) for _ in range(m)}
mod=10**9+7

dp=[0]*(n+1)
dp[0]=1
if 1 not in A:
   dp[1]=1

for i in range(2,n+1):
   if i not in A:
      dp[i]=dp[i-1]+dp[i-2]
print(dp[-1]%mod)

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

int main() {
    int N;
    int A;
    int B;

    cin >> N >> A >> B;

    int HOGE = A * N;

    if (HOGE > B) {
        cout << B << endl;
    } else {
        cout << HOGE << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a,b;
    char op;
    
    while(op != '?'){
        scanf("%d %c %d",&a, &op, &b);
        if(op == '+'){
            printf("%d\n", a+b);
        }else if(op == '-'){
             printf("%d\n", a-b);
        }else if(op == '*'){
             printf("%d\n", a*b);
        }else if(op == '/'){
             printf("%d\n", a/b);
        }
    }
    return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<iomanip>
#include<stdio.h>
using namespace std;

int main(){
	int N;
	cin>>N;
	int res=N/2;
	if(N%2)
		res++;
	double ans=res;
	cout<<setiosflags(ios::fixed)<<setprecision(10)<<ans/N<<endl; 
	return 0;
}

Measured memory_bytes: 256
import copy

n = int(input())
A = []
for _ in range(n):
    a = list(map(int, input().split()))
    A.append(a)

Check = copy.deepcopy(A)

for k in range(n):
    for i in range(n):
        for j in range(n):
            Check[i][j] = min(Check[i][j], Check[i][k]+Check[k][j])

Graph_exist = True
for i in range(n):
    for j in range(n):
        if A[i][j] != Check[i][j]:
            Graph_exist = False

Road_exist = [[True for _ in range(n)] for _ in range(n)]
for i in range(n):
    Road_exist[i][i] = False

for k in range(n):
    for i in range(n):
        for j in range(n):
            if i == j or i==k or j==k:
                continue
            if A[i][j] == (A[i][k] + A[k][j]):
                Road_exist[i][j] = False

ans = 0
for i in range(n):
    for j in range(i+1,n):
        if Road_exist[i][j] == True:
            ans += A[i][j]

if Graph_exist == False:
    ans = -1
print(ans)

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

int main(){
    int n;
    
    while(true){
        int cnt = 0;
        unsigned long long int s[4002]={0},gs[4002]={0};
        
        cin >> n;
        if(!n) break;
        
        int t,cost;
        int num;
        for(int i = 0 ; i < n ; i++){
            cin >> num >> t >> cost;
            s[num] += t*cost;
            gs[i] = num;
        }
        
       for(int i = 0 ; i < n ; i++){
            for(int j = i+1 ; j < n ; j++){
                if(gs[i]==gs[j]&&i < j){
                    gs[j] = 4001;
                }
            }
        }
        
        for(int i = 0 ; i < n ; i++){
            if(s[gs[i]] >= 1000000){
                cout << gs[i] << endl;
                cnt++;
            }
        }
        if(!cnt) cout << "NA" << endl;
    }
    
    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s[3];

int main() {
	inc(i, 3) { cin >> s[i]; }
	
	cout << s[0][0] << s[1][1] << s[2][2] << endl;
	
	return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int main() {
   int n;
   cin >> n;
   if (n >= 1000) {
      printf("ABD\n", n);
   } else {
      printf("ABC\n", n);
   }

   return 0;
}

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

const int N = 123456;

int a[N];

int main(){

	int n;
	scanf("%d", &n);

	for (int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
	}

	int ans = 0;	
	for (int i = 1; i <= n; i++){
		if (i == a[a[i]] && i < a[i]) ans++;
	}

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

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

ll n,a,b,k;

ll fact[300010];
const ll mod = 998244353;

ll Pow(ll b, ll e){
	if(e<0) e=(-e)*(mod-2)%(mod-1);
	ll ret=1;
	while(e){
		if(e&1) (ret*=b)%=mod;
		(b*=b)%=mod; e>>=1;
	}
	return ret;
}

ll Comb(ll n, ll r){
	return fact[n]*Pow(fact[r], -1)%mod*Pow(fact[n-r], -1)%mod;
}

int main()
{
	read(n,a,b,k);
	fact[0]=1;
	for(int i=1; i<=n; ++i) fact[i]=fact[i-1]*i%mod;
	ll ans = 0;
	for(int p=0; p<=n; ++p){
		ll q = (k-p*a)/b;
		if(p*a + q*b == k && 0<=q && q<=n){
			(ans += Comb(n, p) * Comb(n, q) % mod) %= mod;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


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

string s;
bool memo[500][500] = {}, visit[500][500] = {};

bool cat(int i, int j){
    if(visit[i][j]) return memo[i][j];
    visit[i][j] = true;
    if(i >= j)  return memo[i][j] = true;
    if(s[i] != 'm' || s[j] != 'w')  return memo[i][j] = false;
    bool ret = false;
    for(int k = i+1; k < j; k++){
        if(s[k] == 'e'){
            ret |= (cat(i+1, k-1)&&cat(k+1, j-1));
        }
    }
    return memo[i][j] = ret;
}

int main(){
    cin >> s;
    cout << (cat(0, s.length()-1) ? "Cat" : "Rabbit") << endl;
    return 0;
}


Measured memory_bytes: 3620
import math

H, W = map(int, input().split())
n = 0

if(H==1 or W==1):
    n = 1
else:
    if(H%2==0 or W%2==0):
        n = int(H*W/2)
    else:
        n = int(H*(W-1)/2 + math.ceil(H/2))
        
print(n)


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<ctime>
#define INF 1e9
using namespace std;
const int maxn=3;
int s[3],t[10];
int main()
{
	scanf("%d%d%d",&s[0],&s[1],&s[2]);
	t[s[0]]++;
	t[s[2]]++;
	t[s[1]]++;
	if(t[s[0]]==2||t[s[1]]==2||t[s[2]]==2)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 128