akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long long>v1(n + 5), v2(n + 5), v3(n + 5), dp1(n + 5), dp2(n + 5), dp3(n + 5);
    for(int i = 1; i <= n; i++){
        cin >> v1[i] >> v2[i] >> v3[i];
    }
    dp1[1] = v1[1];
    dp2[1] = v2[1];
    dp3[1] = v3[1];
    for(int i = 2; i <= n; i++){
        dp1[i] = v1[i] + max(dp2[i - 1], dp3[i - 1]);
        dp2[i] = v2[i] + max(dp1[i - 1], dp3[i - 1]);
        dp3[i] = v3[i] + max(dp1[i - 1], dp2[i - 1]);
    }
    long long x = max(dp1[n], dp2[n]);
    x = max(x, dp3[n]);
    cout << x;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

using P = pair<ll, int>;

int n;
P d[100009];
int par[100009];
int sz[100009];

ll sum[100009];

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

    cin >> n;
    rep(i, n) {
        cin >> d[i].first;
        d[i].second = i;
    }
    sort(d, d + n, greater<P>());

    memset(par, -1, sizeof(par));
    fill(sz, sz + n, 1);

    rep(i, n - 1) {
        auto [s, idx] = d[i];
        ll x = s + 2 * sz[idx] - n;
        auto it = lower_bound(d, d + n, P(x, 1 << 30), greater<P>());
        if(it->first != x) {
            cout << "-1\n";
            return 0;
        }
        par[idx] = it->second;
        sz[par[idx]] += sz[idx];
        sum[par[idx]] += sum[idx] + sz[idx];
    }

    if(sum[d[n - 1].second] != d[n - 1].first) {
        cout << "-1\n";
        return 0;
    }

    rep(i, n) if(~par[i]) cout << par[i] + 1 << " " << i + 1 << "\n";

    return 0;
}

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

int main(){
    int n, a, b;
    cin >> n >> a >> b;

    if((abs(a-b)-1 + 2) % 2 == 0){
        cout << "Borys" << endl;
    }else{
        cout << "Alice" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            
            if (h == 0 && w == 0) {
                break;
            }
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if ((i + j) % 2 == 0) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
        
        
    }
}


Measured memory_bytes: 33108
#include <bits/stdc++.h>
using namespace std;
 
/*** Template Begins ***/
 
typedef long long   ll;
typedef pair<ll,ll> pll;
typedef long double ld; 
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb           push_back
#define F            first
#define S            second
#define ios          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define hell   1000000007LL
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p){ ll res = 1;x = x % p;while (y > 0) {if (y & 1) res = (res*x) % p;y = y>>1;
  x = (x*x) % p;} return res;} 

const long double PI = acos(-1);
// Debug //
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
ll euclid(ll x,ll y,ll a,ll b){
  return (a-x)*(a-x)+(b-y)*(b-y);
}

void solve()
{
  ll n,i,j;
  cin>>n;
  ll count[n+1];
  memset(count,0,sizeof(count));
  for(i=1;i<=n;i++)
  {
    for(j=i;j<=n;j+=i)
      count[j]++;
  }
  ll ans=0;
  for(i=1;i<=n;i++)
    ans+=i*count[i];
  cout<<ans;
}

int main()
{ 
  ios; 
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  ll t=1,i=1;
  // cin>>t;
  while(i<=t)
  {
    solve();
    i++;
  }
  return 0;
}


Measured memory_bytes: 81736
#include "bits/stdc++.h"
#define ll long long int
#define ld long double
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define pb push_back

using namespace std;
typedef pair<int, int> pii;

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

    for (int i = 0; i < n; i++) cout << "ACL";
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000003;
ll q,x,d,n;
ll fac[2100000];
ll qpow(ll a,ll b){
	ll ans=1;
	while(b){
		if(b&1)
			ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
ll inv(ll a){//mod为素数
	return qpow(a,mod-2);
}
ll solve(ll x,ll d){
	if(n>=mod)
		return 0;
	return fac[x+n-1]*inv(fac[x-1])%mod*qpow(d,n)%mod;
}
int main(){
	fac[0]=1;
	for(int i=1;i<2100000;i++)
		fac[i]=fac[i-1]*i%mod;
	scanf("%lld",&q);
	while(q--){
		scanf("%lld%lld%lld",&x,&d,&n);
		if(d==0){
			printf("%lld\n",qpow(x,n));
			continue;
		}
		printf("%lld\n",solve(x*inv(d)%mod,d));
	}
} 

Measured memory_bytes: 17408
fun main() {
	readLn()
	val a = readInts()
	if (a.size == 1) return println(if (a[0] == 1) 1 else -1)
	if (a[0] != 0) return println(-1)
	val fwd = LongArray(a.size + 1)
	for (i in a.indices.reversed()) {
		fwd[i] = fwd[i + 1] + a[i]
	}
	var ans = 1L
	var nonLeaves = 1L
	for (i in 1 until a.size) {
		nonLeaves = minOf(2 * nonLeaves, fwd[i])
		ans += nonLeaves
		nonLeaves -= a[i]
		if (nonLeaves < 0) return println(-1)
	}
	println(ans)
}

private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }


Measured memory_bytes: 51952
# -*- coding: utf-8 -*-
s = list(str(input()))

"""
tmp = [s[0]]
flag = True
for i in s:
    if i in tmp:
        flag = False
    else:
        tmp.append(i)

if flag:
    print("yes")
else:
    print("no")
"""

if len(s) == len(set(s)):
    print("yes")
else:
    print("no")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;

struct S { int x, y, t; };
bool operator==(S l, S r) {
  return l.x == r.x && l.y == r.y && l.t == r.t;
}
int to_i(const S &s) {
  return s.x + 100 + (s.y + 100) * 201 + s.t * 40401;
}
namespace std {
template<>
struct hash<S> {
  size_t operator()(const S& s) const {
    hash<int> h;
    return h(s.x + h(s.y + h(s.t)));
  }
};
}
constexpr int INF = 1000000001;
class Weight {
 public:
  Weight() : w(INF) {}
  Weight(int w) : w(w) {}
  operator int() const { return w; }
  operator int() { return w; }
 private:
  int w;
};
using Array = unordered_map<S, Weight>;
struct Edge {
  S dest; Weight weight;
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &g, S src, S dest, Weight weight) {
  g[to_i(src)].push_back((Edge){dest, weight});
}

int di[6] = {0,1,1,0,-1,-1};
int dj[2][6] = {
  {1,0,-1,-1,-1,0},
  {1,1,0,-1,0,1}
};

void bfs01(Graph &g, Array &d, S s) {
  d[s] = 0;
  using P = pair<Weight,S>;
  deque<P> que;
  que.push_back(P(0, s));
  while (!que.empty()) {
    P top = que.front(); que.pop_front();
    Weight dist = top.first; S v = top.second;
    if (d[v] < dist) continue;
    REP(i, g[to_i(v)].size()) {
      Edge e = g[to_i(v)][i];
      if (d[e.dest] > d[v] + e.weight) {
        d[e.dest] = d[v] + e.weight;
        if (e.weight) que.push_back(P(d[e.dest], e.dest));
        else que.push_front(P(d[e.dest], e.dest));
      }
    }
  }
}

int main() {
  int sx, sy, gx, gy;
  cin>>sx>>sy>>gx>>gy;
  int n;
  cin>>n;
  set<pair<int,int>> sf;
  REP(i,n){
    int x,y;
    cin>>x>>y;
    sf.emplace(x,y);
  }
  int lx,ly;
  cin>>lx>>ly;
  Graph g(250000);
  FOR(i,-lx,lx+1)FOR(j,-ly,ly+1)REP(k,6) {
    S s = {i,j,k};
    int dir = abs(i*j*k) % 6;
    int ni=i+di[dir];
    int nj=j+dj[abs(i)%2][dir];
    if (abs(ni) > lx || abs(nj) > ly) continue;
    if (sf.count({ni,nj})) continue;
    S t = {ni,nj,(k+1)%6};
    add_edge(g, s, t, 0);
  }
  FOR(i,-lx,lx+1)FOR(j,-ly,ly+1)REP(k,6) {
    S s = {i,j,k};
    REP(l,6) {
      int ni=i+di[l];
      int nj=j+dj[abs(i)%2][l];
      if (abs(ni) > lx || abs(nj) > ly) continue;
      if (sf.count({ni,nj})) continue;
      S t = {ni,nj,(k+1)%6};
      add_edge(g, s, t, 1);
    }
    S t = {i,j,(k+1)%6};
    add_edge(g, s, t, 1);
  }
  Array d;
  S s = {sx, sy, 0};
  bfs01(g, d, s);
  Weight res;
  REP(i,6) {
    S g = {gx, gy, i};
    res = min(res, d[g]);
  }
  if (res == INF) {
    cout << -1 << endl;
  } else {
    cout << res << endl;
  }
  return 0;
}

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

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

void solve(void) {
  int n, m; cin >> n >> m;
  vector<int> s(10, 0);
  vector<char> c(10, 0);
  rep(m, i) cin >> s[i] >> c[i];

  bool flag = false;
  int res = 1000;
  for(int d = 0; d < 1000; ++d) {
    string t = to_string(d);
    if((int)t.size() != n) continue;

    int count = 0;
    rep(m, i) {
      if(t[s[i]-1] != c[i]) continue;
      count++;
    }

    if(count == m) {
      flag = true;
      res = d;
      break;
    }
  }
  cout << ((flag) ? res : -1) << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	int n;
	cin >> n;
	std::vector<vector<double>> v(n,vector<double>(n));
	std::vector<pair<double,double>> p(n);

	rep(i,n){
		cin >> p[i].first >> p[i].second;
	}

	rep(i,n) FOR(j,i,n){
		if(i==j) v[i][j] = 0;
		else{
			double x = p[i].first - p[j].first;
			double y = p[i].second - p[j].second;
			v[i][j] = v[j][i] = sqrt(1.0*(x*x+y*y));
		}
	}

	double ans = 0;
	rep(i,n) rep(j,n){
		ans += v[i][j];
	}
	ans /= 1.0*n;
	printf("%.10lf",ans);
  return 0;
}


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

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<int> balls(N + 1);
    for(int i = 1; i <= N; i++)
    {
        int a;
        cin >> a;
        balls.at(i) = a;
    }
    int M = 0;
    for(int i = N; i >= 1; i--)
    {
        int j = 1;
        int count = 0;
        while(i * j <= N){
            count += balls.at(i * j);
            j++;
        }
        int ball = count % 2;
        balls.at(i) = ball;
        M += ball;
    }
    cout << M << endl;
    bool isFirst = true;
    for (int i = 1; i <= N; i++){
        if(balls.at(i) == 1){
            if(isFirst){
                isFirst = false;
            }else{
                cout << " ";
            }
            cout << i;
        }
    }
    return 0;
}

Measured memory_bytes: 1792
a, b, c, d = map(int, input().split())

start = 0
end = 0

if a >= c:
    start = a
else:
    start = c

if b <= d:
    end = b
else:
    end = d

time = end-start

if time > 0:
    print(time)
else:
    print(0)

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

int n;
vector<pair<double, double>> v;

void input() {
    cin >> n;
    v = vector<pair<double, double>>(n);
    for(int i =0; i < n; i++) {
        cin >> v.at(i).first >> v.at(i).second;
    }
}

void solve() {
    //for(auto e : v) {
        //cout << e.first << ", " << e.second << endl;
    //}
    double a[n][n];
    for(int i = 0; i < n; i++) {
        a[i][i] = 0.0;
    }
    for(int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            a[i][j] = sqrt(pow(v.at(i).first - v.at(j).first, 2) + pow(v.at(i).second - v.at(j).second, 2));
        }
    }
    /*
    for(int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << a[i][j] << ",";
        }
        cout << endl;
    }
    */
    vector<int> seq(n);
    iota(seq.begin(), seq.end(), 0);
    int perm = 1;
    for(int i = 1; i <= n; i++) {
        perm *= i;
    }
    //cout << "perm: " << perm << endl;
    double result = 0;
    do {
        for(int i = 0; i < n-1; i++) {
            result += a[seq[i]][seq[i+1]] / perm;
            //cout << "i: " << seq[i] << ", j: " << seq[i+1] << ", dist: " << a[seq[i]][seq[i+1]] << endl;
        }
    } while(next_permutation(seq.begin(), seq.end()));
    cout << fixed << setprecision(10) << result << endl;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int a,b,k;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      cout<<"OK"<<endl;
      return(0);
    }
  }
  cout<<"NG"<<endl;
  return(0);
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    string s;
    cin >> s;
    vector<int> sfx = suffix_array(s);
    vector<int> lcp = lcp_array(s, sfx);
    ll ans = s.size() * (s.size() + 1) / 2;
    for(int x : lcp){ ans -= x; }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15584
#include <iostream>

using namespace std;

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

	int count = 0;
	int cursor = 0;
	int max = 0;
	do {
		cursor++;
		if (count == 0)
			max += D * 2;
		else
			max += D * 2 + 1;
		count++;
	} while (max < N - 1);

	cout << cursor << endl;

	return 0;
}

Measured memory_bytes: 256
"""
def dfs(s):
    global ans
    for u in v:
        x = s[0] + u[0]
        y = s[1] + u[1]
        if x < h and y < w:
            b[x][y] = "#"
            dfs([x, y])
            b[x][y] = "."
    if a == b:
        ans = 1
    return

h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
v = [[1, 0], [0, 1]]
b = [["."] * w for _ in range(h)]
b[0][0] = "#"
s = [0, 0]
ans = 0
dfs(s)
print("Possible" if ans == 1 else "Impossible")
"""

h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
c = 1
for b in a:
    c += b.count("#")
print("Possible" if c == h + w else "Impossible")

Measured memory_bytes: 38384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
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>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
//

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

  int N;
  cin >> N;

  if (N % 2) {
    double res = (double)(N + 1) / 2;
    printf("%.8f\n", res / (double)N);
  } else {
    double res = (double)N / 2;
    printf("%.8f\n", res / (double)N);
  }

  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 k, s;
		k = sc.nextInt();
		s = sc.nextInt();
		int sum = 0;
		
		for(int i = 0; i <= Math.min(k,  s); ++i) {
			for(int j = 0; j <= k; ++j) {
				if(s - i - j >= 0 && s - i - j <= k)sum++;
			}
		}
		
		System.out.println(sum);
		
		sc.close();
	}

}


Measured memory_bytes: 21332
/*******************************************************
 Auther :- Avinash Kumar Sharma 
 collage :- BIRLA INSTITUTE OF THECHNOLOGY
 hakerearth :-All Tracks -> Basic Programming -> Input/Output -> Basics of Input/Output -> Friend's Relationship ... 
 status :- solved.
 ********************************************************/
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n=0,x=0,t=0;
    cin>>n>>x>>t;
    int N=0,r=0;
    if(n==0)
    {
        cout<<"0";
    }
    if(n<=x)
    {
        cout<<t;
    }
    else if(n>x)
    {
        N=n/x;
        r=n%x;
        if(r!=0)
        {
            cout<<t*N+t;
        }
        else if(r==0)
        {
            cout<<t*N;
        }
    }

}

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

// {
#define debug(var)  do{ std::cout << #var << " : "; view(var); }while(0)
using ll = long long;
using ld = long double;
inline int num (const std::string& S, int idx) noexcept { return S.at(idx) - '0'; }
inline int ctoi(char c) noexcept { return c - '0'; }
inline bool isNumber(char c) noexcept { return ('0'<c && c<'9'? true : false); }
inline int safeCtoi(char c) { if(isNumber(c)) { return ctoi(c); } else { throw 1; } }
inline char itoc(int i) noexcept { return i + '0'; }
inline unsigned int bitMask(int i) noexcept { return (1 << i); }
inline bool isTrue(unsigned int bit, int i) noexcept { return bit & bitMask(i); }
inline bool isEven(int num) noexcept { return !num%2; }
inline bool isOdd(int num) noexcept { return num%2; }
template<typename T> inline short sgn(T num) noexcept { return (num==0? 0 : (num>0? 1 : -1) ); }
template<typename T> inline bool isZero(T num) noexcept { return (num==0? true : false); }
template<typename T> inline bool isPositive(T num) noexcept { return (num>0? true : false); }
template<typename T> inline bool isNegative(T num) noexcept { return (num<0? true : false); }
template<typename T> void view(T e) noexcept { cout << e; }
template<typename T> void view(std::vector<T> v) noexcept { for(const auto& e : v) cout << e << " "; }
template<typename T> void view(std::vector<std::vector<T>> vv) noexcept { for(const auto& v : vv) view(v); }
//}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string str;
	cin >> n >> str;
	int i;
	if( str.length() <= n ){
		cout << str << endl;
	}else{
		cout << str.substr(0, n) << "..." << endl;
	}
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	for (int a = 1; a <= 9; a++) {
		for (int b = 1; b <= 9; b++) {
			if (N == a * b) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head
 
void solve(){
    int n;
    cin >> n;
    cout << (n/2 + n%2)/double(n) << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3812
#include <iostream>
#include <string>
#include <map>

#define MULT(x,y) ((x*y)%1000000007L)
#define llint long long int

int main(void){
  llint n, m;
  std::cin >> n >> m;
  llint result = std::min(n, m/2);
  n-=result;
  m-=2*result;
  result += m/4;
  std::cout << result << std::endl;



  return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    m = max(a)
    M = min(a)
    if abs(M) <= abs(m):
        for i in range(n):
            if a[i] == m:
                break
        x = i+1
        print(2*n-1)
        for i in range(n):
            print(x,i+1)
        for i in range(n-1):
            print(i+1,i+2)
    else:
        for i in range(n):
            if a[i] == M:
                break
        x = i+1
        print(2*n-1)
        for i in range(n):
            print(x,i+1)
        for i in range(n-1)[::-1]:
            print(i+2,i+1)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int z,y,x,w;
  cin>>z>>y;
  y/=1000;
  for(x=0;x<=z;x++){
    for(w=0;w<=z-x;w++){
      if(10*x+5*w+z-x-w==y){
        cout<<x<<' '<<w<<' '<<z-x-w<<endl;
        return 0;
      }
    }
  }
  cout<<"-1 -1 -1"<<endl;
}

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

using namespace std;
#define ll long long
#define N 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

vector<vector<int> > g(100001);
vector<int> col(100001,-1);
vector<vector<long> > w(100001);
vector<bool> v(100001,0);

void dfs(int i){
    v[i]=1;
    for(int j=0;j<g[i].size();j++){
        if(!v[g[i][j]]){
            if(w[i][j]%2==0)    col[g[i][j]]=col[i];
            else    col[g[i][j]]=1-col[i];
            dfs(g[i][j]);
        }
    }
}

int main() {
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++){
	    long a,b,c;
	    cin>>a>>b>>c;
	    g[a].pb(b);
	    w[a].pb(c);
	    g[b].pb(a);
	    w[b].pb(c);
	}
	col[1]=0;
    dfs(1);
    for(int i=1;i<=n;i++)   cout<<col[i]<<endl;
	return 0;
}


Measured memory_bytes: 13696
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll a,b,c,d,e;
	cin>>a>>b>>c>>d;
	if(abs(a-c)<=d)
	cout<<"Yes"<<endl;
	else if(abs(a-b)<=d&&abs(b-c)<=d)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int i;
  char a[4];
  scanf("%s", a);
  for(i = 0; i < 3; i++){
    if(a[i] == a[i+1]){
      printf("Bad\n");
      return 0;
    }
  }
  printf("Good\n");
  return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	
	sort(a.begin(), a.end());
	cout << a[0] << " " << a[n-1] << " " << sum << endl;
	return 0;
}


Measured memory_bytes: 3164
#include <stdio.h>
int main(){
    int n,i,a[100001],cnt[100002]={0},tsum[100001],ans=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        cnt[a[i]]++;
    }
    for(i=0;i<99999;i++){
        tsum[i]=cnt[i]+cnt[i+1]+cnt[i+2];
        if(tsum[i]>ans)ans=tsum[i];
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 896
N = int(input())
a = list(map(int, input().split()))

c = [2*a[0]-sum(a)]
d = [abs(c[0])]
for i in range(N-2):
	c.append(c[i]+2*a[i+1])
	d.append(abs(c[i+1]))

print(min(d))

Measured memory_bytes: 26820
n=int(input(""))
a=[]
t=0
c=0
for i in range(11):
    t=n
    c=i+1
    n-=26**(i+1)
    if(n<=0):
        break
for i in range(c):
    a+=[n%26]
    n=int(n/26)
b=[]
for i in range(c):
    b+=[a[n-1-i]]
s=""
for i in b:
    if (i==1):
        s+="a"
    elif(i==2):
        s+="b"
    elif(i==3):
        s+="c"
    elif(i==4):
        s+="d"
    elif(i==5):
        s+="e"
    elif(i==6):
        s+="f"
    elif(i==7):
        s+="g"
    elif(i==8):
        s+="h"
    elif(i==9):
        s+="i"
    elif(i==10):
        s+="j"
    elif(i==11):
        s+="k"
    elif(i==12):
        s+="l"
    elif(i==13):
        s+="m"
    elif(i==14):
        s+="n"
    elif(i==15):
        s+="o"
    elif(i==16):
        s+="p"
    elif(i==17):
        s+="q"
    elif(i==18):
        s+="r"
    elif(i==19):
        s+="s"
    elif(i==20):
        s+="t"
    elif(i==21):
        s+="u"
    elif(i==22):
        s+="v"
    elif(i==23):
        s+="w"
    elif(i==24):
        s+="x"
    elif(i==25):
        s+="y"
    elif(i==0):
        s+="z"

print(s)
    
    


Measured memory_bytes: 9268
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;



int main() {
	int n, k;
	cin >> n >> k;
	map<int, ll> mp;
	rep(i, n) {
		int l;
		cin >> l;
		mp[l]++;
	}
	vector<ll> a = {};
	for (auto i = mp.begin(); i != mp.end(); i++) {
		a.push_back(i->second);
	}
	sort(a.begin(), a.end());
	ll ans = 0;
	if (a.size() <= k) cout << 0 << endl;
	else {
		rep(i, a.size() - k) ans += a[i];
		cout << ans << endl;
	}
}

Measured memory_bytes: 14964
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_map>

using namespace std;

void solve() {
    int n, a, b; cin >> n >> a >> b;
    cout << min(a*n, b);
}

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

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

int main() {
  int x, y;
  cin >> x >> y;
  vector<int> a = { 0, 1, 5, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  if (a[x] == a[y]) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

func Solve() {
  S := NextLine()
  N := len(S)
  m := make([]int, N)
  m[0] = 1
  for i := range m[1:] {
    m[i + 1] = m[i] * 10 % 2019
  }
  M := make(map[int]int)
  M[0] = 1
  var s int
  k := 0
  for i := 0; i < N; i++ {
    s, _ = strconv.Atoi(S[N - i - 1:N - i])
    k = (k + s * m[i]) % 2019
    _, ok := M[k]
    if !ok { M[k] = 0 }
    M[k]++
  }
  ans := 0
  for _, v := range M {
    ans += v * (v - 1) / 2
  }
  Write(ans)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 4236
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int x;
  cin>>x;
  vector<int> a;
  a.push_back(0);
  int now=1;
  while(now*now*now*now*now < 100000000000000000){
    a.push_back(now*now*now*now*now);
    now++;
  }
  rep(i,a.size() ){
    repi(j,i,a.size() ){
      if(a[i]+a[j] == x){cout<<(j)<<" "<<(i)*(-1)<<endl;return 0;}
      else if(a[i]-a[j] == x){cout<<i<<" "<<j<<endl;return 0;}
      else if(a[j]-a[i] == x){cout<<j<<" "<<i<<endl;return 0;}     
    }
  }
		   

  return 0;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define mx *max_element
#define mi *min_element
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ncr(int n,int r){if(n<r)return 0;int p=1,k=1;if(n-r<r)r=n-r;if(r!=0){while(r){p*=n;k*=r;int g=__gcd(p, k);p/=g;k/=g;n--;r--;}}else p=1;return p;}
#define pi acos(-1)
int ar[N];
int tree[2*N];
int dp[N];
int bit[N];
signed main(){
 
	SaveTime;
	int T=1;
	// cin >> T;
	while(T--){
		string s;
		cin >> s;
		if(s[0]=='S')cout<<"Cloudy";
		else if(s[0]=='C')cout<<"Rainy";else
		cout<<"Sunny";
	}
	
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
h = gets.split(' ').map(&:to_i)

counter = 0
prev = 0
n.times do |i|
  if prev - h[i] == 1 then
    counter += 1
  elsif prev - h[i] > 1 then
    puts 'No'
    exit
  elsif prev - h[i] < 0 then
    counter = 0
  end
  if counter == 2 then
    puts 'No'
    exit
  end
  prev = h[i]
end
puts 'Yes'


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

int main() {
    int A, B,C,D,E;
    cin >> A >> B >> C >> D >> E;
    if(A == 0){
        cout << 1 << endl;
    }else if(B == 0){
        cout << 2 << endl;
    }else if(C == 0){
        cout << 3 << endl;
    }else if(D == 0){
        cout << 4 << endl;
    }else if(E == 0){
        cout << 5 << endl;
    }
    
    return 0;
}

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

int main(){
  long long n,a,b;
  cin >> n >> a >> b;
  if(a>b){
    cout << 0 << endl;
    return 0;
  }
  else if(n==1&&a!=b){
    cout << 0 << endl;
    return 0;
  }
  else if(n==1&&a==b){
    cout << 1 << endl;
    return 0;
  }
  else{
    long long ans = (b - a) * (n - 2) + 1;
    cout << ans << endl;
    return 0;
  }
}


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

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

	vector<int> s(100000, 0);
	int64_t sum = 0;

	vector<int>a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		s[a[i]]++;
		sum += a[i];
	}

	cin >> q;
	vector<int>b(q);
	vector<int>c(q);
	for (int i = 0; i < q; i++)
	{
		cin >> b[i] >> c[i];
	}

	for (int i = 0; i < q; i++)
	{

		s[c[i]] += s[b[i]];
		sum += (c[i] - b[i]) * s[b[i]];
		s[b[i]] = 0;

		cout << sum << endl;
	}

	return 0;
}


Measured memory_bytes: 4840
n,k = map(int,input().split())
a = list(map(int,input().split()))

for i in range(k):
    b = [0]*(n+1)
    for i in range(n):
        if a[i]:
            b[max(0,i-a[i])] += 1
            b[i] -= 1
            b[i+1] += 1 
            b[min(n,i+a[i]+1)] -= 1
    b[0] += 1
    count = b[0]
    for i in range(1,n):
        b[i] += b[i-1]
        count += b[i]
    a = b[:n]
    if count == n*n:
        print(*a)
        exit()
print(*a)

Measured memory_bytes: 169776
n=int(input())
lista = [int(i) for i in input().split()]

ans = [0]*n
sum_ = sum(lista)/2

tmp = 0
for i in range(0,n-1,2):
    tmp+=lista[i]
ans[-1] = int(sum_-tmp)*2
#print(ans)

for i in range(n-1):
    ans[n-2-i] = int(lista[n-2-i]*2 - ans[n-1- i])

for i in range(n):
    print(ans[i]," ",end="")

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

int main() {
  int N ;
  cin >> N;
  int j = 0;
  int sum = 0;
  while (j < N){
    int m , r;
  	cin >> m >> r;
    sum += (r - m + 1) ;
    j++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 100100
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
struct edge{int to,lt;}e[N<<1];
int cnt,in[N],n;
void add(int x,int y)
{
	e[++cnt].to=y; e[cnt].lt=in[x]; in[x]=cnt;
	e[++cnt].to=x; e[cnt].lt=in[y]; in[y]=cnt;
}
char ch[N];
int mn[N],mx[N],sz[N],d;
int ans=inf;
void dfs(int x,int fr,int dis)
{
	int tot=0,p=0; sz[x]=ch[x]-'0';
	if(ch[x]=='1')	d+=dis;
	for(int i=in[x];i;i=e[i].lt)
	{
		int y=e[i].to; if(y==fr)	continue;
		dfs(y,x,dis+1); if(mn[y]>mn[p]) p=y;
		tot+=mx[y],sz[x]+=sz[y];	
	}
	mx[x]=tot; tot-=mx[p];
	mn[x]=max(0,mn[p]-tot);
	if(fr)	mn[x]+=sz[x],mx[x]+=sz[x];
}
void sol(int x)
{
	d=0; dfs(x,0,0); if(d&1)	return;
	if(!mn[x])	ans=min(ans,d/2);
}
int main()
{
	n=read(); scanf("%s",ch+1);
	for(int i=1;i<n;i++)	add(read(),read());
	for(int i=1;i<=n;i++)	sol(i);
	if(ans==inf)	puts("-1");
	else	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//frog1
int solve(vector<int> ar, int n){
    vector<int> dp(n+1);
    dp[1] = 0;
    for(int i=2;i<=n;i++){
        int option1 = abs(ar[i]-ar[i-1]) + dp[i-1];
        int option2 = (i==2) ? INT_MAX : abs(ar[i]-ar[i-2]) + dp[i-2];
        dp[i] = min(option1, option2);
    }
    return dp[n];
}
int main() {
	int n;
	cin>>n;
	vector<int> ar(n+1);
	for(int i=1;i<=n;i++){
	    cin>>ar[i];
	}
	cout<<solve(ar, n);
	
	return 0;
}


Measured memory_bytes: 4188
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

#define MAX 10000010

//??¨????????????????????????
//n??\????????£??´??°????´???°???????????°???????????????is_prime[]???????´?
void eratos(int n, bool is_prime[]) {
	fill(is_prime, is_prime + n + 1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i*i <= n; i++)
		if (is_prime[i]) {
			int j = i + i;
			while (j <= n) {
				is_prime[j] = false;
				j = j + i;
			}
		}
}

signed main() {
	static bool is_prime[MAX] = {};
	eratos(MAX, is_prime);
	for (int n; cin >> n&&n;) {
		rrep(i, 0, n + 1) {
			if (is_prime[i] && is_prime[i - 2] && is_prime[i - 6] && is_prime[i - 8]) {
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 12840
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
  }
  int diff = 1e9;
  int ans = 0;
  for (int i = 0; i <= 101; ++i) {
    bool ok = true;
    for (int j = 0; j < n; ++j) {
      if (i == p[j]) ok = false;
    }
    if (ok && abs(x - i) < diff) {
      ans = i;
      diff = abs(x - i);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
N,Q=map(int,input().split())
s=input()
commands=[input().split() for _ in range(Q)]

def move(i):
  k=i
  if k==-1 or k==N:
    return k
  for t,d in commands:
    #print(t,d,k)
    if s[k]==t:
      if d=='R':
        k+=1
      else:
        k-=1
    if k==-1 or k==N:
      return k
  return k

#left search
low=0
high=N

##左にはみ出る一番右の位置→left
left=(low+high)//2

while(low<=high):
  vanish=False
  if move(left)==-1:
    vanish=True
  if low==high:
    if vanish:
      left=low
    else:
      left=low-1
    break
  if vanish:
    low=left+1
  else:
    high=left-1
  left=(low+high)//2
  if left>high:
    left=high
    break
#print(left)
#右にはみ出る一番左の位置
low=0
high=N
right=(low+high)//2
while(low<=high):
  vanish=False
  if move(right)==N:
    vanish=True
  if low==high:
    if vanish:
      right=low
    else:
      right=low+1
    break
  if vanish:
    high=right-1
  else:
    low=right+1
  right=(low+high)//2
  if right<low:
    right=low
    break
#print(right)
print(right-left-1)
'''
from collections import Counter

N,Q=map(int,input().split())
s=input()
moji={}
for i in range(Q):
  t,d=input().split()
  moji.setdefault(t,[0,0,0])
  if d=='L':
    moji[t][0]-=1
  else:
    moji[t][0]+=1
  #rightmax
  if moji[t][0]>moji[t][1]:
    moji[t][1]=moji[t][0]
  #leftmax
  if moji[t][0]<moji[t][2]:
    moji[t][2]=moji[t][0]

answer=0
for i in range(N):
  key=s[i]
  if moji[s[i]][1]+i>N-1 or i+moji[s[i]][2]<0:
    answer+=1
print(moji)
print(answer)
'''

Measured memory_bytes: 41204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
#define pii pair<int , int>
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
const int INF = 1000 * 1000 * 1000 + 7;
const ll LINF = INF * (ll)INF;
const int mod = INF;
const int MAX = 1 << 25;
int dp[21][1005];
int c[1005][1005];
int n , k;
int a[20];
int mult(int a , int b){
	return a * (ll)b % mod;
}
int add(int a, int b){
	return a + b >= mod ? a + b - mod : a + b;
}
void Add(int &a , int b){
	a = add(a , b);
}
int main()
{
	int n , k;
	cin >> n >> k;
	for(int i = 0; i < k; i++)
		cin >> a[i];
	for(int i = 0; i <= n; i++)
	{
		c[i][0] = 1;
		for(int j = 1; j <= i; j++)
		{
			c[i][j] = add(c[i - 1][j] , c[i - 1][j - 1]);
		}
	}
	dp[0][0] = 1;
	for(int i = 0; i < k; i++)
		for(int j = 0; j <= n; j++)
			for(int l = 0; l <= min(n - j, a[i]); l++)
				Add(dp[i + 1][j + l] , mult(dp[i][j] , mult(c[n - l][a[i] - l] , c[n - j][l])));

	cout << dp[k][n];
}


Measured memory_bytes: 4224
n = gets.to_i
Sn = readlines.map { |i| a = i.chomp.chars.group_by(&:itself).map {|k,v| [k, v.count] }.to_h; a.default = 0; a }
puts(("a".."z").flat_map do |c|
  n = Sn.map { |i| i[c] }.min
  [c] * n
end.join)


Measured memory_bytes: 2172
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	string s;
	cin>>s;
	if(s[s.size()-1]=='s'){
		cout<<s<<"es";
	} 
	else{
		cout<<s<<'s';
	}
	re 0;
}

Measured memory_bytes: 3628
# coding:utf-8
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
ans = [[0] * w for _ in range(h)]
x = [-1, 0, 1, -1, 1, -1, 0, 1]
y = [-1, -1, -1, 0, 0, 1, 1, 1]

# print(s)


for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            ans[i][j] = '#'
        else:
            for k in range(len(x)):
                if 0 <= (i + x[k]) < h and 0 <= (j + y[k]) < w and s[i + x[k]][j + y[k]] == '#':
                    ans[i][j] += 1

for i in range(h):
    print(*ans[i], sep='')


Measured memory_bytes: 9136
#include "bits/stdc++.h"
#include <chrono>
#include <random>
#include <cstdio>
#define ll long long int
#define endl '\n'
#define pb push_back
#define mp make_pair
// #define mod 998244353
#define rep(i,n) for(ll i=0;i<n;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define pll pair<ll, ll>
#define pint pair<int, int>
#define S second
#define F first
#define all(c) (c).begin(),(c).end()
using namespace std;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
const int N=500001;
// vector<pair<ll, ll> > adj[N];
// bool vis[N];
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
#define pi 3.14159265358979323846264338
using namespace std; 
ll max(ll a, ll b){ if(a>b)return a;return b;}
ll min(ll a, ll b){ if(a < b) return a;return b;}
ll inf = 100000000000000000;
vector <pint> adj[N];

void solve() 
{
    ll n, k;
    cin>>n>>k;

    vl a(n+1);
    rep(i, n) cin>>a[i+1];

    int i = 1, j = k + 1;

    while(j <= n)
    {
        if(a[j] > a[i])
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
        i++;
        j++;
    }


}

int main()
{
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)

    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 16368
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
 
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; } 
int main() {
    int n;
    ll x;
    cin >> n >> x;

    vector<ll>a(n);
    ll maxd=0;
    rep(i, 0, n){
        cin >> a[i];
        maxd = max(maxd, abs(x-a[i]));
    }
    if(n == 1){
        cout << abs(x-a[0]) << endl;
        return 0;
    }
    ll p = abs(a[1]-a[0]);
    rep(i, 1, n-1){
        p = gcd(p, abs(a[i+1]-a[i]));
    }
    cout << gcd(p, maxd) << endl;
}

Measured memory_bytes: 1024
package main

import "fmt"

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

	ans := "Three"
	for i := 0; i < n; i++ {
		var tmp string
		fmt.Scan(&tmp)
		if tmp == "Y" {
			ans = "Four"
			break
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
import random

D = int(input())
c_list = list(map(int,input().split(' ')))
s_list = []
for i in range(D):
    s_list.append(list(map(int,input().split(' '))))
for day in range(D):
    print(random.randrange(26)+1)
    # maxs = s_list[day].index(max(s_list[day]))
    # print(maxs+1)


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

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

	int N = 4;
	for (int i = 0; i < 1 << (N - 1); i++) {

		int sum = S[0]-'0';
		char sign[3];
		for (int j = 0; j < N - 1; j++) {
			if (i & 1 << j) {
				sum += S[j + 1] - '0';
				sign[j] = '+';
			}
			else {
				sum -= S[j + 1] - '0';
				sign[j] = '-';
			}
		}

		if (sum == 7) {
			cout << S[0] << sign[0] << S[1] << sign[1] << S[2] << sign[2] << S[3];
			cout << "=7" << endl;
			return 0;
		}

	}
}

Measured memory_bytes: 256
/*
* @Author: AsilenceBTF
* @Buff: ︿(￣︶￣)︿  芜湖塔台 起飞
* @Date: 2019-06-20 09:22:24
 * @LastEditTime: 2020-09-17 09:23:51
*/

#include <bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define ALL(x) x.begin(), x.end()
#define INF 0x3f3f3f3f
#define debug(x) cout << "##### " << x << endl; 
typedef long long ll;

// #define cin in
// #define cout out
// ifstream in("in.txt");
// ofstream out("out.txt");

const int MOD = 1e9 + 7;

const int N = 2e5 + 105;
int a[N], b[N];
int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    for(int i = 1; i <= n; ++i) cin >> b[i];
    sort(b + 1, b + 1 + n, greater<int>());
    int l = -1, r = -1;
    for(int i = 1; i <= n; ++i){
        if(a[i] == b[i]){
            if(l == -1) l = i, r = i;
            else r = i;
        }
    }
    if(l != -1){
        int l1 = 1;
        int i = l;
        for( ; i <= r && l1 <= n; ){
            if(a[l1] != b[i] && b[l1] != b[i]){
                swap(b[l1], b[i]);
                ++i;
            }
            ++l1;
        }
        if(i <= r){
            cout << "No" << endl; return 0;
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i <= n; ++i) cout << b[i] << " ";
    cout << endl;
    // system("pause");
}


Measured memory_bytes: 5200