akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using namespace std;

vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            if (i * i != n) ret.emplace_back(max(i, n/i));
            else ret.emplace_back(i);
        }
    }
    sort(begin(ret), end(ret));
    return(ret);
}

int main() {
    ll n;
    cin >> n;
    vector<ll> v = divisor(n);
    cout << to_string(v.front()).length() << "\n";
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type city struct {
	idx, y int
	ID     string
}

type cs []city

func (c cs) Len() int {
	return len(c)
}

func (c cs) Swap(i, j int) {
	c[i], c[j] = c[j], c[i]
}

type byYear struct {
	cs
}

type byCiti struct {
	cs
}

func (b byYear) Less(i, j int) bool {
	return b.cs[i].y < b.cs[j].y
}
func (b byCiti) Less(i, j int) bool {
	return b.cs[i].idx < b.cs[j].idx
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	set := make([][]city, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < m; i++ {
		var p, y int
		var t city
		sc.Scan()
		p, _ = strconv.Atoi(sc.Text())
		p-- // 0-indexed
		sc.Scan()
		y, _ = strconv.Atoi(sc.Text())
		t.idx = i
		t.y = y
		if set[p] == nil {
			set[p] = make([]city, 0)
		}
		set[p] = append(set[p], t)
	}
	ca := make([]city, 0)
	for i := 0; i < n; i++ {
		if len(set[i]) > 0 {
			sort.Sort(byYear{set[i]})
			for j := 0; j < len(set[i]); j++ {
				set[i][j].ID = fmt.Sprintf("%06d%06d", i+1, j+1)
				ca = append(ca, set[i][j])
			}
		}
	}
	sort.Sort(byCiti{ca})
	for i := range ca {
		fmt.Println(ca[i].ID)
	}
}


Measured memory_bytes: 25600
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, Q;
  cin >> N >> Q;
  string dna;
  cin >> dna;
  int C = 0;
  vector<int> dp(100000 + 5);
  for (int i = 0; i < N; i++){
    if (dna[i] == 'C' && i - 1 >= 0 && dna[i - 1] == 'A'){
      C++;
    }
    dp[i] = C;
  }
  while(Q--){
    int lo, hi;
    cin >> lo >> hi;
    lo--; hi--;
    cout << dp[hi] - dp[lo] << '\n';
  }
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;


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

	char cur;
	for (int i=0;i<n;i++) {
		cin >> cur;
		if (cur == 'Y') {
			cout << "Four" << endl;
			goto four;
		}
	}
	
	cout << "Three" << endl;

four:;

	return 0;
}


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

int main() {
  int n; cin>>n;
  vector<int> v(2*n);
  for(int i=0;i<2*n;i++) cin>>v[i];
  sort(v.begin(),v.end());
  int ans=0;
  for(int i=1;i<2*n;i+=2) {
    ans+=min(v[i],v[i-1]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 764
import System.IO
import Control.Applicative ((<$>))


main = do
  l1 <- getLine
  let (width:height:num:_) = (\x -> read x :: Int) <$> words l1
  ((xO,xW),(yO,yH)) <- goc num (0, width) (0, height)
  putStrLn $ show $ (max 0 (xW - xO)) * (max 0 (yH - yO))


goc :: Int -> (Int,Int) -> (Int,Int) -> IO ((Int,Int), (Int,Int))
goc 0 xL yL = return (xL, yL)
goc n xL@(xO,xW) yL@(yO,yH) = do
  l <- getLine
  let (x:y:a:_) = (\x -> read x :: Int) <$> words l
  next a x y
  where
    next 1 x _ = goc (n - 1) (max xO x, xW) yL
    next 2 x _ = goc (n - 1) (xO, min xW x) yL
    next 3 _ y = goc (n - 1) xL (max yO y, yH)
    next 4 _ y = goc (n - 1) xL (yO, min yH y)


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main()
{
    ll N;
    cin >> N;
    // i  - 1 をi で割った余りを足していくのが最大
    // 0 + 1 + ... + (N - 1)
    ll ans = (N - 1) * N / 2;

    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

// #define DEBUG

const int INTMAX = 2 * 1e9 + 10;

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, m, s, t, d, p;
    cin >> n >> m;
    ll a[n][n];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i == j)
                a[i][j] = 0;
            else
                a[i][j] = INTMAX;
        }
    }
    for (int i = 0; i < m; i++)
    {
        cin >> s >> t >> d;
        a[s][t] = d;
    }

    for (int k = 0; k < n; k++)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                if (a[i][k] != INTMAX && a[k][j] != INTMAX)
                    a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
            }
        }
    }

    p = 0;
    for (int k = 0; k < n; k++)
    {
        if (a[k][k] < 0)
            p = 1;
    }

    if (p == 0)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                if (a[i][j] == INTMAX)
                    cout << "INF";
                else
                    cout << a[i][j];
                if (j != n - 1)
                    cout << " ";
                else
                    cout << endl;
            }
        }
    }
    else cout << "NEGATIVE CYCLE" << endl;

    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)


Measured memory_bytes: 3176
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

int main(void) {

	lli k, n, ans = 10000000,bef_a,first_a;
	cin >> k >> n;

	cin >> bef_a;

	first_a = bef_a;

	for (lli i = 0; i < n - 1; i++) {
		lli a;
		cin >> a;
		
		ans = min(ans, k - abs(a - bef_a));

		bef_a = a;
	}


	ans = min(ans, k - ((first_a + k) - bef_a));

	cout << ans << endl;


	return 0;
}

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

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

  vector<vector<char>> ans(H + 2, vector<char>(W + 2, '#'));
  rep(i, H) rep(j, W) {
    cin >> ans[i + 1][j + 1];
  }

  rep(i, H + 2) {
    rep(j, W + 2) {
      cout << ans[i][j];
    }
    cout << endl;
  }
}

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

using namespace std;

int main()
{
  string temp,mainstr;
  
  while(getline(cin,mainstr)){
    temp = mainstr;
    vector<string> str;
    int i,j,k,judge=0,gosuu=0;
    
    //入力を単語ごとに分割
    i=0;
    while(1){
      int index;
      index = temp.rfind(" ");
      
      if (index==-1){
	str.push_back(temp.substr(index+1));
	temp = temp.substr(0,temp.size()-str[i].size()-1);
	gosuu++;
	break;
      }else{
	str.push_back(temp.substr(index+1));
	temp = temp.substr(0,temp.size()-str[i].size()-1);
	gosuu++;
	i++;
      } 
    }
    
    //単語からピリオドを取り除く
    for(i=0;i<gosuu;i++){
      if (str[i].find(".")!=-1)
	str[i] = str[i].substr(0,str[i].size()-1);
    }
    
    //単語を変換してチェックしていく
    for(i=0;i<gosuu;i++){
      for(k=1;k<26;k++){
	
	//単語を1個ずらしたものに変換
	for(j=0;j<str[i].size();j++){
	  if (str[i][j] == 'z')
	    str[i][j] = 'a';
	  else
	    str[i][j] += 1;
	}
	
	if ((str[i]=="this")||(str[i]=="that")||(str[i]=="the")){
	  judge = 1;
	  break;
	}
	
      }
      if (judge==1) break;
    }
    
    //文章の変換
    
    for(j=0;j<k;j++){
      for(i=0;i<mainstr.size();i++){
	if ((mainstr[i]!=' ')&&(mainstr[i]!='.')){
	  if (mainstr[i] == 'z')
	    mainstr[i] = 'a';
	  else
	    mainstr[i] += 1;
	}
      }
    }
    //変換した文字の出力
    cout << mainstr <<endl;
    
    /*
    for(i=0;i<str.size();i++){
      cout << str[i] <<endl;
    }*/
    
  }

  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;
typedef long long int ll;
int p[100005];

int main()
{
    int n,i;
    int temp;
    int cnt;

    while(scanf("%d",&n) != EOF)
    {
        for(i = 0;i < n;i++)
        {
            scanf("%d",&p[i]);
        }
        cnt = 0;
        for(i = 0;i < n;i++)
        {
            if(p[i] == i+1)
            {
                cnt++;
                if(i == 0)
                {
                    temp = p[i];
                    p[i] = p[i+1];
                    p[i+1] = temp;
                }
                else
                {
                    if(p[i+1] > p[i])
                    {
                        temp = p[i];
                        p[i] = p[i+1];
                        p[i+1] = temp;
                    }
                    else
                    {
                        temp = p[i];
                        p[i] = p[i-1];
                        p[i-1] = temp;
                    }
                }
            }
        }
        printf("%d\n",cnt);
    }

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

	vector<int> A;
	inputVector(A, N);

	bool flag = true;
	int cnt = 1;
	rep(i, N) {
		if (A[i] % 2 == 0) {
			cnt *= 2;
		}
	}

	int ret = 1;
	rep(i, N) ret *= 3;

	cout << ret - cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

bool solve() {
    int a[3][3];
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    bool c[3][3] = {};
    while (n--) {
        int b;
        cin >> b;
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                c[i][j] |= a[i][j] == b;
            }
        }
    }

    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cerr << (c[i][j] ? 'o' : 'x');
        }
        cerr << endl;
    }

    for (int i = 0; i < 3; ++i) {
        bool f = true;
        for (int j = 0; j < 3; ++j) f = f && c[i][j];
        if (f) return true;
    }
    
    for (int j = 0; j < 3; ++j) {
        bool f = true;
        for (int i = 0; i < 3; ++i) f = f && c[i][j];
        if (f) return true;
    }

    bool f = true;
    for (int i = 0; i < 3; ++i) {
        int j = i;
        f = f && c[i][j];
    }
    if (f) return true;

    f = true;
    for (int i = 0; i < 3; ++i) {
        int j = 2 - i;
        f = f && c[i][j];
    }
    if (f) return true;

    return false;
}

int main() {
    int t = 1;
    // cin >> t;
    while (t--) cout << (solve() ? "Yes" : "No") << endl;
    return 0;
}

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

import math

def solver(visited, coord, depth = 0):
  dists = []

  if len(visited) == depth:
    for i in range(1, len(visited)):
      x1, y1 = coord[visited[i - 1]][0], coord[visited[i - 1]][1]
      x2, y2 = coord[visited[i]][0], coord[visited[i]][1]
      dists.append(math.sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)))
    return sum(dists)

  for i in range(0, len(visited)):
    if visited[i] != -1: continue
    visited[i] = depth
    dists.append(solver(visited, coord, depth + 1))
    visited[i] = -1;

  return sum(dists)

def main():
  n = int(input())
  coord = []
  for i in range(0, n):
    coord.append([int(c) for c in input().split()])

  print(solver([-1 for i in range(0, n)], coord) / math.factorial(n))

if __name__ == "__main__":
  main()



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

using namespace std;

namespace {
    int H, W;
    vector<string> F;
    void input() {
        cin >> H >> W;
        F.clear(); F.resize(H);
        for (int i = 0; i < H; i++) cin >> F[i];
    }

    struct Point {
        int y, x;
        Point(int y = 0, int x = 0) : y(y), x(x) {}
        bool operator<(const Point& p) const {
            if (x == p.x) return y < p.y;
            return x < p.x;
        }
    };
    ostream& operator<<(ostream& os, const Point& p) {
        return os << "Point(" << p.y << " " << p.x << ")";
    }

    const string s = "URDL";
    const int dy[] = {-1, 0, 1, 0},
              dx[] = {0, 1, 0, -1};

    int N;
    map<int, Point> M;
    map<Point, int> R;
    int sindex;
    void init() {
        M.clear();
        R.clear();
        int c = 0;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (F[i][j] == 'o') {
                    M[c] = Point(i, j);
                    R[Point(i, j)] = c;
                    c++;
                } else if (s.find(F[i][j]) != string::npos) {
                    sindex = c;
                    M[c] = Point(i, j);
                    R[Point(i, j)] = c;
                    c++;
                }
            }
        }
        N = c;
    }

    ostream& operator<<(ostream& os, const vector<char>& s) {
        for (int i = 0; i < s.size(); i++) {
            os << s[i];
        }
        return os;
    }

    void dfs(int index, int dir, int used, vector<char>& path) {
        if (used == (1 << N) - 1) {
            for (int i = 0; i < path.size(); i++) {
                cout << path[i];
            }
            cout << endl;
            return;
        }
        int cy = M[index].y, cx = M[index].x;
        for (int i = 0; i < 4; i++) {
            if (i == (dir + 2) % 4) continue;
            int ny = cy,
                nx = cx;
            int vy = dy[i],
                vx = dx[i];
            while (true) {
                if (ny < 0 || ny >= H) break;
                if (nx < 0 || nx >= W) break;
                Point p(ny, nx);
                if (F[ny][nx] == 'o' && (not (used & (1 << R[p])))) {
                    int nindex = R[p];
                    path.push_back(s[i]);
                    dfs(nindex, i, used | (1 << nindex), path);
                    path.pop_back();
                    break;
                }
                ny += vy;
                nx += vx;
            }
        }
    }

    void solve() {
        init();
        vector<char> path;
        dfs(sindex, s.find(F[ M[sindex].y ][ M[sindex].x ]), 1 << sindex, path);
    }
}

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

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

int main(){
  int n;
  cin >> n;
  vector<int> v(n,0);
  r(i,n)cin >> v.at(i);
  vector<int> v2(n,0);
  v2=v;
  int a,m,time,count=0;
  cin >> m;
  while(m--){
    cin >> a >> time;
    v2.at(a-1)=time;
    r(i,n)count+=v2.at(i);
    cout << count << endl;
    count = 0;
    v2 = v;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define Coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 nn, tmp, ans = 1000000000;
	cin >> nn;
	vector<int64> aa(nn);
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> aa[ii];
	}
	for(int64 ii = -100;ii <= 100;ii++)
	{
		tmp = 0;
		for(int64 jj = 0;jj < nn;jj++)
		{
			tmp += (ii - aa[jj]) * (ii - aa[jj]);
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i++)

#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#include <cassert>
#include<stack>
#include<deque>
#include<list>
#include<sstream>
#include<unordered_map>
#include<time.h>
#pragma comment(linker, "/STACK:880999999")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef pair<pll, ll> ppll;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const ll settled = 400007;

int main()
{
	ios_base::sync_with_stdio(false); cout.tie(NULL);
#ifndef overlord
	//freopen("qual.in", "r", stdin);
	//freopen("qual.out", "w", stdout);
#else
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	vector<ll> a;
	forn(i, 0, 4)
	{
		a.push_back(0);
		cin >> a.back();
	}
	sort(a.begin(), a.end());
	ll co = 0;
	co += a[0] * 1000 + a[1] + a[2] * 10 + a[3] * 100;
	if (co == 1974)
		cout << "YES";
	else
		cout << "NO";
	return 0;
}

Measured memory_bytes: 256
nums = list(map(int, input().split()))

ans = 0
while True:
    # 終了条件
    if any(map(lambda x:x%2, nums)):
        break
    # 無限にできる
    if nums[0] == nums[1] == nums[2]:
        ans = -1
        break
    s = sum(nums)
    nums = [(s-i)/2 for i in nums]
    ans += 1
print(ans)

Measured memory_bytes: 3060
n=int(input())
s=list(input())
l=[[0,s.count('.')]]
for i in range(n):
    if s[i]=='.':
        l.append([l[-1][0],l[-1][1]-1])
    else:
        l.append([l[-1][0]+1,l[-1][1]])

ans=10**10
for i in range(n+1):
    ans=min(ans,sum(l[i]))

print(ans)

Measured memory_bytes: 31396
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc098_a.cpp
 * time   : Thu Apr 30 18:54:45 2020
 * quest  : A - Add Sub Mul
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << max(a + b, max(a - b, a * b)) << "\n";
  return 0;
}

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

// Contest: AtCoder Beginner Contest 152 (https://atcoder.jp/contests/abc152)
// Problem: F: Tree and Constraints (https://atcoder.jp/contests/abc152/tasks/abc152_f)

using namespace std;

#define sz(x)       ((int)(x).size())
#define rep(a, b)   for(int a = 0; a < (b); ++a)
#define all(a)      (a).begin(),(a).end()
#define trav(a, b)  for(auto& a : b)

template <class T, size_t... Is> struct arr_helper;
template <class T, size_t... Is> using arr = typename arr_helper<T, Is...>::type;
template <class T> struct arr_helper<T> { using type = T; };
template <class T, size_t I, size_t... Is>
struct arr_helper<T, I, Is...> { using type = array<arr<T, Is...>, I>; };

using ll = long long;
using u64 = uint64_t;
using u32 = uint32_t;

using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pi>;

const int INF = (int)1e9;
const ll INFL = (ll)1e18;

int n;
vector<bitset<49>> edges;
ll res = 0;

void branch_bound(bitset<49> cand, vi& ei) {
    if (!sz(ei)) {
        res += (ll)1 << (ll)cand.count();
        return;
    }
    if (!cand.any())
        return;

    int idx = -1, inter = INF;
    trav(i, ei) {
        auto s = (cand & edges[i]).count();
        if (s < inter)
            inter = (int)s, idx = i;
    }
    rep(i, n - 1) {
        if (!edges[idx][i] || !cand[i])
            continue;
        vi ei_new;
        trav(j, ei)
            if (!edges[j][i])
                ei_new.push_back(j);
        cand[i] = false;
        branch_bound(cand, ei_new);
    }
}

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

    cin >> n;
    vvi adj(n);
    map<pair<int, int>, int> edgeindices;
    rep(i, n-1) {
        int a, b; cin >> a >> b; --a, --b;
        adj[a].push_back(b), adj[b].push_back(a);
        edgeindices[{a, b}] = edgeindices[{b, a}] = i;
    }

    int m; cin >> m;
    edges.resize(m);
    queue<int> q;
    vi prev(n);
    rep(i, m) {
        int a, b; cin >> a >> b; a--, b--;
        prev.assign(n, -1);
        q.push(a);
        while (sz(q)) {
            int v = q.front(); q.pop();
            for (auto v2 : adj[v])
                if (prev[v2] == -1)
                    prev[v2] = v, q.push(v2);
        }
        int v = b;
        while (v != a)
            edges[i][edgeindices[{v, prev[v]}]] = true, v = prev[v];
    }

    vi ei(m);
    iota(all(ei), 0);
    bitset<49> cand{};
    rep(i, n - 1) cand[i] = true;
    branch_bound(cand, ei);
    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){    

int a,b,c;    

scanf("%d %d %d",&a,&b,&c);    

if(a<b && b<c){   

printf("%d %d %d\n",a,b,c);  

}    

else if(b<c && c<a){   

printf("%d %d %d\n",b,c,a);  

}    

else if(c<a && a<b){   

printf("%d %d %d\n",c,a,b);  

}    

else if(a<c && c<b){   

printf("%d %d %d\n",a,c,b);

}    

else if(b<a && a<c){   

printf("%d %d %d\n",b,a,c);  

}    

else if(c<b && b<a){   

printf("%d %d %d\n",c,b,a);  

}    

else if(a==b && b<c){   

printf("%d %d %d\n",a,b,c);  

}    

else if(b==c && c<a){   

printf("%d %d %d\n",b,c,a);  

}    

else if(c==a && a<b){  

printf("%d %d %d\n",c,a,b);  

}    

else if(a==c && c<b){   

printf("%d %d %d\n",a,c,b);  

}    

else if(b==a && a<c){   

printf("%d %d %d\n",b,a,c);  

}    

else if(c==b && b<a){   

printf("%d %d %d\n",c,b,a);  

}

return 0;

}        
 

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int solve(){
    int n; cin>>n;
    int a[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    int pre[n],post[n];
    pre[0]=a[0]; post[n-1]=a[n-1];
    for (int i = 1; i < n; ++i)
    {
        pre[i]=a[i];
        pre[i]^=pre[i-1];
    }
    for(int i=n-2; i>=0; i--){
        post[i]=a[i];
        post[i]^=post[i+1];
    }
    cout<<post[1]<<" ";
    for(int i=1; i<n-1; i++){
        int t=pre[i-1]^post[i+1];
        cout<<t<<" ";
    }
    cout<<pre[n-2];
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 8304
T = 'keyence'
S = input()

s = 0
t = 0
while t < len(T) and s < len(S):
    if T[t] != S[s]:
        if T[t:] == S[-(len(T) - t):]:
            print('YES')
            exit()
        else:
            print('NO')
            exit()
        break
    t += 1
    s += 1

print('YES')


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

void solve(int n){
    //cout<<n<<endl;
    int ans=0;
    for(int i=2;i<n;i++){
        if(i%2 && n%i==0 && n/i-(i/2)>0){
            ans++;
        }
        else if((!(i%2)) && (double)n/i-0.5==(double)(n/i) && (double)(n/i)-i/2 >=0){
            ans++;
        }
        
    }
    cout<<ans<<endl;

}


int main(void){
    int n;
    while(cin>>n,n){
        solve(n);
    }
    
}

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

int main() {
double A, B, H, M;


cin >> A >> B >> H >> M;
double kaku =  (M_PI * abs(H * 30.0 - 6.0 * M + (M / 60.0)* 30.0)) / 180.0;

double x = A * A + B * B - 2 * A * B * cos(kaku);

cout << fixed << setprecision(15) << sqrt(x);
  return 0;
}

Measured memory_bytes: 4192
#include<iostream>
#include<cstdio>
#include<cstring>

typedef long long ll;
const int N=301000;

int x[N],t[N];
int n,L;

bool f[N],g[N];
int ans;

int main()
{
	scanf("%d%d",&n,&L);
	for(int i=1;i<=n;i++)scanf("%d",x+i);
	for(int i=1;i<=n;i++)scanf("%d",t+i);

	ans=1;
	for(int i=1;i<=n;i++)ans+=t[i]/(L*2),t[i]%=L*2;
	for(int i=1;i<=n;i++)
		if(t[i]!=0)ans++,f[i]=(L-x[i])*2>=t[i],g[i]=x[i]*2>=t[i];
		else f[i]=g[i]=0;

	int cnt=0,dcnt=0;
	for(int i=1;i<n;i++)
	{
		if(f[i])
		{
			if(cnt>0)
			{
				if(g[i])dcnt++;
				cnt--,ans--;
			}
			else if(dcnt>0 && !g[i])dcnt--,cnt++;
			else if(g[i])cnt++;
		}
		else if(g[i])cnt++;
	}

	if(f[n])ans--;
	printf("%lld\n",(ll)ans*L*2);

	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

int problem[100010];
bool p[100010];

void solve(){

  int n,m;
  cin >> n >> m;

  rep(i,n){
      problem[i]=0;
      p[i]=false;
  }

  rep(i,m){
      int no;
      cin >> no;
      no--;
      string st;
      cin >> st;
      if(!p[no]){
          if(st=="WA"){
              problem[no]++;
          }
          else{
              p[no]=true;
          }
      }
  }

  int ans1=0;
  int ans2=0;

  rep(i,n){
      ans1 += p[i];
      if(p[i]) ans2 += problem[i];
      //cout << p[i] << " " << problem[i] << endl;
  }

  cout << ans1 << " " << ans2 << endl;

}

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


Measured memory_bytes: 896
#include<stdio.h>


int main()
{
    int N,A,B;
    scanf("%d%d%d",&N,&A,&B);
    if(A>B||(N==1&&A!=B))
    {
        printf("0\n");
        return 0;
    }
    long long ans =  (long long)(N-2)*(B-A)+1;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128
import scala.io.StdIn._
object Main extends App {
  val Array(n, l) = readLine.split(" ").map(_.toInt)
  println((
    if (l >= 0) (l + 1 to l + n - 1)
    else if (-l < n) (l to l + n - 1)
    else (l to l + n - 2)
  ).sum)
}

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

int main(){
  int N,M,X;
  cin >> N >> M >> X;
  vector<int> A(N+1,0);
  for (int i = 0; i < M; i++){
    int a;
    cin>>a;
    A[a]++;
  }

  int L=0,R=0;
  for (int i = 0; i < X; i++)L += A[i];
  for (int i = X; i < N; i++)R += A[i];
  cout << min(L,R) << endl;
  
}


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

int main() {
	int n;
    cin >> n;
    int p[n];
    int count = 0;
    for(int i=0;i<n;i++){
         cin >> p[i];
    }

    for(int i=0;i<n-2;i++){
       if((p[i]-p[i+1])*(p[i+1]-p[i+2])>0){
           count++;
        }
    }
    cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<queue>
#include<cmath>
#include<cstdio>

#define rep(i,n) for(int i=0; i<(n); ++i)
#define pai 3.1415926535897932384

using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(int argc, const char * argv[]) {
    
    int N, X, T;
    cin >> N >> X >> T;
    
    int A = N / X;
    int B = N % X;
    if(B > 0) A++;
    
    cout << A * T << endl;
    
    return 0;
}

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

int main() {
    string s,t;
    cin >> s;
    cin >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(), t.end());
    if (s < t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>

//最大公約数
ll gcd(ll a,ll b){
    if(b == 0LL) return a;
    return gcd(b , a % b);
}

//最小公倍数
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;

}

//前後を比較
bool compare(int pos,vector<int>& a){
    if(a[pos] == a[pos + 1]) return true;
    else return false;
}

int main(){

    //
    int N,M,Q;
    cin >> N >> M >> Q;

    vector<int> L(M),R(M);//都市
    vector<int> p(Q),q(Q);

    for(int i=0;i < M;i++) cin >> L[i] >> R[i];
    for(int i = 0;i < Q;i++) cin >> p[i] >> q[i];

    vector<vector<int>> sum(N + 1,vector<int>(N+1,0));

    //各マス目の都市の数を数える
    for(int i=0;i < M;i++){
        sum[L[i]][R[i]]++;
    }

    //二次元累積和 区域がNと決まっているので二次元累積和を使うことができる
    for(int i = 0;i < N;i++){
        for(int j=0;j < N;j++){

            sum[i + 1][j + 1] += sum[i][j + 1];
            sum[i + 1][j + 1] += sum[i + 1][j];
            sum[i + 1][j + 1] -= sum[i][j];


        }

    }


    //クエリ（クエリで指定された範囲内の都市の数の部分和をとる問題と考える）

    for(int i = 0;i < Q;i++){
        cout << sum[q[i]][q[i]] - sum[p[i] - 1][q[i]] - sum[q[i]][p[i]-1] + sum[p[i] -1][p[i] -1] << endl;


    }

    




    //
    

}

Measured memory_bytes: 4224
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;


public class Main {

    static void solve() {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int x = scan.nextInt();
        int y = scan.nextInt();
        int[] arr = new int[n];
        for (int i=1;i<n;i++) {
            for (int j=i+1;j<=n;j++) {
                int min = j-i;
                int s = Math.abs(i-x) + 1 + Math.abs(y-j);
                min = Math.min(min,s);
                arr[min]++;
            }
        }
        for (int i=1;i<n;i++) {
            System.out.println(arr[i]);
        }
    }


    public static void main(String[] args) {

        solve();

        //        Main m = new Main();
        //        Scanner scan = new Scanner(System.in);

        //        long n = scan.nextLong();
        //        long r = scan.nextLong();
        //        List<Long> list = new ArrayList<>();
        ////        int[] arr = new int[n];
        //        for (long i=0;i<n;i++){
        //            list.add(scan.nextLong());
        //        }
//            System.out.println(ch);
        //        solve(n, arr);
        //        scan.close();
    }


    class Counter extends HashMap<Integer, Integer> {
        public int get(int k) {
            return containsKey(k) ? super.get(k) : 0;
        }

        public void add(int k, int v) {
            put(k, get(k) + v);
        }
    }



    static class Node {
        int val;
        Node next;
        Node random;

        public Node(int val) {
            this.val = val;
            this.next = null;
            this.random = null;
        }
    }

//    static class Node {
//        int key;
//        int data;
//        Node next;
//        Node prev;
//
//        Node(int key, int data) {
//            this.key = key;
//            this.data = data;
//        }
//    }

    static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

    static class Trie {
        void add(String word) {

        }

        boolean search(String w) {
            return false;
        }
    }

    static class Node1 {
        public int val;
        public List<Node1> children;

        public Node1() {
        }

        public Node1(int _val, List<Node1> _children) {
            val = _val;
            children = _children;
        }
    }

    ;

    static class TrieNode {

    }

    static class KvNode implements Comparable<KvNode> {
        String key;
        int freq;

        public KvNode(String key, int freq) {
            this.key = key;
            this.freq = freq;
        }

        @Override
        public int compareTo(KvNode o) {
            if (this.key.equals(o.key)) {
                return 0;
            }
            return Integer.compare(o.freq, this.freq);
        }
    }

    static class ListNode {
        int val;
        ListNode next;

        ListNode(int x) {
            val = x;
        }
    }
}


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

#define rep(i, n) for(int i = 0, i_length = (n); i < i_length; i++)
#define MOD 1000000007

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	int ans = 0;
	rep(i, n) if (h[i] >= k) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
from copy import copy
import random
import math
import sys
input = sys.stdin.readline
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(D)]
last = [0]*26
ans = [0]*D
score = 0
for i in range(D):
    ps = [0]*26
    for j in range(26):
        pl = copy(last)
        pl[j] = i+1
        ps[j] += s[i][j]
        for k in range(26):
            ps[j] -= c[k]*(i+1-pl[k])
    idx = ps.index(max(ps))
    last[idx] = i+1
    ans[i] = idx+1
    score += max(ps)
for k in range(1,41001):
    na = copy(ans)
    x = random.randint(1,365)
    y = random.randint(1,365)
    na[x-1] = na[y-1]
    last = [0]*26
    ns = 0
    for i in range(D):
        last[na[i]-1] = i+1
        ns += s[i][na[i]-1]
        for j in range(26):
            ns -= c[j]*(i+1-last[j])
    if k%300 == 1:
        T = 300-(298*k/41000)
    p = pow(math.e,-abs(ns-score)/T)
    if ns > score or random.random() < p:
        ans = na
        score = ns
for a in ans:
    print(a)

Measured memory_bytes: 88208
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
ll mod1=1000000007ll;
ll mod2=998244353ll;

bool vis[200002];
ll ma[200002],bit[200005],rank1[200005],parent[200005];
ll c=0,x=0,n,an=0;
ll gcd(ll a, ll b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
ll power(ll x,ll y)
{   if(y==0) return 1;
    ll p=power(x,y/2);
    p=(p*p)%mod2;
    if(y%2) return  (p*x)%mod2;
    return p;
}
ll sum(ll in)
{   in++;
    ll sum1=0;
    while(in>0)
    {
        sum1+=bit[in];
        in-=in & (-in);
    }
    return sum1;
}
void update(ll in,ll val)
{   in++;
    while(in<=200002)
    {
        bit[in]+=val;
        in+=in & (-in);
    }
}
 struct vec {
    vector<ll> v;
    bool operator<( const  vec& a) const
    { return a.v[0] < v[0]; }
  };

ll find(ll x)
{
    if(x==parent[x])
    return x;
    else
    return find(parent[x]);
}
void merged(ll x, ll y)
{
    x=find(x);
    y=find(y);
    if(rank1[x]>rank1[y])
    {
        parent[y]=x;
        rank1[x]+=rank1[y];
    }
    else
    {
        parent[x]=y;
        rank1[y]+=rank1[x];
    }

}
void solve()
{
   ll n;
   cin>>n;
   cout<<(n*(n-1))/2<<endl;
}

int main()
{
 /*ios::sync_with_stdio(0);
 cin.tie(0);
 cout.tie(0);*/
 int t=1;
 //cin>>t;
 while(t--)
    solve();
 return 0;
}


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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int AB, BC, CA;
    cin >> AB >> BC >> CA;
    cout << AB * BC / 2;
}

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

int main()
{
int x1,x2,x3,x4,x5;
cin>>x1>>x2>>x3>>x4>>x5;    

  if( x1==0){
cout << 1 <<endl;
}
 else if( x2==0){
cout << 2  <<endl;
}
 else if( x3==0) {
cout << 3 <<endl;
}
 else if( x4==0){
cout << 4 <<endl;
}
  else if( x5==0){
cout << 5 <<endl;
}
}


Measured memory_bytes: 3596
package main

import "fmt"

func main() {
	var n, m, q int
	fmt.Scan(&n, &m, &q)

	c := make([][]int, n)
	var l, r int
	for i := 0; i < m; i++ {
		fmt.Scan(&l, &r)
		if c[l-1] == nil {
			c[l-1] = make([]int, n)
		}
		c[l-1][r-1]++
	}

	s := make([][]int, n)
	for i := 0; i < n; i++ {
		if c[i] == nil {
			continue
		}
		s[i] = make([]int, n+1)
		s[i][0] = 0
		for j := 0; j < n; j++ {
			s[i][j+1] = s[i][j] + c[i][j]
		}
	}

	var x int
	for i := 0; i < q; i++ {
		x = 0
		fmt.Scan(&l, &r)
		for j := l - 1; j < r; j++ {
			if s[j] == nil {
				continue
			}
			x += s[j][r] - s[j][l-1]
		}
		fmt.Println(x)
	}
}

Measured memory_bytes: 8576
(defun inc (x)
  (1+ x))

(defun solve(n m a b)
    (dotimes (i n)
      (format t "~A~%" (+ (count (1+ i) a) (count (1+ i) b))))) 

(defun main ()
  (let* ((n (read))
         (m (read))
         (a (make-array m))
         (b (make-array m)))
    (progn
      (dotimes (i m)
        (setf (aref a i) (read))
        (setf (aref b i) (read)))
      (solve n m a b))))

(main)


Measured memory_bytes: 24372
//Waqt Ha Badal Jayega//

#include <bits/stdc++.h>
#include <stdint.h>
#define mod 1000000007
#define ull unsigned ll
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pi 3.1415926535897932
using namespace std;
/*-------------------------------------------------------------*/

//for (a*b)%mod

uint64_t mulmod(uint64_t a, uint64_t b, uint64_t m)
{
	long double x;
	uint64_t c;
	int64_t r;
	if (a >= m) a %= m;
	if (b >= m) b %= m;
	x = a;
	c = x * b / m;
	r = (int64_t)(a * b - c * m) % (int64_t)m;
	return r < 0 ? r + m : r;
}

/*-------------------------------------------------------------*/
ull binpowmod(ull a, ull b, ull m)
{
	ull res = 1;
	while (b > 0)
	{
		if (b & 1)
		{
			res = ((res % m) * (a % m)) % m;
		}
		a = ((a % m) * (a % m)) % m;
		b >>= 1;
	}
	return res;
}
/*-------------------------------------------------------------*/

ll countsetbits(ll n)
{
	ll count = 0;
	while (n > 0)
	{
		n = n & (n - 1);
		count++;
	}
	return count;
}

/*-------------------------------------------------------------*/
ll binpow(ll a, ll b)
{
	ll res = 1;
	while (b > 0)
	{
		if (b & 1)
		{
			res *= a;
		}
		a *= a;
		b >>= 1;
	}
	return res;
}



/*-------------------------------------------------------------*/
ll binarysearch(ll l, ll r, ll a[], ll x)
{
	while (l <= r)
	{
		ll mid = l + ((r - l) / 2);

		if (a[mid] == x )
		{
			return mid ;
		}
		if (a[mid] < x)
		{
			l = mid + 1;
		}
		else
		{
			r = mid - 1;
		}
	}
	return -1;
}
/*--------------------------------------------------------------*/
//Adjacency list

/*vector<ll>adj[100005];

ll vis[100005];  //how many i-th node have been visited
void dfs(ll node)
{
	vis[node] = 1;
	for (ll child : adj[node])
	{
		if (!vis[child])
		{
			dfs(child);
		}
	}
}

*/
/*--------------------------------------------------------------*/
/* Upper bound of x gives numbers less than or equal to x */
ll countdig(ll n)
{
	ll count = 0;
	while (n > 0)
	{
		n /= 10;
		count++;
	}
	return count;
}

// Bad day ! Luck matters > Stop Judging



/*-------------------------------------------------------------*/
int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	ll n;
	cin >> n;
	int p = n % 10;
	if (p == 2 || p == 4 || p == 5 || p == 7 || p == 9)
	{
		cout << "hon\n";
	}
	else if (p == 0 || p == 1 || p == 6 || p == 8)
	{
		cout << "pon\n";
	}
	else
	{
		cout << "bon\n";
	}

	return 0;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

int main()
{
  int N;
  cin >> N;
  vector<long long> A(N);
  rep(i, N)
  {
    cin >> A[i];
  }
  RSORT(A);
  if (N == 2)
  {
    cout << A[0] << endl;
    return 0;
  }
  priority_queue<pair<long long, pair<long long, long long>>> a;
  a.push(make_pair(A[1], make_pair(A[1], A[0])));
  a.push(make_pair(A[1], make_pair(A[1], A[0])));

  long long ans = A[0];
  rep(i, N - 2)
  {
    long long one = min(a.top().second.first, a.top().second.second);
    long long two = max(a.top().second.first, a.top().second.second);
    long long score = min(one, two);
    a.pop();
    ans += score;
    a.push(make_pair(A[i + 2], make_pair(one, A[i + 2])));
    a.push(make_pair(A[i + 2], make_pair(two, A[i + 2])));
  }
  cout << ans << endl;
  return 0;
}

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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;
//const int MOD = (int) 1e9 + 7;
const int MOD = (int) 998244353;
const int maxn = (int) 3e5 + 20;
const int maxm = (int) 1e6 + 20;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL MOD)
{
    if(n < 0) a = fp(a, MOD - 2, MOD), n = -n;
    LL res = 1; for(; n; n >>= 1, a = a * a % MOD) if(n & 1) res = res * a % MOD; return res;
}

void work()
{
    string a, b;
    int c, d;
    cin >>a >>b >>c >>d;
    string t;
    cin >>t;
    if(t == a) c--;
    else d--;
    cout <<c <<" " <<d <<endl;
}


int main(int argc, char **argv)
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


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

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

ll gcd(ll a, ll b) { for (; b; a %= b, swap(a, b)); return a; }

const ll INF = 1e16;

int n;
string s[51];
ll c[51];

map<pair<bool, string>, ll> mp;
ll solve(bool isPre, string cs)
{
	bool flag = true;
	for (int i = 0; i < cs.size(); i++)
	{
		if (cs[i] != cs[cs.size() - 1 - i]) flag = false;
	}

	if (flag) return 0;

	if (mp.find({ isPre, cs }) != mp.end()) return mp[{isPre, cs}];

	ll res = mp[{isPre, cs}] = INF;
	if (!isPre)
	{
		for (int i = 0; i < n; i++)
		{
			bool flag = true;
			for (int j = 0; j < min(cs.size(), s[i].size()); j++)
			{
				if (s[i][s[i].size() - 1 - j] != cs[j])
				{
					flag = false;
					break;
				}
			}

			if (flag)
			{
				if (cs.size() < s[i].size())
				{
					string ns = s[i].substr(0, s[i].size() - cs.size());
					reverse(ns.begin(), ns.end());

					ll tmp = solve(true, ns) + c[i];
					res = min(res, tmp);
				}
				else
				{
					string ns = cs.substr(s[i].size(), cs.size() - s[i].size());

					ll tmp = solve(false, ns) + c[i];
					res = min(res, tmp);
				}
			}
		}
	}
	else
	{
		for (int i = 0; i < n; i++)
		{
			bool flag = true;
			for (int j = 0; j < min(cs.size(), s[i].size()); j++)
			{
				if (s[i][j] != cs[j])
				{
					flag = false;
					break;
				}
			}

			if (flag)
			{
				if (cs.size() < s[i].size())
				{
					string ns = s[i].substr(cs.size(), s[i].size() - cs.size());

					ll tmp = solve(false, ns) + c[i];
					res = min(res, tmp);
				}
				else
				{
					string ns = cs.substr(s[i].size(), cs.size() - s[i].size());

					ll tmp = solve(true, ns) + c[i];
					res = min(res, tmp);
				}
			}
		}
	}

	return mp[{isPre, cs}] = res;
}

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

	cin >> n;
	for (int i = 0; i < n; i++) cin >> s[i] >> c[i];

	ll ans = INF;
	for (int i = 0; i < n; i++)
	{
		bool flag = true;
		for (int j = 0; j < s[i].size(); j++)
		{
			if (s[i][j] != s[i][s[i].size() - 1 - j]) flag = false;
		}

		if (flag) ans = min(ans, c[i]);
	}

	for (int i = 0; i < n; i++)
	{
		ll res = solve(0, s[i]) + c[i];
		ans = min(ans, res);
	}

	if (ans == INF) ans = -1;
	cout << ans;
}

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

int main(){
    int n, a, b, as, bs;
    cin >> n;
    vector<int> po(n,0);
    vector<int> ran(n,0);
    for(int i = 0;i<n*(n-1)/2;i++){
        cin >> a >> b >> as >> bs;
        if(as == bs){
            po[a-1]++;
            po[b-1]++;
        }
        else if(as>bs){
            po[a-1]+=3;
        }
        else{
            po[b-1]+=3;
        }
    }
    bool flag;
    int j = 1, temp=0;
    for(int i = *max_element(po.begin(), po.end());i>=0;i--){
        flag = false;
        temp = 0;
        for(int k = 0;k<n;k++){
            if(po[k] == i){
                ran[k] = j;
                flag = true;
                temp++;
            }
        }
        if(flag){
            j += temp;
        }
    }
    for(int i = 0;i<n;i++){
        cout << ran[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3092