akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;
string yes = "Yes\n";
string no = "No\n";

ll MAX = 1e18;//10^18


int  main()
{
	int n; cin >> n;
	vector<ll>  a(n);
	ll sum = 1;
	rep(i, n)
	{
		cin >> a[i];
		if (a[i] == 0)
		{
			cout << 0 << endl;
			return 0;
		}
	}
	rep(i, n)
	{
		if (1000000000000000001/sum < a[i])
		{
			cout << -1; return 0;
		}
		sum *= a[i];
		if (sum > 1000000000000000000)
		{
			cout << -1;
			return 0;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 4044
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int x[100000 + 10];
int ans[100000 + 10];
int pos;
int find(int i)
{
    int ans = 0;
    int l = 0, r = pos - 1;
    while (l <= r)
    {
        int mid = (l + r) >> 1;
        if (x[mid] < i)
        {
            ans = mid;
            l = mid + 1;
        }
        else
        {
            r = mid - 1;
        }
    }
    return ans;
}
int main()
{
    string a;
    cin >> a;
    pos = 0;
    for (int i = 0; i < a.size(); i++)
    {
        if (a[i] == 'R' && a[i + 1] == 'L')
        {
            ans[i] = 1;
            ans[i + 1] = 1;
            x[pos++] = i;
            x[pos++] = i + 1;
        }
    }

    for (int i = 0; i < a.size(); i++)
    {
        if (a[i] == 'R' && a[i + 1] == 'R' && i + 1 < a.size())
        {
            int h = lower_bound(x, x + pos, i) - x;
            h = x[h];
            if ((h - i) % 2)
                ans[h + 1]++;
            else
                ans[h]++;
        }
        if (a[i] == 'L' && a[i - 1] == 'L')
        {
            int h = find(i);
            h = x[h];
            if ((i - h) % 2)
                ans[h - 1]++;
            else
                ans[h]++;
        }
    }
    for (int i = 0; i < a.size(); i++)
        cout << ans[i] << " ";
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 200005
#define __TRUE "Yes"
#define __FALSE "No"
using namespace std;

int main() {
  vector<int> a(3);
  int k;
  cin >> a[0] >> a[1] >> a[2];
  cin >> k;
  int max=0;
  sort(a.begin(),a.end());
  for(int i=0;i<k;i++) {
    a[2] *= 2;
  }
  max=a[0]+a[1]+a[2];
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
using ll=long long;
#define rep(i,a,b) fr(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl

ll x;
int main() {
    cin >> x;
    ll s = 100;
    int ans = 0;
    while(s < x){
        s += s/100;
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3200
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - FizzBuzz Sum
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

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

  ll sum = 0;
  for (int i = 1; i <= n; i++)
    if (i % 3 != 0 && i % 5 != 0) sum += i;

  printf("%lld\n", sum);
  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  string s; cin >> s;
  int result = 100;
  rep(i,26) {
    string tmp_s = s;
    char now = 'a' + i;
    int count = 0;
    while(true) {
      bool ok = true;
      string tmp;
      rep(l,tmp_s.length()) {
        if (tmp_s[l]!=now) ok = false;
        if (l!=tmp_s.length()-1) {
          if (tmp_s[l]==now||tmp_s[l+1]==now) tmp += now;
          else tmp += tmp_s[l];
        }
      }
      if (ok) break;
      count++;
      tmp_s = tmp;
    }
    // if (result>count) cout << now << endl;
    result = min(result, count);
  }
  cout << result << endl;
  return 0;
}

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

using namespace std;

int main()
{
	string str;

	cin >> str;

	int scount = 0, tcount = 0;
	int ans = 0;

	for (int i = 0; i < str.length(); i++) {

		if (str[i] == 'S') {
			if (tcount > 0) {
				scount = 1;
				tcount = 0;
			}
			else {
				scount++;
			}

		}
		else {
			if (scount > 0) {
				ans += 2;
				scount--;

			}

		}

	




	}

	cout << str.length() - ans << endl;
	return 0;



}



Measured memory_bytes: 640
A, B, M=map(int,input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
t=[list(map(int, input().split())) for i in range(M)]

ans=min(a)+min(b)

for k in range(M):
    i=t[k][0]
    j=t[k][1]
    
    Y=a[i-1]+b[j-1]-t[k][2]
    if Y<=ans:
        ans=Y

print(ans)

Measured memory_bytes: 38488
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7
    H,W,K = LMIIS()
    from itertools import accumulate
    S = [list(accumulate(map(int,input()))) for _ in range(H)]
    


    def divide(pattern):
        lenP = len(pattern)
        divided = [0]*lenP
        count = lenP - 1
        for i in range(lenP):
            if K < pattern[i][0]:
                return H+W
        for i in range(1,W):
            # print('divided=',divided)
            for j in range(lenP):
                if K < pattern[j][i] - divided[j]:
                    for l in range(lenP):
                        divided[l] = pattern[l][i-1]
                    count += 1
                    break
        # print('count=',count)
        return count
                    

            
        



    ans = H+W

    for i in range(2**H):
        pattern = []
        line = [0] * W
        for j in range(H):
            for k in range(W):
                line[k] += S[j][k]
            if 2**j & i:
                pattern.append(line)
                line = [0] * W
        pattern.append(line)
        # print(pattern)
        ans = min(divide(pattern),ans)
    print(ans)
    return
        
    

                

                
                

    

    

if __name__ == '__main__':
    main()

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i,n) for(int64 i = 0; i < (n); i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define FORR(i,a,b) for(int64 i = (a); i >= (b);--i )
#define all(x) x.begin(),x.end()
#define fs first;
#define sc second;

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

template<typename A, typename B> inline void chmin(A &a, B b) { if(a > b) a = b; }
template<typename A, typename B> inline void chmax(A &a, B b) { if(a < b) a = b; }



int main(void){
  cin.tie(0);
  int32 n;
  while (cin >> n && n) {
    int32 m,t,p;
    cin >> m >> t >> p;
    vector<vector<int64>> kami(n*(t+1), vector<int64>(m*(t+1),0));
    int32 a,b;
    a = 0;
    b = 0;
    REP(i,n)REP(j,m){
      kami[i][j] = 1;
    }
    REP(k,t){
      int32 d,c;
      cin >> d >> c;
      if(d == 1){
        REP(i,c)REP(j,m){
          kami[a+c+i][b+j] += kami[a+c-i-1][b+j];
        }
        a += c;
      }else{
        REP(i,n)REP(j,c){
          kami[a+i][b+c+j] += kami[a+i][b+c-j-1];
        }
        b += c;
      }
    }
    // cout << endl;
    // REP(i,2*n){
    //   REP(j,2*m){
    //     cout << kami[i][j];
    //   }
    //   cout << endl;
    // }
    // cout << endl;
    REP(k,p){
      int64 cnt = 0;
      int32 x,y;
      cin >> x >> y;
      cnt += kami[a+x][b+y];
      cout << cnt << endl;
    }
  }
}


Measured memory_bytes: 5172
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int k;
  cin >> k;
  vector<string> v;
  rep(i, 1, 10) v.push_back(to_string(i));

  int cur = 0;
  while (v.size() < k) {
    char tail = v[cur][v[cur].size() - 1];
    if (tail == '9') {
      int a = tail - '0' - 1, b = tail - '0';
      v.push_back(v[cur] + to_string(a));
      v.push_back(v[cur] + to_string(b));
    } else if (tail == '0') {
      int b = tail - '0', c = tail - '0' + 1;
      v.push_back(v[cur] + to_string(b));
      v.push_back(v[cur] + to_string(c));
    } else {
      int a = tail - '0' - 1, b = tail - '0', c = tail - '0' + 1;
      v.push_back(v[cur] + to_string(a));
      v.push_back(v[cur] + to_string(b));
      v.push_back(v[cur] + to_string(c));
    }
    cur++;
  }

  cout << v[k - 1] << endl;
}


Measured memory_bytes: 5748
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		System.out.println(sc.next().indexOf("9")!=-1 ? "Yes" : "No");
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 35456
#include<stdio.h>

int main(void) {
	int N, i;
	long long a[200000] = { 0 };
	long long total = 0;

	scanf("%d", &N);

	for (i = 0; i < N; i++) {
		scanf("%lld", &a[i]);
	}

	for (i = 0; i < N-1; i++) {
		if (a[i] > a[i + 1]) {
			total += (a[i] - a[i + 1]);
			a[i + 1] = a[i];
		}
	}
	printf("%lld", total);
	return 0;
}

Measured memory_bytes: 3252
#include <algorithm>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  LL W, H, x, y; std::cin >> W >> H >> x >> y;
  double ans = (double)(W*H)/2;
  bool b = ((x == W - x) && (y == H - y));
  printf("%lf %d\n", ans, b);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
//#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
#include<set>
//#include<map>
//#include<list>

using namespace std;

class UnionFind {
public:
	vector<int>data;
	UnionFind(int size) :data(size, -1) {};
	bool unionset(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x]) {
				swap(x, y);
			}
				data[x] += data[y];
				data[y] = x;
		}
		return x != y;
	}
	bool findset(int x,int y){
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int main(void) {
	int A, B,res;
	cin >> A >> B;
	if (B % A == 0) {
		res = A + B;
	}
	else {
		res = B - A;
	}
	cout << res << endl;
}

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

#define MAXN 1000001 
  
// stores smallest prime factor for every number 
int spf[MAXN]; 
  
// Calculating SPF (Smallest Prime Factor) for every 
// number till MAXN. 
// Time Complexity : O(nloglogn) 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
  
// A O(log n) function returning primefactorization 
// by dividing by smallest prime factor at every step 
set<int> getFactorization(int x) 
{ 
    set<int> ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 

int main(){
	int n, i, j, k, g ;
	cin >> n;
	int arr[n];
	for(i=0; i<n; i++)
		cin >> arr[i];

	sieve();

	int freq[1000001] = {0}, flag = 0;
	for(i=0; i<n; i++){
		set<int> temp = getFactorization(arr[i]);
		for(auto x: temp){
			if(freq[x] == 1)
				flag = 1;
			else
				freq[x] = 1;
		}
		if(flag == 1)
			break;
	}

	if(flag == 0){
		cout << "pairwise coprime\n";
		return 0;
	}

	g = arr[0];
	for(i=1; i<n; i++)
		g = __gcd(g, arr[i]);

	if(g == 1)
		cout << "setwise coprime\n";
	else
		cout << "not coprime\n";

}

Measured memory_bytes: 15308
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;cin >> a;
    cout << a*a*a+a*a+a << endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int max = 0;

		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			max  = Math.max(max, a[i]);
		}

		int half = (a[0] == max ? a[1] : a[0]);

		for(int  i = 0; i < n; i++) {
			if(a[i] == max) continue;
			if(Math.abs(a[i]*2 - max) < Math.abs(half*2 - max)) {
				half = a[i];
			}
		}
		System.out.printf("%d %d", max, half);
		sc.close();
	}

}

Measured memory_bytes: 50476
import itertools
import math
N=int(input())
P=list(map(int,input().split()))
P=int(''.join(list(map(str,P))))
Q=list(map(int,input().split()))
Q=int(''.join(list(map(str,Q))))

L=list(map(list,itertools.permutations(range(1,N+1))))
for a,x in enumerate(L):
    for b,y in enumerate(x):
        L[a][b]=str(y)
L=[int(''.join(x)) for x in L]
L=sorted(L,reverse=False)

print(int(math.fabs((L.index(P)+1)-(L.index(Q)+1))))

Measured memory_bytes: 29932
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
  string X;
  cin >> X;
  int cnt=0;
  int max_cnt =0;
  for(int i=0; i < X.size(); ++i){
    if(X[i] == 'T' || X[i] == 'A' || X[i] == 'G' || X[i] == 'C') ++cnt;
    else cnt =0;
    if(cnt > max_cnt) max_cnt = cnt;
  }
   cout << max_cnt << endl; 
}

Measured memory_bytes: 256
class UnionFind:

  def __init__(self, n):
    self.n = n

    # parentsの値を木の高さ判定につかっている
    # rankやsizeをつかって木の高さ判定をすることは一般的に多いが、もっとスマートな形
    self.parents = [-1] * n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x]) # 経路圧縮
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y:
      return

    if self.parents[x] > self.parents[y]: # parentsの値を木の高さ判定につかっている
      x, y = y, x

    self.parents[x] += self.parents[y]
    self.parents[y] = x

  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    x = self.find(x)
    y = self.find(y)

    return x == y 

N, M = map(int, input().split())
AB = []

for i in range(M):
  x, y = map(int, input().split())
  AB.append((x, y))


uf = UnionFind(N+1)
base = N * (N-1) // 2
tmp =  base
result = [tmp]

for (x, y) in AB[::-1]:
  if uf.same(x, y):
    result.append(tmp)
  else:
    tmp -= uf.size(x) * uf.size(y)
    result.append(tmp)
    uf.union(x,y)

result.pop()
for r in result[::-1]:
  print(r)




Measured memory_bytes: 106200
// IOI 2021
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////
 
const int N = 3e3 + 5;

int A[N];
vector<int> G[N];

bool DFS(int v, int p = 0) {
	for (int u : G[v]) if (u != p && !DFS(u, v) && A[u] < A[v]) return true;
	return false;
}

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

	int n, ans = 0; cin >> n;
	for (int i = 1; i <= n; i++) cin >> A[i];
	for (int i = 1; i < n; i++) {
		int v, u; cin >> v >> u;
		G[v].push_back(u), G[u].push_back(v);
	}
	for (int i = 1; i <= n; i++) if (DFS(i)) cout << i << ends;
	cout << endl;

	return 0;
}


Measured memory_bytes: 3936
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

typedef
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))

typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    int n, x;
    cin >> n >> x;
    if (n == 2) {
        if (x == 2) {
            cout << "Yes\n";
            cout << "1 2 3\n";
            return;
        }
        cout << "No\n";
        return;
    }
    int m = 2 * n - 1;
    if (x == 1 || x == m) {
        cout << "No\n";
        return;
    }
    vi ans(m);
    ans[n - 1] = x;
    ans[n - 2] = x - 1;
    ans[n] = x + 1;
    if (x + 2 <= m) {
        ans[n - 3] = x + 2;
    } else {
        ans[n + 1] = x - 2;
    }
    set<int> s;
    for2(i, 1, m) s.insert(i);
    for (int x : ans) s.erase(x);
    forn(i, m) {
        if (ans[i] == 0) {
            ans[i] = *s.begin();
            s.erase(ans[i]);
        }
    }
    cout << "Yes\n";
    printvi(ans)
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 13440
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a, b;
  cin >> a>>b;
  
  if (b>=a) {
  cout << a << endl;
  }
  
  else {
  cout << a-1 << endl;
  }
  
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a1 = scan.nextInt();
        int a2 = scan.nextInt();
        int a3 = scan.nextInt();
      	String label = (a1 + a2 + a3 >= 22) ? "bust" : "win";
      	System.out.println(label);
    }
 
}

Measured memory_bytes: 20948
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

int p[32], q[32][64], r[32][64];

int get(int dist, int station)
{
	int ret = 0;
	int prev = 0;
	
	for (int i = 0; i < p[station] - 1; i++){
		if (q[station][i] <= dist){
			ret += r[station][i] * (q[station][i] - prev);
		}
		else {
			ret += r[station][i] * (dist - prev);
			return (ret);
		}
		prev = q[station][i];
	}
	
	if (prev <= dist) ret += r[station][p[station] - 1] * (dist - prev);
	return (ret);
}

int main()
{
	int n, m, c, s, g;
	
	while (scanf("%d %d %d %d %d", &n, &m, &c, &s, &g) && n){
		int cost[128][128];
		int sub[20][128][128];
		
		for (int i = 0; i < 128; i++){
			for (int j = 0; j < 128; j++){
				if (i != j) cost[i][j] = 1000000000;
				else cost[i][j] = 0;
				for (int k = 0; k < c; k++){
					if (i != j) sub[k][i][j] = 1000000000;
					else sub[k][i][j] = 0;
				}
			}
		}

		for (int i = 0; i < m; i++){
			int x, y, d, c;
			scanf("%d %d %d %d", &x, &y, &d, &c);
			--x; --y; --c;
			sub[c][x][y] = min(sub[c][x][y], d);
			sub[c][y][x] = min(sub[c][y][x], d);
		}
		
		for (int S = 0; S < c; S++)
			for (int k = 0; k < n; k++)
				for (int i = 0; i < n; i++)
					for (int j = 0; j < n; j++)
						sub[S][i][j] = min(sub[S][i][j], sub[S][i][k] + sub[S][k][j]);
		
		
		for (int i = 0; i < c; i++){
			scanf("%d", p + i);
		}
		
		for (int i = 0; i < c; i++){
			for (int j = 0; j < p[i] - 1; j++){
				scanf("%d", &q[i][j]);
			}
			for (int j = 0; j < p[i]; j++){
				scanf("%d", &r[i][j]);
			}
		}
		
		for (int S = 0; S < c; S++)
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++)
					if (sub[S][i][j] != 1000000000)
						cost[i][j] = min(cost[i][j], get(sub[S][i][j], S));
		
		for (int k = 0; k < n; k++)
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++)
					cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
		
		printf("%d\n", cost[s - 1][g - 1] != 1000000000 ? cost[s - 1][g - 1] : -1);
	}
}

Measured memory_bytes: 2388
#include <array>
#include <iostream>
#include <map>
#include <vector>

template <typename Map, typename Value = typename Map::mapped_type>
Value &
MapIncrementCount(Map &map, typename Map::key_type key, Value value)
{
    auto [it, flag] = map.try_emplace(key, 0);
    (void)flag;
    auto &v = it->second;
    v += value;
    return v;
}

int
main()
{
    std::size_t n;
    std::cin >> n;
    std::vector<int> inputs;
    inputs.reserve(n);
    for (std::size_t i = 0; i<n; ++i)
    {
        int input;
        std::cin >> input;
        inputs.emplace_back(input);
    }

    std::size_t operationCount;
    std::cin >> operationCount;
    std::vector<std::pair<int, int>> operations;
    operations.reserve(operationCount);
    for (std::size_t i = 0; i<operationCount; ++i)
    {
        int b, c;
        std::cin >> b >> c;
        operations.emplace_back(b, c);
    }

    long long sum = 0;
    std::map<int, int> valueCounts;
    for (auto &input : inputs)
    {
        MapIncrementCount(valueCounts, input, 1);
        sum += input;
    }

    for (std::size_t i = 0; i<operationCount; ++i)
    {
        auto &[b, c] = operations[i];

        auto findB = valueCounts.find(b);
        if (findB==valueCounts.end())
        {
            std::cout << sum << "\n";
            continue;
        }

        sum -= static_cast<long long>(b)*findB->second;
        sum += static_cast<long long>(c)*findB->second;

        MapIncrementCount(valueCounts, c, findB->second);
        valueCounts.erase(b);
        std::cout << sum << "\n";
    }
}


Measured memory_bytes: 7328
#include<stdio.h>

int saiki (int, int);

int main(){
  int x,y,a;

  scanf("%d%d",&x,&y);
  
  a = saiki(x,y);

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

  return 0;
}

int saiki (int x, int y){

  int temp;
  // y を小さいほうにする
  if(x < y) {
    temp = x;
    x = y;
    y = temp;
  }

  
  if(x % y  == 0) return y;

  return saiki(x%y,y);

}




  
    



Measured memory_bytes: 2704
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define INF 1000010;

using namespace std;


int main(void){
  long c,n,m,s,d;
  while(true){
    cin>>c>>n>>m>>s>>d;
    if(c==0 and n==0 and m==0 and s==0 and d==0)break;
    d--;
    s--;

    long a,b,f;
    map<long,long> costs[n];
    for(int i=0;i<m;i++){
      cin>>a>>b>>f;
      a--;
      b--;
      costs[a][b]=f;
      costs[b][a]=f;
    }
    map<long,long> dist[n];
    for(long i=0;i<n;i++){
      for(long j=0;j<=c;j++){
        dist[i][j]=INF;
      }
    }
    dist[s][0]=0;

    vector<long> next,_next;
    next.push_back(s);
    while(next.empty()==false){
      _next.clear();
      for(auto iter=next.begin();iter!=next.end();iter++){
        long city=*iter;
        for(auto iter2=costs[city].begin();iter2!=costs[city].end();iter2++){
          long next_city=iter2->first;
          long fee=iter2->second;
          for(long ticket=0;ticket<=c;ticket++){
            if(dist[next_city][ticket]>dist[city][ticket]+fee){
              dist[next_city][ticket]=dist[city][ticket]+fee;
              _next.push_back(next_city);
            }
          }
          for(long ticket=1;ticket<=c;ticket++){
            if(dist[next_city][ticket]>dist[city][ticket-1]+fee/2){
              dist[next_city][ticket]=dist[city][ticket-1]+fee/2;
              _next.push_back(next_city);
            }
          }
        }
      }

      sort(_next.begin(),_next.end());
      _next.erase(unique(_next.begin(),_next.end()),_next.end());
      next.clear();
      copy(_next.begin(),_next.end(),back_inserter(next));

    }
    long retval=INF;
    for(long ticket=0;ticket<=c;ticket++){
        retval=min(dist[d][ticket],retval);
    }
    cout<<retval<<endl;
  }
}



Measured memory_bytes: 3240
import java.util.Scanner;

//Lunch
public class Main {

	static int[] ans;
	static String[] name;
	static int n;
	static int[] w;
	static int[] s;
	static int[] order;
	static boolean[] used;
	static double best;
	
	static void dfs(int k, int num, int total){
		if(k==0){
			double g = num*1.0/total;
			if(g<best){
				best = g;
				for(int i=1;i<=n;i++)ans[i-1]=order[i];
			}
			return;
		}
		for(int i=0;i<n;i++){
			if(!used[i]&&total<=s[i]){
				used[i] = true;
				order[k] = i;
				dfs(k-1, num+k*w[i], total+w[i]);
				used[i] = false;
			}
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			n = sc.nextInt();
			if(n==0)break;
			name = new String[n];
			w = new int[n];
			s = new int[n];
			order = new int[n+1];
			best = Integer.MAX_VALUE;
			for(int i=0;i<n;i++){
				name[i] = sc.next();
				w[i] = sc.nextInt();
				s[i] = sc.nextInt();
			}
			used = new boolean[n];
			ans = new int[n];
			dfs(n, 0, 0);
			for(int i=0;i<n;i++){
				System.out.println(name[ans[i]]);
			}
		}
	}
}

Measured memory_bytes: 27768
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int k;
string s;
set<string> str;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> s >> k;
    int n = (int)s.size();
    erep(i, 1, k) {
        rep(j, 0, n) {
            str.insert(s.substr(j, i));
        }
    }
    auto itr = str.begin();
    rep(i,1,k) ++itr;
    cout << *itr << endl;
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>

using namespace std;

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

	int l_max = 0;
	int total = 0;

	for (int i = 0; i < N; i++) {
		int l;
		cin >> l;
		total += l;

		if (l_max < l) {
			l_max = l;
		}
	}
	total -= l_max;

	if (total > l_max) {
		cout << "Yes" << endl;
 		return 0;
 	}
 	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	n <- readInt
	print $ n * ( n + 1 ) `div` 2


Measured memory_bytes: 508
n = int(input())
a = list(map(int,input().split()))
ans = 0

for i in a:
  if i%2 ==0 and (i%3 !=0 and i%5 != 0):
    ans += 1
  else:
    pass
  
if ans >0:
  print("DENIED")
else:
  print("APPROVED")

Measured memory_bytes: 2940
int main(int argc, const char * argv[]) {
    char a[1001];
    int b[1000]={0};
    int i=0,j=0,k=0;
    
    while(1){
        while(1){
            scanf("%c",&a[i]);
            
            if(a[i] == '\n'){
                break;
            }
            i++;
        }
        
        for(j=0;j<i;j++){
            b[k] = b[k] + a[j] -48;
        }
        k++;
        
        if(a[i-1] == '0' && i==1){
            break;
        }
        i=0;
    }
    
    for(j=0;j<k-1;j++){
        printf("%d\n",b[j]);
    }
    return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

template <class T>
inline void read(T &x) {
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

int c[20][20];
int h, w, ans, a;

int main() {
    read(h), read(w);
    for (int i = 0; i <= 9; ++i)
        for (int j = 0; j <= 9; ++j)
            read(c[i][j]);
    for (int k = 0; k <= 9; ++k)
        for (int i = 0; i <= 9; ++i)
            for (int j = 0; j <= 9; ++j)
                c[i][j] = std::min(c[i][j], c[i][k] + c[k][j]);
    for (int i = 1; i <= h; ++i)
        for (int j = 1; j <= w; ++j)
            read(a), ans += a == -1 ? 0 : c[a][1];
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3764
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((numba.types.optional(i8), ) * 2, cache=True)
def seg_f(x, y):
    if x is None:
        return y
    if y is None:
        return x
    return max(x, y)


@njit((i8[:], ), cache=True)
def build(raw_data):
    N = len(raw_data)
    seg = np.empty(N + N, np.int64)
    seg[N:] = raw_data
    for i in range(N - 1, 0, -1):
        seg[i] = seg_f(seg[i << 1], seg[i << 1 | 1])
    return seg


@njit((i8[:], i8, i8), cache=True)
def set_val(seg, i, x):
    N = len(seg) // 2
    i += N
    seg[i] = x
    while i > 1:
        i >>= 1
        seg[i] = seg_f(seg[i << 1], seg[i << 1 | 1])


@njit((i8[:], i8, i8), cache=True)
def fold(seg, l, r):
    vl = vr = None
    N = len(seg) // 2
    l, r = l + N, r + N
    while l < r:
        if l & 1:
            vl = seg_f(vl, seg[l])
            l += 1
        if r & 1:
            r -= 1
            vr = seg_f(seg[r], vr)
        l, r = l >> 1, r >> 1
    return seg_f(vl, vr)


@njit((i8[:], i8, i8), cache=True)
def max_right(seg, l, x):
    """[l,r) が ok であるような最大の r を返す"""
    N = len(seg) // 2

    def is_ok(v):
        return v < x

    v = None
    i, node_l, node_w = l + N, l, 1
    while True:
        if not (i & 1):
            i >>= 1
            node_w <<= 1
            continue
        if node_l + node_w > N:
            break
        v1 = seg_f(v, seg[i])
        if is_ok(v1):
            v, i = v1, (i + 1) >> 1
            node_l, node_w = node_l + node_w, node_w << 1
        else:
            break
    # 奇数セルに居て、とりきれないことが分かっている。偶数をとっていく
    i, node_w = i << 1, node_w >> 1
    while node_w:
        if node_l + node_w > N:
            i, node_w = i << 1, node_w >> 1
            continue
        v1 = seg_f(v, seg[i])
        if is_ok(v1):
            v, i = v1, (i + 1) << 1
            node_l, node_w = node_l + node_w, node_w >> 1
        else:
            i, node_w = i << 1, node_w >> 1
    i >>= 1
    return i - N

@njit((i8, i8[:], i8[:]), cache=True)
def main(N, A, query):
    seg = build(A)
    for i in range(0, len(query), 3):
        t, a, b = query[i:i + 3]
        if t == 1:
            set_val(seg, a - 1, b)
        elif t == 2:
            print(fold(seg, a - 1, b))
        elif t == 3:
            print(max_right(seg, a - 1, b) + 1)

N, Q = map(int, readline().split())
A = np.array(readline().split(), np.int64)
query = np.array(read().split(), np.int64)

main(N, A, query)

Measured memory_bytes: 140664
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 100010;
int n, A, B;
bool visited[maxn];

#define all(x) x.begin(),x.end()

map <int, set <pi>> rangex, rangey;
vector <pi> vx, vy;

int newx[maxn],newy[maxn];

int32_t main() {
	FAST
	cin >> n >> A >> B;
	for (int i = 1;i <= n;i++) {
		int x,y; cin >> x >> y;
		newx[i] = x-y; newy[i] = x+y;
		
		rangex[newx[i]].insert(pi(newy[i],i));
		rangey[newy[i]].insert(pi(newx[i],i));
		vx.push_back(pi(newx[i],newy[i]));
		vy.push_back(pi(newy[i],newx[i]));
	}
	
	sort(all(vx));
	sort(all(vy));
	memset(visited,0,sizeof visited);
	
	int dist = max(abs(newx[A]-newx[B]), abs(newy[A] - newy[B]));
	queue <int> q;
	q.push(A);
	visited[A] = 1;
	
	//for (int i =1;i<=n;i++) {
		//cout << i << " " << newx[i] << " " << newy[i] << "\n";
	//}
	
	while (!q.empty()) {
		int v = q.front(); q.pop();
		int x = newx[v], y = newy[v];
		//cout << v << "\n";
		
		for (int d: {-dist,dist}) {
			auto it = rangex[x + d].lower_bound(pi(y-dist,0));
			while (it != rangex[x + d].end() and (*it).f <= y + dist) {
				//cout << x + d << " " <<  it -> f << " I:" << it -> s << "\n";
				if (!visited[(*it).s]) {
					visited[(*it).s] = 1;
					q.push((*it).s);
				}
				it = rangex[x+d].erase(it);
			}			 
		}
		//cout << "HI\n";
		for (int d: {-dist,dist}) {
			auto it = rangey[y + d].lower_bound(pi(x-dist,0));
			while (it != rangey[y+d].end() and (*it).f <= x + dist) {
				//cout << x + d << " " <<  it -> f << " I:" << it -> s << "\n";
				if (!visited[(*it).s]) {
					visited[(*it).s] = 1;
					q.push((*it).s);
				}
				it = rangey[y+d].erase(it);
			}			 
		}	
	}
	
	int ans = 0;
	for (int i = 1; i<=n;i++) {
		if (visited[i]) {
			int x = newx[i], y = newy[i];
			for (int d: {-dist,dist}) { 
				ans += upper_bound(all(vx),pi(x+d,y+dist)) - lower_bound(all(vx),pi(x+d,y-dist));
				ans += lower_bound(all(vy),pi(y+d,x+dist)) - upper_bound(all(vy),pi(y+d,x-dist)); //flip around to prevent double counting
				//i.e. exclude x + dist and x - dist
			}
		}
	}
	cout << ans/2;
}

Measured memory_bytes: 51936
(defun solve (n y)
  (loop for a from n downto 0
        for m = (- n a)
        do (loop for b from m downto 0
                 for c = (- m b)
                 when (= (+ (* 1000 c)
                            (* 5000 b)
                            (* 10000 a))
                         y)
                 do (return-from solve (list a b c)))
        finally
           (return (list -1 -1 -1))))

#-swank
(let* ((n (read))
       (y (read)))
  (format t "~{~A~^ ~}~%" (solve n y)))


Measured memory_bytes: 16096
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int x, y, z, k;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> x >> y >> z >> k;
  vector<ll> a(x);
  vector<ll> b(y);
  vector<ll> c(z);

  REP(i, x) cin >> a[i];
  REP(i, y) cin >> b[i];
  REP(i, z) cin >> c[i];

  vector<ll> ab;
  REP(i, x) REP(j, y) {
    ab.push_back(a[i] + b[j]);
  }

  sort(ab.begin(), ab.end(), greater<ll>());

  vector<ll> ans;
  REP(i, min(x * y, k)) REP(j, z) {
    ans.push_back(ab[i] + c[j]);
  }

  sort(ans.begin(), ans.end(), greater<ll>());

  REP(i, k) cout << ans[i] << endl;
}


Measured memory_bytes: 44088
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    Int A; cin >> A;
    Int B; cin >> B;
    char c; cin >> c;
    Int D; cin >> D;
    cout << A * (B * 100 + D) / 100 << endl;
    return 0;
}


Measured memory_bytes: 3648
package main

import "fmt"

func main(){
	var a, b int
	fmt.Scanf("%d", &a)
	fmt.Scanf("%d", &b)

	list := []int{1,2,3}
	aIndex := index(list, a)
	if aIndex > -1 {
		list = unset(list, aIndex)
	}
	bIndex := index(list, b)
	if bIndex > -1 {
		list = unset(list, bIndex)
	}

	fmt.Printf("%d\n", list[0])

}

func index( list []int, match int) int {
	for k, v := range list {
		if v == match {
			return k
		}
	}
	return -1
}

func unset(s []int, i int) []int {
	if i >= len(s) {
		return s
	}
	return append(s[:i], s[i+1:]...)
}


Measured memory_bytes: 512
// coding on smartphone
#include<iostream>
using namespace std;

int main(){
	int t, a[2];
	cin >> t;
	
	while(t-- > 0){
		int n, ma = 0, mi = 0;
		cin >> n >> a[1];
		for(int i = 0; i < n-1; i++){
			cin >> a[i%2];
			ma = max(ma, a[i%2]-a[1-(i%2)]);
			mi = min(mi, a[i%2]-a[1-(i%2)]);
		}
		cout << ma << " " << -mi << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3092
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    B = []
    for i in range(n):
        B.append([i + 1, A[i]])
    B = sorted(B, key=lambda x: x[1])

    res = []
    for i in range(n):
        res.append(B[i][0])

    print(*res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 23640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

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

}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  vi32 a(4), b(4);
  while (cin >> a >> b) {
    int hit = 0, blow = 0;
    rep(i, 4) rep(j, 4) {
      if (a[i] == b[j]) {
        if (i == j) hit++;
        else blow++;
      }
    }
    cout << hit << " " << blow << '\n';
  }
}



Measured memory_bytes: 3208
import copy
h,w=map(int, input().split())
s=[list(input())  for i in  range(h)]
ans=copy.deepcopy(s)

around=[[0,1],[0,-1],[1,0],[-1,0],[1,1],[1,-1],[-1,1],[-1,-1]]

for i in range(h):
  for j in range(w):
    x,y=i,j
    if s[x][y]==".":
      cnt=0
      for a in around:
        if (x+a[0]<0 or x+a[0]>h-1) or (y+a[1]<0 or y+a[1]>w-1):
          continue
        if s[x+a[0]][y+a[1]]=="#":
          cnt+=1
      ans[x][y]=str(cnt)
    

for i in ans:
  print("".join(i))


Measured memory_bytes: 9360
n=int(input())
a=list(map(int,input().split()))
import collections
c=collections.Counter(a)
t=list(c.items())
t.sort(reverse=True)
s=c.most_common()
if s[0][1]<4 and s[1][1]<2:
  print(0)
  exit()
while t[0][1]<2:
  del t[0]
if t[0][1]>=4:
  print(t[0][0]**2)
else:
  while t[1][1]<2:
    del t[1]
  print(t[0][0]*t[1][0])

Measured memory_bytes: 29192
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;
typedef pair<ll, ll> pll;

int mod = 1e9 + 7;

map<pll, bool> calculated;
map<pll, ll> f;

ll func(ll s, ll x) {
  if (s == 0) {
    return 1;
  }
  if (s == 1) {
    if (x == 0) {
      return 1;
    } else {
      return 2;
    }
  }
  if (x == 0) {
    return (1 + s / 2) % mod;
  }
  auto mpsx = mp(s, x);
  if (calculated[mpsx]) {
    return f[mpsx];
  }
  f[mpsx] = (func(s/2, x/2) + func((s-1)/2, (x-1)/2) + func((s-2)/2, x/2)) % mod;
  calculated[mpsx] = true;
  return f[mpsx];
}

int main() {
  ll n;
  scanf("%lld", &n);
  ll ans = func(n, n);
  
  printf("%lld\n", ans);
  return 0;
}


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

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int sum = 0;
    if(A <= B) {
        sum += A;
    } else {
        sum += B;
    }
    if(C <= D) {
        sum += C;
    } else {
        sum += D;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;

int main(){


    string w;
    cin >> w ;
    string judge  = "Yes";
    for (char c = 'a'; c < 'z'; c++){

        int cnt = 0;

        for ( int i = 0; i < w.size(); i++){

            if (w[i] ==  c){
                
                cnt++; 
            }
        }
        
        if(cnt % 2 != 0){
            judge = "No";
        }
    }

    cout << judge << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rall(s) (s).rbegin(),(s).rend()
#define bs(x) (bitset<18>(x)).to_string()
#define sep ios::sync_with_stdio(0),cin.tie(0)
using namespace std;
typedef long long ll;
int main(){
    sep;
    ll n;
    cin>>n;
    vector<ll>v(n);
    map<ll,ll>m,dp;
    for(int i=0;i<n;i++)  cin>>v[i],m[v[i]]++; 
    ll total=0;
    for(auto x:m) total+=x.second*(x.second-1)/2;
    for(auto x:v)
      cout<<total-(m[x]*(m[x]-1)/2)+((m[x]-1)*(m[x]-2)/2)<<"\n";
}


Measured memory_bytes: 11136
#include <iostream>
#include <stdio.h>
 
using namespace std;
 
main(){
  int H1,M1,H2,M2,K;
  scanf("%d %d %d %d %d",&H1,&M1,&H2,&M2,&K);
  printf("%d",H2*60+M2-H1*60-M1-K);
  return 0;
}

Measured memory_bytes: 3844