akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//-----CODE------//


void solve(void)
{
  int N,M;
  cin>>N>>M;
  map<int,int,greater<int> > mp;
  for (int i = 0; i < N; i++)
  {
    int X; cin>>X;
    mp[X]++;
  }
  for (int i = 0; i < M; i++)
  {
    int B,C;cin>>B>>C;
    mp[C] += B;
  }
  // reverse(ALL(mp));
  int ANS = 0;
  int cnt = 0;
  for (auto &&i : mp)
  {
    ANS += i.first*(min(i.second,N - cnt));
    cnt += i.second;
    if(cnt >= N)break;
  }
  cout<<ANS<<endl;
  
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#define N 200005
using namespace std;
int n, mn, mj, d[N], e[N], c[N], x[30];
string a, s;
int main() {
	int i, j;
	cin>>a;
	n = a.size();
	a = '.' + a;
	for(i=0; i<26; i++) x[i] = n+1;
	for(i=n; i>=0; i--) {
		mn = N;
		for(j=0; j<26; j++)
			if(d[x[j]] < mn) mn = d[x[j]], mj = j;
		d[i] = mn + 1;
		e[i] = x[mj];
		c[i] = mj;
		x[a[i]-'a'] = i;
	}
	for(i=0; i<=n; i=e[i]) s += c[i]+'a';
	cout<<s;
	return 0;
}

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

int main(){

  string s;
  cin >> s;

  string res="";
  int i=0;
  for(auto x:s){
    if (x == 'B'){
      if (res.size()>0)
        res.erase(res.size()-1);
    }
    else
      res += x;
  }
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define mp(a, b) make_pair(a, b)
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 1e6 + 10;
int a[maxn];
int cnt[maxn];
int main()
{
	int n;
	scanf("%d", &n);
	int d = 0;
	for(int i = 1; i <= n; ++i) 
	{
		scanf("%d", &a[i]);
		++cnt[a[i]];
		d = __gcd(d, a[i]);
	}
	if(d > 1) 
	{
		puts("not coprime");
		return 0;
	}
	for(int i = 2; i < maxn; ++i)
	{
		int ret = 0;
		for(int j = i; j < maxn; j += i) ret += cnt[j];
		if(ret > 1)
		{
			puts("setwise coprime");
			return 0;
		}
	}
	puts("pairwise coprime");
	return 0;
}

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

int main() {
  long long A, B, K;
  cin >> A >> B >> K;
  if (A < K) {
    K -= A, A = 0;
    if (B < K)
      B = 0;
    else
      B -= K;
  } else {
    A -= K;
  }
  cout << A << ' ' << B << endl;
}

Measured memory_bytes: 256
import scala.io.StdIn.{readInt, readLine}
object Main {
    def main(args: Array[String]): Unit = {
        val len = readInt
        val list = readLine.split(" ").map(_.toInt).toList
        readInt
        readLine.split(" ").map(_.toInt).foreach { target =>
            if (search(list, target, len)) println("yes") else println("no")
        }
    }
    // haystack から count 個の要素を足し合わせて target になる組み合わせがあるかどうかを調べる。
    def search(haystack: List[Int], target: Int, len: Int): Boolean = {
        if (target == 0) return true
        if (len == 0) return false
        else {
            val x = haystack.head
            val xs = haystack.tail
            search(xs, target - x, len - 1) || search(xs, target, len - 1)
        }
    }
}


Measured memory_bytes: 44160
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.IntMap as IM
import Data.List
import Control.Monad

readInput :: IO [Int]
readInput = map (either error fst . T.decimal) . T.words <$> T.getLine

solve x k
  | x' < x = solve x' k
  | otherwise = x
  where
    x' = abs (x - k * mult) `min` abs (x - k * succ mult)
    mult = x `div` k

main = do
  [n, k] <- readInput
  print $ solve n k

Measured memory_bytes: 508
#include <bits/stdc++.h>
 
using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long
 
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}
 
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}
 
 
int main()
{
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x = x2 - x1;
    int y = y2 - y1;
    int xx = -y,yy = x;
    int x3 = xx + x2,y3 = yy + y2;
    x = x3 - x2;y = y3 - y2;
    xx = -y;yy = x;
    int x4 = xx + x3,y4 = yy + y3;
    printf("%d %d %d %d\n",x3,y3,x4,y4);
    return 0;
}

Measured memory_bytes: 256
from collections import deque

n, x, y = map(int, input().split())

g = [[] for _ in range(n)]

# make graph
for i in range(n - 1):
    g[i].append(i + 1)
    g[i + 1].append(i)

g[x - 1].append(y - 1)
g[y - 1].append(x - 1)

def bfs(g, n_node, start_node):
    dist = [-1] * n_node
    dist[start_node] = 0
    queue = deque([start_node])

    while queue:
        node = queue.popleft()
        for n in g[node]:
            if dist[n] != -1:
                continue
            dist[n] = dist[node] + 1
            queue.append(n)
    return dist


ans_array = [0] * n
for i in range(n):
    dist = bfs(g, n, i)
    for d in dist:
        ans_array[d] += 1

for i in ans_array[1:]:
    print(i // 2)

Measured memory_bytes: 9756
#include <bits/stdc++.h>
using ll = int64_t;
using ld = long double;
using namespace std;

const int MAXN = 4001;
const ll MOD = 1000 * 1000 * 1000 + 7;

int cnk[MAXN][MAXN];
int scnk[MAXN][MAXN];

ll add(ll x, ll y) {
    return (x + y) % MOD;
}

ll sub(ll x, ll y) {
    ll ans = (x - y) % MOD;
    if (ans < 0) ans += MOD;
    return ans;
}

const int MAXM = 2002;
int f[MAXM][MAXM];
int sf[MAXM][MAXM];

int main() {
#ifdef PAUNSVOKNO
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20);
    int a, b;
    cin >> a >> b;

    int n = a + b;
    for (int i = 0; i <= n; i++) {
        cnk[i][0] = 1;
        for (int j = 1; j <= i; j++) {
            cnk[i][j] = add(cnk[i - 1][j - 1], cnk[i - 1][j]);
        }
    }

    for (int i = 0; i <= n; i++) {
        scnk[i][0] = 0;
        for (int j = 0; j <= n; j++) {
            scnk[i][j + 1] = add(scnk[i][j], cnk[i][j]);
        }
    }

    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            f[i][j] = scnk[j][min(i, j) + 1];
        }
    }

    for (int i = 0; i <= b; i++) {
        sf[0][i] = 0;
        for (int j = 0; j <= a; j++) {
            sf[j + 1][i] = add(sf[j][i], f[j][i]);
        }
    }

    ll ans = 0;

    for (int fa = 0; fa <= a; fa++) {
        int lb = b - 1;
        for (int bs = 0; bs <= lb; bs++) {
            int as = lb - bs;
            if (as > fa) {
                continue;
            }
            
            ll mul = cnk[lb][bs];

            int ca = fa - as;
            int cb = lb - bs;

            ll can;
            if (cb == 0) {
                can = 1;
            } else {
                can = sf[ca + 1][cb - 1];
            }
            ans = add(ans, can * mul);
        }
    } 

    cout << ans << "\n";
}

Measured memory_bytes: 156672
def modi2p(i):
    if i < 0:
        return 1
    return 2**i
S = input()
n = len(S)
ans = 0
for i in range(n):
    for j in range(i+1,n+1):
        ans += int(S[i:j])*modi2p(i-1)*modi2p(n-j-1)
print(ans)

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

using namespace std;

typedef long long LL;

int MOD=1000000007;
int n;
int dp[2][3010];
int sum[3010];

int main() {
    cin>>n;
    string s;
    cin>>s;
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for (int i=1;i<=n;i++) {
        sum[0]=dp[(i-1)%2][0];
        for (int j=1;j<=i;j++) sum[j]=(sum[j-1]+dp[(i-1)%2][j])%MOD;
        for (int j=0;j<i+1;j++)
            if (s[i-1]=='>') {
                dp[i%2][j]=(sum[i]-(j>0?sum[j-1]:0)+MOD)%MOD;
            } else {
                dp[i%2][j]=(j>0?sum[j-1]:0);
            }
    }
    int ret=0;
    for (int i=0;i<n;i++) ret=(ret+dp[(n-1)%2][i])%MOD;
    cout<<ret<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) begin(x),end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << " " <<
using namespace std;
using ll=long long;

const int MXN=405;

int n,a[MXN];
ll memo[MXN][MXN];

ll dp(int l,int r){
  if(l==r)return 0;
  if(l+1==r)return a[l]+a[r];
  if(memo[l][r])return memo[l][r];
  ll ret=1e18,sum=a[r];
  for(int i=l;i<r;++i){
    sum+=a[i];
    ret=min(ret,dp(l,i)+dp(i+1,r));
  }
  return memo[l][r]=ret+sum;
}

int main(){
  scanf("%d",&n);
  for(int i=1;i<=n;++i)scanf("%d",a+i);
  printf("%lld\n",dp(1,n));
}


Measured memory_bytes: 1536
program sample
	integer ::a
    read(*,*) a
    if(a==22) then
    	write(*,*) 'Christmas Eve Eve Eve'
    else if(a==23) then
    	write(*,*) 'Christmas Eve Eve'
    else if(a==24) then
    	write(*,*) 'Christmas Eve'
    else
    	write(*,*) 'Christmas'
    end if
    stop
end program sample

Measured memory_bytes: 2712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int K = 19;
const int KM = 1 << (K - 1);
int laz[1 << K];
int zero = 2e9;
void update(int L, int R, int X, int A, int l, int r) {
	if (r <= L || R <= l) return;
	if (L <= l && r <= R) {
		laz[A] = min(laz[A], X);
		return;
	}
	update(L, R, X, A * 2, l, (l + r) / 2);
	update(L, R, X, A * 2 + 1, (l + r) / 2, r);
}

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


	int N, Q;
	cin >> N >> Q;
	pair<int, pair<int, int>> XST[200000];
	rep(i, N) {
		int S, T, X;
		cin >> S >> T >> X;
		XST[i] = mp(X, mp(S, T));
	}
	int D[200002];
	D[0] = -zero;
	D[Q + 1] = zero;
	rep1(i, Q) cin >> D[i];
	rep(i, 1 << K) laz[i] = zero;

	rep(i, N) {
		int L = lower_bound(D, D + Q + 2, XST[i].second.first - XST[i].first) - D;
		int R = lower_bound(D, D + Q + 2, XST[i].second.second - XST[i].first) - D;
		if (L < R) update(L, R, XST[i].first, 1, 0, KM);
	}
	rep1(i, KM - 1) {
		laz[i * 2] = min(laz[i * 2], laz[i]);
		laz[i * 2 + 1] = min(laz[i * 2 + 1], laz[i]);
	}
	rep1(i, Q) {
		if (laz[KM + i] == zero) co(-1);
		else co(laz[KM + i]);
	}

	Would you please return 0;
}

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

using namespace std;

int main(){

  ll h,n;
  
  ll sum = 0;
  
  cin >> h >> n;
  
  rep(i,n){
    int tmp;
    cin >> tmp;
    sum += tmp;
  }

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

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

typedef struct _Node {
  int key;
  struct _Node *next, *prev;
} Node;

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while(cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void init(void) {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(void) {
  Node *cur = nil->next;
  int isf = 0;
  while(1) {
    if(cur == nil) break;
    if(isf++>0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if(t==nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(void) {
  deleteNode(nil->next);
}

void deleteLast(void) {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(void) {
  int key, n, i;
  int size = 0;
  int np = 0, nd = 0;
  char com[20];
  scanf("%d", &n);
  init();
  for(i=0;i<n;i++) {
    scanf("%s%d",com, &key);
    if (com[0] == 'i') {
      insert(key);
      np++;
      size++;
    } else if(com[0] == 'd') {
      if(strlen(com) > 6) {
        if(com[6] == 'F')
          deleteFirst();
        else if(com[6] == 'L')
          deleteLast();
      } else {
        deleteKey(key);
        nd++;
      }
      size--;
    }
  }
  printList();
  return 0;
}



Measured memory_bytes: 32940
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll max(ll a, ll b){
    if(a > b) return a;
    else return b;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}

int main(void){
    int N; cin >> N;
    
    int ans = 0;
    for(int i = 1; i <= N; i++){
        string s = to_string(i);
        if(s.size() % 2 == 1) ans++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>


using namespace std;

int main(){
  int n=100;
  int A,B;
  cin>>A>>B;
  int c[n][n]={};
  for(int i=n/2;i<n;i++){
    for(int j=0;j<n;j++)c[i][j]=1;
  }
  A--;
  B--;
  for(int i=0;i<n/2;i+=2){
    for(int j=0;j<n;j+=2){
      if(B>0){
        c[i][j]=1;
        B--;
      }
    }
  }
  for(int i=n-1;i>n/2;i-=2){
    for(int j=0;j<n;j+=2){
      if(A>0){
        c[i][j]=0;
        A--;
      }

    }
  }
  cout<<n<<" "<<n<<endl;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(c[i][j]==0)cout<<".";
      else cout<<"#";
    }
    cout<<"\n";
  }
  return 0;
}


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

using namespace std;

int main(void)
{
    int bounce_times;
    int area;
    vector<int> bounce_ranges;

    cin >> bounce_times >> area;

    for(int i = 0; i < bounce_times; i++){
        int br;
        cin >> br;
        bounce_ranges.push_back(br);
    }

    int bounce_distance = 0;
    int i;
    for(i = 0; i < bounce_times && bounce_distance <= area; i++){
        
        bounce_distance += bounce_ranges[i];
    }

    if(bounce_distance <= area){
        i += 1;
    }
    cout << i << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int size=2e5+5;
vector <int> g[size];
int in[size],out[size],t=0;
typedef pair<int,int> pi;
vector <pi> lin;
vector <int> ans(size);
void dfs(int src,int par=-1)
{
    in[src] = t++;
    lin.push_back({0,src});
    for(auto v:g[src])
    {
        if(v==par)
            continue;
        dfs(v,src);
    }
    out[src] = t;
}
int main()
{
    int n,q;
    cin>>n>>q;
    for(int i=1,u,v;i<n;i++)
    {
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1,-1);
    for(int i=0,p,x;i<q;i++)
    {
        cin>>p>>x;
        int l = in[p];
        int r = out[p];
        lin[l].first += x;
        if(r<lin.size())
            lin[r].first -= x;
    }
    for(int i=1;i<lin.size();i++)
        lin[i].first += lin[i-1].first;
    for(int i=0;i<n;i++)
        ans[lin[i].second] = lin[i].first;
    for(int i=1;i<=n;i++)
        cout<<ans[i]<<" ";
    cout<<"\n";
    return 0;
}


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

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define int long long int
    int a,b,m,ans=INT_MAX;
    cin>>a>>b>>m;
    int p[a],q[b];
    int x,y,c;
    for(int i=0;i<a;i++)cin>>p[i];
    for(int i=0;i<b;i++)cin>>q[i];
    for(int i=0;i<m;i++)
    {
        cin>>x>>y>>c;
        ans=min(p[x-1]+q[y-1]-c,ans);
    }
    int ans1=INT_MAX;

    sort(p,p+a);
    sort(q,q+a);

    cout<<min(p[0]+q[0],ans)<<endl;

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  int N;  cin >> N;
  string s; cin >> s;
  int ans=1;  char c=s[0];
  REP(i, N){
    if(c!=s[i]) {
      ans++;
      c=s[i];
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long int ll;

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

  int n;
  cin >> n;
  vector < int > a (n), cnt (n);
  for (auto &i : a) cin >> i, cnt[i]++;

  int mx = 1;
  for (int i = 0; i < n; i++) {
    if (cnt[i] > 0) mx = i;
  }

  bool ok = true;
  for (int i = 0; i < (mx + 1) / 2; i++) ok &= (cnt[i] == 0);
  for (int i = ((mx + 1) / 2) + 1; i <= mx; i++) ok &= (cnt[i] > 1);
  if (mx & 1) {
    ok &= (cnt[(mx + 1) / 2] == 2);
  } else {
    ok &= (cnt[(mx + 1) / 2] == 1);
  }

  cout << (ok ? "Possible" : "Impossible") << '\n';
}


Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <ios>
#include <vector>
#include <cmath>
using namespace std;
int main(void){
  int a,b;
  cin >> a >> b;
  
  if(a < b)
    cout << 0 << endl;
  else
    cout << 10 << endl;
  
  return 0;
}



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

int main(){
    int a[3][3];
    bool appear[3][3];
    int n;
    string s = "No";
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> a[i][j];
        }
    }
    cin >> n;
    vector<int> b(n);
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            appear[i][j] = false;
            for(int k=0;k<n;k++){
                if(a[i][j] == b[k]) appear[i][j] = true;
            }
        }
    }
    for(int i=0;i<3;i++){
        if(appear[0][i] && appear[1][i] && appear[2][i]) s="Yes";
        if(appear[i][0] && appear[i][1] && appear[i][2]) s="Yes";
    }
    if(appear[0][0] && appear[1][1] && appear[2][2]) s="Yes";
    if(appear[0][2] && appear[1][1] && appear[2][0]) s="Yes";

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int test;
    scanf("%d", &test);
    getchar();
    char word[test];
    int x = 0;
    int max = 0;
    for(int i = 0; i < test; i++){
        scanf("%c", &word[i]);
        if(word[i] == 'D'){
            x--;
        }else{
            x++;
        }
        if(x > max){
            max = x;
        }
    }
    printf("%d", max);
    return 0;
}

Measured memory_bytes: 1700
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

ll dfs(ll N,ll X, vector<ll> &burger, vector<ll> &pa){
  if(N==0){
    if(X<=0)return 0;
    else return 1;
  }else{
    if(X<=1+burger[N-1]){
      return dfs(N-1,X-1, burger, pa);
    }else{
      return pa[N-1] + 1 + dfs(N-1, X-burger[N-1]-2, burger, pa);
    }
  }
}

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll N,X;
  cin>>N>>X;
  vector<ll>burger(N+1),pa(N+1);
  burger[0]=1,pa[0]=1;
  REP(i,N){
    burger[i+1]=2*burger[i]+3;
    pa[i+1]=2*pa[i]+1;
  }
  cout<<dfs(N,X,burger,pa)<<endl;
}


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

ll rui[200010];
ll sum(int l, int r){
    return rui[r] - rui[l-1];
}

ll L_sm[200010], L_bg[200010];
ll R_sm[200010], R_bg[200010];

int main(){

    int N;
    cin >> N;
    rep(i, N){
        cin >> rui[i+1];
        rui[i+1] += rui[i];
    }
    
    for(int i=2, j=1; i<=N; i++){
        while(abs(sum(1,j)-sum(j+1,i)) > abs(sum(1,j+1)-sum(j+2, i)))j++;
        L_sm[i] = min(sum(1, j), sum(j+1, i));
        L_bg[i] = max(sum(1, j), sum(j+1, i));
    }
    
    for(int i=N-1, j=N; i>=0; i--){
        while(abs(sum(i, j-2)-sum(j-1, N)) < abs(sum(i, j-1)-sum(j, N)))j--;
        R_sm[i] = min(sum(i, j-1), sum(j, N));
        R_bg[i] = max(sum(i, j-1), sum(j, N));
    }
    
    ll ans = 1e17;
    for(int i=2; i+2<=N; i++){
        ll bg = max(L_bg[i], R_bg[i+1]);
        ll sm = min(L_sm[i], R_sm[i+1]);
        ans = min(ans, bg-sm);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8064
if __name__ == '__main__':
    H, N = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(N)]
    maxA = max(AB)[0]

    dp = [[float('inf') for _ in range(H + maxA + 1)] for _ in range(N + 1)]

    for j in range(H + maxA, -1, -1):
        if j == 0:
            dp[0][j] = 0
        else:
            factor = j // AB[0][0] if j % AB[0][0] == 0 else j // AB[0][0] + 1
            dp[0][j] = factor * AB[0][1]

    for i in range(N):
        for j in range(H + maxA + 1):
            if j - AB[i][0] >= 0:
                dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - AB[i][0]] + AB[i][1])
            else:
                dp[i + 1][j] = dp[i][j]

    print(min([dp[N][j] for j in range(H, H + maxA + 1)]))


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

int main(){
    int a,b,k;
    cin>>a>>b>>k;
    int ans=0;
    for(int i=100;i>0;i--){
        if(a%i==0 && b%i==0){
            ans++;
            if(ans==k){
                cout<<i<<endl;
                break;
            }
        }
    }
    return 0;
}

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

int main(){
  int N;
  string S;
  cin>>N>>S;
  
  int m=N;
  vector<int> mae(N),usiro(N);
  mae.at(0)=0;
  usiro.at(0)=0;
  for(int i=1;i<N;i++){
    if(S.at(i-1)=='W')
      mae.at(i)=mae.at(i-1)+1;
    else
      mae.at(i)=mae.at(i-1);
  }
  reverse(S.begin(),S.end());
  for(int i=1;i<N;i++){
    if(S.at(i-1)=='E')
      usiro.at(i)=usiro.at(i-1)+1;
    else
      usiro.at(i)=usiro.at(i-1);
  }
  
  for(int i=0;i<N;i++){
    m =min(m,mae.at(i)+usiro.at(N-1-i));
  }
  cout<<m<<endl;
}


Measured memory_bytes: 3076
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] sp = s.split("/");
        int y = Integer.parseInt(sp[0]);
        int m = Integer.parseInt(sp[1]);
        int d = Integer.parseInt(sp[2]);
        String ans = "Heisei";
        if(y > 2019) ans = "TBD";
        else if(y == 2019 && m > 4) ans = "TBD";
        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
#include <cstdio>
int A, B, C, D;

bool solve() {
  while (A > 0) {
    C -= B;
    if (C <= 0) {
      return true;
    }
    A -= D;
  }
  return false;
}

int main() {
  scanf(" %d%d%d%d", &A, &B, &C, &D);
  puts(solve() ? "Yes" : "No");
  return 0;
}

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

int main(){
	int A, B, C;
	cin >> A >> B >> C;
	cout << C << " "<< A << " " << B << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;


int main(){
    int count = 0;
    int max = 0;
    string str;
    cin >> str;

    for (int i = 0; i < str.length(); i++) {
        char ch = str.at(i);
        while (ch == 'C' || ch == 'G' || ch == 'A' || ch == 'T') {
            count++;
            // cout << str.at(i) << endl;
            if (++i < str.length()) ch = str.at(i);
            else break;
        }
        if (count > max) {
            max = count;
            count = 0;
        }
    }
    cout << max;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> red(n);
  vector<pair<int, int>> blue(n);
  for (int i = 0; i < n*2; i++) {
    if(i>=n){
        cin>>blue[i-n].first>>blue[i-n].second;
    }else{cin>>red[i].first>>red[i].second;}
  }
 
  sort(red.begin(), red.end());
  sort(blue.begin(), blue.end());
  vector<bool> used(n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    const int c = blue[i].first;
    const int d = blue[i].second;
 
    int max_y = -1;
    int min_j = -1;
    for (int j = 0; j < n; j++) {
      const int a = red[j].first;
      const int b = red[j].second;
      if (c < a || d < b) {
        continue;
      }
      if (max_y < b && !used[j]) {
        max_y = b;
        min_j = j;
      }
    }
    if (min_j >= 0) {
      used[min_j] = true;
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    long long score = 0;
    for (int i = 0; i < n; i++){
        if(t[i]=='r'){
            score += p;
            if (i > k - 1 && t[i] == t[i - k])
            {
                score -= p;
                t[i] = '0';
            }
        }else if(t[i]=='s'){
            score += r;
            if (i > k - 1 && t[i] == t[i - k])
            {
                score -= r;
                t[i] = '0';
            }
        }else{
            score += s;
            if (i > k - 1 && t[i] == t[i - k])
            {
                score -= s;
                t[i] = '0';
            }
        }
        //cout << score << endl;
    }
    cout << score << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

//INT_MAX	2,147,483,647 = 2*1.0e9

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

  int start = -1;
  int end = 1000000;
  vector<bool> card(N, true);
  for(int i = 0; i < M; i++){
    int L, R; cin >> L >> R;
    if( L > start) start = L;
    if( R < end) end = R;
  }

  int ans;
  if(start > end) ans = 0;
  else ans = end - start + 1;
  cout << ans << endl;

  return 0;
}



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

int main() {
int n,a[100000],b=0;
long long x=0,y=0;
cin>>n;
for(int i=0;i<n;i++){
    cin>>a[i];
}
sort(a,a+n,greater<int>());
for(int i=0;i<n;i++){
    if(a[i]==b){
        if(x==0){
            x=b;
            b=0;
        }else{
            y=b;
            i=n;
        }
    }else{
        b=a[i];
    }
}
cout<<x*y<<endl;
	return 0;
}

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

int main()
{
    string S, T;
    int ans = 0;
    cin >> S >> T;
    
    for (int i = 0; i < 3; ++i)
    {
        if (S[i] == T[i]) ans++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, K; 
double X[64], Y[64], C[64]; 
vector<pair<double, double>> P;
double eps = 1e-10; 
void add1(double x1, double x2, double y1, double y2, double r1, double r2){
	double a = x2-x1; double b = y2-y1; 
	double k = (r1*r1-r2*r2+a*a+b*b)*0.5; 
	double dis = (a*a+b*b)*r1*r1-k*k; 
	if(dis < -eps) return; 
	else if(abs(dis) <= eps){
		double x = k*a / (a*a + b*b); double y = k*b / (a*a + b*b); 
		P.push_back(make_pair(x+x1, y+y1)); 
	}
	else{
		double xp = (k*a + b * pow(dis, 0.5)) / (a*a + b*b); 
		double yp = (k*b - a * pow(dis, 0.5)) / (a*a + b*b); 
		double xm = (k*a - b * pow(dis, 0.5)) / (a*a + b*b); 
		double ym = (k*b + a * pow(dis, 0.5)) / (a*a + b*b); 
		P.push_back(make_pair(xp+x1, yp+y1)); P.push_back(make_pair(xm+x1, ym+y1)); 
	}
}
void add2(double a, double b){
	P.push_back(make_pair(a, b)); 
}
bool check(double t, vector<pair<double, double>> &P){
	int mx = 0; 
	for(auto p : P){
		int cnt = 0; 
		for(int i = 0; i < N; i++){
			double dx = p.first - X[i]; 
			double dy = p.second - Y[i]; 
			if(pow(dx*dx + dy*dy, 0.5) <= t/C[i] + eps) cnt ++; 
		}
		mx = max(mx, cnt); 
	}
	return mx >= K; 
}
int main(){
	cin >> N >> K; 
	for(int i = 0; i < N; i++){
		cin >> X[i] >> Y[i] >> C[i]; 
	}
	if(K == 1){
		cout << 0 << endl; return 0; 
	}
	double ok = 314514.1919; double ng = 0; 
	for(int t = 0; t < 60; t++){
		double mid = (ok + ng) * 0.5; 
		for(int i = 0; i < N; i++){
			for(int j = i+1; j < N; j++){
				add1(X[i], X[j], Y[i], Y[j], mid/C[i], mid/C[j]); 
			}
		}
		for(int i = 0; i < N; i++) add2(X[i], Y[i]); 
		if(check(mid, P)) ok = mid; 
		else ng = mid; 
		P.clear(); 
	}
	cout.precision(15);
	cout << ok << endl;  
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000
#define MAX 200001
#define PI 3.1415926535897932384626433

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

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

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

int main(){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    for(int i = 0; i < tx - sx; i++){
        cout << 'R';
    }
    for(int i = 0; i < ty - sy; i++){
        cout << 'U';
    }
    for(int i = 0; i < tx - sx; i++){
        cout << 'L';
    }
    for(int i = 0; i < ty - sy; i++){
        cout << 'D';
    }
    cout << 'D';
    for(int i = 0; i <= tx - sx; i++){
        cout << 'R';
    }
    for(int i = 0; i <= ty - sy; i++){
        cout << 'U';
    }
    cout << 'L';
    cout << 'U';
    for(int i = 0; i <= tx - sx; i++){
        cout << 'L';
    }
    for(int i = 0; i <= ty - sy; i++){
        cout << 'D';
    }
    cout << 'R' << endl;
}

Measured memory_bytes: 3640
N, M = map(int, input().split())
ds = []
for _ in range(M):
  itr = map(int, input().split())
  k = itr.__next__()
  s = [ i-1 for i in itr]
  ds.append((k, s))

ds = [ (d[0], d[1], p) for d, p in zip(ds, map(int, input().split()))]

cnt = 0
for i in range(2**N):
  state = format(i, 'b').zfill(N)
  lights_up = True
  for k, ss, p in ds:
    s_on = 0
    for s in ss:
      if state[s] == '1':
        s_on += 1
    if s_on%2 != p:
      lights_up = False
      break
  if lights_up:
    cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))



int main(){
    long N,T;cin>>N>>T;
    vector<long>A(N);
    long mini=0;
    long maxi=0;
    map<long,long>mp;
    REP(i,N){
        cin>>A[i];
        if(i>0){
            maxi=max(maxi,A[i]-mini);
            mp[A[i]-mini]++;
        }else{
            mini=A[i];
        }
        mini=min(mini,A[i]);
    }
    cout<<mp[maxi]<<endl;
    return 0;
}


Measured memory_bytes: 7296
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void){
  int H, W, N;
  cin >> H >> W >> N;

  map<pair<int, int>, int> black;
  long long ans[10];
  int a, b;
  pair<int, int> p;

  for(int i=0;i<10;i++) ans[i] = 0;

  for(int i=0;i<N;i++){
    cin >> a >> b;
    a--;
    b--;
    for(int k=0;k<=2;k++){
      for(int l=0;l<=2;l++){
        p.first  = a-k;
        p.second = b-l;
        if(a-k<0 || b-l<0 || a-k>=H-2 || b-l>=W-2) continue;
        if(black.count(p) == 0) black[p] = 1;
        else black[p]++;
      }
    }
  }

  for(map<pair<int, int>, int>::iterator itr = black.begin(); itr != black.end(); ++itr){
    ans[itr->second]++;
  }

  long long sum = 0;
  for(int i=0;i<10;i++){
    sum += ans[i];
  }

  ans[0] = (long long) (H-2)*(W-2)-sum;

  for(int i=0;i<10;i++){
    cout << ans[i] << endl;
  }

  return 0;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vector<int> roads(n, 0);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        roads[a - 1]++;
        roads[b - 1]++;
    }
    for (int i = 0; i < n; i++) {
        cout << roads[i] << '\n';
    }
}

Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

int main(void)
{
	
	while(1){
		int n;
		cin >> n;
		if(n == 0) break;
		int c1, m1, s1, m2, s2, m3, s3, m4, s4;
		vector< pair<int, int> >g;
		for (int i = 0; i < n; ++i){
			cin >> c1 >> m1 >> s1 >> m2 >> s2 >> m3 >> s3 >> m4 >> s4;
			g.push_back(make_pair(60 * (m1 + m2 + m3 + m4) + (s1 + s2 + s3 + s4), c1));
		}
		
		sort(g.begin(), g.end());
	
		cout << g[0].second << endl;
		cout << g[1].second << endl;	
		cout << g[n - 2].second	<< endl;
	}
	return 0;
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int N;
    cin >> N;
    vector<string> s;
    string tmp;
    for(int i=0;i<N;i++){
        cin >> tmp;
        s.push_back(tmp);
    }

    ll ans = 0;
    int l, A = 0, B = 0, BA = 0;
    for(int i=0;i<N;i++){
        l = s[i].size();
        if(s[i].substr(l-1, 1) == "A")
            A++;
        if(s[i].substr(0, 1) == "B")
            B++;
        if(s[i].substr(l-1, 1) == "A" && s[i].substr(0, 1) == "B"){
            BA++;
            A--;
            B--;
        }
        for(int j=0;j+1<l;j++){
            if(s[i].substr(j, 2) == "AB")
                ans++;
        }
    }
    if(A == 0 && B == 0){
        if(BA == 0)
            cout << ans << endl;
        else
            cout << ans + BA - 1 << endl;
    }else{
        A += BA;
        B += BA;
        cout << ans + min(A, B) << endl;
    }

}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <cstdlib>
#include <vector>
#include <iomanip>
using namespace std;

int main() {
    string date[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    int ans;
    string s;
    cin >> s;

    for(int i = 0; i < 7; i++) {
        if(date[i] == s) {
            ans = 7 - i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
const int NMAX = 1e6 + 10;
const int MOD = 1e9 + 7;

int vis[NMAX],fac[NMAX];

int main(int argc, char const *argv[])
{
	int n;
	scanf("%d",&n);
	vector<int> v(n);
	for(register int i = 0;i < n;i++)
	{
		scanf("%d",&v[i]);
		vis[v[i]]++;
	}
	sort(v.begin(), v.end());
	int ans = 0;
	for(register int i = 0;i < n;i++)
	{
		if(vis[v[i]] == 1)
		{
			int flag = 1;
			for(register int j = 1;flag && j * j <= v[i];j++)
				if(v[i] % j == 0 && (fac[j] || fac[v[i]/j]))
					flag = 0;
			ans += flag;
		}
		fac[v[i]]++;
	}
	printf("%d\n",ans );
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  
  vector<char> v(s.size(), '0');
  
  for(long long i = 0; i<(s.size()+1)/2; i++){
    v[2 * i] = '1';
  }
  
  long long count = 0;
  for(long long i = 0; i<s.size(); i++){
    if(s[i] == v[i])
      ++count;
  }
  cout << min(count, static_cast<long long>(s.size()) - count) << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#define MN 100000
#define N 131072
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,a[4][MN+5],T1[N*2+5],T2[N*2+5],flip[2],rev[2];
void Renew(int*T,int x){for(T[x+=N]=1;x>>=1;)T[x]=T[x<<1]^T[x<<1|1];}
int Query(int*T,int l,int r)
{
	int res=0;
	for(l+=N-1,r+=N+1;l^r^1;l>>=1,r>>=1)
	{
		if(~l&1) res^=T[l+1];
		if( r&1) res^=T[r-1];	
	}
	return res;
}
int main()
{
	n=read();
	for(int i=1;i<=3;++i)for(int j=1;j<=n;++j) a[i][j]=read();
	for(int i=1;i<=n;++i)
	{
		int mn=1e9,mx=0;
		for(int j=1;j<=3;++j) mx=max(mx,a[j][i]),mn=min(mn,a[j][i]);
		if(mx-mn!=2) return 0*puts("No");
		if(mn%3!=1) return 0*puts("No");
		if(a[2][i]%3!=2) return 0*puts("No");
		if((mn%6==1)!=(i&1)) return 0*puts("No");
		if(mn!=a[1][i]) rev[i&1]^=1;
		flip[i&1]^=Query((i&1)?T1:T2,mx/3,n);
		Renew((i&1)?T1:T2,mx/3); 
	}
	if(flip[0]!=rev[1]||flip[1]!=rev[0]) return 0*puts("No");
	puts("Yes"); 
	return 0;
}



Measured memory_bytes: 3072
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here

        Scanner sc = new Scanner(System.in);
        int v = sc.nextInt();
        int ans =  v / 2;
        if (v % 2 == 1) {
            ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21716
fn get_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().to_string()
}

fn reads<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug {
    get_line().split(' ').map(|x| x.parse().unwrap()).collect()
}

fn main() {
    let mut cs = vec![];

    for _ in 0..3 {
        let xs: Vec<i64> = reads();
        cs.push(xs);
    }

    let mut res = true;
    'outer:
    for i in 0..3 {
        for j in 0..3 {
            let v0 = cs[i][0] - cs[j][0];
            let v1 = cs[i][1] - cs[j][1];
            let v2 = cs[i][2] - cs[j][2];

            let u0 = cs[0][i] - cs[0][j];
            let u1 = cs[1][i] - cs[1][j];
            let u2 = cs[2][i] - cs[2][j];

            if !(v0 == v1 && v1 == v2 && v2 == v0 && u0 == u1 && u1 == u2 && u2 == u0) {
                res = false;
                break 'outer;
            }
        }
    }

    println!("{}",
    if res {
        "Yes"
    }
    else {
        "No"
    });
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<iostream>

using namespace std;

int a, b, c, d, e, f, g, N, Result;

int main(void) {

	cin >> a >> b;
	c = a + b / 2;
	cout << c;

}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

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

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

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  string S = readString();
  for (int i = 0; i < 1 << 3; i++) {
    string s;
    s += S[0];
    int sum = S[0] - '0';
    REP(j, 3) {
      if ((i >> j) & 1)
        s += '+', sum += S[j + 1] - '0';
      else
        s += '-', sum -= S[j + 1] - '0';
      s += S[j + 1];
    }
    if (sum == 7) {
      std::cout << s << "=7" << std::endl;
      return 0;
    }
  }
}


Measured memory_bytes: 2304
use std::io::*;

fn solve(s1: &str, s2: &str) -> &'static str{
    if s1 == s2 {
        return "IDENTICAL";
    }
    let s1_split: Vec<&str> = s1.split('"').collect();
    let s2_split: Vec<&str> = s2.split('"').collect();
    if s1_split.len() != s2_split.len(){
        return "DIFFERENT";
    }
    let mut diff_count = 0;
    for i in 0..s1_split.len() {
        if s1_split[i] != s2_split[i] {
            if i % 2 == 0 {
                return "DIFFERENT";
            } else {
                diff_count += 1;
                if diff_count >= 2 {
                    return "DIFFERENT";
                }
            }
        }
    }
    "CLOSE"
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    loop {
        let s1 = iter.next().unwrap();
        if s1 == "." {
            break;
        }
        let s2 = iter.next().unwrap();
        println!("{}", solve(&s1, &s2));
    }
}



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

int main()
{
    int a, b, c;
    int tmp;

    cin >> a >> b >> c;

    if ((a >= 1 && a <= 10000) && (b >= 1 && b <= 10000) && (c >= 1 && c <= 10000)) {
        if (a > b) {
            tmp = a;
            a = b;
            b = tmp;
        }
        if (a > c) {
            tmp = a;
            a = c;
            c = b;
            b = tmp;
        } else if (b > c) {
            tmp = b;
            b = c;
            c = tmp;
        }
        cout << a << " " << b << " " << c << endl;
    }

    return 0;
}


Measured memory_bytes: 3136
#include<iostream>
#include<algorithm>

using namespace std;

int main() {

	int S = 0, T = 0;

	for (int i = 0; i < 4; ++i) {
		int temp;
		cin >> temp;
		S += temp;
	}
	for (int i = 0; i < 4; ++i) {
		int temp;
		cin >> temp;
		T += temp;
	}

	cout << max(S, T) << endl;

	return 0;
}

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

int main(){
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    int minx=200,miny=200,maxx=-200,maxy=-200;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        maxx=max(maxx,a);
        minx=min(minx,a);
    }
    for(int i=0;i<m;i++){
        int a;
        cin>>a;
        maxy=max(maxy,a);
        miny=min(miny,a);
    }
    if(maxx<miny&&maxx<y&&miny>x)cout<<"No War"<<endl;
    else cout<<"War"<<endl;

    return 0;
}

Measured memory_bytes: 3588