akhauriyash/Code-Regression huggingface dataset:
int N, M, P;
int xi[100], xsum;

int main(){
	int i;
	int result;
	while(1){
		scanf("%d%d%d", &N, &M, &P);
		if(N == 0 && M == 0 && P == 0)break;
		xsum = 0; M--;
		for(i = 0; i < N; i++){
			scanf("%d", &xi[i]);
			xsum += xi[i];
		}
		if(xi[M] == 0){
			result = 0;
		}else{
			result = 100*xsum*(100-P)/100/xi[M];
		}
		printf("%d\n", xi[M]?result:0);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin  = new Scanner(System.in);
		while(cin.hasNext()){
			int[] a = new int[4];
			int[] b = new int[4];
			for(int i = 0; i < 4;i++){
				a[i]=cin.nextInt();
			}
			for(int i = 0; i < 4;i++){
				b[i]=cin.nextInt();
			}
			int hit=0, blow=0;
			for(int i = 0; i < 4;i++){
				for(int j = 0; j < 4;j++){
					if(a[i]==b[j]){
						if(i==j){
							hit++;
						}
						else{
							blow++;
						}
					}
					
				}
			}
			System.out.println(hit + " " + blow);
		}
	}

}

Measured memory_bytes: 12000
# import sys
# input = sys.stdin.readline
import itertools
import collections
from decimal import Decimal
from functools import reduce
import heapq

def main():
    n = int(input())
    a = input_list()
    money = 1000
    stocks = 0
    for i, v in enumerate(a):
        if stocks > 0:
            money += v * stocks
            stocks = 0
        if i == len(a)-1:
            continue
        if v < a[i+1]:
            stocks = money // v
            money -= stocks * v
    print(money)


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def bfs(H, W, black_cells, dist):
    d = 0
    while black_cells:
        h, w = black_cells.popleft()
        d = dist[h][w]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if dist[new_h][new_w] == -1:
                dist[new_h][new_w] = d + 1
                black_cells.append((new_h, new_w))
    return d


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()


Measured memory_bytes: 77324
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<set>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){
long long ans=0;

string s;
cin>>s;
string t;
cin>>t;
bool alpha[26]={};
bool al[26]={};

//可能か不可かの判定
rep(i,s.size()){
    alpha[s[i]-'a']=true;
}
rep(i,t.size()){
    if(!alpha[t[i]-'a']){
        cout<<"-1"<<endl;
        return 0;
    }
    else{

    }
}
//存在位置の設定
vector<set<int>>v(26);
rep(i,t.size()){
    al[t[i]-'a']=true;
}

rep(i,s.size()){
    if(al[s[i]-'a']){
        v[s[i]-'a'].insert(i+1);
    }
}

int alMAX[26];
rep(i,26){
    if(!v[i].empty()){
        set<int>::iterator k = v[i].end();
        k--;
        alMAX[i]=*k;
    }
}

int cnt=0;
int limit=t.size();
int sample=s.size();
int before=0;
while(cnt<limit){
    if(alMAX[t[cnt]-'a']>before){
            set<int>::iterator k =v[t[cnt]-'a'].upper_bound(before);
            ans+=*k-before;
            before=*k;    
    }
    else{
        set<int>::iterator k  =v[t[cnt]-'a'].begin();
        ans+=*k+(sample-before);
        before=*k;
    }
    cnt++;
}
cout<<ans<<endl;
 return 0;
}
/*
contest
son

10

contest
programming

-1

contest
sentence

33

*/

Measured memory_bytes: 5120
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll n;
  cin >> n;
  vector<ll> vx;
  vector<ll> vy;
  vector<ll> vh;
  rep(i, 0, n) {
    ll a, b, c;
    cin >> a >> b >> c;
    if(c==0)continue;
    vx.pb(a);
    vy.pb(b);
    vh.pb(c);
  }
  if(vh.sz==1){
    cout << vx[0] << " " << vy[0] << " " << vh[0] << endl;
    return 0;
  }
  rep(x, 0, 101) {
    rep(y, 0, 101) {
      rep(h, 0, 211) {
        ll hh = vh[0]+h;
        ll flag = 1;
        rep(i, 0, vh.sz) {
          ll x1 = vx[i];
          ll y1 = vy[i];
          ll h1 = vh[i];
          if(hh != h1 + abs(x-x1)+abs(y-y1)){
            flag = 0;
          }
        }
        if(flag==1){
          cout << x << " " << y << " " << hh << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long ll;
ll a[100000];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int sum = 0;
	for (int i = 0; i < n;) {
		int j = i+1;
		sum++;
		int s = 1, u = 1;
		while (j < n&&a[j] >= a[j - 1]) {
			s++;
			j++;
		}
		j = i + 1;
		while (j < n&&a[j] <= a[j - 1]) {
			u++;
			j++;
		}
		i += max(s, u);
	}
	cout << sum << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   string s;
   cin >> s;

   bool flg = 0;
   for(int i=0;i<s.size();i++){
      if((i+1)%2==0){
         if(s[i] == 'R'){
            flg = 1;
         }
      }else{
         if(s[i] == 'L'){
            flg = 1;
         }
      }
   }

   cout << (flg != 1? "Yes":"No") << endl;


   return 0;
}

Measured memory_bytes: 256
// 

// g++ -std=c++11 abc145_c.cc && ./a.out 
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

bool isContained(int needle, vector<int> &haystack, int min, int max) {
    int mid = (max + min) / 2;
    if (max - min <= 2) {
        return (needle == haystack[min]) || (needle == haystack[max]) || (needle == haystack[mid]);
    }

    if (needle < haystack[mid]) {
        return isContained(needle, haystack, min, mid);
    } else if (needle > haystack[mid]) {
        return isContained(needle, haystack, mid, max);
    } else {
        return true;
    }
}

int main() {
    int n, q, i, j;
    cin >> n;

    // 重複あり
    vector <int> S(n);
    rep(i, n) cin >> S[i];
    sort(S.begin(), S.end());

    cin >> q;
    // すべて異なる
    vector <int> T(q);
    rep(i, q) cin >> T[i];

    int count = 0;
    rep(i, q) {
        int t = T[i];
        if (isContained(t, S, 0, S.size() - 1)) {
            // for debug
            // cout << t << " is contained" << endl;

            count++;
        }
    }
    cout << count << endl;

    return 0;
}



Measured memory_bytes: 3324
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define tc int t; cin>>t; while(t--)
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define vc vector<char>
#define eb emplace_back
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define fo(i,x,n) for(int i=x;i<n;i++)
#define csb(x) __builtin_popcount(x)
#define tz(x) __builtin_ctz(x)
#define lsbp(x) __builtin_ffs(x)
#define msbp(x) __lg(x)
#define btoi(str,i) stoi(str,0,i)
#define ff first
#define ss second
const int inf=0x3f3f3f3f3f3f3f3f;



int32_t main(){

int n;cin>>n;
int x=n/500;
x*=1000;
int y=n%500;
int z=y/5;
cout<<x+z*5<<endl;

}

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

int main(){
int N,A,B,C,D,E,G;
  cin>>N>>A>>B>>C>>D;
  string S;
  cin>>S;
  G=0;
  if(C>D){
  for(int i=B-2;i<D-1;i++){
    if(S[i]=='.'&&S[i+1]=='.'&&S[i+2]=='.'){
      G=1;
      break;
    }
  }
  }
  for(int i=0;i<N;i++){
    if(B<D-2){
    	if(S[B+1]=='.'){
     		B+=2;
      		continue;
    	}
    	else if(S[B]=='.'){
      		B++;
      		continue;
    	}
    	else{
      			cout<<"No"<<endl;
      return 0;
    	}
    }
    else{
B=D;
   break;
    }
  }
    for(int i=0;i<N;i++){
      	if(A<C-2){
    		if(S[A+1]=='.'){
      			A+=2;
      			continue;
    		}
    		else if(S[A]=='.'){
      			A++;
      			continue;
    		}
    		else{
      				cout<<"No"<<endl;
      return 0;
    		}
      	}
      	else{
       		A=C;
          break;
  		}
    }
  if(D>C){
    cout<<"Yes"<<endl;
    return 0;
  }
  else{
   	if(G==0){
		cout<<"No"<<endl;
      return 0;
      }
    else{
        cout<<"Yes"<<endl;
        return 0;
    }
  }
}

Measured memory_bytes: 640
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import Math._

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, Q = in.next().toInt
  val s = "0" + in.next()

  val t = new Array[Char](Q+1)
  val d = new Array[String](Q+1)


  for (i <- 1 to Q) {
    val _t, _d = in.next()
    t(i) = _t(0)
    d(i) = _d
  }

  //
  var ans = N

  // 左に落ちるかどうか
  def checkLeft(m: Int): Boolean = {
    var res = false
    var ind = m

    breakable {
      for (q <- 1 to Q) {
        if(s(ind) == t(q)) {
          if (d(q) == "L")
            ind -= 1
          else
            ind += 1
        }

        if (ind <= 0) {
          res = true
          break
        }
        else if(ind > N)
          break
      }
    }

    res
  }

  // 条件を満たす最大の値を返す
  def binarySearchLeft(min: Int, max: Int): Int = {
    val mid: Int = (max + min) / 2
      (max - min) match{
      case 0 | 1 =>
        checkLeft(max) match{
          case true  => max
          case false => min
        }
      case _ =>
        (checkLeft(mid)) match{
          case true  => binarySearchLeft(mid, max)
          case false => binarySearchLeft(min, mid)
        }
    }
  }

  if (checkLeft(1)) {
    val max = binarySearchLeft(1, N)
    ans -= max
  }
  


  ///////////////////////
  // 右に落ちるかどうか
  def check(m: Int): Boolean = {
    var res = false
    var ind = m

    breakable {
      for (q <- 1 to Q) {
        if(s(ind) == t(q)) {
          if (d(q) == "L")
            ind -= 1
          else
            ind += 1
        }

        if (ind <= 0) {
          break
        }
        else if(ind > N){
          res = true
          break
        }
      }
    }

    res
  }


  // 条件を満たす最小の値を返す
  def binarySearch(min: Int, max: Int): Int = {
    val mid: Int = (max + min) / 2
      (max - min) match{
      case 0 | 1 =>
        check(min) match{
          case true  => min
          case false => max
        }
      case _ =>
        (check(mid)) match{
          case true  => binarySearch(min, mid)
          case false => binarySearch(mid, max)
        }
    }
  }

  if (check(N)) {
    val min = binarySearch(1, N)
    ans -= (N - min + 1)
  }




  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}



Measured memory_bytes: 60524
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    abc = [0] * N
    for i in range(N):
        abc[i] = list(map(int, input().split()))

    dp = [[0] * 3 for _ in range(N)]
    dp[0] = abc[0]
    for i, (a, b, c) in enumerate(abc[1:], start=1):
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c

    ans = max(dp[-1])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 50780
#include <stdio.h>
 
struct _map {
  int  nDepth;
  char chMap;
} stMap[20000];
 
int chLake(int staMap, const int finMap, const struct _map* stMap, const int nDepth);
 
int main(){
  int maxH=0,minH=0,endMap=0;
  int A=0,L[10000],k=0;
 
  if (1) {
    char theMap; int m=0;
    int curH=0;
    while(scanf("%c",&theMap) !=EOF){
      stMap[m].chMap = theMap;
      if(theMap=='\\'){
    stMap[m].nDepth = --curH;
    if(curH<minH) minH=curH;
      }
      else if(theMap=='/'){
    stMap[m].nDepth = curH++;
    if(curH>maxH) maxH=curH;
      }
      else
    stMap[m].nDepth = curH;
      m++;
    }
    endMap=m;
  }
 
  if (1) {
    int m;
    for(m=0; m<endMap; m++) {
      if(stMap[m].chMap=='\\') {
    int n;
    for (n=m; n<endMap; n++) {
      if ((stMap[n].chMap=='/')&&(stMap[n].nDepth==stMap[m].nDepth)) {
        int a = chLake(m, n, stMap, stMap[m].nDepth);
        L[k] = a/2;
        A = A + L[k];
        k++;
        m = n;
        break;
      }
    }
      }
    }
  }
 
  printf("%d\n",A);
  if (k==0)
    printf("%d\n",0);
  else {
    int l;
    printf("%d ",k);
    for(l=0; l<k-1; l++)
      printf("%d ",L[l]);
    printf("%d\n",L[k-1]);
  }
  return 0;
}
 
int chLake(int staMap, int endMap, const struct _map* stMap, int nDepth){
  int a=0;
  int m;
  for(m=staMap;m<=endMap;m++){
    if(stMap[m].chMap=='\\'){
      a = a + 1 + (nDepth - stMap[m].nDepth) * 2;
    }
    else if(stMap[m].chMap=='_'){
      a = a + 2 + (nDepth - stMap[m].nDepth) * 2;
    }
    else if(stMap[m].chMap=='/'){
      a = a + 1 + (nDepth - stMap[m].nDepth) * 2;
    }
  }
  return (a);
}

Measured memory_bytes: 712
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <map>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <bitset>
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
using namespace std;    
const int N = int(3e5), mod = int(1e9)  + 7; 

string s;

int main () {
	cin >> s;
	int ans = int(s.size());
	for(char i = 'a'; i <= 'z';i++){
	    string t = s;
	    int cnt = 0;
	    string tt = "";
	    while(true){
	    	bool ok = 1;
	    	tt = "";
	    	for(int j = 0; j < t.size(); j++){
	    		if(t[j] != i) ok = 0;
	    	}
	    	if(ok) break;
	    	cnt++;
	        for(int j = 0; j < int(t.size()) - 1; j++){
	        	if(t[j] == i || t[j + 1] == i)  tt += i;
	        	else tt += t[j] ;
	        }
	        t = tt;
	    }
	    ans = min(ans, cnt);
	}
	cout << ans;

return 0;
}

Measured memory_bytes: 256
L, R = map(int, input().split())
pred = 2019
if (R)-(L)>2019:
    print(0)
else:
    for i in range(L,R+1):
        for j in range(i+1, R+1):
            if (i*j)%2019 < pred:
                pred = (i*j)%2019
            else:
                pass
    print(pred)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
	
	int number, notation, digit; // number(整数), notation(表記法), digit(桁数)をint型の変数として宣言
	scanf("%d %d", &number, &notation); // number, notationを入力
	
	digit = 0; // 桁数を初めは0としておく
	// 整数numberをnotation進数で表すと何桁になるかをnumberが何回notationで割れるかで計算する
	while (number > 0){
		number = number / notation;
		digit++; // numberをnotationで1回割ったら桁数digitを1増やす
	}
	
	printf("%d", digit); // 桁数digitを出力
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<set>
using namespace std;
#define ll int64_t
#define REP(i, n) for (int i=0; i<n; i++)

struct UnionFind{
    vector<ll> par;

    UnionFind(ll N) : par(N){
        REP(i, N) par[i] = i;
    }

    ll root(ll x){
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

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

    ll N, M;
    cin >> N >> M;
    vector<ll> X(M), Y(M), Z(M);
    REP(i, M) {
        cin >> X[i] >> Y[i] >> Z[i];
        X[i]--;
        Y[i]--;
    }

    UnionFind tree(N);

    REP(i, M){
        tree.unite(X[i], Y[i]);
        // REP(i, N) cout << tree.par[i] << " ";
        // cout << "\n";
    }

    set<ll> ans;
    REP(i, N) ans.insert(tree.root(i));

    cout << ans.size() << "\n";    
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;  typedef pair<ll,ll> pii;
typedef vector<int> VI; typedef vector<ll> VL;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

vector<VI> r;
VI ck;

void rec(int s, const pii& chn){
	ck[s] = 1;
	for(auto x: r[s]){
		if(pii(s, x)==chn || pii(x,s)==chn) continue;
		if(!ck[x]) rec(x, chn);
	}
}

int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	r.resize(n);
	vector<pii> hen;
	rep(i, m){
		int a,b;
		cin >>a >>b;
		r[a-1].push_back(b-1);
		r[b-1].push_back(a-1);
		hen.emplace_back(a-1, b-1);
	}
	
	int ans =0;

	for(auto z: hen){
		ck.assign(n, 0);
		rec(0, z);
		//for(auto x :ck) printf("%d, ",x); puts("");
		if(count(all(ck),1) != n) ans++;
	}
	cout << ans <<"\n";
	return 0;
}


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

enum direction {
  TOP, EAST, WEST, SOUTH, NORTH, BOTTOM
};

void north(int *state);
void east(int *state);
void west(int *state);
void south(int *state);
void right(int *state);
void left(int *state);

int main(int argc, char const* argv[])
{
  while (true) {
    int n;
    std::cin >> n;
    if (n == 0) {
      break;
    }
    // top, east, west, south, north, bottom
    int state[] = { 1, 3, 4, 2, 5, 6 };
    int ans = 1;
    for (int i = 0; i < n; ++i) {
      std::string s;
      std::cin >> s;
      if ("North" == s) {
        north(state);
      } else if ("East" == s) {
        east(state);
      } else if ("West" == s) {
        west(state);
      } else if ("South" == s) {
        south(state);
      } else if ("Right" == s) {
        right(state);
      } else if ("Left" == s) {
        left(state);
      } else {
        return 1;
      }
      ans += state[0];
    }
    std::cout << ans << std::endl;
  }
  return 0;
}

void north(int *state) {
  state[NORTH] = state[TOP];
  state[TOP] = state[SOUTH];
  state[SOUTH] = 7 - state[NORTH];
  state[BOTTOM] = 7 - state[TOP];
}

void east(int *state) {
  state[EAST] = state[TOP];
  state[TOP] = state[WEST];
  state[WEST] = 7 - state[EAST];
  state[BOTTOM] = 7 - state[TOP];
}

void west(int *state) {
  state[WEST] = state[TOP];
  state[TOP] = state[EAST];
  state[EAST] = 7 - state[WEST];
  state[BOTTOM] = 7 - state[TOP];
}

void south(int *state) {
  state[SOUTH] = state[TOP];
  state[TOP] = state[NORTH];
  state[NORTH] = 7 - state[SOUTH];
  state[BOTTOM] = 7 - state[TOP];
}

void right(int *state) {
  state[WEST] = state[SOUTH];
  state[SOUTH] = state[EAST];
  state[EAST] = 7 - state[WEST];
  state[NORTH] = 7 - state[SOUTH];
}

void left(int *state) {
  state[EAST] = state[SOUTH];
  state[SOUTH] = state[WEST];
  state[WEST] = 7 - state[EAST];
  state[NORTH] = 7 - state[SOUTH];
}

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

using namespace std;
map<string,int> mp;
int main(){
	mp["MON"] = 1;
	mp["TUE"] = 2;
	mp["WED"] = 3;
	mp["THU"] = 4;
	mp["FRI"] = 5;
	mp["SAT"] = 6;
	mp["SUN"] = 7;
	string s;
	cin>>s;
	if(mp[s] == 7) cout<<7<<endl;
	else{
		cout<<7 - mp[s]<<endl;
	}
	
	
	return 0;
} 

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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

int main() {

  ll N; cin >> N;
  vector<ll> A(N);
  REP(i, N){
    cin >> A[i];
  }
  ll max = 0;
  ll ans = 0;
  REP(i, N){
    if(A[i]>max){
      max = A[i];
    }else{
      ans += max - A[i];
    }
  }
  cout << ans << endl;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 4836
#include<bits/stdc++.h>
#define ll long long

using namespace std;
void solve(){
    int A,B;
    cin>>A>>B;
    int seki=A*B;
    for(int i=1;i<4;i++){
        int res=seki*i;
        if(res%2!=0){
            cout<<"Yes"<<endl;
            return;
        }
    }
        cout<<"No"<<endl;
 
}

int main(){

    solve();
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]

ans = a[0][0]+sum([a[1][j] for j in range(n)])
now = ans

for j in range(n-1):
    now += a[0][j+1]-a[1][j]
    ans = max(ans, now)

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
const int N=2e5+50,oo=2e9;
vector<int>h[N];char s[N];
int n,c[N],fa[N],sz[N],f0[N],f1[N],g[N],gg[N];
inline void dfs1(int x,int f) {
    fa[x]=f;sz[x]=c[x];
	f0[x]=0;f1[x]=oo;
    for(auto y:h[x])
		if(y!=f){
        dfs1(y,x);sz[x]+=sz[y];
        f0[x]=max(f0[x],f0[y]+1); 
        if(f1[y]<oo)f1[x]=min(f1[x],f0[y]+1);
    }if(c[x])f1[x]=min(f1[x],f0[x]); 
}
inline void dfs2(int x,int f) {
    g[x]=max(g[x],g[f]+1);
    if(f)gg[x]=max(gg[x],g[x]-1);
    int mx;mx=-1;
    for(int y,k=0;k<(int)h[x].size();k++)
	if((y=h[x][k])!=f){
        g[y]=max(g[y],mx+2);
        mx=max(mx,f0[y]);
    }mx=-1;
    for(int y,k=h[x].size()-1;k>=0;k--)
	if((y=h[x][k])!=f){
        g[y]=max(g[y],mx+2);
        mx=max(mx,f0[y]);
    }
	for(auto y:h[x])if(y!=f)dfs2(y,x);
}
inline void addl(int x,int y){
	h[x].push_back(y);
	h[y].push_back(x);
}
int main(){
	g[0]=-1;
    memset(f1,120,sizeof(f1));
    int i;n=read();
    for(i=1;i<n;i++)addl(read(),read());
	scanf("%s",s+1);
	for(i=1;i<=n;i++)c[i]=s[i]-'0';
    dfs1(1,0);dfs2(1,0);
    long long ans=0;
    for(int i=1;i<=n;i++) {
        int up=max(f0[i],g[i])-1,dw;
		dw=c[i]?0:min(f1[i],(sz[i]==sz[1])?oo:g[i]);
        for(auto y:h[i]){
            if(y==fa[i])up=min(up,f0[i]+1);
            else up=min(up,gg[y]+1);
        }if(up>=dw)ans+=up-dw+1;
    }printf("%lld\n",ans+1);
	return 0;
}

Measured memory_bytes: 21632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int a = GetInt();
		int b = GetInt();
		int c = GetInt();
		WriteLine((a < b) && (b < c) ? "Yes" : "No");
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}


Measured memory_bytes: 15984
N, A, B = map(int, input().split())
souwa = 0
for i in range(1, N+1):
    sumketa = i//10000 + ((i%10000)//1000) + ((i%1000)//100) + ((i%100)//10) + (i%10)
    if A <= sumketa <= B:
        souwa += i
print(souwa)

Measured memory_bytes: 9120
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int ans=1;
    int preans=0;
    for(int i=0; i<3; i++){
        if(s[i]==s[i+1]){
            ans++;
        }else{
            ans=1;
        }
        preans=max(preans, ans);
    }
    if(preans>=3){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
A, B, K = map(int, input().split())

if A>=K:
    A=A-K
    B=B
    print(A,B)
elif A<K and K-A<B:
    print(0,B-(K-A))

elif A<K and K-A>B:
    print(0,0)
else:
    print(0,0)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
int n,m,i,j,typ[200005],f,g,ans=1,mod=1e9+7,cnt;
string st;
int main()
{
	scanf("%d",&n);
	rdst(st,200005);
	st="W"+st+"W";
	fz1(i,n+n){
		if(g&1){
			st[i]='W'+'B'-st[i];
		}
		if(st[i]==st[i-1]){
			typ[i]=-1;
			g^=1;
		}
		else{
			typ[i]=1;
			g^=1;
			st[i]='W'+'B'-st[i];
		}
		f+=typ[i];
		if(f<0) break;
	}
	if(f){
		puts("0");
		return 0;
	}
	fz1(i,n+n){
		if(typ[i]==1)cnt++;
		else{
			ans=1ll*ans*cnt%mod;
			cnt--;
		}
	}
	fz1(i,n){
		ans=1ll*ans*i%mod;
	}
	cout<<ans<<endl;
	return 0;
}

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

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<typename T> void view(T cont) {std::cout << cont << std::endl;}
template<typename T> void view(T* cont, ll sz) {rep(i, sz) std::cout << cont[i] << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<T>& v) {for (const auto& f: v) std::cout << f << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v: vv) {view(v);}}
#define INF 1000000000

int main(){
    ll N, W; cin >> N >> W;
    vector<ll> w_;
    vector<ll> v;
    rep(i, N) {
        int temp_w, temp_v;
        cin >> temp_w >> temp_v;
        w_.push_back(temp_w);
        v.push_back(temp_v);
    }
    vector<vector<ll> > dp(N + 1, vector<ll>(W + 1, 0));
    for (ll i = 0; i < N; i++) {
        for (ll w = 0; w <= W; w++) {
            if (w >= w_[i]) {
                dp[i + 1][w] = max(dp[i][w - w_[i]] + v[i],
                            dp[i][w]);
            } else {
                dp[i + 1][w] = dp[i][w];
            }
        }
    }
    // view(dp);
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 80256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

bool bo[1000010];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[N + 2];
    REP(i, 0, N) {
        cin >> A[i];
    }
    A[N] = inf;
    A[N + 1] = inf;
    sort(A, A + N + 2);
    REP(i, 1, 1000001) {
        for (ll j = 1; i * j <= 1000000; j++) {
            ll num = i * j;
            ll id = lower_bound(A, A + N + 2, i) - A;
            if (j >= 2) {
                if (A[id] == i) {
                    bo[num] = true;
                }
            } else {
                if (A[id + 1] == i) {
                    bo[num] = true;
                }
            }
        }
    }
    ll ans = 0;
    REP(i, 0, N) {
        if (!bo[A[i]]) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6212
#include<bits/stdc++.h>
using namespace std;
int main()
{
	vector<string>strings(200);
	int n,l;cin>>n>>l;
	for(int i=0;i<n;i++)
	{
		cin>>strings[i];
	}
	sort(strings.begin(),strings.end());
	for(vector<string>::iterator it=strings.begin();it!=strings.end();it++)
		cout<<(*it);
 	return 0;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


vector<ll> cnt={2,5,5,4,5,6,3,7,6};


string ans;


const ll MX=10001;

int main(){
    ll n,m;
    cin>>n>>m;
    vector<bool> A(9,false);
    for(int i=0;i<m;i++){
        ll a;
        cin>>a;
        A[a-1]=true;
    }
    vector<bitset<MX>> dp(n,bitset<MX>(false));
    dp[0][0]=true;
    for(int i=0;i+1<n;i++){
        for(int t=0;t<9;t++){
            if(A[t]){dp[i+1]|=(dp[i]<<cnt[t]);}
        }
    }
    ll mx=0;
    for(int i=0;i<n;i++){
        if(dp[i][n]){mx=i;}
    }
    string ans;
    pll w={mx,n};
    pll s={0,0};
    while(w!=s){
        for(int k=8;k>=0;k--){
            if(A[k] && w.S-cnt[k]>=0 && dp[w.F-1][w.S-cnt[k]]){
                ans.push_back('1'+k);
                w={w.F-1,w.S-cnt[k]};
                break;
            }
        }
    }
    cout<<ans<<endl;
    

    return 0;
}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
#define N 2020
using namespace std;
char grid[N][N];
vector<int> wall[N],vwall[N];
int main(){
	int n,m,i,j,k,l,num,ans=0,pos1,pos2,posa,posb;
	cin>>n>>m;
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			cin>>grid[i][j];
			if(grid[i][j]=='#')
			{
				wall[i].push_back(j);
				vwall[j].push_back(i);
			}
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			if(grid[i][j]=='#')
			{
				continue;
			}
			pos1=upper_bound(wall[i].begin(),wall[i].end(),j)-wall[i].begin();
			pos2=upper_bound(vwall[j].begin(),vwall[j].end(),i)-vwall[j].begin();
			posa=pos1-1;
			posb=pos2-1;
			if(pos1==wall[i].size())
			{
				pos1=m-1;
			}
			else
			{
				pos1=wall[i][pos1]-1;
			}
			if(pos2==vwall[j].size())
			{
				pos2=n-1;
			}
			else
			{
				pos2=vwall[j][pos2]-1;
			}
			if(posa==-1)
			{
				posa=0;
			}
			else
			{
				posa=wall[i][posa]+1;
			}
			if(posb==-1)
			{
				posb=0;
			}
			else
			{
				posb=vwall[j][posb]+1;
			}
			num=pos1-posa+pos2-posb+1;
			ans=max(ans,num);
		}
	} 
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 38400
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

void solve() {
    int n, m, b;
    cin >> n >> m >> b;

    vector<int> line_cnt(n + 1, 0), col_cnt(m + 1, 0);
    set<ii> bombs;

    fori (i, 0, b) {
        int x, y;
        cin >> x >> y;

        line_cnt[x]++;
        col_cnt[y]++;

        bombs.emplace(x, y);
    }

    vector<int> lines(n);
    iota(begin(lines), end(lines), 1);
    sort(begin(lines), end(lines), [&] (int lhs, int rhs) {
        return line_cnt[lhs] < line_cnt[rhs];
    });

    vector<int> cols(m);
    iota(begin(cols), end(cols), 1);
    sort(begin(cols), end(cols), [&] (int lhs, int rhs) {
        return col_cnt[lhs] < col_cnt[rhs];
    });

    vector<int> best_lines;
    for (auto &line : lines) {
        if (line_cnt[line] == line_cnt[lines.back()]) {
            best_lines.push_back(line);
        }
    }

    vector<int> best_cols;
    for (auto &col : cols) {
        if (col_cnt[col] == col_cnt[cols.back()]) {
            best_cols.push_back(col);
        }
    }

    int ans = line_cnt[best_lines[0]] + col_cnt[best_cols[0]];
    for (auto &line : best_lines) {
        for (auto &col : best_cols) {
            if (!bombs.count(ii(line, col))) {
                cout << ans << endl;
                return;
            }
        }
    }

    cout << ans - 1 << endl;
}

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



Measured memory_bytes: 26100
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;

int n, m, a[N];
int tmp = 0, ans[N];

bool cmp(int x, int y) {
	return (x & 1) > (y & 1);
}

int main() {
	cin >> n >> m;
	for (int i = 1; i <= m; ++i)
		cin >> a[i];
	if (m == 1) {
		if (a[1] == 1) {
			return 0 * printf("1\n1\n1\n");
		}
		cout << a[1] << endl;
		puts("2");
		cout << a[1] - 1 << ' ' << 1 << endl;
		return 0;
	}
	sort(a + 1, a + m + 1, cmp);
	int cnt = 0;
	for (int i = 1; i <= m; ++i) {
		if (a[i] & 1) ++cnt;
	}
	if (cnt > 2) return 0 * puts("Impossible");
	if (cnt == 2) swap(a[2], a[m]);
	ans[1] = a[1] + 1, ans[m] = a[m] - 1;
	for (int i = 2; i < m; ++i) {
		ans[i] = a[i];
	}
	for (int i = 1; i <= m; ++i) {
		if (ans[i] > 0) ++tmp;
	}
	for (int i = 1; i <= m; ++i)
		cout << a[i] << ' ';
	puts("");
	cout << tmp << endl;
	for (int i = 1; i <= m; ++i) {
		if (ans[i]) cout << ans[i] << ' ';
	}
	puts("");
}
	


Measured memory_bytes: 256
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    long double A, B;
    cin >> A >> B;
    cout << (long long)(A * B + 0.001) << endl;
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x;cin>>n>>x;
  vector<int>m(n);
  for(int i=0;i<n;i++){
    cin>>m.at(i);
    x-=m.at(i);
  }
  sort(m.begin(),m.end());
  cout<<n+x/m.at(0)<<endl;
}
  

Measured memory_bytes: 256
W, H, X, Y = gets.chomp.split.map(&:to_i)
area = sprintf("%1f", (H * W) / 2r)

if (H == 2 * Y) && (W == 2 * X)
  puts area.to_s + " 1"
else
  puts area.to_s + " 0"
end


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

vector<string> l = {
  "0111111",
  "0000110",
  "1011011",
  "1001111",
  "1100110",
  "1101101",
  "1111101",
  "0100111",
  "1111111",
  "1101111",
  "0000000"
};

string change(int now ,int nxt){
  string s = "";
  for(int i=0;i<l[now].size();i++){
    if(l[now][i]!=l[nxt][i]){
      s += '1';
    }else{
      s+='0';
    }
  }
  return s;
}

int solve(){
  int now = 10;
  int n = 0;
  cin>>n;
  if(n==-1)return false;
  for(int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    cout<<change(now,tmp)<<endl;
    now = tmp;
  }
  return 1;
}

int main(){
  while(solve());
}

Measured memory_bytes: 1204
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <deque>
#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <iomanip>
#include <utility>
#include <functional>
using namespace std;
#define ll long long
#define ull unsigned ll
/*Fast I/O goes here*/
const double EPS = 1e-8;
const ll PR = 19260817;
const ll inv2 = 500000004;
const ll inv3 = 333333336;
int main() {
	int n;cin>>n;int ans=1, res=1;for(int i=0; i<n; i++) ans*=3;
	while(n--) {int x;cin>>x;if(x%2==0) res*=2;}
	cout<<ans-res<<endl;
	return 0;
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	a -= b;
	cout << max(0, c - a);
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 256
N = int(input())

A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()

if N%2==1:
    min_X = A[(N+1)//2-1]
    max_X = B[(N+1)//2-1]
    print(max_X - min_X + 1)
else:
    min_X = (A[N//2-1] + A[N//2])/2
    max_X = (B[N//2-1] + B[N//2])/2
    print(int((max_X - min_X)*2) + 1)


Measured memory_bytes: 98976
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T lcm(T x,T y){
    return x*y/GCD(x,y);
}


int main(){
    int n,m; cin >> n >> m;
    string a[n],b[m];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < m; i++){
        cin >> b[i];
    }
    for(int i = 0; i < n-m+1; i++){
        for(int j = 0; j < n-m+1; j++){
            bool flg = true;
            for(int k = 0; k < m; k++){
                for(int l = 0; l < m; l++){
                    if(a[i+k][j+l] != b[k][l]) flg = false;
                }
            }
            if(flg){
                //cout << i << j << endl;
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}
  



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(x) x.begin(), x.end()
#define pb(x) push_back(x)
#define INF 1000000000000000000
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define x first 
#define y second
const int maxx = 2000006;
const int mod2 = 987654319;
const int maxlog = 20;
const ll mod = 1000000007;

int main() {
    IOS
    ld a, h, x;
    cin >> a >> h >> x;
    cout << fixed << setprecision(10);
    if (x * 2 >= a * a * h) {
        ld theta = atan(((a * a * a) / (2 * (h * a * a - x)))) * (180 / acos(-1));
        cout << (ld)90 - theta;
    }
    else {
        ld theta = atan((2 * x)/ (h * h * a)) * (180 / acos(-1));
        cout << (ld)90 - theta;
    }
}


Measured memory_bytes: 256
use proconio::fastout;
use whiteread::parse_line;

#[fastout]
fn main() {
    let (a, b, c, d): (i64, i64, i64, i64) = parse_line().unwrap();

    println!(
        "{}",
        *[a*c, a*d, b*c, b*d].iter().max().unwrap()
    );
}


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


void solve(long long A, long long B, long long C, long long D){
    cout << min(A,B)+min(C,D) << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    solve(A, B, C, D);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100000
#define Q 50000

int T[Q], S[N];
int n, c = 0;
void binarySearch(int);

int main(){

  int i, q;
 
  scanf("%d", &n);
  for( i=0 ; i<n ; i++ ) scanf("%d", &S[i]);
  scanf("%d", &q);
  for( i=0 ; i<q ; i++ ) scanf("%d", &T[i]);
  
  for( i=0 ; i<q ; i++ ){
    binarySearch(T[i]);
  }
  printf("%d\n", c); 
  return 0;
}

void binarySearch(int key) {
  int left, right, mid;
  left = 0;
    right = n;
    while( left<right ){
      mid = (left + right) / 2;
      
      if( S[mid]==key ){
	c++;
	break;
      }
      else if( key<S[mid] ) right = mid; 
      else left = mid + 1;
    }
}

Measured memory_bytes: 1184
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<utility>
#include<queue>
#include <map>

using namespace std;



int main(){

	string s,t;
	int a,b;
	cin>>s>>t>>a>>b;
	string u;
	cin>>u;
	if(u==s)a--;
	else b--;
	cout<<a<<" "<<b;


	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
from collections import deque, defaultdict

def solve(N, M, paths):
    used = [False for _ in range(M)]
    stack = deque([1])
    ret = [[float("inf"), -1] for _ in range(N + 1)]
    ret[1] = [0, 1]

    while stack:
        cur = stack.popleft()
        nexts = paths[cur]
        for n in nexts:
            if used[n[0]]:
                continue
            used[n[0]] = True
            if ret[cur][0] + 1 < ret[n[1]][0]:
                ret[n[1]] = [ret[cur][0] + 1, cur]
                stack.append(n[1])

    print("Yes")
    for r in ret[2:]:
        print(r[1])

if __name__ == "__main__":
    N, M = map(int, input().split())
    paths = defaultdict(list)
    for idx in range(M):
        a, b = map(int, input().split())
        paths[a].append([idx, b])
        paths[b].append([idx, a])

    solve(N, M, paths)

Measured memory_bytes: 157376
import java.util.Scanner;

public class Main {
	static long count = 0;

	public static long merge(int[] A, int left, int mid, int right) {
		int n1 = mid - left;
		int n2 = right - mid;
		int[] L = new int[n1 + 1];
		int[] R = new int[n2 + 1];
		for (int i = 0; i < n1; i++) {
			L[i] = A[left + i];

		}
		for (int i = 0; i < n2; i++) {
			R[i] = A[mid + i];

		}
		L[n1] = 1000000001;
		R[n2] = 1000000001;
		int i = 0;
		int j = 0;
		for (int k = left; k < right; k++) {
			if (L[i] <= R[j]) {
				A[k] = L[i];
				i = i + 1;
			} else {
				A[k] = R[j];
				j = j + 1;
				count += n1 - i;
			}

		}
		return count;

	}

	public static long mergeSort(int[] A, int left, int right) {
		if (left + 1 < right) {
			int mid = (left + right) / 2;
			mergeSort(A, left, mid);
			mergeSort(A, mid, right);
			count = merge(A, left, mid, right);
		}
		return count;
	}

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] numbers = new int[n];
		for (int i = 0; i < n; i++) {
			numbers[i] = scanner.nextInt();
		}
		count = mergeSort(numbers, 0, n);
		System.out.println(count);
		scanner.close();
	}

}


Measured memory_bytes: 101400