akhauriyash/Code-Regression huggingface dataset:
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <list>
#include <string>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;

int main()
{
    int a[5];
    int k;
    for (int i = 0; i < 5; i++)
        cin >> a[i];
    cin >> k;

    for (int i = 0; i < 5 - 1; i++)
        for (int j = i + 1; j < 5; j++)
        {
            if (abs(a[i] - a[j]) > k)
            {
                cout << ":(" << endl;
                return 0;
            }
        }
    cout << "Yay!" << endl;
}

void cheatsheet()
{
    // loop
    // vector<int> vec(10);
    vector<int> vecloop;
    REP(i, 10)
    {
        vecloop.push_back(i);
    }

    // swap
    int a = 1;
    int b = 5;
    swap(a, b); // -> a = 5, b = 1

    // sort
    int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    sort(arr, arr + 9, greater<int>()); // 9 8 7 6 5 4 3 2 1

    // lower
    vector<int> vec(arr, end(arr));
    sort(vec.begin(), vec.end());
    cout << lower_bound(vec.begin(), vec.end(), 2)[0]; // 2

    // map
    map<Pll, ll> m;
    m[Pll(10, 100)] = 100;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;

template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

char st[2];

void query(LL a) {
    printf("? %lld\n", a), fflush(stdout), scanf("%s", st);
}

int main() {
#ifdef Wearry
    //freopen("data.txt", "r", stdin);
    //freopen("ans.txt", "w", stdout);
#endif
    
    query(1000000000);
    if(st[0] == 'Y') { 
        LL Ans = 2;
        for(LL i = 1; i <= 1000000000; Ans *= 10, i *= 10) {
            query(Ans);
            if(st[0] == 'Y') {
                printf("! %lld\n", i);
                fflush(stdout);
                break;
            }
        }return 0;
    }

    int len = 1;
    for(LL i = 10; i <= 1000000000; i *= 10, ++ len) {
        query(i);
        if(st[0] == 'N') break;
    }

    int Ans = 0;
    for(int i = len; i >= 1; --i) {
        int l = i == len ? 1 : 0, r = 9, ans = -1;

        while(l <= r) {
            int m = (l+r) >> 1;
            query(LL(Ans * 10 + m) * 1000000000 + 999999999);

            if(st[0] == 'N') l = m+1; else r = m-1, ans = m;
        }
        Ans = Ans * 10 + ans;
    }
    printf("! %d\n", Ans);
    fflush(stdout);

    return 0;
}


Measured memory_bytes: 596
sa = input()
sb = input()
sc = input()
s = [[ord(s)-97 for s in sa], [ord(s)-97 for s in sb], [ord(s)-97 for s in sc]]
turn = 0
while True:
    if len(s[turn]) == 0:
        print(chr(turn+65))
        break
    turn = s[turn].pop(0)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] H = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();

            int h = 0;
            for (int i = 0; i < N; i++) {
                if (h < H[i]) {
                    h = H[i] - 1;
                } else if (h > H[i]) {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }
    }
}


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

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

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int m, d;
    cin >> m >> d;
    int cnt = 0;
    for(int i = 1; i <= m; ++i){
        for(int j = 1; j <= d; ++j){
            int d1 = j % 10, d10 = j / 10;
            if(d1 >= 2 && d10 >= 2 && d1 * d10 == i) ++cnt;
        }
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final List<Long> list = IntStream.range(0, n)
            .mapToObj(i -> scanner.nextLong())
            .collect(Collectors.toList());
        final boolean zeroContained = list.stream().anyMatch(i -> i == 0);
        if (zeroContained) {
            System.out.println(0);
            return;
        }

        BigInteger product = BigInteger.ONE;
        for (int i = 0; i < n; i++) {
            final long a = list.get(i);
            product = product.multiply(BigInteger.valueOf(a));
            final BigInteger max = BigInteger.valueOf(1_000_000_000_000_000_000L);
            if (product.compareTo(max) > 0) {
                System.out.println(-1);
                return;
            }
        }

        System.out.println(product.longValue());
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }
    }
}


Measured memory_bytes: 58008
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    map <int,int> cnt;
    int n; cin>>n; 
    while (n--){
        int a; cin>>a;
        cnt[a]++;
    }
    int a=-1,b=-1;
    for (auto it=cnt.rbegin();it != cnt.rend();it++){
        if (it->ss>1){
            if (a==-1) {
                a=it->ff;
                if (it->ss>3) b=it->ff;
            }
            else b=it->ff;
            if (a != -1 and b != -1) cout << a*b << endl,exit(0);
        }
    }
    cout << 0 << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 9848
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    int64_t n, k;
    cin >> n >> k;

    vector<int64_t> h(n);
    for (auto i : irange(0L, n)) {
        cin >> h[i];
    }

    vector<unordered_map<int64_t, int64_t>> dp(k + 1);
    dp[0][0] = 0;
    for (auto i : irange(0L, n)) {
        decltype(dp) next(k + 1);

        for (auto j : irange(0L, k + 1)) {
            for (const auto& row : dp[j]) {
                int64_t val;
                if (row.first < h[i]) {
                    val = row.second + (h[i] - row.first);
                } else {
                    val = row.second;
                }

                if (next[j].count(h[i]) > 0) {
                    next[j][h[i]] = min(next[j][h[i]], val);
                } else {
                    next[j][h[i]] = val;
                }
            }
        }

        for (auto j : irange(1L, k + 1)) {
            for (const auto& row : dp[j - 1]) {
                if (next[j].count(row.first) > 0) {
                    next[j][row.first] = min(next[j][row.first], row.second);
                } else {
                    next[j][row.first] = row.second;
                }
            }
        }

        dp = std::move(next);
    }

    int64_t ans = numeric_limits<int64_t>::max();
    for (auto i : irange(0L, k + 1)) {
        for (auto kv : dp[i]) {
            ans = min(kv.second, ans);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4224
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	k := getNextInt(scanner)

	ans := pow3(n, k)
	if k%2 == 0 {
		ans += pow3(n+(k>>1), k)
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}

func pow3(n, k int) int64 {
	c := int64(n / k)
	return c * c * c
}


Measured memory_bytes: 640
n,m=map(int,input().split())
dp=[10**20]*(1<<n)
dp[0]=0
for i in range(m):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    bit=0
    for j in c:bit|=1<<(j-1)
    for j in range(1<<n):
        dp[j|bit]=min(dp[j|bit],dp[j]+a)
if dp[-1]==10**20:print(-1)
else:print(dp[-1])

Measured memory_bytes: 9236
class Graph:
    def __init__(self, n_vertices, edges, directed=True):
        self.n_vertices = n_vertices
        self.edges = edges
        self.directed = directed

    @property
    def adj(self):
        try:
            return self._adj
        except AttributeError:
            adj = [[] for _ in range(self.n_vertices)]
            if self.directed:
                for u,v in self.edges:
                    adj[u].append(v)
            else:
                for u,v in self.edges:
                    adj[u].append(v)
                    adj[v].append(u)
            self._adj = adj
            return adj

max2 = lambda x,y: x if x > y else y
min2 = lambda x,y: x if x < y else y

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

def solve(N, edges):
    adj = Graph(N, edges, directed=True).adj
    parent = [-1]*N
    
    # find root
    deg = [0]*N
    for u,v in edges:
        deg[v] += 1

    root = next(v for v,d in enumerate(deg) if d==0)

    topo = [-1]*N
    stack = [root]
    for i in range(N):
        v = stack.pop()
        topo[i] = v
        for u in adj[v]:
            deg[u] -= 1
            if deg[u] == 0:
                stack.append(u)

    dist = [0]*N
    for v in topo:
        d = dist[v]
        for u in adj[v]:
            dist[u] = max2(dist[u], d+1)

    parent = [-1]*N
    for v,l in enumerate(adj):
        d = dist[v]+1
        for u in l:
            if d == dist[u]:
                parent[u] = v
    return (p+1 for p in parent)




if __name__ == '__main__':
    N,M = map(int,readline().split())
    m = map(lambda x: int(x)-1, read().split())
    edges = list(zip(m,m))
    print(*solve(N,edges), sep='\n')

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

int main(){
    int n;
    cin >> n;
    if((n / 10) % 111 == 0 || (n % 1000) % 111 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVETSE(c) reverse((c).begin(),(c).end())
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define ALL(a)  (a).begin(),(a).end()
// int gcd(int a,int b){return b?gcd(b,a%b):a;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> T maxt(T x,T y) {
    if (x>y) return x;
    else return y;
}
template<class T> T mint(T x,T y) {
    if (x>y) return y;
    else return x;
}
//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

//小数出力
double print_double(double d){printf("%.8f", d);}

long long m = 1e9+7, mod = 1e9+7;
//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

//約数列挙
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

// int bfs

int main() {
  int N,a,b;
  scanf("%d",&N);
  vector<pair <int,int>> v(N);
  Vi count(N+1,0);
  map<int,Vi> m;
  rep(i,N-1){
    scanf("%d%d",&a,&b);
    v[i].first=a;
    v[i].second=b;
    count[a]++;count[b]++;
    m[a].push_back(b);m[b].push_back(a);
  }
  auto maxix = max_element(ALL(count)) - count.begin();
  auto ansnum = *max_element(ALL(count));
  count.clear();

  printf("%d\n",ansnum);
  map<int,map<int,int>> ans;
  Vi used(N+1,0);
  queue<int> q;
  q.push(maxix);
  used[maxix]=1;
  while (!q.empty()) {
    auto v=q.front();q.pop();
    int cur = 1,ngcolor=0;
    for (int u:m[v]) {
      if (used[u]) ngcolor=ans[v][u];}
  
    for (int u:m[v]) {
      if (used[u])continue;
      if (cur==ngcolor)cur++;
      ans[v][u] = ans[u][v] = cur;
      cur++;
      used[u]=1;
      q.push(u);
    }
  }

  rep(i,N-1){
    a = v[i].first;
    b = v[i].second;
    printf("%d\n",ans[a][b]);
  }
}

Measured memory_bytes: 31744
#include <iostream>

int main()
{
    int K, A, B;
    std::cin >> K >> A >> B;

    if ((A - 1) / K == B / K) {
        std::cout << "NG" << std::endl;
    } else {
        std::cout << "OK" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3636
def io_tmp():
    global input
    import io, sys
    f = io.StringIO(open(0).read())
    input = f.readline

io_tmp()


from scipy.sparse.csgraph import floyd_warshall


N, M, L = map(int, input().split())
graph = [[0] * N for _ in range(N)]
for _ in range(M):
    s, t, w = map(int, input().split())
    graph[s-1][t-1] = graph[t-1][s-1] = w
dist = floyd_warshall(graph, directed=False)
graph = [[0] * N for _ in range(N)]
for i in range(N):
    for j in range(i+1, N):
        if dist[i][j] <= L:
            graph[i][j] = graph[i][j] = 1
dist = floyd_warshall(graph, directed=False)

Q = int(input())
for _ in range(Q):
    s, t = map(int, input().split())
    ans = dist[s-1][t-1]
    if ans == float("inf"):
        print(-1)
    else:
        print(int(ans - 1))


Measured memory_bytes: 23340
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n){
        vector<int> v(n);
        for (int i = 0; i < n; ++i) {
            char c;
            cin >> c;
            v[i] = c-'A';
        }
        vector<int> cnt(26);
        bool det = false;
        for (int i = 0; i < n; ++i) {
            cnt[v[i]]++;
            auto cnt2(cnt);
            sort(cnt2.begin(),cnt2.end(), greater<>());
            if(cnt2[0]-cnt2[1] > n-i-1 && !det){
                det = true;
                cout << char((max_element(cnt.begin(),cnt.end())-cnt.begin()+'A')) << " " << i+1 << "\n";
            }
        }

        if(!det){
            puts("TIE");
        }
    }
    return 0;
}


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

int main() {
  vector<int> a(9);
  for(int i=0; i<9; i++){
    cin >> a.at(i);
  }
  
  int n;
  cin >> n;
  
  vector<int> b(n);
  vector<int> c(9);
  
  for(int i=0; i<n; i++){
    cin >> b.at(i);
    	for(int j=0; j<9; j++){
          if(a.at(j) == b.at(i)){
            c.at(j)++;
          }
        }
    
  }
  
  int count=0;
  
  for(int i=0; i<=6; i+=3){
    if(c.at(i)*c.at(i+1)*c.at(i+2) != 0){
      count++;
    }
  }
  
  for(int i=0; i<=2; i++){
    if(c.at(i)*c.at(i+3)*c.at(i+6) != 0){
      count++;
    }
  }
  
  if(c.at(0)*c.at(4)*c.at(8) != 0){
      count++;
  }
  
  if(c.at(2)*c.at(4)*c.at(6) != 0){
      count++;
  }
  
  if(count > 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
	return 0;
}


Measured memory_bytes: 256
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

  int n;
  cin >> n;
  int cur = 100;
  int ans = 0;
  while(cur<n){
    cur+=(cur/100);
    ans++;
  }
  cout << ans << endl;

return 0;
}
///....


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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


    ll n;
    cin >> n;

    vpl r(n);
    map<pll, ll> m;
    vpl f;
    REP(i, n) {
        string s;
        cin >> s;

        ll k = s.size();
        ll p = k - 1;
        REP(i, k) {
            if (s[i] == '.')
                p = i;
        }

        ll num = 0;
        REP(i, k) {
            if (s[i] == '.')
                continue;
            num *= 10;
            num += s[i] - '0';
        }
        ll r2 = 0, r5 = 0;
        REP(i, k - p - 1) {
            if (num % 2 == 0)num /= 2;
            else r2 -= 1;

            if (num % 5 == 0)num /= 5;
            else r5 -= 1;
        }

        while (num % 2 == 0) {
            num /= 2;
            r2++;
        }
        while (num % 5 == 0) {
            num /= 5;
            r5++;
        }

        r[i].first = r2;
        r[i].second = r5;

        m[r[i]] += 1;
    }


    ll ans = 0;
      for(ll i=-20; i<=24; i++){
          for (ll j = -20; j <= 24; j++) {
              ll t = m[pll(i, j)];
              if (t == 0)
                  continue;
    
    		  ll res = 0;
    		  for (ll k = i; k <= 24; k++) {
                  for (ll q = -20; q <= 24; q++) {
    				  if (k + i < 0 || q + j < 0)
    					  continue;
    
    
                      if (k == i && q < j)
                          continue;
    				  if (k == i && q == j)
    					  res += t * (t - 1) / 2;
    				  else
    					  res += t * m[pll(k, q)];
    
    
                  }
              }
    
    		  ans += res;
    
    	  }
      }

	cout << ans << endl;

}




Measured memory_bytes: 6376
#include <bits/stdc++.h>
#define mod 9929
#define inf 1e18
#define endl '\n'
#define eps 1e-9
#define zeros(x) ((x)&(-x))
#define nmax 100000

using namespace std;

typedef long long ll;
typedef long double ld;

ll x, y, n, maxim = 0, nr, Ans[100005];
vector<pair<ll, ll> > V[100005];

void DFS(int x, int last = -1, int lc = -1)
{
    int clr = 1;
    if (clr == lc)
        clr++;

    for (auto i : V[x])
    {
        if (i.first == last) continue;
        Ans[i.second] = clr;
        DFS(i.first, x, clr);
        clr++;
        if (clr == lc)
            clr++;
    }
}

int main()
{
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for (int i=1; i<n; i++)
    {
        cin>>x>>y;
        V[x].push_back({y, i});
        V[y].push_back({x, i});
        if (V[x].size() > maxim)
        {
            maxim = V[x].size();
            nr = x;
        }
        if (V[y].size() > maxim)
        {
            maxim = V[y].size();
            nr = y;
        }
    }

    DFS(nr);

    cout<<maxim<<'\n';
    for (int i=1; i<n; i++)
        cout<<Ans[i]<<'\n';
    return 0;
}



Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rusha() scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb() scanf("%d",&t);while(t--)
#define debug(x) cout<<"LBWNB    "<<x<<"---\n"
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define p() puts("")
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
using namespace std;
typedef long long ll;
const int mod=998244353;
const int inf=1e9+7;
const int maxn=2e5+10;
int t,n,m;
char a[maxn];
int main(){
    scanf("%s",a+1);
    int s=strlen(a+1);
    int k=(s-1)/2,f=1,kk=(s+3)/2;
    rep(i,1,k) if(a[i]!=a[k+1-i]) f=0;
    rep(i,kk,s) if(a[i]!=a[s+1-i]) f=0;
    rep(i,1,s) if(a[i]!=a[s+1-i]) f=0;
    printf("%s\n",f?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int left(int);
int right(int);
void maxHeapify(int);
void buildHeap();
int A[500000];
int H;
int main(){
	int i;
	scanf("%d",&H);
	for(i=1;i<=H;i++){
		scanf("%d",&A[i]);
	}
	buildHeap();
	for(i=1;i<=H;i++){
		printf(" %d",A[i]);
	}
	printf("\n");
	return 0;
}
int left(int key){
  return 2*key;
}

int right(int key){
  return 2*key+1;
}

void maxHeapify(int i){
	int l,r,largest,tmp;
	l = left(i);
	r = right(i);
	if(l <= H && A[l] > A[i] ) largest = l;
	else largest = i;
	if(r <= H && A[r] > A[largest]) largest = r;
	if(largest != i){
		tmp = A[i];
		A[i] = A[largest];
		A[largest] = tmp;
		maxHeapify(largest);
	}
}

void buildHeap(){
	int i;
	for(i=H/2;i>=1;i--){
		maxHeapify(i);
	}
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vch = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

int main(){
  ll n, m, q;
  cin >> n >> m >> q;
  vll a(q), b(q), c(q), d(q);
  rep(i, 0, q) cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);

  ll ans = 0;
  vll seq(11, 1);
  for(seq.at(1) = seq.at(0); seq.at(1) < m + 1; seq.at(1)++)for(seq.at(2) = seq.at(1); seq.at(2) < m + 1; seq.at(2)++)
  for(seq.at(3) = seq.at(2); seq.at(3) < m + 1; seq.at(3)++)for(seq.at(4) = seq.at(3); seq.at(4) < m + 1; seq.at(4)++)
  for(seq.at(5) = seq.at(4); seq.at(5) < m + 1; seq.at(5)++)for(seq.at(6) = seq.at(5); seq.at(6) < m + 1; seq.at(6)++)
  for(seq.at(7) = seq.at(6); seq.at(7) < m + 1; seq.at(7)++)for(seq.at(8) = seq.at(7); seq.at(8) < m + 1; seq.at(8)++)
  for(seq.at(9) = seq.at(8); seq.at(9) < m + 1; seq.at(9)++)for(seq.at(10) = seq.at(9); seq.at(10) < m + 1; seq.at(10)++){
    ll summ = 0;
    rep(i, 0, q) if(seq.at(b.at(i)) - seq.at(a.at(i)) == c.at(i)) summ += d.at(i);
    chmax(ans, summ);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int x = 0;
        int ans = 0;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] strArray = sc.next().split("");
        for (String s : strArray) {
           if (s.equals("I")) {
               x += 1;
           } else {
               x -= 1;
           }
           ans = Math.max(ans, x);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
package main

import (
	"container/heap"
	"fmt"
)

type Item struct {
	priority int
}

type PriorityQueue []*Item

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	return pq[i].priority > pq[j].priority
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *PriorityQueue) Push(x interface{}) {
	item := x.(*Item)
	*pq = append(*pq, item)
}

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

func main() {
	var N, M, w, r int
	fmt.Scan(&N, &M)

	pq := make(PriorityQueue, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&w)
		pq[i] = &Item{
			priority: w,
		}
	}
	heap.Init(&pq)

	for i := 0; i < M; i++ {
		p := heap.Pop(&pq).(*Item)
		item := &Item{
			priority: p.priority / 2,
		}
		heap.Push(&pq, item)
	}
	for pq.Len() > 0 {
		p := heap.Pop(&pq).(*Item)
		r += p.priority
	}
	fmt.Println(r)
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll ara[200005], b[200005];
bool chck(int n, ll k, ll r)
{
    for(int i=0; i<n; i++)
    if((ara[i]*b[i])>r)
    {
        ll x= r/b[i];
        k-= (ara[i]-x);
        if(k<0)return 0;
    }
    return 1;
}
int main()
{
    ll n, k, sum= 0;
    scanf("%lld %lld", &n, &k);
    for(int i=0; i<n; i++)scanf("%lld", &ara[i]);
    for(int i=0; i<n; i++)scanf("%lld", &b[i]);
    sort(ara, ara+n, greater<ll>());
    sort(b, b+n);
    ll lo= 0, hi= 1000000000001ll, res, cnt= 100;
    while(lo<=hi && cnt--)
    {
        ll mid= (lo+hi)>>1;
        if(chck(n, k, mid))res= mid, hi= mid-1;
        else lo= mid+1;
    }
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	Scanner scanner = new Scanner(System.in);
	String s = scanner.nextLine();
	int count = 0;
	for(int i = 0;i < s.length() / 2;i++){
	    if(!(s.charAt(i) == s.charAt(s.length() - i - 1))){
		count++;
	    }		
	}
	System.out.println(count);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long N,i;
	cin>>N;
	long long A[N],c=0;
	for(i=1;i<=N;i++)
	{
		cin>>A[i];
		c^=A[i];
 }
if(c==0)
	cout<<"Yes";
else cout<<"No";




}

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

int n, ans;
vector<int> v;
vector<pair<int, int> > q;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++){
		int a;
		cin >> a;
		v.push_back(a);
	}	
	sort(v.begin(), v.end());
	int t = v[0], c = 1;
	for (int i = 1; i < n; i++){
		if(v[i] != v[i - 1]){
			q.push_back({t, c});
			t = v[i];
			c = 1;
		}
		else
			c++;
	}
	if(c > 0)
		q.push_back({v[n - 1], c});
	
	for (auto p : q){
		if(p.second < p.first)
			ans += p.second;
		if(p.second > p.first)
			ans += p.second - p.first;
	}
	cout << ans;
}



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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, r);
  if (r < 1200) {
    out("ABC");
  } else if (r < 2800) {
    out("ARC");
  } else {
    out("AGC");
  }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <queue>
#define REP(i, n) for (ll i = 1; i <= n; i++)
#define rep(i, n) for (ll i = 0; i < n; i++)
#define ll long long
#define ld long double
using namespace std;

int main()
{
    ll a,b,c,d; // a <= x <= b  , c <= y <= d
    ll ans = 0;
    cin >> a >> b >> c >> d;
    ans = max(a * c, b * d);
    //ans = max(ans,a*b);
    ans = max(ans,b*c);
    ans = max(ans,a*d);
    //ans = max(ans,c*d);
    cout << ans << endl;
}

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

int main(){
  int y, z, E, res;
  
  while(cin >> E){
    if(!E) break;
    res = 1000000;
    for(z=0; z*z*z<=E; ++z){
      for(y=0; y*y+z*z*z<=E; ++y){
	res = min(res, E-(y*y+z*z*z) + y + z);
      }
    }
    cout << res << endl;
  }
  return 0;
}

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

int main()
{
    long long  a,b,tmp, r,x;
    std::cin >> a >> b;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    x = a*b;
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }

    std::cout << x/b  << std::endl;
    return 0;
}


Measured memory_bytes: 256
//"BISMILLAHIR RAHMANIR RAHIM"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const long long M = 1e8 ;
int main()
{
    string s,t;
    cin>>s>>t;
    int a= s.size();
    int b = t.size();
    int num= a-b+1;
    int k;
    int ans= 10000;
    for(int i=0;i<num;i++){
        int cnt=0,k=0;
        for(int j=i;j<b+i;j++){
            if(s[j]!=t[k])
                cnt++;
            k++;
        }
        ans = min(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3592
N=int(input())
XL=[list(map(int,input().split())) for i in range(N)]

R=[]
for i in range(N):
    a=max(0,XL[i][0]-XL[i][1])
    b=XL[i][1]+XL[i][0]
    R.append([b,a])
R.sort()

ans=0
con_l=0
for i in range(N):
    if con_l <= R[i][1]:
        ans += 1
        con_l = R[i][0]
print(ans)

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

int main() 
{
    int N, K;
    cin >> N >> K;
    vector<int> fruits(N);

    for (int i = 0; i < N; i++)
    {
        cin >> fruits[i];
    }

    sort(fruits.begin(), fruits.end());

    int res = 0;
    for (int i = 0; i < K; i++)
    {
        res += fruits[i];
    }

    cout << res << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(void) {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d || (abs(b - a) <= d && abs(c - b) <= d  ) )
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int w = sc.nextInt();
    int n = sc.nextInt();
    int[] values = new int[w];
    for(int i=0;i<values.length;i++){
      values[i]=i+1;
    }
    for(int i=0;i<n;i++){
      String str = sc.next();
      String[] ab = str.split(",");
      int a = Integer.parseInt(ab[0]) - 1;
      int b = Integer.parseInt(ab[1]) - 1;
      int work;
      work = values[a];
      values[a] = values[b];
      values[b] = work;
    }
    for(int i=0;i<values.length;i++){
      System.out.println(values[i]);
    }
  }
}

Measured memory_bytes: 26360
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll n,cnt=0; cin>>n;
	string s; cin>>s;
	for(auto i=0;i+2<n;){
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){++cnt; i+=3;}
		else
			++i;
	}
	cout<<cnt<<'\n';
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 256
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <set>
#include <list>

using namespace std;

typedef struct {
    int x, y;
} pos_t;

typedef struct {
    pos_t *a, *b;
} path_t;

path_t make_path(pos_t *a, pos_t *b) {
    path_t t;
    t.a = a;
    t.b = b;
    return t;
}


int main() {
    int n = 0;
    scanf("%d", &n);
    pos_t *p = (pos_t *) malloc(sizeof(pos_t) * n);
    pos_t **px = (pos_t **) malloc(sizeof(pos_t *) * n);
    pos_t **py = (pos_t **) malloc(sizeof(pos_t *) * n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &p[i].x, &p[i].y);
        px[i] = py[i] = &p[i];
    }
    auto cpx = [](pos_t *a, pos_t *b) { return a->x == b->x ? a < b : a->x < b->x; };
    auto cpy = [](pos_t *a, pos_t *b) { return a->y == b->y ? a < b : a->y < b->y; };

    sort(px, px + n, cpx);
    sort(py, py + n, cpy);

    auto dist = [](path_t &a) { return min(abs(a.a->x - a.b->x), abs(a.a->y - a.b->y)); };
    auto comp = [&dist](path_t &a, path_t &b) { return dist(a) > dist(b); };

    priority_queue<path_t, deque<path_t>, typeof(comp)> q(comp);
    set<pos_t *> t;
    int r = 0;

    t.insert(&p[0]);

    auto pushnext = [&, px, py, cpx, cpy](pos_t *pp) {
        auto rx = lower_bound(px, px + n, pp, cpx);
        auto ry = lower_bound(py, py + n, pp, cpy);
        if (rx != px) q.push(make_path(*rx, *(rx - 1)));
        if (rx + 1 != px + n) q.push(make_path(*rx, *(rx + 1)));
        if (ry != py) q.push(make_path(*ry, *(ry - 1)));
        if (ry + 1 != py + n) q.push(make_path(*ry, *(ry + 1)));
    };

    pushnext(&p[0]);

    while (t.size() != n) {
        auto pp = q.top();
        q.pop();
        if (t.find(pp.b) == t.end()) {
            r += dist(pp);
            t.insert(pp.b);
            pushnext(pp.b);
        }
    }
    printf("%d\n", r);
    return 0;
}

Measured memory_bytes: 11520
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

MOD = 2  # type: int

def solve(N: int, P: int, A: "List[int]"):

    if all([i%2 == 0 for i in A]):
        if P == 0:
            print(2**N)
        else:
            print(0)

    else:
        od = len([i%2 == 1 for i in A])
        print(2**(N-1))

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
	int h, m, hl, ml;
	double angle, radian, ans;
	scanf("%d%d%d%d", &hl, &ml, &h, &m);
	angle = fabs(0.5 *( h * 60 + m) - 6 * m * 0.1 * 10);
	//cout<<angle<<endl;
	if(angle > 180) angle = 360 - angle;
	if(angle == 0) 
	{
		printf("%d", abs(hl - ml));
		return 0;
	}
	if(angle == 180) 
	{
		printf("%d", hl + ml);
		return 0;
	}
	printf("%.20f", sqrt(hl * hl + ml *ml - 2 * hl * ml * cos(angle * M_PI/180)));
	return 0;
} 

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

#define rep(i,n) for (int i=0; i<(n); i++)
const int INF =1001001001;
const ll BIG = 1000000007;

int main(){
    int n;
    cin >> n;
    n = n % 10;
    if(n==3) cout << "bon" << endl;
    else if(n==2||n==4||n==5||n==7||n==9) cout << "hon" << endl;
    else cout << "pon" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

LL A, B, N;

LL func(LL x) {
	return floor((LD)A * x / B) - A * floor((LD)x / B);
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> A >> B >> N;
	LL ans = 0;
	if (N < B) {
		cout << func(N) << "\n";
	}
	else if (N == B) {
		cout << func(N - 1) << "\n";
	}
	else {
		cout << func(B - 1) << "\n";
	}
	return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b;
  int c[110];
  int tmp;
   cin >> a >> b;
  int d = a;
  int count1 = 0;
  int count2 = 0;

  if(b==0){
   cout << a << endl;
  }
 else{
   for(int i=0;i<b;i++){
  cin >> c[i];
 }
   for(int m=0;m<b-1;m++){
    int j = m;
       for(int k=m+1;k<b;k++){
         if(c[j]<c[k]){ j=k; }
       }
     tmp = c[j];
     c[j]=c[m];
     c[m]=tmp;
   }

  for(int j=0;j<b;j++){
   if(a==c[j]){
    a--;
     count1++;
   }
  }
    for(int j=b-1;j>=0;j--){
   if(d==c[j]){
    d++;
     count2++;
   }
  }
   if(count2<count1){
     cout << d << endl;
   }
else{
cout << a << endl;
  
 }
 }
}


Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++)
    {
        if(i % 2 == 0)
        {
            if(s[i] == 'L')
            {
                cout << "No" << endl;
                exit(0);
            }
            else
            continue;
            
            
        }
        else
        {
            if(s[i] == 'R')
            {
                cout << "No" << endl;
                exit(0);
            }
            else
            continue;
            
        }
    }
    cout << "Yes" << endl;

    return 0;
}


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

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

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

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

template<class T>
struct UnionFind {
    vector<T> par,rank,large;

    void init(T N){
        rank.assign(N,0);
        large.assign(N,1);
        par.resize(N);
        for(T i= 0; i < N; i++){
            par[i]=i;
        }
    }

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

    void unite(T x, T y) {
        T rx = root(x);
        T ry = root(y);
        if (rx == ry) return;
        if(rank[rx]<rank[ry]) {
            par[rx]=ry;
            large[ry]+=large[rx];
            large[rx]=0;
        }
        else {
            par[ry]=rx;
            large[rx]+=large[ry];
            large[ry]=0;
            if(rank[rx]==rank[ry])rank[x]++;
        }
    }

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

    T size(int x) {
        return large[root(x)];
    }
};

int main() {
    ll N,M;
    cin>>N>>M;
    UnionFind<ll> tree;
    tree.init(N);
    rep(i,M){
        ll x,y;
        cin>>x>>y;
        x--;
        y--;
        tree.unite(x,y);
    }
    ll ans = 0;
    rep(i,N) chmax(ans,tree.size(i));
    cout<<ans<<endl;
}

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

int main(){
  string S;
  cin >> S;
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX_N (100000)
#define rep(i, n) for(int i = 0; i < n; i++)

int main(void) {
  int A, B, C;
  scanf("%d %d %d", &A, &B, &C);

  C -= (A - B);
  if(C < 0) C = 0;
  printf("%d\n", C);
  return 0;
}


Measured memory_bytes: 128
def judge(c, north, west):
    if (c[north][west+1] - c[north][west]) != (c[north+1][west+1] - c[north+1][west]):
        return False
    elif (c[north+1][west] - c[north][west]) != (c[north+1][west+1] - c[north][west+1]):
        return False
    
    return True

def find_ans(c):
    for i in range(2):
        for j in range(2):
            if not judge(c,i,j):
                return False
            
    return True

c = []
for i in range(3):
    c.append(list(map(int, input().split())))

if find_ans(c):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
def main():
    from bisect import bisect_left

    s = input()
    n = len(s)

    RL = []
    for i in range(n - 1):
        pair = s[i:i + 2]
        if pair == 'RL':
            RL.append(i)

    cnt = [0] * n
    for i, c in enumerate(s):
        if c == 'R':
            j = bisect_left(RL, i)
            j = RL[j]
            if (j - i) % 2 == 0:
                cnt[j] += 1
            else:
                cnt[j + 1] += 1
        else:
            j = bisect_left(RL, i)
            j -= 1
            j = RL[j]
            if (j - i) % 2 == 0:
                cnt[j] += 1
            else:
                cnt[j + 1] += 1
    print(*cnt)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 8288
k, a, b = gets.split.map(&:to_i)
c = 1
y = 0

if b - a > 2
  if k >= a - 1
    k -= (a + 1)
    c  = b
  end
  c += (k / 2) * (b - a)
  k  = k % 2
end
if k > 0
  c += k
end

puts c


Measured memory_bytes: 1788