akhauriyash/Code-Regression huggingface dataset:
from operator import itemgetter
n = int(input())
a = [input().split() for _ in range(n)]
a = [[i + 1, k, int(v)] for i,(k, v) in enumerate(a)]
# d = {k: v for (k, v) in enumerate(a)}
a.sort(key=itemgetter(2), reverse=True)
# print(a)
a.sort(key=itemgetter(1))

{print(t[0]) for t in a}

Measured memory_bytes: 38384
N, M = map(int,input().split())

TALL = list(range(1,M+1))

for i in range(N):
  A = list(map(int,input().split()))
  del A[0]
  NTALL = []
  for k in TALL:
    if k in A:
      NTALL.append(k)
    else:
      NTALL.append(0)
  TALL = NTALL

TALL = [i for i in TALL if not i==0]
print(len(TALL))

Measured memory_bytes: 3064
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math") 
///#pragma GCC target("avx2")
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <functional>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <climits>
#include <numeric>

using namespace std;
#define open_streams ifstream fin("olympiad.in");ofstream fout("olympiad.out")
#define close_streams fin.close();fout.close()
#define speed cout.tie(0);cin.tie(0);ios_base::sync_with_stdio(0)
#define ll long long
#define ull unsigned long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define UNIQ(a) a.resize(unique(all(a)) - a.begin())
#define eps 1e-6
//const double PI = M_PI;
const int INF = INT_MAX;
const ll limit = 1LL * 4e18;
const int MOD = 1e9 + 711;
const int MOD2 = 1e9 + 933;
//---------------------------------------------------------------------------
const int mod = 1e9 + 7;
const int maxn = 2e5 + 100;





signed main() {
	speed;
	ll x;
	cin >> x;
	ll s = 1000*(x / 500);
	x %= 500;
	cout << s + 5 * (x / 5);
	return 0;
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
ans=""
dx=tx-sx
dy=ty-sy
ans+=("U"*dy+"R"*dx)+("D"*dy+"L"*dx)+("L"+"U"*(dy+1)+"R"*(dx+1)+"D")+("R"+"D"*(dy+1)+"L"*(dx+1)+"U")
print(ans)


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int c[200005],cnt[200005],ans[200005],sub[200005],n;
V<int> v[200005]; 
void get(int p,int fa){
	sub[p]=1;
	for(auto u:v[p])if(u!=fa){
		get(u,p);sub[p]+=sub[u];
	}
}
void dfs(int p,int fa){
	int pre=cnt[c[p]],t=n-sub[p]+1-pre,last=cnt[c[p]],sum=0,add=0;
	V<int> tv;
	for(auto u:v[p])if(u!=fa){
		dfs(u,p);
		ans[c[p]]-=(cnt[c[p]]-pre)*t;
		tv.PB(sub[u]-(cnt[c[p]]-pre));
		pre=cnt[c[p]];
	}
	reverse(ALL(tv));
	sum=sub[p]-1-(cnt[c[p]]-last);
	for(auto u:v[p])if(u!=fa){
		add+=tv.back()*(sum-tv.back());
		tv.pop_back();
	}
	ans[c[p]]=ans[c[p]]+sub[p]*t+add/2;
	cnt[c[p]]=last+sub[p];
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x,y;
	cin>>n;
	FOR(i,1,n)cin>>c[i];
	rep(i,1,n){
		cin>>x>>y;
		v[x].PB(y);v[y].PB(x);
	}
	get(1,-1);
	dfs(1,-1);
	FOR(i,1,n)cout<<ans[i]<<'\n';
	RE 0;
}




Measured memory_bytes: 52040
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n + 1); ++i)
using namespace std;
using ll = long long;
const int INF = +100100100;
// typedef pair<int,int> P;
const int  WHITE = 0;
const int GRAY =1;
const int BLACK =2;
const int NIL = -1;
const int MAX = 100;

// 配列のサイズを大きく取りすぎるとエラーが出ないが、実行できなくなる.
vector<vector<int>> M(MAX,vector<int>(MAX,INF));
vector<int> color(MAX,WHITE), P(MAX,NIL),D(MAX,INF);
int n;

void dijkstra(){
    int u = 0;
    D[u] = 0;
    while(1){
        int mini =INF;
        rep(i,n){
            if(mini>D[i] && color[i]!=BLACK){
                u = i;
                mini = D[i];
            }
        }
        if(mini==INF)break;
        color[u]=BLACK;
        rep(i,n){
            if(color[i]==BLACK)continue;
            if(D[u]+M[u][i]<D[i]){
                D[i] = D[u]+M[u][i];
            }
            color[i]=GRAY;
        }

    }
}

int main(){
    cin >> n;
    rep(i,n){
        int id, m;
        cin >> id>>m;
        rep(j,m){
            int opp;cin>>opp;
            int cost; cin >> cost;
            M[i][opp]=cost;
        }
    }
    dijkstra();
    rep(i,n){
        cout<<i << " " << D[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    int k;
    cin >> s >> k;
    int r = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '1') {
            r = i + 1;
        } else {
            break;
        }
    }
    if (k <= r) {
        cout << "1" << endl;
    } else {
        cout << s[r] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : August 30, 2020 12:02 PM
 *    Problem Name  : B - Greedy Takahashi
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc149/tasks/abc149_b
 *    @genarated by : ai-virtual-assistant
**/

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

int main(){
    ios_base::sync_with_stdio(false);

    ll a,b,k;
    cin >> a >> b >> k;

    ll mini = min(a,k);

    a = a - mini;
    k = k - mini;
    
    b = b - min(b,k);

    cout << a << " " << b << endl;
    return 0 ;
}


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

int main(){
    int n,x,t,cnt=0;
    cin>>n>>x>>t;

    for(int i=1;i<=n;i++){
        cnt++;
        if(n<=x*i){
            break;
        }
    }
    cout<<t*cnt<<endl;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  char a, b;
  cin >> a >> b;
  if(a == b)
    cout << 'H' << endl;
  else
    cout << 'D' << endl;
  return 0;
}



Measured memory_bytes: 256
namespace ABC128.A
{
    using System.Collections.Generic;
    using System.Linq;
    using static System.Console;
    public class Program
    {
        public static void Main(string[] args)
        {
            var l = ReadInputsAsInt().ToList();
            WriteLine(Solve(l[0], l[1], l[2]));
        }

        public static int Solve(int p, int q, int r)
        {
            var a = new List<int> { p, q, r };
            a.Sort();
            return a.Take(2).Sum();
        }
        static IEnumerable<int> ReadInputsAsInt() => ReadLine().Split(' ').Select(x => int.Parse(x));
    }
}

Measured memory_bytes: 13396
import java.util.Scanner;
class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        	for(int i=0;i<n;i++){
                a[i] = sc.nextInt();
            }
       		 for(int j=1;j<=n;j++){
                 System.out.print(a[n-j]);
                 if(j != n){
                 System.out.print(" ");
                 }
             }
        System.out.println();
        sc.close();
    }
}


Measured memory_bytes: 26276
#include "bits/stdc++.h"

/*#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>*/

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

//#define int long long
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct UnionFind
{
	vector<int> parent;
	vector<int> rank;

	UnionFind(int N) :parent(N, 0), rank(N, 0)
	{
		rep(i, 0, N)
		{
			parent[i] = i;
		}
	}

	int find(int x)
	{
		if (parent[x] == x)
		{
			return x;
		}
		else
		{
			return parent[x] = find(parent[x]);
		}
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (x == y)
		{
			return;
		}

		if (rank[x] < rank[y])
		{
			parent[x] = y;
		}
		else
		{
			parent[y] = x;
			if (rank[x] == rank[y])
			{
				rank[x]++;
			}
		}
	}

	bool same(int x, int y)
	{
		return find(x) == find(y);
	}
};

int d[50][50];

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

	while (true)
	{
		int n;
		cin >> n;
		if (n == 0)
		{
			break;
		}
		rep(i, 0, 50)rep(j, 0, 50)if (i != j)d[i][j] = INF;

		int a, b, c;
		int vn = 0;
		rep(i, 0, n)
		{
			cin >> a >> b >> c;
			d[a][b] = c;
			d[b][a] = c;
			chmax(vn, max(a, b) + 1);
		}

		rep(k, 0, vn)rep(i, 0, vn)rep(j, 0, vn)
		{
			if (d[i][k] != INF&&d[k][j] != INF)
			{
				chmin(d[i][j], d[i][k] + d[k][j]);
			}
		}

		int ansi, ansv = INF;
		rep(i, 0, vn)
		{
			int tans = 0;
			rep(j, 0, vn)
			{
				tans += d[i][j];
			}
			if (chmin(ansv, tans))
			{
				ansi = i;
			}
		}
		cout << ansi << " " << ansv << endl;
	}

	return 0;
}


Measured memory_bytes: 3112
#include <stdio.h>
#include <string.h>

int main(void){
	int x,y;
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0&&y==0) break;
		if(x<y){
			printf("%d %d\n",x,y);
		}else{
			printf("%d %d\n",y,x);
		}
	}
	return 0;
}


Measured memory_bytes: 1972
#include <iostream>
#include <cmath>
#include <cfenv>
using namespace std;

int main(){

    float A, B, s;
    int a1, b1, s1;
    int a2, b2, s2;
    cin >> A >> B;

    a1 = ceil(float (A*100/8));
    b1 = ceil(float (B*10));

    s = a1;
    s1 = a1;


    a2 = ceil(float ((A+1)*100/8));
    s2 = a2 - 1;

    for(int i = s1; i <= s2; i++){
        if(i == b1) {
            s = i;
            break;
        }
    }

    if(floor(s/10) != B) s = -1;

    cout << s << endl;


}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    xyz = [list(map(int, input().split())) for _ in range(n)]

    def calc(i, j, k):
        a = []
        for x, y, z in xyz:
            a.append(x*i+y*j+z*k)
        a.sort(reverse=True)
        return sum(a[:m])

    res = 0
    # 基準 0:負 1:正
    for i in range(-1, 2, 2):
        for j in range(-1, 2, 2):
            for k in range(-1, 2, 2):
                res = max(res, calc(i, j, k))
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3692
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
namespace mp = boost::multiprecision;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using llGraph = vector<vl>;
using vb = vector<bool>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

template<typename T>
struct is_vector : false_type{};

template<typename T>
struct is_vector<vector<T>> : true_type{};

template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) {
    return ostr;
  }
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    if (is_vector<T>()) ostr << "\n" << *itr;
    else ostr << ' ' << *itr;
  }
  return ostr;
}

template<typename T>
bool CompareBySecond(pair<T, T> a, pair<T, T> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

template<typename T>
bool CompareBySlope(pair<T, T> a, pair<T, T> b) {
// counterclockwise from 12 o'clock direction
  if (a.first * b.first < 0) {
    return a.first < b.first;
  }
  if (a.first == 0) {
    if (a.second >= 0) {
      return true;
    }
    return a.first < b.first;
  }
  if (b.first == 0) {
    if (b.second >= 0) {
      return false;
    }
    return a.first < b.first;
  }
  return a.second * b.first < a.first * b.second;
}

template<typename T>
T GCD(T a, T b) {
  T c = a % b;
  while (c != 0) { a = b; b = c; c = a % b; }
  return b;
}


/* -------- <templates end> -------- */


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

  vi ans;
  int idx = n;
  while (idx > 0) {
    bool possible = false;
    for (int i=max(0, idx-m); i<idx; ++i) {
      if (s[i] == '1') continue;
      ans.push_back(idx-i);
      idx = i;
      possible = true;
      break;
    }
    if (!possible) {
      cout << -1 << endl;
      return;
    }
  }

  reverse(ALL(ans));
  cout << ans << endl;
}


/* -------- <programs end> -------- */


int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 1096
use std::io::Read;

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

    println!("{}", match x { 3 => "YES", 5 => "YES", 7 => "YES", _ => "NO" });
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1010, mod = 1e9+7;
int h, w;
char a[N][N];
ll memo[N][N];
ll dp(int i, int j){
    if(i == h-1 && j == w-1)
        return 1;
    ll &ret = memo[i][j];
    if(ret != -1)
        return ret;
    ll path1 = 0, path2 = 0;
    if(i+1 < h && a[i+1][j] != '#')
        path1 = dp(i+1, j);
    if(j+1 < w && a[i][j+1] != '#')
        path2 = dp(i, j+1);
    return ret = (path1 + path2) % mod;
}
int main(){
    memset(memo, -1, sizeof memo);
    scanf("%d%d", &h, &w);
    for(int i = 0; i < h; ++i)
        for(int j = 0; j < w; j++)
            cin>>a[i][j];
    printf("%lld", dp(0, 0));
    return 0;
}


Measured memory_bytes: 9344
# -*- coding: utf-8 -*-
import sys
from bisect import bisect_left, bisect_right
N,M,K=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())
B=map(int, sys.stdin.readline().split())
ASUM=[0]
BSUM=[0]
for a in A: ASUM.append(ASUM[-1]+a)
for b in B: BSUM.append(BSUM[-1]+b)

ans=0
for ai in range(N+1):   #Aから何個取るか
    nokori=K-ASUM[ai]
    if 0<=nokori:   #Aを取った結果、Bで取得できるポイントがマイナスになるパターンは成立しない
        ans=max(ans,ai+bisect_right(BSUM,nokori)-1)   #Bから何個取るかは二分探索
print ans

Measured memory_bytes: 131760
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int x[n+1],y[n+1],t[n+1];
  for(int i=0;i<=n;++i){
    if(i==0){
      t[i]=0;
      x[i]=0;
      y[i]=0;
    }else{
      cin>>t[i]>>x[i]>>y[i];
    }
  }
  bool ok=true;
  for(int i=0;i<n;++i){
    bool dist=false;
    bool adj=false;
    int T=t[i+1]-t[i];
    int D=(x[i+1]-x[i])+(y[i+1]-y[i]);
    if(D<=T)dist=true;
    if((T-D)%2==0)adj=true;
    
    if((dist&adj)==false){
      ok=false;
    }
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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 GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
int dx[4] = { 0,  0, 1, -1 };
int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

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

	rep(i, n) {
		int val; cin >> val;
		pairs.push_back({ val, i + 1 });
	}

	sort(ASC(pairs));

	rep(i, n) {
		cout << pairs[i].second << endl;
	}
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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 gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N; cin >> N;
  ll H, W; cin >> H >> W;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  vector<vector<ll>> a(10, vector<ll>(10));
  rep(i, 10) rep(j, 10)  cin >> a[i][j];
  vector<ll> w(H*W);
  rep(i, H*W) cin >> w[i];

  
  ll ans = 0;
  bool chg = false;
  rep(k, 10) rep(i, 10) rep(j,10) {
    if(a[i][k] + a[k][j] < a[i][j]) {
      a[i][j] = a[i][k] + a[k][j];
    }
  }


  rep(i, 10) {
    rep(j, 10) {
      cerr << a[i][j] << " ";
    }
    cerr << "\n";
  }

  rep(i, H*W) {
    if(w[i] >= 0) {
      ans += a[w[i]][1];
    }
  }
  
  cout << ans << endl;

}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3656
// B - Palindrome-philia
#include <bits/stdc++.h>
using namespace std;

int main(){
	string S; cin>>S;
	int ans = 0;
	for(int l=0, r=S.size()-1; l < r; l++, r--) if(S[l] != S[r]) ans++;
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a , b ;
	char op ;
	while( 1 ){
		cin >> a >> op >> b ;
		if ( op  == '?' ) break;
		else if( op == '+' )
		{
			cout << a + b << endl;
		}
		else if ( op == '*' )
		{
			cout << a * b << endl;
		}
		else if ( op == '-' )
		{
			cout << a - b << endl;
		}
		else if ( op == '/' )
		{
			cout << a / b << endl;
		}
	}
}

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

using namespace std;

vector<int> v[100005];
int zero;

bool dfs1(int a,int b,vector<int> &path,int p=-1)
{
    if(a==b) return 1;
    for(int to:v[a])
    {
        if(to==p) continue;
        if(dfs1(to,b,path,a))
        {
            path.push_back(to);
            if(p==-1) path.push_back(a);
            return 1;
        }
    }
    return 0;
}

pair<int,int> dfs2(int a,int p=-1)
{
    pair<int,int> best=make_pair(0,0);
    if(a==zero) return make_pair(0,zero);
    for(int to:v[a])
    {
        if(to==p) continue;
        pair<int,int> d=dfs2(to,a);
        d.first++;
        best=max(best,d);
    }
    if(best.first==0) best.second=a;
    return best;
}

int main()
{
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    for(int i=0;i<n-1;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        v[x].push_back(y);
        v[y].push_back(x);
    }
    vector<int> path;
    dfs1(b,a,path);
    int res=0;
    int ida=0,idb=path.size()-1;
    while(ida<idb-1)
    {
        if(ida+2==idb) break;
        ida++;
        idb--;
        res++;
    }
    zero=path[idb];
    int dest=dfs2(path[ida]).second;
    vector<int> patha,pathb;
    dfs1(dest,path[ida],patha);
    patha.push_back(patha[patha.size()-2]);
    pathb.push_back(zero);
    if(ida+2==idb) pathb.push_back(path[idb-1]);
    for(int to:patha) pathb.push_back(to);
    int one=0,two=0;
    while(patha[one]!=pathb[two])
    {
        one++;
        if(patha[one]==pathb[two]) break;
        two++;
        res++;
    }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 12664
h,w = input().split()
H = int(h)
W = int(w)

list_masu = []

for i in range(H):
	str1 = str(input())
	charlist = list(str1)
	list_masu.append(charlist)

blacklist = []
for n in range(H):
	for m in range(W):
		if(list_masu[n][m]=="#"):
			blacklist.append((n,m))

blacklist.sort()

count = 0

for b in range(0,len(blacklist)):
	for i in range(0,len(blacklist)):
		if(b!=i and blacklist[b][0] == blacklist[i][0]):
			if((blacklist[b][1] == blacklist[i][1]+1) or (blacklist[b][1] == blacklist[i][1]-1)):
				count += 1
				break
		elif(b!=i and blacklist[b][1] == blacklist[i][1]):
			if((blacklist[b][0] == blacklist[i][0]+1) or (blacklist[b][0] == blacklist[i][0]-1)):
				count += 1
				break


if(count==len(blacklist)):
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3188
'''بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ'''
#codeforces
gi = lambda : list(map(int,input().split()))
n, x, t = gi()
cnt = n // x
if n % x:
	cnt += 1
print(cnt * t)

Measured memory_bytes: 9096
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;

ll N, M, ans = 0, MAX = 1, X, sw_count, lamp_count; 
vector<vector<ll>> sw;
vector<ll> p;
vector<int> onoff; //on or off of switches

bool lamp(ll a)
{
	sw_count = 0;
  	for (ll b = 0; b < sw[a].size(); b++) {
    	if (onoff[sw[a][b]] == 1) {
        	sw_count++;
        }
    } 
  	if (sw_count % 2 == p[a]){
    	return true;
    } else {
    	return false;
    }  
}

int main()
{
  //input
  cin >> N >> M;
  sw = vector<vector<ll>>(M, vector<ll>(0));
  p = vector<ll>(M);
  onoff = vector<int>(N);
  for (ll i = 0; i < M; i++) {
  	ll k; cin >> k;
    sw[i] = vector<ll>(k);
    for (ll j = 0; j < k; j++) {
    	cin >> sw[i][j];
      	sw[i][j]--;
    }
  }
  for (ll i = 0; i < M; i++) {
  	cin >> p[i];
  }
  // input is end
  
  for (ll i = 0; i < N; i++) { // MAX = 2^N
  	MAX *= 2;
  }
  for (ll i = 0; i < MAX; i++) {
  	X = i;
    lamp_count = 0;
    for (ll j = 0; j < N; j++) {
    	onoff[j] = X % 2;
      	X /= 2;
    }
    for (ll j = 0; j < M; j++) {
    	if (lamp(j)) {
        	lamp_count++;
        }
    }
    if (lamp_count == M) ans++;
  }
  cout << ans << endl;
}

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

int main() {
  string w;
  cin >> w;
  
  int s_before, s_after;
  string check_w = "abcdefghijklmnopqrstuvwxyz";
  for (int i=0; i<(int)check_w.size(); i++){
    s_before = (int)w.size();
    string::size_type pos = 0;
    while((pos = w.find(check_w.at(i), pos)) != string::npos){
      w.erase(pos, 1);
      if(w.empty()) break;
    } 
    s_after = (int)w.size();

    if ((s_before - s_after) % 2 == 1 ) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int x=0,y=0,z=0;
	1<=x,y,z&&x,y,z<=10000;
	scanf("%d %d %d",&x,&y,&z);
	if(x<=y&&y<=z)
	{
		printf("%d %d %d\n",x,y,z);
	}
	else if(x<=z&&z<=y)
	{
		printf("%d %d %d\n",x,z,y);
	}
	else if(y<=x&&x<=z)
	{
		printf("%d %d %d\n",y,x,z);
	}
	else if(y<=z&&z<=x)
	{
		printf("%d %d %d\n",y,z,x);
	}
	else if(z<=x&&x<=y)
	{
		printf("%d %d %d\n",z,x,y);
	}
	else if(x<=z&&z<=y)
	{
		printf("%d %d %d\n",x,z,y);
	}
	else if(y<=x&&x<=z)
	{
		printf("%d %d %d\n",y,x,z);
	}
	else if(y<=z&&z<=x)
	{
		printf("%d %d %d\n",y,z,x);
	}
	else if(z<=x&&x<=y)
	{
		printf("%d %d %d\n",z,x,y);
	}
	else if(z<=y&&y<=x)
	{
		printf("%d %d %d\n",z,y,x);
	}
	return 0;
}

Measured memory_bytes: 596
import java.util.*;

public class Main {
	
	class DishDiff{
		int time;
		int diff;
		public DishDiff(int time, int diff){
			this.time = time;
			this.diff = diff;
		}
	}
	
	public int earliestFinalDish(int[] dishes){
		
		List<DishDiff> list = new ArrayList<>();
		
		for(int tmp : dishes){
			int diff = tmp % 10 == 0? 0 : (10 - (tmp % 10));
			list.add(new DishDiff(tmp, diff));
		}
		
		Collections.sort(list, new Comparator<DishDiff>() {
			@Override
			public int compare(DishDiff o1, DishDiff o2) {
				return o1.diff - o2.diff;
			}
		});
		
		int ans = 0;
		int len = list.size();
		for(int i = 0; i < len - 1; i++){
			DishDiff tmp = list.get(i);
			ans += tmp.diff + tmp.time;
		}
		
		ans += list.get(len - 1).time;
		
		return ans;
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int[] dishes = new int[5];
		// get values for 5 antennas and val for k
		dishes[0] = sc.nextInt();
		dishes[1] = sc.nextInt();
		dishes[2] = sc.nextInt();
		dishes[3] = sc.nextInt();
		dishes[4] = sc.nextInt();
		
		Main bFiveDishes = new Main();
		
		System.out.println(bFiveDishes.earliestFinalDish(dishes));
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int MOD = 1000000007;

ll gcd(ll a, ll b){
    if (b == 0) return a;
    else return gcd(b, a % b);
}

int main(void){
    int N; cin >> N;
    vector<ll> T(N); for(int i = 0; i < N; i++) cin >> T[i];
    
    ll ans = 1;
    for(int i = 0; i < N; i++){
        ans = T[i] / __gcd(ans, T[i]) * ans;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
N,x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0

for i in range(1,N):
    if a[i-1] + a[i] > x:
        if a[i-1] + a[i] - x > a[i]:
            ans += a[i-1] + a[i] - x
            a[i] = 0
        else:
            ans += a[i-1] + a[i] - x
            a[i] = a[i] - (a[i-1] + a[i] - x)
print(ans)


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

using namespace std;

int A[200005],B[200005];

int main(){
    int t = 1;
    //cin >> t;
    while (t--) {
        int n, m ,ms;
        scanf("%d%d%d", &n, &m, &ms);
 
        for(int A_i = 0; A_i < n; A_i++){
            scanf("%d",&A[A_i]);
        }
        for(int B_i = 0; B_i < m; B_i++){
           scanf("%d",&B[B_i]);
        }

        long long sum = 0;
        int x = 0, y = 0;

        while (x < n && sum + A[x] <= ms) {
            sum += A[x++];
        }

        int ans = x;

        while (y < m && x >= 0) {
            sum += B[y++];
            while (sum > ms && x > 0) {
                sum -= A[--x];
            }

            if (sum <= ms && ans < x + y) {
                ans = x + y;
            }
        }

        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 5368
#include<bits/stdc++.h>
using namespace std;
int main (){
    string S;cin>>S;
    if(S=="SUN")cout<<7<<endl;
    if(S=="MON")cout<<6<<endl;
    if(S=="TUE")cout<<5<<endl;
    if(S=="WED")cout<<4<<endl;
    if(S=="THU")cout<<3<<endl;
    if(S=="FRI")cout<<2<<endl;
    if(S=="SAT")cout<<1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
void solve()
{
    ll N;
    cin>>N;
    map<ll,ll>pcnt;
    ll t=N;
    for(ll p=2;p*p<=t;p++){
        ll a=0;
        while(t%p==0&&t){
            a++;
            t/=p;
        }
        if(a)
        pcnt[p]=a;
    }
    if(t!=1)pcnt[t]=1;
    ll ans=0;
    for(auto p:pcnt){
        ll tmp=sqrt(p.second*2);
        if(tmp*(tmp+1)/2>p.second)tmp--;
        ans+=tmp;
    }
    cout<<ans<<'\n';
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

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

int main(void) {
  int N, T;
  cin >> N >> T;

  int t;
  cin >> t;
  int pre_time = t;
  int ans = 0;
  for (int i = 1; i < N; i++) {
    cin >> t;
    ans += min(t - pre_time, T);
    pre_time = t;
  }
  ans += T;

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,q;
int a[10][10],check[10][10];
int main()
{
    //freopen("main.inp","r",stdin);
    //freopen("main.out","w",stdout);
    n=3;
    for(int i=0; i<n; ++i)
    {
        for(int j=0; j<n; ++j)
            cin>>a[i][j];
    }
    cin>>q;
    while(q--)
    {
        int x;
        cin>>x;
        for(int i=0; i<n; ++i)
            for(int j=0; j<n; ++j)
            {
                if(a[i][j]==x)
                    {
                        check[i][j]=1;
                        break;
                    }
            }
    }
    if(check[0][0]==1 && check[0][0]==check[1][1] && check[1][1]==check[2][2]) {cout<<"Yes"; return 0;}
    else
    if(check[0][2]==1 && check[1][1]==check[0][2] && check[2][0]==check[0][2])
        {cout<<"Yes"; return 0;}
    else
    for(int i=0;i<n;++i)
    {
     if(check[i][0]==1 && check[i][0]==check[i][1] && check[i][1]==check[i][2])
           {
               cout<<"Yes";
               return 0;
           }
    else if (check[0][i]==1 && check[0][i]==check[1][i] && check[1][i]==check[2][i])
            {
                cout<<"Yes";
                return 0;
            }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private static final int PI = 0;

	public static void main(String[] args){
		//????????£????????????????????°?????????????????£?¨?
		Scanner sc = new Scanner(System.in);
		//?????¨????????£?¨?
		double P=Math.PI;
		//????????????????????£?????\???
		double dbR = sc.nextDouble();
		//??¢???
		double dbS =dbR * dbR * P;
		//?????¨?????????
		double dbC =(dbR + dbR) * P;
		 //?¨??????????db????????°??????string???????????????
		 String f1 = String.format("%.6f", dbS);
		 String f2 = String.format("%.6f", dbC);
		//???????????¨???
		System.out.println(f1 + " " + f2);

	}
}

Measured memory_bytes: 28300
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;
int main() {
	cin >> N >> Y;
	int i, j;
	bool flag = 0;
	for (i = 1; i < N + 2; i++) {
		for (j = i + 1; j <= N + 2; j++) {
			ans = 10000 * (i - 1) + 5000 * (j - i-1) + 1000 * (N + 2 - j);
			if (ans == Y) { flag = 1; break; }
		}
		if (flag)break;
	}
	if(flag)cout << i - 1 << " " << j - i-1 << " " << N + 2 - j;
	else cout << -1 << " " << -1 << " " << -1;
}

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

int main() {
  long long n,a,b,c,d,e,mn,ans = 5;
  cin >> n >> a >> b >> c >> d >> e;
  mn = min(a,b);
  mn = min(mn,c);
  mn = min(mn,d);
  mn = min(mn,e);
  ans += n/mn;
  if(n%mn == 0) ans--;
  cout << ans << endl;
}


Measured memory_bytes: 384
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write

root = None
def insert(z):
    global root
    y = None
    x = root
    while x is not None:
        y = x
        if z[2] < x[2]:
            x = x[0]
        else:
            x = x[1]
    z[3] = y

    if y is None:
        root = z
    elif z[2] < y[2]:
        y[0] = z
    else:
        y[1] = z

def find(k):
    x = root
    while x is not None:
        if x[2] == k:
            return 1
        if k < x[2]:
            x = x[0]
        else:
            x = x[1]
    return 0

def debug():
    s0 = [""]
    s1 = [""]

    def dfs(nd):
        v = str(nd[2])
        s0.append(v)
        if nd[0] is not None:
            dfs(nd[0])
        s1.append(v)
        if nd[1] is not None:
            dfs(nd[1])
    dfs(root)
    return " ".join(s1), " ".join(s0)


M = int(readline())
ans = []
for m in range(M):
    cmd, *V, = readline().split()
    if cmd == "print":
        ans.extend(debug())
    elif cmd == "find":
        ans.append("yes" if find(int(V[0])) else "no")
    else:
        insert([None, None, int(V[0]), None])
write("\n".join(ans))
write("\n")



Measured memory_bytes: 108228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 0x3F3F3F3F;
const int maxn = 2e5 + 555;
const int MOD = 1e9 + 7;
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    cout << fixed;
    string a, b;
    cin >> a >> b;
    int ans = 1e9;
    for (int i = 0; i < (int)a.size(); i++) {
        int L = i, R = i + b.size() - 1;
        if (R >= (int)a.size())
            continue;
        int res = 0;
        for (int j = L; j <= R; j++) {
            res += (a[j] != b[j - L]);
        }
        ans = min(ans, res);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
  int A,B,H,M;
  cin >> A >> B >> H >> M;

  //時針と分針のなす角度arg
  long double arg = 2 * M_PI *( (long double)H/12 + (long double)1/12 * (long double)M/60 - (long double)M/60 );
  
  //求める距離X
  long double X = (long double)(A*A + B*B) - (long double)(2*A*B) * ( cosl(arg) );
  X = sqrtl( X );
  
  printf("%20.20Lf\n", X);
  
  return 0;
}

Measured memory_bytes: 4136
#!/usr/bin/env python3

n = int(input())
s = input()

S =[]
for i in s:
    S.append(i)

w = 0
b = 0

for i in range(n):
    if S[i] == "#":
        b += 1
    elif S[i] == ".":
        w += 1

ans = [0 for i in range(n+1)]

ans[0] = w
for i in range(n):
    if S[i] == "#":
        ans[i+1] = ans[i]+1
    elif S[i] == ".":
        ans[i+1] = ans[i]-1
        
print(min(ans))


Measured memory_bytes: 12936
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(ll i=0;i<n;++i)
#define FOR(i,j,n) for(ll i=j;i<n;++i)
#define MOD (10e9 + 7)

int main(void){
    int R;
    cin >> R;
    double pi = 3.14159;
    cout << (2*R*pi) << endl;

}


Measured memory_bytes: 3784
#include <iostream>
#include <string>
#include <vector>

int main(void)
{
  std::string res = "NO";
  int n5 = 0, n7 = 0;
  std::vector<int> sub(3, 0);
  std::cin >> sub[0] >> sub[1] >> sub[2];

  for(int i = 0; i < sub.size(); i++){
    if(sub[i] == 5)
      n5++;
    else if(sub[i] == 7)
      n7++;
    else
      break;
  }

  if(n5 == 2 && n7 == 1)
    res = "YES";

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



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

x = [0 for _ in range(n)]
_x = 0
for i, _a in enumerate(a):
    if i % 2 == 0:
        _x += _a
    else:
        _x -= _a

x[0] = _x

for i in range(1, n):
    x[i] = a[i-1] * 2 - x[i-1]

print(" ".join(map(str, x)))


Measured memory_bytes: 19096
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}

template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){
    vector<pair<T,T>> out(input.size()-1);
    rep(i,input.size()-1){
        out[i].first =input[i  ];
        out[i].second=input[i+1];
    }
    return(out);
}
vector<char> String_to_vector_char(const string& input){
    vector<char> out(input.size());
    rep(i,input.size()){
        out[i]=input[i];
    }
    return out;
}
inline bool operator<(const pii &lhs,const pii &rhs){
    return(lhs.first<rhs.first);
}

int a,b;
void input(){
    cin>>a>>b;
}
void src(){
    cout<<(a>=13 ? b:(a>=6 ? b/2:0));
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char s[101];
int main(void){
    scanf("%s",s);
    int res = 0;
    int n=strlen(s);
    for(int i = 0; i<n; i++){
        if(s[i] != s[n-1-i]) res++;
    }
    printf("%d\n", res/2);
}


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

long convert(long n);

int main(void){
  long n;
  while(true){
    cin>>n;
    if(n==0)break;
    cout<<convert(n)<<endl;
  }
  return 0;
}

long convert(long n){
  long order=1;
  long retval=0;
  while(n>0){
    int mod=n%8;
    if(mod>=5){
      mod+=2;
    }
    else if(mod>=4){
      mod+=1;
    }
    retval+=order*mod;
    n=n/8;
    order=order*10;
  }
  return retval;
}



Measured memory_bytes: 3068
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

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

int main() {
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(s == u) a--;
    else b--;
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

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

//********************************template END****************************************//

void solve(void){

	int N;
	cin >> N;
	int cnt = 0, now = -1, ans = 0;;
	rep(N, i)
	{
		if (cnt == 0)
		{
			cin >> now;
			cnt++;
			continue;
		}

		int t;
		cin >> t;

		if (t == now)
		{
			cnt++;
		}
		else
		{
			now = t;
			ans += cnt / 2;
			cnt = 1;
		}

	}

	ans += cnt / 2;

	cout << ans << endl;

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,h[100009];
int main() {
	cin>>n;
	for(int i=0;i<n;i++) cin>>h[i];
	for(int i=n-2;i>=0;i--) {
		if(h[i]-1>h[i+1]) {
			cout<<"No"<<endl;
			return 0;
		}
		if(h[i]>h[i+1]) h[i]--;
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#define MAX 26
#define NIL -1

struct Node { int p, l, r; };
struct Node T[MAX];


void preParse(int u) {
    if (u == NIL) return;
    printf(" %d", u);
    preParse(T[u].l);
    preParse(T[u].r);
}

void inParse(int u) {
    if (u == NIL) return;
    inParse(T[u].l);
    printf(" %d", u);
    inParse(T[u].r);
}

void postParse(int u) {
    if (u == NIL) return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d", u);
}

int main() {
    int n,v, a, b, i, r;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
	T[i].p = NIL;
	T[i].l = NIL;
	T[i].r = NIL;
    }
    for (i = 0; i < n; i++) {
	scanf("%d %d %d", &v, &a, &b);
	T[v].l = a;
	T[v].r = b;
	if (a != NIL) T[a].p = v;
	if (b != NIL) T[b].p = v;
    }

    for (i = 0; i < n; i++) if (T[i].p == NIL) r = i;
    
    printf("Preorder\n");
    preParse(r);
    printf("\nInorder\n");
    inParse(r);
    printf("\nPostorder\n");
    postParse(r);
    printf("\n");

    return 0;
}

Measured memory_bytes: 616
#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
    int i, H, W;
    char buf[256], *p;
    scanf("%d %d\n", &H, &W);
    for ( i = 0; i < W+2; i++ ){
        printf("#");
    }
    printf("\n");
    for ( i = 0; i < H; i++ ){
        fgets(buf, sizeof(buf), stdin);
        p = strchr(buf, '\n');
        *p = '#';
        printf("#%s\n", buf);
    }
    for ( i = 0; i < W+2; i++ ){
        printf("#");
    }
    printf("\n");
    return 0;
}

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

int main(){
    int S,x,y,z;
    cin>>S;
    x=S/3600;
    y=(S-3600*x)/60;
    z=S-3600*x-60*y;

    cout<<x<<":"<<y<<":"<<z<<endl;
}



Measured memory_bytes: 3084
function Main(input) {
	input = input.trim();
	//input = input.trim().split(" ");
	//input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	input = input.trim().split("\n").map((a)=>Number(a));
  	console.log(Math.min(input[0],input[1]) + Math.min(input[2],input[3]));
}

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


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
const ll MOD = 1e9 + 7;
const ll INF = (ll)1e18;

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  char arr[n];
  int sum=0;
  fi(0,n){
    cin>>arr[i];
    if(i>0&&arr[i]=='E')++sum;
  }
  int min=sum;
  fi(1,n){
    if(arr[i]=='E')--sum;
    if(arr[i-1]=='W')++sum;
    if(sum<min)min=sum;
  }
  cout << min << endl;
  return 0;
}



Measured memory_bytes: 512
//Reconstruction of a tree
//木の再現
//2分木にのみ
//参考：https://onlinejudge.u-aizu.ac.jp/solutions/problem/ALDS1_7_D/review/1911401/emine/C%23
//preとinの差異でどこがinternal nodeかわかる
using System;
using System.Collections.Generic;

namespace tst
{
    class Program
    {
        public static int n = 0;
        public static int[] P;
        public static int[] I;
        public static int pos=0;
        public static void Recon(int left, int right, List<int>A)
        {
            if (left >= right) return;
            int root = P[pos++];
            int m = 0;
            //mはinternal node
            for(int i=0; i<n; i++)
            {
                if (root == I[i]) m= i;
            }
            Recon(left, m, A);
            Recon(m+1, right,A);
            A.Add(root);
        }
        public static void Main()
        {
            n = int.Parse(Console.ReadLine());
            string[] In1 = Console.ReadLine().Split(' ');
            string[] In2 = Console.ReadLine().Split(' ');
            P = new int[n];
            I = new int[n];
            for(int i=0; i<n; i++)
            {
                P[i] = int.Parse(In1[i]);
                I[i] = int.Parse(In2[i]);
            }
            List<int> A = new List<int>();
            Recon(0, n, A);
            Console.Write(A[0]);
            if (A.Count > 1)
            {
                for (int i = 1; i < A.Count; i++)
                {
                    Console.Write(" "+A[i]);
                }
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 17948