akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  init();
  ll N, A;
  cin >> N >> A;

  N %= 500;
  if (N <= A) {
    COUT("Yes");
  } else {
    COUT("No");
  }
  return 0;
}

Measured memory_bytes: 3624
#ABC166c

N, M = map(int, input().split())
H = []
H = list(map(int, input().split()))
road = []
for i in range(M):
    road.append(list(map(int,input().split())))

count = [0] * N
for r in road:
    if H[r[0]-1] > H[r[1]-1]:
        count[r[1]-1] += 1
    elif H[r[0]-1] == H[r[1]-1]:
        count[r[0]-1] += 1
        count[r[1]-1] += 1
    else:
        count[r[0]-1] += 1

ans = 0
for k in range(N):
    if count[k] == 0:
        ans += 1
print(ans)


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

int index(char c){
	if(c == 'A') return 0;
	if(c == 'B') return 1;
	if(c == 'C') return 2;
}

void swap(int a[], int i, int j){
	int t;
	t = a[i]; a[i] = a[j]; a[j] = t;
}

void change(int ball[], char a, char b){
	swap(ball, index(a), index(b));
}

int main(){
	int ball[] = {
		1, 0, 0
	};
	char a, b;
	char co;
	while(cin >> a >> co >> b){
		change(ball, a, b);
	}
	int i = 0;
	while(ball[i] == 0) i++;
	if(i == 0) cout << 'A' << endl;
	if(i == 1) cout << 'B' << endl;
	if(i == 2) cout << 'C' << endl;
	return 0;
}

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

int a1[105],a2[105],a3[105],a4[105],c1,c2,c3,c4;
int w,h,q;
int x,y,a;

int main(){
	cin >> w >> h >> q;
	for(int i=0; i<q; i++){
		cin >> x >> y >> a;
		if(a==1)
			a1[c1++] = x;
		if(a==2)
			a2[c2++] = x;
		if(a==3)
			a3[c3++] = y;
		if(a==4)
			a4[c4++] = y;
	}
	sort(a1,a1+c1),sort(a2,a2+c2),sort(a3,a3+c3),sort(a4,a4+c4);
	int x1,x2,y1,y2;
	x1 = a1[c1-1],x2 = a2[0];
	y1 = a3[c3-1],y2 = a4[0];
	// cout << x1 << " " << x2 << " " << y1 << " " << y2 << endl;
	if(c2 == 0) x2 = w;
	if(c4 == 0) y2 = h;
	if(x2-x1<=0 || y2-y1<=0)
		cout << "0" << endl;
	else
		cout << (x2-x1)*(y2-y1) << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>

#include<cmath>
#include<map>
#include<string>
#include<vector>
#include<algorithm> 

using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) std::cout << (j ? s1 : s2) << endl;
# define YES(j) std::cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define rep(n,i) for(i = 0 ; i < n ; i++)
# define swap_int(a,b) int t=a;a=b;b=t;

int main()
{
   int a,b,t;cin >> a >> b >> t;
   p(t/a*b)
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

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

    vector<int> b(n + 1);
    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;

        b[i] = (b[i - 1] + a) % m;
    }

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

    ll r = 0;
    int c = 0, j = -1;
    for (int i = 0; i <= n; i++) {
        if (b[i] != j) {
            r += (ll)c * (c - 1) / 2;
            c = 0;
            j = b[i];
        }
        c++;
    }
    r += (ll)c * (c - 1) / 2;

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
a.append(0)

for i in range(n):
    ans += b[i]
    if a[i+1] - a[i] == 1:
        ans += c[a[i]-1]

print(ans)

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

int n;

ll gcd(ll x, ll y){
    if(x < y) swap(x,y);
    while( y > 0 ){
        ll r = x%y;
        x = y;
        y = r;
    }
    return x;
}
ll lcm(ll x, ll y){
    ll aa = gcd(x,y) ;
    ll bb = x/aa;
    ll cc = bb*y;
    return cc;
}

int main(){
    cin >> n;
    ll ans = 1;
    for(int i =0;i < n;i++){
        ll t;
        cin >>t;
        ans = lcm(ans, t);    
    }
    cout<< ans <<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int[] data = new int[101];
		String sdata;
		int[] use = new int[31];
		while (!"0,0".equals(sdata = in.next())) {
			int team = Integer.parseInt(sdata.substring(0, sdata.indexOf(',')));
			int point = Integer
					.parseInt(sdata.substring(sdata.indexOf(',') + 1));
			data[team] = point;
			if (use[point] == 0) {
				use[point] = 1;
			}
		}
		int rank = 1;
		for (int i = 30; i >= 0; i--) {
			if (use[i] == 1) {
				use[i] = rank++;
			}
		}
		while (in.hasNext()) {
			System.out.println(use[data[in.nextInt()]]);
		}
	}
}

Measured memory_bytes: 17180
#include <stdio.h>
#include <stdlib.h>
#define N 45
 
int f[N];
int fib(int);

int main(){
  int n,i;
  
  scanf("%d",&n);
  printf("%d\n",fib(n));
  return 0;
}
 
int fib(int n){
  if(n==0 || n==1) return f[n]=1;
  if(f[n]!=NULL) return f[n];
  return f[n]=fib(n-2)+fib(n-1);
}

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

const int N = (int) 1e5 + 5;

int n;
int a[N];
long long b[N];

int main() {
	//freopen(".inp", "r", stdin); freopen(".out", "w", stdout);
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= n; i++) {
		if (i & 1) b[1] = b[1] + a[i];
		else b[1] = b[1] - a[i];
	}
	// b[n] = 2 * a[n] - b[1];
	for (int i = 1; i < n; i++) b[i + 1] = 2 * a[i] - b[i];
	for (int i = 1; i <= n; i++) printf("%d ", b[i]);
	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#include <complex.h>
#include <math.h>
#include <iostream>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace std;
#define int ll
// fendwick tree
//#include <ext / pb_ds / assoc_container.hpp> //required
//#include <ext/pb_ds/tree_policy.hpp>         //required
using namespace __gnu_pbds; //required
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<int> s;
ordered_set<int>::iterator itr;
// fendwick tree
/*
ll ans[200005];
void fun(ll a, ll b, ll c)
{
    //ll val = 1;

    while (a <= b)
    {
        ans[a] += c;
        ll p = -a;
        a += (a & p);
    }
}
ll find1(ll a)
{
    ll sum = 0;
    while (a != 0)
    {
        sum += ans[a];
        ll p = -a;
        a -= (a & p);
    }
    return sum;
}*/
int fastexpo(int a, int b, int m)
{
    int ans = 1;
    while (b)
    {
        if (b & 1)
            ans = (ans * a) % m;
        b = b / 2;
        a = (a * a) % m;
    }
    return ans;
}
int32_t main()
{
    int t;
    int k;
    cin >> t >> k;
    int arr[t];
    int max1 = 0;
    int sum = 0;
    for (int i = 0; i < t; i++)
    {
        cin >> arr[i];
        // max1 = max(max1, arr[i]);
        sum += arr[i];
    }
    sort(arr, arr + t);
    int min1 = 100000000000;
    for (int i = t - 1; i >= 0; i--)
    {
        if (i - k >= -1)
            min1 = min(min1, arr[i] - arr[i - k + 1]);
    }
    cout << min1 << "\n";
    return 0;
}

Measured memory_bytes: 4412
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
	long long W, H, x, y;

	cin >> W >> H >> x >> y;

	int can = 0;
	if (W == x * 2 && H == y * 2)
	{
		can = 1;
	}
	else
	{
		can = 0;
	}

	cout << setprecision(20) << W * H / 2.0 << " ";
	cout << can << endl;
	
	return 0;
}


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

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

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

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll n, k;
P pp[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> k;
  REP(i, n) {
    ll a, b;
    cin >> a >> b;
    pp[i] = make_pair(a, b);
  }

  sort(pp, pp + n);

  int ans = 0;
  ll sum = 0;
  REP(i, n) {
    sum += pp[i].second;
    if(sum >= k) {
      ans = pp[i].first;
      break;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {
        int N;
        cin >> N;
        vector<int> A(N);
        for (int i = 0; i < N; ++i) {
            cin >> A[i];
        }

        multiset<int> ms;
        for (int i = 0; i < N; ++i) {
            auto it = ms.lower_bound(A[i]);
            if (it == ms.begin()) {
                ms.insert(A[i]);
            } else {
                it--;
                cerr << "delete " << *it << endl;
                ms.erase(it);
                ms.insert(A[i]);
            }
            cerr << "size" << ms.size() << endl;
        }

        cout << ms.size() << endl;


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


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

int main(){
  int N, M;

  cin >> N >> M;
  G A(M, vector<int>(2, 0));

  for( int i=0; i<M; i++){
    for( int j=0; j<2; j++){
      cin >> A.at(i).at(j);
    }    
  }

  int maxL = 1;
  int minR = N;

  rep(i, M){
    maxL = max(maxL, A.at(i).at(0));
    minR = min(minR, A.at(i).at(1));
  }
  int ans = minR - maxL + 1;
  ans = max(ans, 0);
  cout << ans << endl;
}


Measured memory_bytes: 8764
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	vi arr(n),ns;
	for(int &i:arr)cin>>i,ns.PUB(i);
	sort(arr.begin(),arr.end());
	int req = n/2;
	REP(i,0,n-1) {
		if(ns[i]<arr[req])cout<<arr[req]<<"\n";
		else cout<<arr[req-1]<<"\n";
	}
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 5104
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> A(N),B(N);
    rep(i,N) cin >> A[i] >> B[i];
    if (N&1) {
        sort(all(A));
        sort(all(B));
        cout << B[N/2]-A[N/2]+1 << ln;
    } else {
        sort(all(A));
        sort(all(B));
        ll a = A[N/2] + A[N/2-1];
        ll b = B[N/2] + B[N/2-1];
        ll ans = (b/2-a/2)*2+1;
        if ((A[N/2]-A[N/2-1])&1) ans--;
        if ((B[N/2]-B[N/2-1])&1) ans++;
        cout << ans << ln;
    }
}

Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b;
	cin>>a>>b;
	if(b == 1){cout<<0<<endl;return 0;}
	else{
		b -= a;
		int r = 1;
		if(b > 0){
			r += b / (a - 1);
			if(b % (a - 1) != 0)r++;
			cout<<r<<endl;
		}
		else cout<<r<<endl;
		return 0;
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

/* FastZetaTransform */

// a[1001] = a[1001] + a[1011] + a[1101] + a[1111];

void FZT(int n, int *a){
  for(int i=0;i<n;i++)
    for(int j=0;j<(1<<n);j++)
      if(!(j & (1<<i))) a[j] += a[j | (1<<i)]; //総和
}

// a[1001] = a[1001] + a[1000] + a[0001] + a[0000];

void FZT2(int n, ll *a){
  for(int i=0;i<n;i++)
    for(int j=0;j<(1<<n);j++)
      if(j & (1<<i)) a[j] += a[j ^ (1<<i)]; //総和
}


ll gcd(ll a, ll b){
  return __gcd(a,b);
}

ll lcm(ll a, ll b){
  ll w = a/gcd(a,b);
  if(w < LLONG_MAX/b) return w*b;
  return LLINF;
}

ll lower_bit(int t){
  if(t == 0) return -1;
  for(int i=0;;i++) {if(t%2) return i; t/=2;}
}

ll lcmmemo[1<<20];
ll dp[1<<20] = {};

int main(){
  int n, p[30];
  ll m, a[30];
  
  scanf("%d%lld", &n, &m);

  for(int i=0;i<n;i++) scanf("%lld", a+i);
  for(int i=0;i<n;i++) scanf("%d", p+i);



  lcmmemo[0] = 1;
  dp[0] = 0;

  for(int i=1;i<(1<<n);i++){
    int t = i^(i&(-i));
    lcmmemo[i] = lcm(lcmmemo[t], a[lower_bit(i)]);
    dp[i] = m/lcmmemo[i] * (__builtin_popcount(i)%2 ? 1 : -1);
  }

  FZT2(n, dp);

  double ans = 0;
  
  for(int i=0;i<(1<<n);i++){
    double rate = 1;
    for(int j=0;j<n;j++){
      if(i & (1 << j)){
        rate *= p[j]/100.0;
      }else{
        rate *= 1-p[j]/100.0;
      }
    }
    ans += rate * dp[i];
  }

  printf("%.10lf\n", ans);
  
  
  return 0;
}



Measured memory_bytes: 19608
k = int(input())

lunlun = [1,2,3,4,5,6,7,8,9]

p = 0

def generate_lunlun(p):
    last = p % 10
    if last - 1 >= 0:
        yield p * 10 + last - 1
    yield p * 10 + last
    if last + 1 <= 9:
        yield p * 10 + last + 1

while len(lunlun) < k:
    for new_lunlun in generate_lunlun(lunlun[p]):
        lunlun.append(new_lunlun)
    p += 1

print(lunlun[k-1])
    

Measured memory_bytes: 7268
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int N,M;
  char c;
  int A[55][55];
  int B[55][55];
  cin >> N >> M;
  rep(i, N) {
    rep(j, N) {
      cin >> c;
      if (c == '#') A[i][j] = 0;
      else A[i][j] = 1;
    }
  }
  rep(i, M) {
    rep(j, M) {
      cin >> c;
      if (c == '#') B[i][j] = 0;
      else B[i][j] = 1;
    }
  }
  rep(i, N-M+1) {
    rep(j, N-M+1) {
      int k,l;
      bool f = true;
      for(k=0; k < M; k++) {
        for (l=0; l < M; l++) {
          if (A[i+k][j+l] != B[k][l]) {f=false;break;}
        }
        if (!f) break;
      }
      //cout << k << " " << l << endl;
      if (f) {cout << "Yes" << endl; return 0;}
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <iomanip>
#include <set>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);

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

	string s;

	cin >> s;

	s[3] = '8';

	cout << s;


	return 0;
}

Measured memory_bytes: 764
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n'
#define pe(x) cout<<x<<" "
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
int MOD = 1e9+7;

const int MAX = 200060;
const double pi = acos(-1);
const double EPS = 1e-12;

vector<int>par[606];
//unordered_set<int>par[606],chi[606];
//vector<int>par[606], chi[606];
double dp_first[606], dp[606];
bool vis[606];
int N, M;

double calc_init(int n) {
	if (dp_first[n] != 0)return dp_first[n];
	if (n == N - 1)return 0;
	double ret = 0;
	for (auto nxt : par[n]) {
		ret += (calc_init(nxt) + 1) / par[n].size();
	}
	dp_first[n] = ret;
	return ret;
}
double calc(int n) {
	if (dp[n] != 0)return dp[n];
	if (n == N - 1)return 0;
	double ret = 0;
	for (auto nxt : par[n]) {
		ret += (calc(nxt) + 1) / par[n].size();
	}
	dp[n] = ret;
	return ret;
}

void solve(){
	cin >> N >> M;
	REP(i, M) {
		int u, v; cin >> u >> v;
		u--, v--;
		//par[u].insert(v);
		par[u].pb(v);
		//chi[v].insert(u);
	}
	double ans = calc_init(0);
	REP(i, N) {
		if (par[i].size() <= 1)continue;

		int id = 0,idx=0;
		double mx = 0;
		REP(j, par[i].size()) {
			int nxt = par[i][j];
			if (dp_first[nxt] > mx) {
				mx = dp_first[nxt];
				id = nxt;
				idx = j;
			}
		}
		/*for (auto nxt : par[i]) {
			if (dp_first[nxt] > mx) {
				mx = dp_first[nxt];
				id = nxt;
			}
		}*/
		
		par[i].erase(par[i].begin()+idx);
		REP(i, N)dp[i] = 0;
		ans = min(ans, calc(0));
		par[i].pb(id);
	}
	cout << setprecision(10) << ans << endl;

}


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


Measured memory_bytes: 2560
import itertools
import math
N = int(input())


citys = []
for i in range(N):
    citys.append([int(x) for x in input().split()])

a = list(itertools.permutations(range(N), N))

ans = 0
for i in a:
    b = 0
    for j in range(N-1):
        b += math.sqrt((citys[i[j]][0] - citys[i[j+1]][0])**2 + (citys[i[j]][1] - citys[i[j+1]][1])**2)
    ans += b

print(ans/len(a))


Measured memory_bytes: 13792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              (double)3.14159265358979323844
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    rep(i,0,n){
    	cin>>arr[i];
    	arr[i]--;
    }
    ll dp[n][61];
    rep(i,0,n){
    	dp[i][0]=arr[i];
    }
    rep(i,1,61){
    	rep(j,0,n){
    		dp[j][i]=dp[dp[j][i-1]][i-1];
    	}
    }
    ll start=61;
    ll pos=0;
    while (k){
    	ll x=(ll)log2(k);
    	//trace(x);
    	pos=dp[pos][x];
    	k-=(1LL<<(x));
    	//trace(k);
    }
    cout<<pos+1<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 100704
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s;
  cin>>s;
  int n=s.size();
  int ans=0;
  for(i=1;i*2<n;i++){
    int c=0;
    rep(j,i)if(s[j]!=s[j+i])c++;
    if(c==0)ans=i*2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}
string tostr(char s[], int a = 0, int n = 1500) {string res = "";for(int i=a;i<a+n;++i){if(s[i]!=0)res+=s[i];}return res;}


char cstr[2000];
string str;
string ap = "apple", pe = "peach";

int main() {
    memset(cstr, 0, sizeof(cstr));
    cin.getline(cstr, 1500);
    str = tostr(cstr);
    int n = str.size();
    for (int i = 0; i < n-4; ++i) {
        string sstr = str.substr(i, 5);
        if (str.substr(i, 5) == ap) REP(j,5) str[i+j] = pe[j];
        else if (str.substr(i, 5) == pe) REP(j,5) str[i+j] = ap[j];
    }
    cout << str << endl;
    
    return 0;
}


Measured memory_bytes: 1184
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<fstream>

#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
using namespace std;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
       
    ll i,j,k,x,y,z,p,q;
    ll n,m,tmp;
    string s[200000];
    string str;
    ll sum=0;
    ll strr[200005];
    cin>>n>>k;
    n=n%k;
    if(abs(n-k)<abs(n)) n=abs(n-k);
    cout<<abs(n)<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>

using namespace std;

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

  vector<int> A;
  for(int i=0;i<N;i++){
    int temp;
    cin >> temp;
    A.push_back(temp);
  }

  int ans=-1;

  for(vector<int>::iterator it=A.begin();it!=A.end();it++){
    int count=0; 
    while(((*it)%2)==0){
      *it /=2;
      count++;
    }
    if(ans<0 || ans>count) ans=count;
  }

  cout<<ans<<endl;
  
  return 0;
 }


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N;
    vector<ll> X(N); rep(i, N){cin >> X.at(i);}
    vector<ll> sorted_X(X.size()); copy(X.begin(), X.end(), sorted_X.begin());
    sort(sorted_X.begin(), sorted_X.end());

    // 中央値候補は sorted_X.at(N / 2 - 1), sorted_X.at(N / 2) のどちらか
    // cout << X.at(N / 2 - 1) << " " << X.at(N / 2) << endl;
    rep(i, N){
        if (X.at(i) <= sorted_X.at(N / 2 - 1)){
            cout << sorted_X.at(N / 2) << endl;
        } else {
            cout << sorted_X.at(N / 2 - 1) << endl;
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 5376
import numpy as np

l = list(map(int, input().split()))
a = l[0]
b = l[1]

if not(a==1 or b==1):
    if a*b %2==0:
        print(int(a*b/2))
    else:
        print(int(a*b/2+1))

else:
    print(1)


Measured memory_bytes: 27100
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

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

  int N, A, B;
  cin >> N >> A >> B;

  int x = 0, y = 0, z = 0;
  rep(i, N) {
    int p;
    cin >> p;
    if (p <= A) {
      x++;
    } else if (p <= B) {
      y++;
    } else {
      z++;
    }
  }
  cout << min(x, min(y, z)) << endl;

  return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>

using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main()
{
	ll sieve[200005] = {0}, prime[200005], k=0;
	for(ll i=2; i<=200004; i++)
	{
		if(sieve[i]==0)
		{
			for(ll j=i*i; j<=200004; j+=i)
				sieve[j] = -1;
		}
	} 

	for(ll i=2; i<=200004; i++)
	{
		if(sieve[i]==0)
			prime[k++] = i;
	}

	ll n;
	cin >> n;
	ll ans = 0;
	for(ll i=0; i<=k; i++)
	{
		if(prime[i]>=n)
		{
			ans = prime[i];
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
n = int(input())
a = list(map(int,input().split()))
d = {}
ans = ''

for i in range(0,n):
  d[a[i]] = i+1

d_sorted = sorted(d.items(), key=lambda x:x[0])

for i in range(n):
  if ans != '':
    ans = ans + ' '
  ans = ans + str(d_sorted[i][1])

print(ans)

Measured memory_bytes: 29860
N, K = gets.split.map(&:to_i)
R, S, P = gets.split.map(&:to_i)
T = gets.strip

t = T
(K .. N).each{|i| t[i] = '*' if t[i - K] == t[i]}
ans = t.chars.inject(0) do |s, c|
  s + case c
      when 'r'; P
      when 's'; R
      when 'p'; S
      else    ; 0
      end
end
puts ans

Measured memory_bytes: 7164
import sys
import os
import math


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    TIMES = [int(sys.stdin.readline().rstrip()) for _ in range(5)]

    ret = 0
    tmp = -1
    for time in TIMES:
        t = math.ceil(time / 10) * 10
        ret += t
        if tmp < t - time: tmp = t - time

    print(ret - tmp)


if __name__ == '__main__':
    main()


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

using namespace std;

const long long mod = 1e9 + 7ll ;
const int MAX = 100010 , N = 110 ;
long long dp[MAX][N] , dp2[MAX][N] ;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n , k ;
    cin>>n>>k ;
    long long arr[n+1] ;
    for(int i = 1 ; i <= n ; ++i)
        cin>>arr[i] ;
    for(int i = 0 ; i <= k ; ++i)
    {
        for(int j = 1 ; j <= n ; ++j)
        {
            if(j == 1)
            {
                if(i <= arr[j])
                    dp[i][j] = 1ll ;
            }
            else if(i - arr[j] <= 0)
                dp[i][j] = dp2[i][j-1] % mod;
            else
                dp[i][j] = (dp2[i][j-1] - dp2[i-arr[j]-1][j-1] + mod) % mod ;
            if(i == 0)
                dp2[i][j] = 1ll ;
            else
                dp2[i][j] = (dp[i][j] + dp2[i-1][j]) % mod ;
        }
    }
    return cout<<dp[k][n]<<"\n" , 0 ;
}


Measured memory_bytes: 172160
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s; cin >> s;
    string T = "AKIHABARA";
    bool flag = false;
    rep(i,0,1<<4){
        string k = "";
        if(i & (1 << 0)){
            k += "A";
        }
        k += "KIH";
        if(i & (1 << 1)){
            k += "A";
        }
        k += "B";
        if(i & (1 << 2)){
            k += "A";
        }
        k += "R";
        if(i & (1 << 3)){
            k += "A";
        }

        if(s == k){
            flag = true;
        }
    }

    if(flag){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

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

int n;
int a[100002];

int main(){
    cin >> n;
    for(int i=1; i <= n; i++) cin >> a[i];

    int sum = 0;

    for(int i=0; i <= n; i++) sum += abs(a[i+1] - a[i]);
    //cout << sum << endl;

    for(int i=1; i <= n; i++){
        cout << sum - abs(a[i-1] - a[i]) + abs(a[i-1] - a[i+1]) - abs(a[i] - a[i+1]) << endl;
    }

    return 0;
}


Measured memory_bytes: 1664
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
//#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) {if (a > b) a = b;}
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) {if (a < b) a = b;}
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
// const int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };

void solve() {
	int N; cin >> N;
	if (N <= 2 || __builtin_popcount(N) == 1) {
		print("No"); return;
	}
	else {
		print("Yes");
		FOR(i, 1, 6) {
			int a = i, b = i + 1;
			if (a > 3)a = a % 3 + N;
			if (b > 3) {
				if (b % 3 == 0)b = 3 + N;
				else b = b % 3 + N;
			}
			cout << a << " " << b << endl;
		}
		for (int i = 4; i < N;i+=2) {
			cout << i << " "<<1 << endl;
			cout << i + 1 << " " << 1 << endl;
			cout << i + N << " " << i + 1 << endl;
			cout << i + 1 + N << " " << i << endl;
		}
		if (N % 2 == 0) {
			int x = N ^ (N - 1);
			int y = x ^ 1;
			cout << N - 1 << " " << N << endl;
			cout << y << " " << N + N << endl;
		}
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// mt.seed((int)(time(0)));
	// int q;
	// cin >> q;
	// while (q--)
	solve();
}


Measured memory_bytes: 3660
import numpy as np
from numba import njit
 
n, k = map(int, input().split())
a = np.array(list(map(int, input().split())), dtype=np.int64)
 
@njit
def loop1(a):
  b = np.zeros(n+1, dtype=np.int64)
  for i in range(n):
    l = max(0, i-a[i])
    r = min(i+a[i]+1, n)
    b[l] += 1
    if r <= n-1: b[r] -= 1
  
  b = np.cumsum(b)[:-1]
  return b
 
for q in range(min(42, k)):
  a = loop1(a)
    
print(*a)

Measured memory_bytes: 123640
import Data.Bool  (bool)
import Data.Maybe (fromMaybe)

import qualified Data.List as L

main :: IO ()
main = do
    s <- getLine
    answer $ solve s

type Answer = Bool
answer :: Answer -> IO ()
answer = putStrLn . bool "No" "Yes"

solve :: String -> Answer
solve s = False `fromMaybe` do
    c <- headMay $ L.elemIndices 'C' s
    f <- lastMay $ L.elemIndices 'F' s
    return $ c < f

headMay, lastMay :: [a] -> Maybe a
headMay [] = Nothing
headMay xs = Just $ L.head xs

lastMay [] = Nothing
lastMay xs = Just $ L.last xs


Measured memory_bytes: 508
#include <stdio.h>

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

    if ((a < 1 || 9 < a) || (b < 1 || 9 < b))
    {
        printf("-1\n");
        return 0;
    }
    else
    {
        printf("%d\n", a * b);
        return 0;
    }
}

Measured memory_bytes: 128
#include <string>
#include <iostream>

using namespace std;

int main()
{
	long long ans = 0, i, j, k = 0, H, W, cnt, b[100] = { 0 }, c[100] = { 0 };
	string a[100];

	cin >> H >> W;

	for (i = 0; i < H; i++) {
		cin >> a[i];
	}
	
	for (i = H-1; i >= 0; i--) {
		cnt = 0;
		for (j = 0; j < W; j++) {
			if (a[i][j] == '.') {
				cnt++;
				c[j]++;
			}
		}
		if (cnt == W) {
			b[i]++;
		}
	}

	cnt = 0;
	for (j = W - 1; j >= 0; j--) {
		if (c[j] == H) {
			for (i = 0; i < H; i++) {
				a[i].erase(a[i].begin() + j);
			}
			cnt++;
		}

	}

	for (i = 0; i < H; i++) {
		if(b[i]==0)
		cout << a[i] << endl;
	}

	return 0;
}

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

class UnionFind{
public:
  vector<int> par;
  vector<int> rank;
  vector<int> sz;
  int N;

  UnionFind(int n){N = n;}

  //初期化
  void init(){
    for(int i=0;i<N;i++){
      par.push_back(i);
      rank.push_back(0);
      sz.push_back(1);
    }
  }

  //木の根を求める
  int find(int x){
    if(par[x]==x) return x;
    else{
      par[x]=find(par[x]);
      return par[x];
    }
  }

  //xとyの集合の併合
  void unite(int x, int y){
    x=find(x);
    y=find(y);
    if(x == y) return;

    if(rank[x] < rank[y]){
      par[x] = y;
      sz[y] += sz[x];
    }else{
      par[y] = x;
      sz[x] += sz[y];
      if(rank[x] == rank[y]) rank[x]++;
    }
  }

  //x,yが同じ集合にあるか
  bool same(int x, int y){
    return find(x) == find(y);
  }

  //xの木のサイズ
  int size(int x){
    return sz[find(x)];
  }
};

int main(){
  int x, y;
  cin >> x >> y;
  UnionFind uf = UnionFind(13);
  uf.init();
  uf.unite(1, 3);
  uf.unite(1, 5);
  uf.unite(1, 7);
  uf.unite(1, 8);
  uf.unite(1, 10);
  uf.unite(1, 12);
  uf.unite(4, 6);
  uf.unite(4, 9);
  uf.unite(4, 11);

  if(uf.same(x, y)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;

}


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

int arr[200005], ans;
int cnt[2000005];

int main(){ 
	int n;
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> arr[i];
		cnt[arr[i]]++;
	}

	for(int i = 1;i <= n;++i){
		if(cnt[arr[i]] > 1 || (cnt[1] && arr[i] != 1) )
			continue;
		bool ok = 1;
		for(int j = 2;j * j <= arr[i];++j){
			if(arr[i] % j != 0)
				continue;
			ok &= ((cnt[j] > 0) || (cnt[arr[i] / j])) ^ 1;
		}
		ans += ok;
	}

	cout << ans;
}

Measured memory_bytes: 8264
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
 
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define MAX pow(10,9)+1

using namespace std;
 
typedef long long ll;

int main(int argc, char const *argv[])
{
  int n;
  cin >> n;
  vector<int> a(n);
  int minimum = MAX;
  ll sum = 0;
  bool zero_exist = false;
  int minus_num = 0;
  REP(i,n) {
    cin >> a[i];
    minimum = min(minimum,abs(a[i]));
    sum += abs(a[i]);
    zero_exist = a[i] == 0;
    if (a[i] < 0) minus_num++;
  }
  if (zero_exist || minus_num%2==0) {
    cout << sum << endl;
  }
  else {
    sum -= 2*minimum;
    cout << sum << endl;
  }

  return 0;
}


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

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

  vector<int> p(N);
  p.at(0) = 1;
  for (int i = 1; i < N; i++) {
    cin >> p.at(i);
  }


  vector<int> children(N);
  for (int x : p) {
    children.at(x - 1) ++;
  }
  children.at(0) --;
  for (int i = 0; i < N; i++) {
    cout << children.at(i) << endl;
  }
}

Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long l,r;
    cin >>l>>r;
    r = min(r, l+2019);
    int ans = 2018;
    for(long long i = l; i<=r;i++){
        for(long long j = i+1; j<=r; j++){
            int x = i*j%2019;
            ans=min(ans,x);
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;

const char cs[] = "xo";
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 };
const int dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };

inline bool valid(int x, int y){
    return 0 <= x && x < 8 && 0 <= y && y < 8;
}

struct state {
    vi score;
    vs g;
    state(){}
};

state flip(const int x, const int y, state s, bool turn){
    bool update = false;
    for (size_t i = 0; i < 8; i++){
        int cx = x + dx[i];
        int cy = y + dy[i];
        if (!valid(cx, cy) || s.g[cy][cx] == cs[turn]) continue;
        while (valid(cx, cy) && s.g[cy][cx] == cs[!turn]){
            cx += dx[i];
            cy += dy[i];
        }
        if (valid(cx, cy) && s.g[cy][cx] == cs[turn]){
            update = true;
            for (int ix = x + dx[i], iy = y + dy[i];
                !(ix == cx && iy == cy);
                ix += dx[i], iy += dy[i]){
                s.g[iy][ix] = cs[turn];
                s.score[turn]++;
                s.score[!turn]--;
            }
        }
    }
    if (update){
        s.g[y][x] = cs[turn];
        s.score[turn]++;
        s.score[1 - turn]--;
    }
    return s;
}

int main(){
    state cur;
    cur.score = vector < int > {0, 0};
    for (size_t i = 0; i < 8; i++){
        string s; cin >> s;
        cur.g.push_back(s);
        cur.score[0] += count(s.begin(), s.end(), 'x');
        cur.score[1] += count(s.begin(), s.end(), 'o');
    }

    for (size_t turn = 1; turn <= 64; turn++){
        bool ok = false;
        state next = cur;
        for (size_t y = 0; y < 8; y++){
            for (size_t x = 0; x < 8; x++){
                if (cur.g[y][x] == '.'){
                    state cand = flip(x, y, cur, turn & 1);
                    if (((turn & 1) == 1 && next.score[1] < cand.score[1]) ||
                        ((turn & 1) == 0 && next.score[0] <= cand.score[0])){
                        ok = true;
                        next = cand;
                    }
                }
            }
        }

        cur = next;
    }

    for (size_t i = 0; i < 8; i++){
        cout << cur.g[i] << endl;
    }
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>
#include <cmath>
#include <cstdio>

using namespace std;

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

using ll = long long;
using ull = unsigned long long;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif


void solve() {
    string x;
    cin >> x;
    putchar(x[0]);
    cin >> x;
    putchar(x[1]);
    cin >> x;
    putchar(x[2]);
    putchar('\n');
}


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


Measured memory_bytes: 256