akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

int main() {
	int N, K;
	string S;
	cin >> N >> K;
	cin >> S;
	int a[200000];
	int prev = 0;
	int ans = 0;
	a[0] = 1;
	for (int i = 1; i < N+2; i++) {
		a[i] = 0;
	}
	int cnt = 0;
	for (int i = 1; i < N; i++) {
		if (S[i] == S[i - 1]) a[cnt]++;
		else {
			cnt++;
			a[cnt]++;
		}
	}
	if (2 * K > cnt) {
		cout << N << endl;
		return 0;
	}
	if (S[0] == '0') {
		for (int i = 0; i < 2 * K; i++) ans += a[i];
		for (int i = 1; i < cnt + 1; i += 2) {
			for (int j = i; j < 2 * K + 1 + i; j++) prev += a[j];
			if (prev > ans) ans = prev;
			prev = 0;
		}
	}
	else {
		for (int i = 0; i < cnt + 1; i += 2) {
			for (int j = i; j < 2 * K + 1 + i; j++) prev += a[j];
			if (prev > ans) ans = prev;
			prev = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 896
import sys
from itertools import accumulate
sys.setrecursionlimit(10 ** 9)

N = int(input())
A = list(map(int, input().split()))
acc = [0] + list(accumulate(A))

# dp[i][j] := 区間[i, j]のスライムたちを１匹にまとめるのに必要なコスト
dp = [[None] * N for _ in range(N)]
for i in range(N):
    dp[i][i] = 0


def dfs(i, j):
    if j - i == 1:
        dp[i][j] = A[i] + A[j]
        return dp[i][j]

    if dp[i][j] is not None:
        return dp[i][j]

    ret = float('inf')
    for x in range(i, j):
        ret = min(ret, dfs(i, x) + dfs(x + 1, j) + acc[j + 1] - acc[i])

    dp[i][j] = ret
    return ret


print(dfs(0, N - 1))


Measured memory_bytes: 48092
#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include "bits/stdc++.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
//typedef tree<int, null_type, less<int>, rb_tree_tag, 
//             tree_order_statistics_node_update> 
//    ost;
#define rep(i,l,r)   for (int i = (l); i < (r); i++)
#define here cout << " Hey!!\n";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
template <typename T>
void etch(T V) {
	for (auto x : V)	cout << x << ' ' ;
	cout << '\n';
}
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
const int MOD = 1e9+7;
const int MOD1 = 998244353;
const int N = 2e5+5;
const int INF = 1000111000111000111LL;
const ld EPS = 1e-12;
const ld PI = 3.141592653589793116;
int a[3001][3001];
int dp[3001][3001][4];

int solve (int r, int c, int k) {
	if (dp[r][c][k] != -1)	return dp[r][c][k];
	if (k < 0)	return -INF;
	if (r < 1 or c < 1)	return 0;
	int res = 0;
	res = max(res, a[r][c] + solve(r-1,c,2));
	res = max(res, a[r][c] + solve(r, c-1, k-1));
	res = max(res, solve(r, c-1, k));
	return (dp[r][c][k] = res);
}
int32_t main()
{
	SYNC
	int r, c, k; cin >> r >> c >> k;
	while (k--) {
		int i, j, val;
		cin >> i >> j >> val;
		a[i][j] = val;
	}
	memset(dp, -1, sizeof dp);
	cout << max({solve(r, c, 2), solve(r, c, 2), solve(r, c, 1), solve(r, c, 0)});
	return 0;
}

Measured memory_bytes: 355804
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


N, C, K = il()
T = sorted(imi(N))
ll = []
c = 1
ll = [T[0]]
for t in T[1:]:
    if len(ll) == C or ll[0] + K < t:
        ll = []
        c += 1
    ll.append(t)
print(c)


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

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
    mint choose(int n, int a){
        mint x = 1 ,y = 1;
        for(int i = 0; i < a; ++i){
            x *= n-i;
            y *= i+1;
        }
        return x / y;
    }
    friend istream& operator>>(istream& is, mint& m){
        is >> m.x;
        return is;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

mint d[100010];

int main(){
  int n,k;
  cin>>n>>k;
  for(int i=1; i<=k; ++i){
    d[i]=mint(k/i).pow(n);
  }
  for(int i=k; i>=1; --i){
    for(int j=i+i; j<=k; j+=i){
      d[i]-=d[j];
    }
  }
  mint ans=0;
  for(int i=1; i<=k; ++i)ans+=d[i]*i;
  cout<<ans<<endl;
}

Measured memory_bytes: 4432
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())

N, M, C = tuple(li())
Bs = tuple(li())
cnt = 0

for i in range(N):
    total = 0
    Ai = tuple(li())
    for j, b in enumerate(Bs):
        total += b * Ai[j]
    if total + C > 0:
        cnt += 1

print(cnt)


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

int main()
{
	int n;
	cin >> n;
	bool ans = false;
	for(auto i = 0; i < n; ++i){
		char s;
		cin >> s;
		if(s == 'Y') ans = true;
	}
	cout << (ans ? "Four" : "Three") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
using namespace std;
#define int long long
 
signed main() {
	int dig = -1;//10^p
	for (int i = 0; i < 10; i++) {
		int a = pow(10, i);
		cout << "? " << a << endl;
		char c;
		cin >> c;
		if (c == 'N') {
			dig = i-1;
			break;
		}
	}
	
	if (dig == -1) {
		for (int i = 0; i < 10; i++) {
			int a = pow(10, i) + 1;
			cout << "? " << a << endl;
			char c;
			cin >> c;
			if (c == 'Y') {
				int ans = pow(10, i);
				cout <<"! "<<ans<< endl;
				return 0;
			}
		}
	}
	int lb=pow(10,dig+1), ub=pow(10,dig+2);
 
	while (ub - lb > 1) {
		int mid = (ub + lb) / 2;
		cout << "? " << mid << endl;
		char c;
		cin >> c;
		if (c == 'Y') {
			ub = mid;
		}
		else lb = mid;
	}
	cout << "! " << ub/10 << endl;
}

Measured memory_bytes: 596
#include <string>
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

string X;

int main() {

	cin >> X;

	int i = 0;

	while (1) {
		if (i == X.length() - 1||X.length()==0) { break; }
		if (X[i] == 'S'&&X[i + 1] == 'T') { X.erase(i, 2); i--; }
		else { i++; }
	}

	cout << X.length() << endl;

	return 0;
}

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

int N;
string S;

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

    vector<int> ans;
    int all_E = 0;
    for (int i = 0; i < N; i++){
        if (S[i] == 'E') all_E++;
    }
    ans.push_back(all_E);

    int cnt_W = 0; 
    for (int i = 0; i < N; i++) {
        if (S[i] == 'W') {
            ans.push_back(ans[i] + 1);
        }
        else {
            ans.push_back(ans[i] - 1);
        }
    }

    sort(begin(ans), end(ans));

    cout << ans[0] << endl;

    return 0;
}


Measured memory_bytes: 2812
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

unordered_map<ll, ll> mp;

void solve() {
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = unordered_map<ll, ll>();
#pragma clang diagnostic pop
#endif

        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        cout << max(a * b, c * d) << endl;
        solve();

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]

ans = []
A.sort()
if A[0] >= 0:
    ans.append([A[0], A[1]])
    A[1] = A[0]-A[1]
    A.pop(0)
elif A[-1] <= 0:
    ans.append([A[-1], A[-2]])
    A[-2] = A[-1]-A[-2]
    A.pop(N-1)
for i in range(1, len(A)-1):
    if A[i] < 0:
        ans.append([A[-1], A[i]])
        A[-1] -= A[i]
    else:
        ans.append([A[0], A[i]])
        A[0] -= A[i]
if N > 2:
    ans.append([A[-1], A[0]])
print(A[-1]-A[0])
for a in ans:
    print(*a)

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

using namespace std;

const int N = 25;
int a[N],b[N],c[N];

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    for(int i=1;i<=n;i++) cin >> b[i];
    for(int i=1;i<=n-1;i++) cin >> c[i];
    
    int ans = b[a[1]];
    for(int i=2;i<=n;i++){
    	if(a[i]==a[i-1]+1) ans += c[a[i]-1];
    	ans += b[a[i]];
	}
	cout << ans << endl;
    
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		long n, k;
		long ans = 0;
		Scanner scan = new Scanner(System.in);

		n = scan.nextLong();
		k = scan.nextLong();

		long a = n % k;

		if(a == 0) {
			System.out.println(0);
		} else {
			System.out.println(Math.min(a, Math.abs(a-k)));
		}
	}
}


Measured memory_bytes: 22996
def main():
    n, *a, = map(int, open(0).read().split())
    m = max(a)

    d = [0] * (m+1)
    d[1] = 1
    for i in range(2, m+1):
        for j in range(i, m+1, i):
            if d[j] == 0:
                d[j] = i

    def primes(x):
        ps = set()
        while x != 1:
            p = d[x]
            ps.add(p)
            x = x // d[x]
        return ps

    b = set()
    c = primes(a[0])
    f = 1
    for i in a:
        ps = set()
        while i != 1:
            p = d[i]
            ps.add(p)
            i = i // d[i]
        if f:
            if b & ps:
                f = 0
            b |= ps
        c &= ps

    if f:
        ans = "pairwise coprime"
    elif len(c) == 0:
        ans = "setwise coprime"
    else:
        ans = "not coprime"

    print(ans)


if __name__ == '__main__':
    main()


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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second

typedef long long ll;
typedef pair<int, int> pii;

const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int memo[MAXN];

inline int nxt(int i, vector<pii>& a, int n) {
	return upper_bound(a.begin(), a.end(), mk(a[i].se, -INF)) - a.begin();
}

int solve(int i, vector<pii>& a, int n) {
	if (i == n) return 0;

	int& ret = memo[i];
	if (~ret) return ret;

	ret = 1 + solve(nxt(i, a, n), a, n);
	ret = max(ret, solve(i+1, a, n));	
	return ret;
}

int main() {
	memset(memo, -1, sizeof memo);

	int n; scanf("%d", &n);
	vector<pii> a(n);

	for (int i = 0; i < n; i++) {
		int x, l; scanf("%d%d", &x, &l);
		a[i] = {x-l, x+l};
	}
	sort(a.begin(), a.end());
	printf("%d\n", solve(0, a, n));

	return 0;
}

Measured memory_bytes: 6144
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;
long long n; 
int main()
{
  cin>>n;
  cout<<n*800-(n/15)*200<<endl;
  return 0;
}


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

void Main() {
    // input
    int A, B;
    cin >> A >> B;


    // translate
    for (u_int64_t price = 1; price < 1010; price++) {
        if (floor(price * 0.08) == A && floor(price * 0.1) == B) {
            cout << price << endl;
            return;
        }
    }
    cout << -1 << endl;


    // output

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3604
"use strict"
 const Main = (input) =>{
   let xs = input.trim().split('\n');
   let N = xs[0].split(' ')[0] -0;
   let M = xs[0].split(' ')[1] -0;
   let p =xs.slice(1).map(v=>v.split(' ')[0]);
   let s =xs.slice(1).map(v=>v.split(' ')[1]);
   
   let ans = 0;
   let pena = 0;
   let list = new Array(N);
   let miss = new Array(N);
   list.fill(0);
   miss.fill(0);
   
   for (let i=0; i<M; i++) {
    if (list[p[i]-1]){ //list[p[0]=1-1] list[0]=0 つまりfalseということ
    continue;//falseはここを飛ばす
    }
    if (s[i] === "AC"){　　　　　//ここの処理でACがあったらfor文を止める
      pena += miss[p[i]-1];//0
      ans++;
      list[p[i]-1] = 1;
    }
    else if (s[i] === "WA"){
      miss[p[i]-1]++;//+1
    }
  }
 
  console.log(ans + " " + pena);
 
  return;
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 50200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n, m;
  cin >> n >> m;
  vll a(n), b(n), c(m), d(m);
  for (ll i = 0; i < n; i++) cin >> a[i] >> b[i];
  for (ll i = 0; i < m; i++) cin >> c[i] >> d[i];

  for (ll i = 0; i < n; i++) {
    vector<vll> v(0);
    for (ll j = 0; j < m; j++) {
      ll dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      vll w = {dist, j};
      v.push_back(w);
    }
    sort(all(v));
    cout << v[0][1] + 1 << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
using static Func;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static T[] Recurse<T>(int n, T a0, Func<int, T, T> f) { var a = new T[n]; a[0] = a0; for (var i = 1; i < n; i++) a[i] = f(i, a[i - 1]); return a; }
	static T[] Accumulate<T>(IList<T> a, T zero, Func<T, T, T> f) { var s = new T[a.Count + 1]; s[0] = zero; for (var i = 0; i < a.Count; i++) s[i + 1] = f(s[i], a[i]); return s; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		int N = I[0], M = I[1];
		var uf = new UnionFindTree(N);
		for (var i = 0; i < M; i++)
		{
			I = G;
			uf.UniteCategory(I[0] - 1, I[1] - 1);
		}
		var s = new HashSet<int>();
		for (var i = 0; i < N; i++) s.Add(uf.GetRootOf(i));
		WriteLine(s.Count);
	}
}
static class Func { }
class Pair
{
	public readonly int A, B;
	public Pair(int a, int b) { A = a; B = b; }
}
class UnionFindTree
{
	int N;
	int[] parent, rank, size;
	public UnionFindTree(int capacity)
	{
		N = capacity;
		parent = new int[N];
		rank = new int[N];
		size = new int[N];
		for (var i = 0; i < N; i++) { parent[i] = i; size[i] = 1; }
	}
	public int GetSize(int x) => size[GetRootOf(x)];
	public int GetRootOf(int x) => parent[x] == x ? x : parent[x] = GetRootOf(parent[x]);
	public bool UniteCategory(int x, int y)
	{
		if ((x = GetRootOf(x)) == (y = GetRootOf(y))) return false;
		if (rank[x] < rank[y]) { parent[x] = y; size[y] += size[x]; }
		else
		{
			parent[y] = x; size[x] += size[y];
			if (rank[x] == rank[y]) rank[x]++;
		}
		return true;
	}
	public bool IsSameCategory(int x, int y) => GetRootOf(x) == GetRootOf(y);
}


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

string str;
vector<string> formula;

int generate(string s, int now, int additions) {
  if (now == str.length()) {
    formula.push_back(s);
  }else{
    generate(s, now+1, additions);
    s.insert(s.begin()+now+additions, '+');
    generate(s, now+1, additions+1);
  }
  return 0;
}

ll evaluate(string s) {
  ll sum = 0;
  ll num = 0;
  int digit = 0;
  s.push_back('+');
  rep (i, s.length()) {
    if (s[i] == '+') {
      sum += num;
      num = 0;
      digit = 0;
    }else{
      num = num*10 + s[i] - '0';
      digit++;
    }
  }
  return sum;
}

int main() {
  cin >> str;
  generate(str, 1, 0);
  ll ans = 0;
  rep (i, formula.size()) {
    ans += evaluate(formula[i]);
  }
  cout << ans << endl;
  return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,m;
string S="100";
bool b[3];

signed main() {
    cin >> n >> m;
    if (n == 1) S = "0";
    if (n == 2) S = "10";
    if (m == 0) {
        cout << S << endl;
        return 0;
    }
    rep(i,m) {
        int s,c;
        cin >> s >> c;
        if (s == 1 && c == 0 && n != 1) {
            cout << -1 << endl;
            return 0;
        }
        --s;
        if (b[s]) {
            if (S[s] != c+'0') {
                cout << -1 << endl;
                return 0;
            }
        } else {
            S[s] = c+'0';
            b[s] = true;
        }
    }
    cout << S << endl;

}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		ArrayList<Long> num = new ArrayList<Long>();
		ArrayList<String> param = new ArrayList<String>();
		int system = 0; // 文字の空白区切り 0:ON 1:OFF

		while (sc.hasNext()) {
			if (sc.hasNextLong()) {
				num.add(sc.nextLong());
			} else {
				if (system == 0)
					param.add(sc.next());
				if (system == 1)
					param.add(sc.nextLine());
			}
		}
		Method(num, param);
	}

	static void Method(ArrayList<Long> num, ArrayList<String> param) {
		int count = 0;

		String s = String.valueOf(num.get(0));
		if(s.charAt(0) == s.charAt(1) && s.charAt(1) == s.charAt(2)) count++;
		if(s.charAt(1) == s.charAt(2) && s.charAt(2) == s.charAt(3)) count++;
		
		if(count >= 1){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21972
s=list(input())
n=len(s)

count=1
a=[]
for i in range(1,n):
  if s[i]==s[i-1]:
    count += 1
  else:
    a.append(count)
    count=1
if count!=0:
  a.append(count)

size=len(a)
a.append(0)

total = 0

if s[0] == "<":
  for i in range((size+1)//2):
    large=max(a[2*i],a[2*i+1])
    small=min(a[2*i],a[2*i+1])
    total += (large+1)*large//2 + small*(small-1)//2
  print(total)
  
if s[0] == ">":
  total += a[0]*(a[0]+1)//2
  for i in range(size//2):
    large=max(a[2*i+1],a[2*i+2])
    small=min(a[2*i+1],a[2*i+2])
    total += (large+1)*large//2 + small*(small-1)//2
  print(total)
  


Measured memory_bytes: 9776
#!python3.4
# -*- coding: utf-8 -*-
# abc157/abc157_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    A = [None] * 3
    for i in range(3):
        A[i] = i2nn()
    N = i2n()
    b = set()
    for i in range(N):
        b.add(i2n())
    for i in range(3):
        if len(set(A[i]) & b) == 3:
            print('Yes')
            return
        if len({A[j][i] for j in range(3)} & b) == 3:
            print('Yes')
            return
    if len({A[0][0], A[1][1], A[2][2]} & b) == 3:
        print('Yes')
        return
    if len({A[0][2], A[1][1], A[2][0]} & b) == 3:
        print('Yes')
        return
    print('No')
    return

main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, p;
    cin >> n >> p;
    vector<int> arr(n, 0);
    for(auto& val:  arr)
        cin >> val;
    vector<ll> dp(2, 0);
    dp[0] = 1;
    for(int i = 0; i < n; i++) {
        vector<ll> new_dp = dp;
        if (arr[i] % 2 == 0) {
            new_dp[0] += dp[0];
            new_dp[1] += dp[1];
        } else {
            new_dp[0] += dp[1];
            new_dp[1] += dp[0];
        }
        dp = new_dp;
    }
    cout << dp[p] << endl;
}



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

using namespace std;

int main()
{
    bool flag = false;
    int n, num = 1;
    vector<int> h;

    cin >> n;
    h.resize(n);
    for (auto & elem:h) cin >> elem;

    for (int i = n - 1; i > 0; --i) {
        flag = true;
        for (int j = i - 1; j >= 0; --j) {
            if (h[i] - h[j] < 0) flag = false;
        }
        if (flag) ++num;
    }
    cout << num << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> tower(5);
  for (int i = 0;i< tower.size();i++){
  	cin >> tower.at(i);
  }
  int key,flag = 0;
  cin >> key;
  for(int i = 0;i < tower.size()-1;i++){
    for(int j = i+1;j < tower.size();j++){
      if(tower.at(j)-tower.at(i) > key){
        cout << ":(" << endl;
        flag = 1;
        break;
      }
    }
    if(flag == 1)
      break;
  }
  if(flag == 0)
    cout << "Yay!" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
char s[105], t[105], ls, lt, m;
bool ok;
int main(){
	scanf("%s\n%s", s, t);
	ls = strlen(s); lt = strlen(t);
	sort(s,s+ls);
	sort(t,t+lt,greater<char>());
	m = min(ls, lt);
	rep(i,m) if(s[i] != t[i]){
		puts(s[i] < t[i] ? "Yes" : "No");
		return 0;
	}
	puts(ls < lt ? "Yes" : "No");
}

Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = []
count = 0
for i in range(N):
    Ai = list(map(int, input().split()))
    tmp = C
    for j in range(M):
      tmp += Ai[j]*B[j]
    if tmp > 0:
      count += 1
print (count)      
      
      


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    ll cnt = 0;
    for (int i = 1; i < N; i++) cnt += (N-1) / i;
    cout << cnt << endl;
}


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

int main()
{
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    cout << min(abs(a2 - a1) + abs(a3 - a1),
                min(abs(a3 - a1) + abs(a2 - a3),
                    min(abs(a2 - a1) + abs(a1 - a3),
                        min(abs(a2 - a3) + abs(a3 - a1),
                            min(abs(a3 - a1) + abs(a1 - a2),
                                min(abs(a3 - a2) + abs(a2 - a1), 1001001001))))))
         << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

int n, a[21];

int main() {
  while (cin >> n, n) {
    rep (i,n) cin >> a[i];
    int diff = 1 << 29;
    for (int S = 0; S < (1 << n); ++S) {
      int as = 0, bs = 0;
      rep (i,n) {
        if (S & (1 << i)) {
          as += a[i];
        } else {
          bs += a[i];
        }
      }
      int temp = abs(as - bs);
      diff = min(diff, temp);
    }
    cout << diff << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#define MOD 1000000007
#define INT long long int
#define REP(i,n) for(int(i)=0;(i)<(n);(i)++) 
using namespace std;
const long long INF = numeric_limits<long long>::max();

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }

  template< typename C >
  int find_subtree(int a, const C &check, Monoid &M, bool type) {
    while(a < sz) {
      Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]);
      if(check(nxt)) a = 2 * a + type;
      else M = nxt, a = 2 * a + 1 - type;
    }
    return a - sz;
  }


  template< typename C >
  int find_first(int a, const C &check) {
    Monoid L = M1;
    if(a <= 0) {
      if(check(f(L, seg[1]))) return find_subtree(1, check, L, false);
      return -1;
    }
    int b = sz;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) {
        Monoid nxt = f(L, seg[a]);
        if(check(nxt)) return find_subtree(a, check, L, false);
        L = nxt;
        ++a;
      }
    }
    return -1;
  }

  template< typename C >
  int find_last(int b, const C &check) {
    Monoid R = M1;
    if(b >= sz) {
      if(check(f(seg[1], R))) return find_subtree(1, check, R, true);
      return -1;
    }
    int a = sz;
    for(b += sz; a < b; a >>= 1, b >>= 1) {
      if(b & 1) {
        Monoid nxt = f(seg[--b], R);
        if(check(nxt)) return find_subtree(b, check, R, true);
        R = nxt;
      }
    }
    return -1;
  }
};
#define INT_MAX 1000000000000000
int main()
{
    INT N,M;
    cin>>N>>M;
    vector<vector<INT>> edge;
    SegmentTree< INT > seg(N+1, [](INT a, INT b) { return min(a, b); }, INT_MAX);
    REP(i,M){
        INT l,r,c;
        cin>>l>>r>>c;
        l--;r--;
        edge.push_back({l,r,c});
    }
    sort(edge.begin(), edge.end());
    INT dp[N+10];
    REP(i,N+10)dp[i]=INT_MAX;
    dp[0]=0;
    seg.update(0,0);

    REP(i,M){
        int l,r,c;
        l=edge[i][0];r=edge[i][1];c=edge[i][2];
        dp[r] = min(dp[r],seg.query(l,r)+c);
        seg.update(r,dp[r]);
    }
    if(dp[N-1]==INT_MAX){
        cout<<-1<<endl;
        return 0;
    }
    cout<<dp[N-1]<<endl;
    return 0;
}

Measured memory_bytes: 8372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

ll r[4001], g[4001], b[4001];

void solve(long long N, string S) {
    rep(i, N) {
        r[i + 1] = r[i];
        g[i + 1] = g[i];
        b[i + 1] = b[i];
        if (S[i] == 'R') r[i + 1]++;
        if (S[i] == 'G') g[i + 1]++;
        if (S[i] == 'B') b[i + 1]++;
    }
    // rep(i, N) { cout << r[i + 1] << g[i + 1] << b[i + 1] << endl; }
    ll res = 0;
    rep(i, N) {
        rep(j, N) {
            if (j <= i) continue;
            if (S[i] == 'R' && S[j] == 'G' && j + 1 <= N) {
                res += b[N] - b[j + 1];
                if (j + j - i < N && S[j + j - i] == 'B') res--;
            }

            if (S[i] == 'G' && S[j] == 'R' && j + 1 <= N) {
                res += b[N] - b[j + 1];
                if (j + j - i < N && S[j + j - i] == 'B') res--;
            }
            if (S[i] == 'R' && S[j] == 'B' && j + 1 <= N) {
                res += g[N] - g[j + 1];
                if (j + j - i < N && S[j + j - i] == 'G') res--;
            }
            if (S[i] == 'B' && S[j] == 'R' && j + 1 <= N) {
                res += g[N] - g[j + 1];
                if (j + j - i < N && S[j + j - i] == 'G') res--;
            }
            if (S[i] == 'G' && S[j] == 'B' && j + 1 <= N) {
                res += r[N] - r[j + 1];
                if (j + j - i < N && S[j + j - i] == 'R') res--;
            }
            if (S[i] == 'B' && S[j] == 'G' && j + 1 <= N) {
                res += r[N] - r[j + 1];
                if (j + j - i < N && S[j + j - i] == 'R') res--;
            }
        }
    }
    cout << res << endl;
}

int main() {
    string S;
    long long N;
    scanf("%lld", &N);
    cin >> S;
    solve(N, S);
    return 0;
}


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

int main(void){
  int n, x, buf;
  vector<int> list;
  cin >> n >> x;
  for(int i = 0;i<n;i++){
    cin >> buf;
    list.push_back(abs(buf - x));
  }
  sort(list.begin(),list.end());
  int res = list.at(0);
  size_t len = list.size();
  for(size_t i = 1; i < len; i++){
    if(list.at(i) % res != 0){
        res--;
        i = -1;
    }
    if(res == 1) break;
  }

  cout << res <<  endl;
  return 0;
}

Measured memory_bytes: 892
<?php
  while (true) {
    list($a, $op, $b) = explode(" ", trim(fgets(STDIN)));
    if ($op == "?") {
      return;
    }
    switch ($op) {
      case "+";
        print floor($a + $b);
        break;
      case "-";
        print floor($a - $b);
        break;
      case "*";
        print floor($a * $b);
        break;
      case "/";
        print floor($a / $b);
        break;
    }
    print "\n";
  }
?>

Measured memory_bytes: 6588
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");

    var a = input[0];
   
 // SUN,MON,TUE,WED,THU,FRI,SAT
    if (a == 'SUN'){console.log('7');}
    else if(a == 'MON'){console.log('6');}
    else if(a == 'TUE'){console.log('5');}
    else if(a =='WED'){console.log('4');}
    else if(a == 'THU'){console.log('3');}
    else if (a == 'FRI'){console.log('2');}
    else if (a == 'SAT'){console.log('1');}
    
	
	
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
n,y = map(int, input().split())
err = '-1 -1 -1'

for i in range(n+1):
    for j in range(n+1-i):
        if y == 10000 * (n-i-j) + 5000 * j + 1000 * i:
            ans = str(n-i-j) + " " + str(j) + " " +  str(i)
            break
        else:
            ans = err
    # 以下,多重ループを抜ける手法。
    else:
        continue
    break

print(ans)

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

typedef long long ll;


const int MAX_N=1e5+1;

int data[MAX_N];

int main(){
	int n;
	cin>>n;
	ll ans=0;
	for(int i=0;i<n;i++){
		cin>>data[i];
	}
	ans+=data[0]/2;
	data[0]%=2;
	for(int i=1;i<n;i++){
		if(data[i-1]==1){
			if(data[i]>0){
				ans++;
				data[i]--;
			}
		}
		ans+=data[i]/2;
		data[i]%=2;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640
# _*_ coding:utf-8 _*_
#  Atcoder_Beginnger_Contest081-C
#  TODO https://atcoder.jp/contests/abc081/tasks/arc086_a
import collections as col

def solveProblem(neededBallKind,BallsList):
	AsListCounter = col.Counter(BallsList)
	allBallKind = len(AsListCounter)
	sortCounter = sorted(AsListCounter.items(),reverse=False,key=lambda x:x[1])
	replaceBallCount = 0
	replaceBallKind = allBallKind-neededBallKind
	if replaceBallKind <= 0:
		answer = 0
	else:
		for k,v in sortCounter:
			replaceBallCount = replaceBallCount + v
			replaceBallKind = replaceBallKind - 1
			if replaceBallKind <= 0:
				break
		answer = replaceBallCount
	return answer

if __name__ == '__main__':
	_,K = map(int,input().strip().split(' '))
	AsList = list(map(int,input().strip().split(' ')))
	solution = solveProblem(K,AsList)
	print("{}".format(solution))


Measured memory_bytes: 39344
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include <ios>     
#include <iomanip> 
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;



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

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

//ここまで共通

llong N;
int S[1000000];

int main() {
	cin >> N;
	if (N == 0) cout << 0;
	else {
		int i;
		for (i = 0;;i++) {
			if (N == 1) {
				S[i] = 1;
				break;
			}

			if (N < 0) {
				S[i] = (-N) % 2;
				N = (-N) / 2;

				if (S[i] == 1) N++;
			}

			else {
				S[i] = N % 2;
				N = -(N / 2);
			}

		
		}

		for (; i >= 0; i--) {
			cout << S[i];
		}
	}
}

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

/* Save Memory */

int n, k;
long dp[2][4*4*4];
long a[64][64];
long ans;
const long MOD = 1e9 + 7;
const string c[4] = {"A", "G", "C", "T"};
string s1, s2;
const vector<string> ng3 = {"AGC", "GAC", "ACG"};
const vector<string> ng4 = {"AGGC", "ACGC", "ATGC", "AGAC", "AGGC", "AGTC"};
vector<string>::const_iterator p;

void quad2dec(long n, long& a1, long& a4, long& a16){
	a16 = n / 16; n %= 16;
	a4 = n / 4; n %= 4;
	a1 = n;
}

string quad2str(long n){
	long i, j, k;
	quad2dec(n, i, j, k);
	return (c[i] + c[j] + c[k]);
}

int main(){
	cin >> n;
	fill(dp[0], dp[1], 0);
	fill(a[0], a[4*4*4], 0);

	for (int i = 0; i < 4*4*4; ++i){
		s1 = quad2str(i);
		for (int j = 0; j < 4*4*4; ++j){
			s2 = quad2str(j);
			if (s1.substr(1, 2) == s2.substr(0, 2)){
				p = find(ng3.begin(), ng3.end(), s1.substr(1, 2) + s2.substr(2, 1));
				if (p != ng3.end()) continue;
				p = find(ng3.begin(), ng3.end(), s1);
				if (p != ng3.end()) continue;
				p = find(ng3.begin(), ng3.end(), s2);
				if (p != ng3.end()) continue;
				p = find(ng4.begin(), ng4.end(), s1 + s2.substr(2, 1));
				if (p != ng4.end()) continue;
				a[i][j]++;
			}
		}
	}

	for (int i = 0; i < 4*4*4; ++i){
		p = find(ng3.begin(), ng3.end(), quad2str(i));
		dp[0][i] = (p == ng3.end()) ? 1 : 0;
	}

	for (int i_ = 0, i = 1; i_ < n-3; ++i_, i = 1 - i){
		for (int j = 0; j < 4*4*4; ++j){
			dp[i][j] = 0;
			for (int k = 0; k < 4*4*4; ++k){
				(dp[i][j] += dp[1-i][k]*a[k][j]) %= MOD;
			}
		}
	}

	ans = 0;
	for (int j = 0; j < 4*4*4; ++j){
		(ans += dp[(n+1)%2][j]) %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int N,n;
  scanf("%d",&N);

  n = N%10;

  if(n == 3)
    printf("bon");
  else if (n == 0 || n == 1 || n == 6 || n == 8)
    printf("pon");
  else
    printf("hon");

  return 0;
}


Measured memory_bytes: 1728
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int X = stdIn.nextInt();

        int happinessValue = (X / 500) * 1000 + ((X % 500) / 5) * 5;

        System.out.println(happinessValue);
    }
}

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

using namespace std;

bool arr[100100];

void eratosthenes(){
  for(int i = 0; i < 100100; i++){ arr[i] = true;}
  arr[0] = false; arr[1] = false;
  
  for(int i = 2; i < 100100; i++){
    if( arr[i] == false){ continue;}
    else{
      //iが素数だった
      for(int j = 2; i* j < 100100; j++){
        arr[ i * j ] = false;} }
  }
}

int main(){
  int Q; cin >> Q;
  eratosthenes();
  
  int sum[100100];
  for(int i = 0; i < 100100; i++){
    sum[i] = 0;}
  //sum[i+1]はi以下の２０１７に似た数の個数を数える
    
  for(int i = 0; i < 100010; i++){
    if( i % 2 == 0){ sum[i+1] = sum[i];}
    else{
    if( arr[i] == true && arr[(i+1) / 2] == true){ sum[i+1] = sum[i] + 1;}
    else{ sum[i+1] = sum[i];}}}
  
  for(int i = 0 ;i < Q; i++){
    int l,r; cin >> l >> r;
    cout << sum[r + 1] - sum[l] << endl;}
  
      return 0;}
  


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

int main() {
  int a, b, h;
  cin >> a >> b >> h;
  cout << (a+b)*h/2 << endl;
  return 0;
}


Measured memory_bytes: 3584
/*
      author : nishi5451
      created: 11.08.2020 22:32:36
*/

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


int main(){
    string s;
    cin >> s;
    if(s == "SUN") cout << 7 << endl;
    else if(s == "MON") cout << 6 << endl;
    else if(s == "TUE") cout << 5 << endl;
    else if(s == "WED") cout << 4 << endl;
    else if(s == "THU") cout << 3 << endl;
    else if(s == "FRI") cout << 2 << endl;
    else if(s == "SAT") cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3596
# ABC 119, B - digital gift

n = int(input())
total = 0
for i in range(n):
    tmp = input().split(' ')
    x = float(tmp[0])
    u = tmp[1]

    if u == "BTC":
        total += x*380000
    if u == "JPY":
        total += x

print(total)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N;
  cin >> N;
  vl A(N);
  ll ans=1;
  bool flag=true;
  rep(i,N) {
    cin >> A[i];
    flag&=(A[i]!=0);
  }
  if(flag) {
    rep(i,N) {
      if(A[i]<=(ll)1e18/ans) ans*=A[i];
      else {
        ans=-1;
        break;
      }
    }
  }
  else ans=0;
  
  cout << ans << endl;
}

Measured memory_bytes: 4048
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;




int main() {
    int n;  cin >> n;
    ll *a = new ll[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a+n);

        auto ite = lower_bound(a, a+n, (a[n-1]+1)/2);
        ll d, e;

        if (ite != a+n)
            d = *ite;
        if (ite != a) {
            e = *(ite-1);
            if (abs((a[n-1]-1)/2 - d) > (abs(a[n-1]/2 - e)))
                d = e;
        }
            cout << a[n-1] << " " << d << endl;
        
}

Measured memory_bytes: 1152
module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

------------------------------------------

main :: IO ()
main = do
  [a, b, c] <- readInts
  k <- readInt
  let m = a `max` b `max` c 
  print $ a + b + c - m + m * (2 ^ k)

------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin >> n >> m;
	vector<int> h(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> h.at(i);
	}
	vector<int> a(m);
	vector<int> b(m);
	for (int i = 0; i < m; ++i)
	{
		cin >> a.at(i) >> b.at(i);
	}
	vector<int> z(n);
	for (int i = 0; i < m; ++i)
	{
		if(h.at(a.at(i)-1)>h.at(b.at(i)-1)){
			z.at(b.at(i)-1)++;
		}
		else if(h.at(a.at(i)-1)<h.at(b.at(i)-1)){
			z.at(a.at(i)-1)++;
		}
		else{
		    z.at(a.at(i)-1)++;
		    z.at(b.at(i)-1)++;
		}
	}
	int count=0;
	for (int i = 0; i < n; ++i)
	{
		if(z.at(i)==0){
			count++;

		}
	}
	cout << count << endl;
	

}

Measured memory_bytes: 4844
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

const int M = 1e9+7;

using namespace std;

main()
{
    fast;
    ll n,p=1,i;
    cin>>n;
    for (i=2;i<=n;i++)
        p=(p*i)%M;
    cout<<p<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
//A - Double Helix
int main(void){
    char b;
    char ans;
    std::cin >> b;
    if(b=='A'){
        ans='T';
    }else if(b=='T'){
        ans='A';
    }else if(b=='C'){
        ans='G';
    }else{
        ans='C';
    }
    std::cout << ans << std::endl;
    
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    set<seika> s;
    while (n--)
    {
        seika ss;
        cin >> ss;
        s.insert(ss);
    }
    cout << s.size() << endl;
}

int main()
{
    solve();
    return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)

int main() {
	int n, m;
	cin >> n >> m;
	vector<ll> fibo(100001);
	fibo[0] = 1;
	fibo[1] = 1;
	FOR(i, 2, n) {
		fibo[i] = fibo[i - 1] + fibo[i - 2];
		fibo[i] = fibo[i] % MOD;
	}
	vector<int> a(m + 2);
	a[0] = -1;
	a[m + 1] = n + 1;
	FOR(i, 1, m) {
		cin >> a[i];
	}
	FOR(i, 1, m-1) {
		if (a[i + 1] - a[i] == 1) {
			ps(0);
			return(0);
		}
	}
	ll res = 1;
	FOR(i, 0, m) {
		int d = a[i + 1] - a[i] - 2;
		res *= fibo[d];
		res %= MOD;
	}
	pv(res);
	return(0);
}

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

int main() {

int n1,n2,n3;
cin >> n1 >> n2 >> n3;
//int *num=new int[3];

//int num[]={300000,200000,100000,0};
//string *name=new string[N+1];

int ma=max(max(n1,n2),n3);
int mi=min(min(n1,n2),n3);
if(ma==mi)
cout << "Yes" << endl;
else
cout << "No" << endl;


}


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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=1e5+5;
ll dis[MAXN];
struct EDGE{int nxt,to,w;}edge[MAXN*10+100];
int n,head[MAXN],tot;
inline void add_edge(int u,int v,int w){edge[++tot].nxt=head[u];edge[tot].to=v;edge[tot].w=w;head[u]=tot;}
struct RULE{bool operator()(int &x,int &y)const{return dis[x]>dis[y];}};
int main() {
	n=read();if(n==1){puts("1");return 0;}
	for(int i=0;i<n;++i)for(int j=0;j<10;++j)add_edge(i,(i*10+j)%n,j);
	for(int i=1;i<10;++i)add_edge(n,i,i);
	memset(dis,0x3f,sizeof(dis));dis[n]=0;priority_queue<int,vector<int>,RULE>q;q.push(n);
	while(!q.empty()){
		int u=q.top();q.pop();
		//if(u==0){cout<<dis[u]<<endl;return 0;}
		for(int i=head[u];i;i=edge[i].nxt){
			int v=edge[i].to;
			if(dis[v]>dis[u]+edge[i].w){
				dis[v]=dis[u]+edge[i].w;
				q.push(v);
			}
		}
	}cout<<dis[0]<<endl;return 0;
}

Measured memory_bytes: 14328