akhauriyash/Code-Regression huggingface dataset:
// //Coded by Abhijay Mitra
// #include <iostream>
// #include <stdlib.h>
// #include <algorithm>
// #include <cstdio>
// #include <numeric>
// #include <cstring>
// #include <numeric>
// #include <vector>
// #include <iterator> 
// #include <map>
// #include <set>
// #include <climits>
// #include <queue>
// #include <cmath>
// #include <stack>
// #include <cctype>
// #include <bitset>
#include <bits/stdc++.h>
// #define double long double
#define int long long int
// #define ll int
// #define ibs ios_base::sync_with_stdio(false)
// #define cti cin.tie(0)
// #define bp __builtin_popcount
// #define pb push_back
// #define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
// #define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
// #define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
// #define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
// using vi = std::vector<int>;
// using vvi = std::vector<vi>;
// using pii = std::pair<int,int>;
// using vpii = std::vector<pii>;
// using vvpii = std::vector<vpii>;
// #define mp         make_pair
// #define rep(i,a,b) for (int i = a; i <= b; i++)
// #define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
// const int N=2e6+10;
// const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
// const double Pi = 3.14159265;
#define F first
#define S second

int n, ans;

void Solve(vector<pair<int, int>>& cams)
{
    priority_queue<int> pq;
    // int result = 0;
    int initalAns = ans;

    for(auto i : cams)
    {
        pq.push(-i.second);
        ans+=i.second;
        //we assume its left is best
        while(pq.size()>i.first)ans+=pq.top(),pq.pop();
    }

}

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

    int testcases;
    cin >> testcases;
    while(testcases--)
    {

        cin>>n;ans=0;

        std::vector<pair<int, int>> f;
        std::vector<pair<int, int>> b;

        for(int i = 1; i <=  n; i++)
        {
            int K, L, R;
            cin >> K >> L >> R;

            if(L>R)
            {
                ans+=R;
                f.push_back({K,L-R});
            }
            else{
                ans+=L;
                b.push_back({n-K,R-L});
            }
        }

    // rep(i,1,n)cin>>k[i]>>l[i]>>r[i];
    // rep(i,1,n){
    //     if(l[i]>r[i]){
    //         ans+=r[i];
    //         f.pb({k[i],l[i]-r[i]});
    //     }
    //     else{
    //         ans+=l[i];
    //         b.pb({n-k[i],r[i]-l[i]});
    //     }
    // }
    sort(all(f));
    sort(all(b));

    Solve(f);
    Solve(b);

        std::cout << ans << "\n";

    }

    return 0;
}


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

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    for(int i = 1; i <= 1000; i++){
        if(a == int(i * 0.08) && b == int(i * 0.1)){
            cout << i <<endl;
            return 0;
    }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

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

    ll n;
    cin >> n;
    string ans;
    if (n == 0) ans = "0";

    while (n != 0) {
        if (n % 2 == 0) ans = "0" + ans;
        else {
            n--;
            ans = "1" + ans;
        }
        n /= (-2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1000000000


void test_case()
{
	ll n;
	cin >> n;
	ll W;
	cin >> W;
	ll weight[n], value[n], max_value = 0;
	for (ll i = 0; i < n; i++) {
		cin >> weight[i] >> value[i];
		max_value += value[i];
	}

	ll dp[n + 1][max_value + 1];
	for (ll i = 0; i <= n; i++) {
		for (ll j = 0; j <= max_value; j++) {
			if (j == 0)
				dp[i][j] = 0;
			else if (i == 0)
				dp[i][j] = INF;
			else if (j >= value[i - 1])
				dp[i][j] = min(weight[i - 1] + dp[i - 1][j - value[i - 1]], dp[i - 1][j]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	}
	for (ll i = max_value; i >= 0; i--) {
		if (dp[n][i] <= W) {
			cout << i;
			return;
		}
	}
}


int main()
{
	fastio
	// int t;
	// cin >> t;
	// while (t--)
	test_case();
}


Measured memory_bytes: 82456
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

typedef long long ll;
typedef std::pair<int, std::string> P;

struct result {
  bool isAC;
  int WAcnt;
  result() : isAC(false), WAcnt(0) {}
  void cntupWA() {
    if (!isAC) {
      WAcnt++;
    }
  }
};

int main(void) {
  int n, m;
  std::cin >> n >> m;
  std::map<int, result> mp;
  for (int i = 0; i < m; i++) {
    int p;
    std::string S;
    std::cin >> p >> S;
    if (S == "AC") {
      mp[p].isAC = true;
    }
    else if (S == "WA") {
      mp[p].cntupWA();
    }
  }

  int cor = 0;
  int pen = 0;
  for (auto el : mp) {
    if (el.second.isAC) {
      cor++;
      pen += el.second.WAcnt;
    }
  }

  std::cout << cor << " " << pen << std::endl;

  return 0;
}


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

const ll INF = 1LL<<61;
struct edge { int from, to; ll cost; };

int main() {
  int n, m, p;
  cin >> n >> m >> p;
  vector<edge> E(n);
  for(int i=0;i<m;++i){
    int a, b, c;
    cin >> a >> b >> c;
    E.push_back(edge{a-1, b-1, p - c}); // negate to make minimize
  } 
  vector<ll> d(n, INF);
  d[0] = 0;
  for (int i = 0; i < n; i++) {
    for (const auto& e : E) {
      int u=e.from, v=e.to;
      ll cost = e.cost;
      if (d[u] == INF) continue;
      if (d[v] > d[u] + cost) {
        d[v] = d[u] + cost;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (const auto& e : E) {
      int u=e.from, v=e.to;
      ll cost = e.cost;
      if (d[v] != INF && d[v] > d[u] + cost) { //neg cycle
        d[v] = -INF;
      }
    }
  }
  if(d[n-1]==-INF) cout << -1 << '\n';
  else cout << max(0LL, -d[n-1]) << '\n';
  return 0;
}

Measured memory_bytes: 3720
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int h[251];
	for(int i = 1; i <= n; i++){
		cin >> h[i];
	}
	for(int i = 1; i <= n; i++){
		cout << "node " << i << ": key = " << h[i] << ", ";
		if(i > 1) cout << "parent key = " << h[i / 2] << ", ";
		if(2 * i <= n) cout << "left key = " << h[2 * i] << ", ";
		if(2 * i + 1 <= n) cout << "right key = " << h[2 * i + 1] << ", ";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3068
#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;

  long long ac = a * c;
  long long ad = a * d;
  long long bc = b * c;
  long long bd = b * d;

  cout << max(max(ac, ad), max(bc, bd)) << endl;

  return 0;
}


Measured memory_bytes: 3196
H, W, M = map(int, input().split())
bomb = [tuple(map(lambda a: int(a) - 1, input().split())) for _ in range(M)]

cntRow = [0] * H
cntCol = [0] * W
for h, w in bomb:
    cntRow[h] += 1
    cntCol[w] += 1

mxR = max(cntRow)
mxC = max(cntCol)

R = set([h for h in range(H) if cntRow[h] == mxR])
C = set([w for w in range(W) if cntCol[w] == mxC])

ans = mxR + mxC
if len([0 for h, w in bomb if h in R and w in C]) == len(R) * len(C):
    ans -= 1

print(ans)


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

char result[8] = "IMLU";

int main() {
    string expr;
    int ans, a, b, c, res1, res2;
    char op;
    stringstream ss, tt;
    cin >> expr >> ans;
// left-to-right
    ss << expr;
    ss >> a;
    while (!ss.eof()) {
        ss >> op;
        ss >> b;
        if (op == '+') {
            a += b;
        } else if (op == '*') {
            a *= b;
        }
    }
    res1 = a;

    ss.clear();
    // multiplication-first
    ss << expr;
    ss >> a;
    while (!ss.eof()) {
        ss >> op;
        ss >> b;

        if(op == '+') {
            tt << a;
            tt << '+';
            a = b;
        } else if (op == '*') {
            a *= b;
        }
    }
    tt << a;

    ss.clear();
    ss << tt.str();
    ss >> a;
    while (!ss.eof()) {
        ss >> op;
        ss >> b;
        if (op == '+') {
            a += b;
        } else if (op == '*') {
            a *= b;
        }
    }
    res2 = a;

    int status = 0;
    if (res1 == ans) {
        status += 2;
    }
    if (res2 == ans) {
        status += 1;
    }

    cout << result[status] << endl;

    return 0;
}

Measured memory_bytes: 1236
fun main(args: Array<String>) = yorukatsu23d()

fun yorukatsu23d() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map { it.toInt() }.toIntArray()

    val arr = IntArray(n)

    for (i in n - 1 downTo 0) {
        var j = i
        var sum = 0
        while (j < n) {
            sum += arr[j]
            j += i + 1
        }
        arr[i] = if (sum % 2 == aList[i]) 0 else 1
    }

    val map = arr.withIndex().filter { it.value != 0 }.map { it.index + 1 }
    val answer = buildString {
        appendln(map.size)
        if (map.isNotEmpty()) appendln(map.joinToString(" "))
    }

    print(answer)
}


Measured memory_bytes: 67644
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[][] inter = new int[N][2];
        int a,l;

        for (int i = 0; i < N; i++) {
           a = sc.nextInt();
           l = sc.nextInt();
           inter[i][0] = a-l;
           inter[i][1] = a+l;
        }

        int res = 0;
        int now = -9999999;

        Arrays.sort(inter, (x, y) -> Integer.compare(x[1], y[1]));

        for (int i = 0; i < N; i++) {
            if (now > inter[i][0]) continue;
            res++;
            now = inter[i][1];
        }

        System.out.println(res);

    }
}

Measured memory_bytes: 96156
#include <cmath>
#include <string.h>
#include <iostream>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <algorithm>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_nested(i, s, n) for (int i = s; i <= n; i++)
#define ll long long
#define ull unsigned long long

const int N = 500;
const ll INF = 1000000007;

using namespace std;

template <class T>
T limit(T n, T k) {
	return (n > k) ? k : n;
}

template <class T>
T has_order(T a, T b, T c) {
	return (b > a && b < c) || (b < a && b > c);
}

int count_number_divide_k();

int main() {
	cout << count_number_divide_k() << endl;
    return 0;
}

int count_number_divide_k() {
	int n, k;
	
	cin >> n;
	
	vector<int> v(n, 0);
	
	rep(i, n) {
		cin >> v[i];
	}
	
	sort(v.begin(), v.end());
	
	k = n / 2;
	
	if (v[k] == v[k - 1]) {
		return 0;
	}
	
	return v[k] - v[k - 1];
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	if(abs(n-m)>1){
		cout << 0 << endl;
		return 0;
	}
	ll ans=1;
	rep(i,n){
		ans*=i+1;
		ans%=mod;
	}
	rep(i,m){
		ans*=i+1;
		ans%=mod;
	}
	if(n==m){
		ans*=2;
		ans%=mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
const int Maxn = 10;
char f[Maxn][Maxn];

int main() {
    int h, w, s = 0;
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> f[i][j];
            if (f[i][j] == '#') ++s;
        }
    }

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (i == h - 1 && j == w - 1) break;
            if (f[i][j] == '#' && f[i + 1][j] != '#' && f[i][j + 1] != '#') {
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }

    if (s != h + w - 1) cout << "Impossible" << endl;
    else cout << "Possible" << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000)
n,m=map(int,input().split())
bridge=[list(map(int,input().split())) for _ in range(m)]
def dfs(v):
    for i in g[v]:
        if visited[i]==0:
            visited[i]=1
            dfs(i)
    return

cnt=0
for i in range(m):
    g=[[] for _ in range(n)]
    visited=[0 for i in range(n)]
    bridge_=bridge[:i]+bridge[i+1:]
    for i in range(m-1):
        g[bridge_[i][0]-1].append(bridge_[i][1]-1)
        g[bridge_[i][1]-1].append(bridge_[i][0]-1)
#    print(g)
    dfs(0)
    if 0 in visited:
        cnt+=1
print(cnt)



Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
  char n[3];
  scanf("%s",n);
  if((n[0] < n[1]) ||( n[0] < n[2])){
    n[0] += 1;
  }
  printf("%c%c%c\n",n[0],n[0],n[0]);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int N;
int A[100000];
int M,sum;


int main(void){
    cin >> N;
    rep(i,N){cin >> A[i];}
    M=0;
    sum = 0;
    rep(i,N-1){
        if(A[i] >= A[i+1]){
            sum++;
        }else{
            sum =0;
        }
        M = max(sum,M);
    }
    cout << M << endl;
    return 0;
}


Measured memory_bytes: 640
//  Copyright © 2019 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 1000005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
typedef long long i64;

// REMEMBER SPECIAL CASE = 1
int pr[MAX];
void sieve( int LIM ) {
    
    for( int i = 2; i <= sqrt( LIM ); i ++ )
        if( ! pr[i] ) 
            for( int j = i * i; j <= LIM; j += i )
                if( ! pr[j] )
                    pr[j] = i;
}

const int LIM = 1e5 + 500;


int main()
{
    optimiza_io
    
    sieve(  LIM );
    int X;
    cin >> X;
    for( int i = X; i <= LIM; i ++ )
        if( ! pr[i] ) {
            cout << i << "\n";
            exit( 0 );
        }
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,i,c=0;
	char s[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%c",&s[i]);
		if(s[i]=='Y') c=1;
	}
	if(c==1) printf("Four\n");
	else printf("Three\n");
	return 0;
}


Measured memory_bytes: 1640
#include <bits/stdc++.h>
#define rep(i, e, n) for (int i = e; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const ll inf=1000000000007;

int main() {
  int n,m,c;
  cin >> n >> m >>c;
  vector<int> b(m);
  rep(i,0,m) cin >> b[i];
  ll ans=0;
  rep(i,0,n){
    vector<int> a(m);
    rep(j,0,m) cin >> a[j];
    ll total=0;
    rep(j,0,m){
      total+= a[j]*b[j];
    }
    total +=c;
//    cout << total << endl;
    if(total>0) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3612
N = int(input())
H = [int(_) for _ in input().split()]
YN = 0

for i in range(N-1):
    if H[N-i-2] > H[N-i-1]:
        H[N-i-2] -= 1
        if H[N-i-2] < 0:
            H[N-i-2] = 0

for i in range(N-1):
    if H[N-i-2] > H[N-i-1]:
        YN = 1
        break

if YN == 0:
    print('Yes')

else:
    print('No')

Measured memory_bytes: 14704
#include <stdio.h>
 
 
int main(int argc, char *argv[]) {
 
    int h = 0, m = 0, s = 0;
    int in = 0;
 
    scanf("%d", &in);
 
    h = in / 3600;
    m = ( in % 3600 ) / 60;
    s = ( in % 3600 ) % 60;
 
    printf("%d:%d:%d\n", h, m, s);
 
    return 0;
 
}

Measured memory_bytes: 592
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;

int n;
int x[10];
int y[10];

double dist(int i, int j) {
  double dx = x[i] - x[j];
  double dy = y[i] - y[j];
  return pow(dx * dx + dy * dy, 0.5);
}

int fact(int x) {
  int ans = 1;
  for (size_t i = 2; i <= x; i++) {
    ans *= i;
  }
  return ans;
}

int main() {
  cin >> n;
  for (size_t i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  double sum = 0;
  vector<int> v(n);
  for (size_t i = 0; i < n; i++) {
    v[i] = i;
  }
  do {
    for (size_t i = 0; i < n - 1; i++) {
      sum += dist(v[i], v[i + 1]);
    }
  } while (next_permutation(v.begin(), v.end()));
  cout << fixed << setprecision(10) << sum / fact(n) << endl;
  return 0;
}

Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;

long long gcd(long long x, long long y){
			if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }

int main(){
int N;
cin >> N;
vector<int> a(N);
for(int i = 0;i<N;i++)cin >> a[i];
long long ans = 0;
for(int i = 0;i < N; i++){
	ans += a[i]-1;
}
cout << ans <<endl;
}



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

int main() {
  int a[5];
  rep(i, 5) cin>>a[i];
  
  int b[5];
  int sum = 0;
  rep(i, 5) {
    if (a[i]%10==0) b[i] = a[i];
    else b[i] = ((a[i]/10)+1)*10;
  }
  rep(i, 5) sum+=b[i];

  int ans = 1e9;
  rep(i, 5) {
    int tmp = sum - b[i] + a[i];
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    string S;
    int Q;
    cin >> S >> Q;

    string prefix = "", suffix = "";
    bool rev = false;
    rep(i, Q) {
        int t;
        cin >> t;
        if (t == 1) {
            rev = !rev;
        }
        else {
            int f;
            char c;
            cin >> f >> c;
            if (f == 2 ^ rev) {
                suffix.push_back(c);
            }
            else {
                prefix.push_back(c);
            }
        }
    }
    if (rev) {
        reverse(all(S));
        swap(prefix, suffix);
    }
    reverse(all(prefix));
    write(prefix + S + suffix);
}

Measured memory_bytes: 1300
#ifdef LOCAL
#define debug(_) cerr << #_ << ": " << (_) << '\n'
#define _GLIBCXX_DEBUG
#else
#define debug(_) (void(0))
#endif  // LOCAL

#include <bits/stdc++.h>

#include <atcoder/all>
using namespace std;
using namespace atcoder;

const long long MOD = 998244353;
const long long mask32 = (1ll << 32) - 1;

long long op(long long m1, long long m2) {
    long long v1 = m1 >> 32;
    long long l1 = m1 & mask32;
    long long v2 = m2 >> 32;
    long long l2 = m2 & mask32;
    long long v = (v1 * pow_mod(10, l2, MOD) + v2) % MOD;
    long long l = l1 + l2;
    return (v << 32) + l;
}

long long e() { return 0; }

long long inv9 = pow_mod(9, MOD - 2, MOD);

long long mapping(long long o, long long m) {
    if (o == -1)
        return m;
    else {
        long long l = m & mask32;
        long long v = o * (pow_mod(10, l, MOD) - 1) * inv9 % MOD;
        return (v << 32) + l;
    }
}

long long composition(long long f, long long g) { return (f == -1 ? g : f); }

long long id() { return -1; }

int main() {
    long long N, Q;
    cin >> N >> Q;
    vector<long long> v(N, (1ll << 32) + 1);

    lazy_segtree<long long, op, e, long long, mapping, composition, id> lst(v);

    for (int i = 0; i < Q; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        lst.apply(l - 1, r, d);
        cout << (lst.all_prod() >> 32) << '\n';
    }
}

Measured memory_bytes: 10952
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int R;
  cin >> R;
  cout << setprecision(10) << 2 * 3.1415926535 * R << endl;
  return 0;
}


Measured memory_bytes: 3780
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int m = sc.NextInt();

        List<int>[] nums = new List<int>[n];

        for (int i = 0; i < n; i++)
        {
            List<int> person = new List<int>();
            int k = sc.NextInt();
            for (int j = 0; j < k; j++)
            {
                person.Add(sc.NextInt());
            }
            nums[i] = person;
        }

        int answer = 0;
        for (int i = 1; i <= m; i++)
        {
            bool ok = true;
            for (int j = 0; j < n; j++)
            {
                if (!nums[j].Contains(i))
                {
                    ok = false;
                    break;
                }
            }
            if (ok)
            {
                answer++;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

int main()
{
string s,t;
int c=0,j=0;
cin >> s >> t;

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

       if (s[i]!=t[j]){
        c++;
       }
       j++;
}

cout << c << endl;

	return 0;

}


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

int main(){
    int N, flag, count=0;
    cin >> N;
    vector<int> list(N);
    for (int i=0; i<N; i++){
        cin >> list.at(i);
    }
    flag = 1;
    while (flag){
        flag = 0;
        for (int i=N-1; i>0; i--){
            if (list.at(i)<list.at(i-1)){
                swap(list.at(i), list.at(i-1));
                flag = 1;
                count++;
            }
        }
    }
    for (int i=0; i<N; i++){
        if (i==N-1){
            cout << list.at(i) << endl;
        }else{
            cout << list.at(i) << ' ';
        }
    }
    cout << count << endl;
}


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

int main(){
	long long x;
	cin >> x;
	long long ans = 0;
	ans += x/11;
	ans *= 2;
	x = x%11;
	if(x == 0){
		
	}else if(x <= 6){
		ans++;
	}else{
		ans+=2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int r, g, b;
  scanf ("%d %d %d", &r, &g, &b);
  int q = 10*g + b;
  if (q%4 == 0){
    printf("YES");
  }else {
    printf("NO");
  }
  return 0;
}


Measured memory_bytes: 1736
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val l = sc.nextInt()
    val max = l + n - 1
    val sum = (0 until n).map { l + it }.sum()
    if (l <= 0 && max >= 0) {
        println(sum)
    } else if (l < 0) {
        println(sum - max)
    } else {
        println(sum - l)
    }
}

Measured memory_bytes: 29604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] tmp = br.readLine().split(" ");
		StringBuilder sb = new StringBuilder();
		int n = Integer.parseInt(tmp[0]);
		int h = Integer.parseInt(tmp[1]);

		if(h % 100 != 0) {
			sb.append(tmp[1]);
			for(int i = 0; i < Integer.parseInt(tmp[0]); i++) {

				sb.append("00");
			}
		}else {

			sb.append(h + 1);
			for(int i = 0; i < Integer.parseInt(tmp[0]); i++) {

				sb.append("00");
			}
		}



		System.out.println(sb.toString());

	}
}


Measured memory_bytes: 32580
#include<cstdio>
#include<algorithm>
#include<functional>
#define M 1000000007
using namespace std;
long long a[300000];
int main(void)
{
	int n,i,j,c[61];
	long long sum,mask,s2,x;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%lld",&a[i]);
	mask=1;
	for(i=0;i<60;i++)	{
		c[i]=0;
		for(j=0;j<n;j++)	{
			x=a[j]&mask;
			if(x!=0)	c[i]++;
		}
		mask*=2;
	}
	mask=1;
	sum=0;
	for(i=0;i<60;i++)	{
		x=mask%M;
		x=(x*c[i])%M;
		x=(x*(n-c[i]))%M;
		sum+=x;
		sum%=M;
		mask*=2;
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 2560
n=int(input())
s=list(input())
l=[]
ctl=0;ctr=0
for i in range(n):
  if s[i]=='(':
    ctl+=1
  else:
    ctr+=1
  if ctl<ctr:
    l.append('(')
    ctl+=1
l.reverse()
for i in range(ctl-ctr):
  s.append(')')
s=l+s
print(''.join(s))

Measured memory_bytes: 3064
#!/usr/bin/env python3
n = int(input())
s = [input() for _ in range(n)]
cnt = [50]*26 #a~z の出現回数　のmin INFしょきか
for i in range(n):
    tmp = [0]*26
    for c in s[i]:
        tmp[ord(c)-97] += 1
    for j in range(26):
        cnt[j] = min(cnt[j],tmp[j])
#出力は辞書順最小
for c in range(26):
    print(chr(97+c)*cnt[c],end="")

Measured memory_bytes: 3064
def slove():
    import sys
    import heapq
    input = sys.stdin.readline
    n, h = list(map(int, input().rstrip('\n').split()))
    m_k = 0
    t = []
    heapq.heapify(t)
    for i in range(n):
        a, b = list(map(int, input().rstrip('\n').split()))
        m_k = max(m_k, a)
        heapq.heappush(t, -b)
    cnt = 0
    while True:
        if len(t) != 0:
            p = heapq.heappop(t)
            if m_k < -p:
                h += p
                cnt += 1
                if h <= 0:
                    print(cnt)
                    exit()
            else:
                break
        else:
            break
    print((h + m_k - 1) // m_k + cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 52188
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<P> vp;
typedef vector<T> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n, k;
  cin >> n >> k;
  vector<double> p(n);
  rep(i,n) cin >> p[i];
  vector<double> e(n);
  rep(i,n) e[i] = (1+p[i])/2;
  double ans = 0;
  double s = 0;
  queue<double> q;
  rep(i,n) {
    s += e[i];
    q.push(e[i]);
    if (q.size() > k) {
      s -= q.front(); q.pop();
    }
    if (q.size() == k) ans = max(ans, s);
  }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 4992
import numpy as np
from itertools import combinations, permutations
import math

N = int(input())
t = np.zeros((N, 2))
for _ in range(N):
    t[_] = np.array(list(map(int, input().split())))

def distance(i, j):
    return np.sqrt(np.sum((t[i] - t[j])**2))

dm = np.zeros((N,N))

for i, j in combinations(range(N), 2):
    dm[i, j] = distance(i, j)

total = 0
for r in permutations(range(N), N):
    r = list(r)
    for i, j in zip(r[:-1], r[1:]):
        total += dm[min(i,j),max(i,j)]
    
res = total / math.factorial(N)
print(res)


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

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

int main(){
int A,B;
cin>>A>>B;
int ans=0;
if(A-2*B>0){
    ans=A-2*B;
}
cout<<ans<<endl;
 return 0;
}
/*
12 4

4

20 15

0

20 30

0

*/

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
int main() {
	int a, b;
	cin >> a >> b;
	
	string abstr = to_string(a) + to_string(b);
	int ab = stoi(abstr);
	string ans = "No";
	REP(i, 1, 1000) {
		if (i * i == ab) {
			ans = "Yes";
		}		
	}
	cout << ans << endl;
}





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

class Chain {
  public:
    int len;
    bool is_reversed;
    Chain() { len = 0; is_reversed = false; }
    Chain(int x) { len = x; is_reversed = false; }
    Chain(int x, bool flag) { len = x; is_reversed = flag; }
};

int main()
{
  int n, k;
  std::string input;
  std::cin >> n >> k;
  std::cin >> input;
  bool is_reversed = false;
  int len = 0;
  std::vector<Chain> chain;
  for (char ch : input) {
    if (ch == '0') {
      if (len == 0) {
        len = 1;
        is_reversed = false;
        continue;
      }
      if (is_reversed) {
        chain.push_back(Chain(len, is_reversed));
        len = 1;
        is_reversed = false;
      } else {
        len += 1;
      }
    } else if (ch == '1') {
      if (len == 0) {
        len = 1;
        is_reversed = true;
        continue;
      }
      if (is_reversed) {
        len += 1;
      } else {
        chain.push_back(Chain(len, is_reversed));
        len = 1;
        is_reversed = true;
      }
    } else {
      std::cerr << "Unknown char found\n";
      exit(1);
    }
  }
  chain.push_back(Chain(len, is_reversed));
  int max_value = 0;
  int cnt = 0;
  int index = 0;
  for (index = 0; index < (int)chain.size(); index++) {
    if (chain.at(index).is_reversed) {
      max_value += chain.at(index).len;
    } else {
      if (cnt == k) {
        break;
      }
      cnt++;
      max_value += chain.at(index).len;
    }
  }
  int first = 0;
  int last = std::max(0, index-1);
  int value = max_value;
  while (last < (int)chain.size()) {
    if (!chain.at(first).is_reversed) {
      value -= chain.at(first).len;
      first++;
    } else {
      value -= chain.at(first).len;
      first++;
      if ((int)chain.size() <= first) {
        break;
      }
      value -= chain.at(first).len;
      first++;
    }
    last++;
    if ((int)chain.size() <= last) {
      break;
    }
    value += chain.at(last).len;
    max_value = std::max(value, max_value);
    last++;
    if ((int)chain.size() <= last) {
      break;
    }
    value += chain.at(last).len;
    max_value = std::max(value, max_value);
  }
  std::cout << max_value << '\n';
  return 0;
}


Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
#define very_slow       ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define no_of_test(x)        int x; cin>>x; while(x--)
//Actual Code Is At The Top
const int mod = 1e9 + 7;
int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}
int binary_exponentation(int a, int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = (ret * a) % mod;
		b >>= 1;
		a = (a * a) % mod;
	}
	return ret;
}

int32_t main()
{   
	very_slow
	//no_of_test(x)
	{  
      int n,m;
	  cin>>n>>m;int sum=0;
	  vector<int>a(n);
	  for(int i=0;i<n;i++)
	  {
		  cin>>a[i];
		  sum+=a[i];
	  }
	  int mini=ceil(sum/(4*m));
	  int cnt=0;
       for(int i=0;i<n;i++)
	   {
		   if(a[i]*4*m>=sum)
		   cnt++;
	   }
	   if(cnt>=m)
	   {
		   cout<<"Yes"<<'\n';
	   }
	   else
	   {
		   cout<<"No"<<'\n';
	   }
	   
	}
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()


//library mod int
template <int mod>
struct modint{
    ll x;

    //constructor
    modint(ll x=0): x((x%mod+mod)%mod){}

    //unary operator
    modint operator-() const { return modint(mod-x);}
    modint inv() const { return this->pow(mod-2);}
    
    //compound assignment
    modint& operator+=(const modint& a){
        if((x+=a.x)>=mod) x-=mod;
        return *this;
    }
    modint& operator-=(const modint& a){
        if((x-=a.x)<0) x+=mod;
        return *this;
    }
    modint& operator*=(const modint& a){
        (x*=a.x)%=mod;
        return *this;
    }
    modint& operator/=(const modint& a){
        return *this *= a.inv();
    }

    //arithmetic
    // なぜmodintの後ろに＆を書いたり書かなかったりしてるかの理解ができていない
    //おそらく＆をつけるとポインタで参照しているのでもとの値を書き換えることができる
    //＆をつけないとコピーを作ってからそれに対して計算するので、もとの値は変更されない
    modint operator-(const modint& a) const {return modint (*this) -= a ; }
    modint operator+(const modint& a) const {return modint (*this) += a ; }
    modint operator*(const modint& a) const {return modint (*this) *= a ; }
    modint operator/(const modint& a) const {return modint (*this) /= a ; }
    //n should not be smaller than 0.
    modint pow(ll n) const{
        auto x=modint(1);
        auto m=*this;
        while(n>0){
            if(n&1) x*=m;
            n>>=1;
            m*=m;
        }
        return x;
    }

    //compare
    bool operator==(const modint& a) const {return x==a.x ; }
    bool operator!=(const modint& a) const {return x!=a.x ; }

    //I/O
    friend istream& operator>>(istream& is, modint& a ) noexcept {return is >> a.x ; }
    friend ostream& operator<<(ostream& os, const modint& a ) noexcept {return os << a.x ; }
};

//modの調整
constexpr int mod = 1e9 + 7;
using mint = modint<mod>;

//////////////////////////////////////////////////////////////////////
//combination
vector<mint> mintcombvector(3e7);
int startmintcomb(){
    mintcombvector[0]=0;
    mintcombvector[1]=1;
    rep(i,3e6-5){
        mintcombvector[i+2]=mintcombvector[i+1]*(i+2);
    }
    return 0;
}
mint comb(mint a, mint b){
    if(a.x<b.x || a.x<=0 || b.x<0) return mint(0);
    if(b.x==0) return mint(1);
    if(a==b) return mint(1);
    return mintcombvector[a.x]*(mintcombvector[b.x].inv())*(mintcombvector[a.x-b.x].inv());
}
//combinationを使いたいときは　startmintcomb(); を始めに打つこと

int main(){
    startmintcomb();
    int x,y;
    cin>>x>>y;
    if((x+y)%3!=0){
        cout<<0<<endl;
        return 0;
    }
    int z=(x+y)/3;
    mint a=x-z, b=y-z;
    cout<<comb((a+b),b)<<endl;
    return 0;
}

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

int main(void){
    int A;
    int B;
    cin >> A >> B;

    int i=0;
    while(true){
        int A_max = i*A-(i-1);

        if(B<=A_max){
            cout << i << endl;
            break;
        }
        ++i;
    }


}


Measured memory_bytes: 256
import java.util.*;

class Main
{
    public static  void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        String s = sc.next();
        String t = sc.next();
        
        StringBuilder buf = new StringBuilder();
        
        for (int i = 0; i < n; i++) {
            buf.append(s.substring(i, i + 1));
            buf.append(t.substring(i, i + 1));
        }
        
        String ans = buf.toString();
        
        System.out.println(ans);
        
        
    }
}
        

Measured memory_bytes: 22996
// E - Colorful Hats 2
#include <bits/stdc++.h>

using namespace std;

#define	MOD	1000000007

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<long long> dp(n), c(n);
	for (int i = 0; i < n; i++) {
		int x = a[i];
		if (c[x] == 0) {
			if (x == 0) dp[i] = (i == 0 ? 1 : dp[i - 1]) * 3LL;
			else dp[i] = dp[i - 1] * c[x - 1] % MOD;
		} else {
			if (x == 0) dp[i] = dp[i - 1] * (3LL - c[x]) % MOD;
			else dp[i] = dp[i - 1] * (c[x - 1] - c[x]) % MOD;
		}
		c[x]++;
	}

	// for (int i = 0; i < dp.size(); i++) cerr << dp[i] << ' '; cerr << endl;
	cout << dp[n - 1] << endl;

	return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 long double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007LL
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  101LL
#define tmod             998244353LL
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<pair< ll ,ll > > &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
ll P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n,ll m);

bool check(int m,vector<ll> &A,int n)
{
    for(int i=0;i<=n-m;i++)
    {
        if(A[i]!=A[i+m] ) return true;
    }
    return false;
}

int main()
{
fast;
ll q=1,t;
//cin >> q; t = q;
while(q--)
{
    ll i,j,n,m,k,l,r,a=0,b=0,c=0,d=0,e,g=1,p,u,v,w,x,y,flag=0;
    //n=m=k=i=j=l=r=a=b=c=d=u=v=w=p=x=y=0;
    cin >> x >> n;
    map<int,bool> M;
    for(i=0;i<n;i++)
    {
        cin >> u;
        M[u] = true;
    }
    a = mod; b = 0;
    for(i=x;;i++)
    {
        if(!M[i])
        {
            a = abs(x-i); b = i; break;
        }
    }
    for(i=x;i>=x-n-10;i--)
    {
        if(!M[i])
        {
            if(a>= abs(x-i))
            {a = abs(x-i); b = i;}
        }
    }
    cout << b ;

}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n,ll m)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2,m);
    if(n%2==0){return (temp*temp)%m;}
    else{return (b*((temp*temp)%m))%m;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<pair<ll,ll> > &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid].F==ser)
    {
        return mid;
    }
    else if(PS[mid].F > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

void Sieve(int n)
{
    //memset(P,true,sizeof(P));
    //P[0] = false;
    //P[1]= false;
    for(int i=1;i<=n;i++) P[i] = i;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i]==i)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                if(P[j]==j)
                    P[j]=i;
            }
        }
    }

}



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

int main(){
  string s;
  int tmp, x = 753;
  int res=1000;
  cin >> s;
  for(int i=0;i<s.size()-2;i++){
    tmp = stoi(s.substr(i,3));
    res = min(res,abs(x-tmp));
  }
  cout << res << endl;
}


Measured memory_bytes: 256
package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
	wtr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()
	a := make(sts, n)

	for i := 0; i < n; i++ {
		a[i].a = i + 1
		a[i].b = scanInt()
	}

	sort.Sort(a)

	for i := 0; i < n; i++ {
		fmt.Fprint(wtr, a[i].a)
		if i != n-1 {
			fmt.Fprint(wtr, " ")
		}
	}
	fmt.Fprintln(wtr)
	wtr.Flush()

}

type st struct {
	a int
	b int
}

type sts []st

func (a sts) Len() int           { return len(a) }
func (a sts) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a sts) Less(i, j int) bool { return a[i].b < a[j].b }


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define pb push_back
#define mp make_pair
#define INF 1e15
#define mod 1000000007
#define eps 1e-6
#define abs(x) ((x)>=0?(x):-(x))
#define y1 solai
#define fi first
#define se second
typedef long long ll;
void read(ll &x)
{
	scanf("%lld",&x);
}
void read(ll &x, ll &y)
{
	scanf("%lld%lld",&x,&y);
}
void read(ll &x, ll &y, ll &z)
{
	scanf("%lld%lld%lld",&x,&y,&z);
}
void print(ll x)
{
	printf("%lld ",x);
}
void println(ll x)
{
	printf("%lld\n",x);
}
const ll N=100000;
ll n,k,sz;
string s,t[N+10];
int main()
{
	//freopen("c.cpp","r",stdin);
 
	cin>>s>>k;
	n=s.size();
	for(ll len=1;len<=min(n,5LL);len++)
		for(ll i=0;i<=n-len;i++)
			t[++sz]=s.substr(i,len);
	sort(t+1,t+sz+1);
	for(ll i=1;i<=sz;i++)
	{
		if(i==1||t[i]!=t[i-1])
			k--;
		if(k==0)
			cout<<t[i],i=sz;
	}
}

Measured memory_bytes: 2176
s = set(list(input()))

if 'N' in s:
  if not 'S' in s:
    print("No")
    exit()
  elif len(s) == 2 or len(s)==4:
    print("Yes")
    exit()
    
if 'S' in s:
  if not 'N' in s:
    print("No")
    exit()
  elif len(s) == 2 or len(s)==4:
    print("Yes")
    exit()

if 'W' in s:
  if not 'E' in s:
    print("No")
    exit()
  elif len(s) == 2 or len(s)==4:
    print("Yes")
    exit()

if 'E' in s:
  if not 'W' in s:
    print("No")
    exit()
  elif len(s) == 2 or len(s)==4:
    print("Yes")
    exit()
    
print("No")

Measured memory_bytes: 3064
N, K = map(int,input().split())
R,S,P = map(int,input().split()) #point
T = input() #r or s or p

def janken_win(x):
    if x == "r": 
        return "p"
    if x == "s": 
        return "r"
    if x == "p": 
        return "s"

def win_point(x):
    if x == "r": 
        return P
    if x == "s": 
        return R
    if x == "p": 
        return S


point = 0
janken = []
## mod group
for text in range(len(T)):
    if text < K : 
        janken.append(janken_win(T[text]))
        point = point + win_point(T[text])

    elif T[text] == T[text-K]:
        if janken[text-K] == janken_win(T[text]):
            janken.append("a")
        
        else:
            janken.append(janken_win(T[text]))
            point = point + win_point(T[text])
    
    else:
        janken.append(janken_win(T[text]))
        point = point + win_point(T[text])



print(point)

Measured memory_bytes: 4212