akhauriyash/Code-Regression huggingface dataset:
#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;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;

struct edge { int to, cost; };
int V;//頂点数
vector<edge>G[MAX];
int d[MAX];//始点からの距離
using P = pii;
void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P>>que;
	fill(d, d + V, INF);
	d[s] = 0;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

void solve() {
	int K; cin >> K;
	V = K;
	REP(i, K) {
		int nxt = (i + 1) % K;
		G[i].push_back({ nxt,1 });
		nxt = (i * 10) % K;
		G[i].push_back({ nxt,0 });
	}
	dijkstra(1);
	print(d[0]+1);
}





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: 16124
#include <bits/stdc++.h>
using namespace std;

int main(void) {
   long A,B;
   cin>>A>>B;
   while (1) {
      if (A>B) {
         A -= ((long)A/B) * B;
         if (A==0) break;
      } else {
         B -= ((long)B/A) * A;
         if (B==0) break;
      }
      // cout<<A<<" "<<B<<endl;
   }
   long GCD = max(A,B);
   // cout<<GCD<<endl;
   // long Gsq = (long)sqrt(GCD);
   set<int> ans;
   ans.insert(1);
   long i = 2;
   while(1) {
      if (GCD== 1) break;
      while (GCD%i == 0) {
         GCD /= i;
         ans.insert(i);
      }
      i++;
      if (i > sqrt(GCD)) i = GCD;
   }
   cout<<ans.size()<<endl;
   return 0;
}

Measured memory_bytes: 256
s=input()
l=len(s)
alpha=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
ans=[0]*26
for i in range(l):
  for j in range(26):
    if s[i]==alpha[j]:
      ans[j]+=1
for i in range(26):
  if ans[i]==0:
    print(alpha[i])
    break
  if i==25:
    print('None')

Measured memory_bytes: 3188
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
    int n;
    double a;
    
    cin >> n;
    
    if ((n % 2) == 0) {
        cout << 0.5000000000;
    }else{
        a = (n / 2 + 1) / (double)n;
        cout<<setiosflags(ios::fixed|ios::showpoint)<<setprecision(10)<<a<<endl;
    }


    
   
    
    return 0;
}


Measured memory_bytes: 256
/*  ex2_3
    kosaq       */

#include <stdio.h>

int main(void){
    int N;      // The length of one side of square
    int A;      // The number of white

    // The number of black is (N * N) - A

    scanf("%d" "%d", &N, &A);       // input N and A
    printf("%d\n", N * N - A);      // output the number of black
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int to_int(char ch)
{
    return (ch - '0');
}

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

    int month = to_int(date[5])*10 + to_int(date[6]);
    cout << (month <= 4 ? "Heisei\n" : "TBD");

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;

const ll MOD = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()



int main() {
	string s;
	cin >> s;
	bool b = false, f = false;
	if (s[0] == s[s.size() - 1])b = true;
	if ((s.size()) % 2 == 0)f = true;
	if (b^f)cout << "Second" << endl;
	else cout << "First" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  string s;
  cin >> s;
  char last = 'A';
  int cc = 0;
  long long ans = 0;
  for (char c : string(s.rbegin(), s.rend())) {
    if (c == 'A') {
      int mv = 0;
      if (last == 'B') {
        mv = cc / 2;
      }
      ans += mv;
      cc = 2 * mv;
    } else {
      if (c != last) {
        last = c;
        ++cc;
      } else {
        cc = 1;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 788
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int n;
    cin >> n;

    for ( int i = n; i > 0; i-- ) {
        if ( (int) (i * 1.08) == n ) {
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(\n";

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 500000
#define INFTY 1000000000

void merge(int *,int,int,int);
void mergesort(int *,int,int);

int n,num[MAX],count=0;

int main() {

  int i;
  
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&num[i]);

  mergesort(num,0,n);

  for(i=0;i<n;i++) {
    if(i>0) printf(" ");
    printf("%d",num[i]);
  }
  printf("\n%d\n",count);

  return 0;

}


void merge(int *A, int left, int mid, int right) {

  int i,j,k;
  int n1 = mid - left;
  int n2 = right -mid;

  int L[n1],R[n2];

  for(i=0;i<n1;i++) L[i] = A[left+i];
  for(i=0;i<n2;i++) R[i] = A[mid+i];

  L[n1] = INFTY;
  R[n2] = INFTY;

  i=j=0;

  for(k=left;k<right;k++) {
    if( L[i] <= R[j]) {
      A[k] = L[i];
      i+=1;
    } else {
      A[k] = R[j];
      j+=1;
    }
    count++;
  }
}

void mergesort(int *A, int left, int right) {
  
  if( left+1 < right ) {
    int mid = ( left + right )/2;
    mergesort(A,left,mid);
    mergesort(A,mid,right);
    merge(A,left,mid,right);
  }
  
}


Measured memory_bytes: 5628
s = list(input())
n = len(s)

si = s[::-1]

ans = 'Yes'

for i in range(n):
    if s[i] != si[i]:
        ans = 'No'

sa = s[:(n-1)//2]
sa = sa[::-1]

for i in range((n-1)//2):
    if s[i] != sa[i]:
        ans ='No'

sb = s[(n-1)//2+1:]
sb = sb[::-1]

for i in range((n-1)//2):
    if s[i] != sb[i]:
        ans = 'No'

print(ans)

Measured memory_bytes: 38384
#include <iostream>
using namespace std;
int prime[1000001];
int a,d,n,cnt,ans;



int main(){
	prime[1]=0;
	for(int i=2;i<1000001;i++){
		prime[i]=1;
	}
	for(int i=2;i<=1000;i++){
		if(prime[i]==0)continue;
		int k=i*i;
		while(k<1000001){
			prime[k]=0;
			k+=i;
		}
	}
	//cout <<"OK"<<endl;
	while(1){
		cin >>a >>d >>n;
		if(!(a||d||n))break;
		cnt=0;
		for(int i=a;i<=1000001;i+=d){
			cnt+=prime[i];
			if(cnt==n){
				ans=i;
				break;
			}
		}
		cout <<ans<<endl;
	}
}

Measured memory_bytes: 6880
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

string s;
long long k;
 
int main(){
  ios_base::sync_with_stdio(false);

  cin >> s >> k;

  if(s[0] == '1' && k == 1){
    cout << "1" << endl;
  } else {
    for(int i=0;i<k;i++){
      if(s[i] != '1'){
        cout << s[i] << endl;
        return 0;
      }
    }
    cout << "1" << endl;
  }
 
  return 0;
}



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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  double a, b, n;
  cin >> a >> b >> n;
  cout << (ll)(floor(a * min(n, (b - 1))/ b) - a * floor(min(n, (b-1)) / b)) << endl;
}


Measured memory_bytes: 3724
import math
N, D = [int(x) for x in input().split(' ')]

X = []
for n in range(N):
 X.append([int(x) for x in input().split(' ')])

count = 0
for i in range(N):
 for j in range(i+1, N):
  if math.sqrt(sum([(X[i][d] - X[j][d])**2 for d in range(D)])) % 1 == 0.:
          count +=1

print(count)

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

deque<int> deq;

void push(int d, int x){
  if(d) deq.push_back(x);
  else deq.push_front(x);
}

int randomAccess(int p){
  return deq[p];
}

void pop(int d){
  if(d) deq.pop_back();
  else deq.pop_front();
}

int main(){
  int q, com, d, x, p;
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> com;
    switch(com){
    case 0:
      cin >> d >> x;
      push(d, x);
      break;
    case 1:
      cin >> p;
      cout << randomAccess(p) << endl;
      break;
    case 2:
      cin >> d;
      pop(d);
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 4636
use proconio::{ input, fastout };

#[fastout]
fn main() {
    input! {
        n: usize,
    };
    let yomi = match n % 10 {
        2 | 4 | 5 | 7 | 9 => "hon",
        0 | 1 | 6 | 8 => "pon",
        _ => "bon",
    };
    print!("{}", yomi);

}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const ll inf=1e18;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   ll x,y,r=0;
   cin>>x>>y;
   if(x==1)r=r+300000;
   else if(x==2)r=r+200000;
   else if(x==3)r=r+100000;
   if(y==1)r=r+300000;
   else if(y==2)r=r+200000;
   else if(y==3)r=r+100000;
   if(x==1 && y==1)r=r+400000;
   cout<<r<<endl;
}


Measured memory_bytes: 256
(defun solve (a b)
  (cond
    ((= a b) (+ a b))
    ((< a b) (+ b (1- b)))
    (t (+ a (1- a)))))

(defun main ()
  (let ((a (read))
        (b (read)))
    (format t "~A~%" (solve a b))))

(main)


Measured memory_bytes: 12004
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    set<ll> st;
    ll free = 0;

    rep(i, n){
        ll a; cin >> a;
        if(a >= 3200){ free++; continue; }
        for(ll j=0; j<8; j++) if(400*j <= a && a < 400*(j+1)) st.insert(j);
    }
    cout << ((st.size()==0 && free >= 1) ? 1 : st.size()) << " " << (ll)st.size()+free << endl;
}

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

int main() {
	int N, H, MAX,  count = 1;
	cin >> N >> MAX;
	for (int i = 1; i < N; i++) {
		cin >> H;
		if (MAX <= H) {
			count++;
			MAX = H;
		}
	}
	cout << count;
}

Measured memory_bytes: 256
N,M = map(int,raw_input().split())
AB = [0]*N
for i in range(0,N):
  AB[i] = map(int,raw_input().split())
AB = sorted(AB,key=lambda x: x[0])
con = 0
ans = 0

for i in range(0,N):
  for j in range(0,AB[i][1]):
    con = con + 1
    ans = ans + AB[i][0]
    if con == M:
      break
  else:
    continue
  break
print ans

Measured memory_bytes: 25076
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};

//全二点間の距離
//ヨ i,d[i][i]<0なら負の閉路
in MAX_dist=1e9+7;
in V=0;
vector<vector<in>> d(0,vector<in>(0,MAX_dist));//d[x][y]:=x->yのcost,枝が無ければMAX_dist,d[i][i]=0

void init(in n){
    d=vector<vector<in>>(n,vector<in>(n,MAX_dist));
    rep(i,n) d[i][i]=0;
    V=n;
}

void warshall(){
    rep(k,V){
        rep(i,V){
            if(d[i][k]==MAX_dist) continue;
            rep(j,V){
                if(d[k][j]==MAX_dist) continue;
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in n;
    cin>>n;
    init(n);
    vector<vector<in>> a(n,vector<in>(n));
    rep(i,n)rep(j,n) cin>>a[i][j];
    rep(i,n)rep(j,n) d[i][j]=a[i][j];
    warshall();
    rep(i,n)rep(j,n){
        if(d[i][j]!=a[i][j]){
            cout<<-1<<endl;
            return 0;
        }
    }
    rep(i,n)REP(j,i+1,n){
        rep(k,n){
            if(i==k) continue;
            if(j==k) continue;
            if(d[i][j]==d[i][k]+d[k][j]){
                a[i][j]=0;
                a[j][i]=0;
                break;
            }
        }
    }
    in ans=0;
    rep(i,n)REP(j,i+1ll,n) ans +=a[i][j];
    cout<<ans<<endl;
}

Measured memory_bytes: 1664
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    s: chars
    }

    let mut z = 0i64;
    let mut o = 0;
    for i in s {
        if i == '0' {
            z += 1;
        }

        if i == '1' {
            o += 1;
        }
    }

    println!("{}", z + o - (z - o).abs());
}


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

using namespace std;

int main(){
    int h,w,cnt=0;
	cin>>h>>w;
	int a[h][w];
	vector<string> ans;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w-1;j++){
			if(a[i][j]%2==1){
				a[i][j+1]++;
				cnt++;
				ans.push_back(to_string(i+1)+' '+to_string(j+1)+' '+to_string(i+1)+' '+to_string(j+2));
			}
		}
	}
	for(int i=0;i<h-1;i++){
		if(a[i][w-1]%2==1){
			a[i+1][w-1]++;
			cnt++;
			ans.push_back(to_string(i+1)+' '+to_string(w)+' '+to_string(i+2)+' '+to_string(w));
		}
	}
	cout<<cnt<<endl;
	for(int i=0;i<ans.size();i++){
		cout<<ans[i]<<endl;
	}
}

Measured memory_bytes: 11892
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int cnt[3];

int main() {
  // 入力
  string s;
  cin >> s;

  for (int i = 0; i < s.size(); i++) {
    cnt[s[i]-'a']++;
  }
  sort(cnt, cnt + 3);

  // 解答
  cout << (cnt[2] - cnt[0] <= 1 ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 512
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
 
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD=1e9+7;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
int N;
ll calc(vector<ll> &hoge,ll x){
	ll ret=0;
	rep(i,N){
		ret+=abs(hoge[i]-x);
	}
	return ret;
}
pair<plli,plli> dp[314514];
int main(){
	cin>>N;;
	vector<ll>hoge;
	if(N==1){
		cout<<0<<endl;
		return 0;
	}
	rep(i,N){
		ll num;
		cin>>num;
		hoge.pb(num-(ll)i-(ll)1);
	}
	sort(all(hoge));
	int check = (N-1)/2;
	cout<<min(calc(hoge,hoge[check]),calc(hoge,hoge[check+1]))<<endl;
	
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n],b[n],c=0,d;
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    if(c<a[i]){
      c=a[i];
      d=a[i]+b[i];
    }
  }
  cout << d;
}

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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vi, greater<int>> mpqi;

#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define F0R(i,a) for(int i = 0; i < a; i++)
#define R0F(i,a) for(int i = a - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define ins insert
#define ft front()
#define bk back()
#define f first
#define s second
#define trav(a,x) for(auto& a : x)
#define ALL(x) (x).begin(), (x).end()

const int MOD = 1000000007;
const int MX = 2e5+2;
const ll INF = 1000000000000000000;
const ld PI = 4*atan((ld)1);
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

bool ckmin(int& a, int b){ return b < a ? a = b, true : false; }
bool ckmax(int& a, int b){ return b > a ? a = b, true : false; }
int rudiv(int a, int b){ return (a+b-1)/b; }

// Output
void op(int ok){ cout << ok << endl; }
void op(string ok){ cout << ok << endl; }
void op(ll ok){ cout << ok << endl; }
void op(char ok){ cout << ok << endl; }
void op(db ok){ cout << fixed << setprecision(7) << ok << endl; }
void op(ld ok){ cout << fixed << setprecision(7) << ok << endl; }
void op(pi ok){ cout << ok.f << " " << ok.s << endl; }
void op(pl ok){ cout << ok.f << " " << ok.s << endl; }
void op(pd ok){ cout << ok.f << " " << ok.s << endl; }

// -----------

map<string, int> m;
int n;
string str;
int maxAmm;
vector<string> ok;

int main(){
    IOS;
    cin >> n;
    F0R(i,n){
        cin >> str;
        m[str]++;
        maxAmm = max(maxAmm, m[str]);
    }
    trav(x, m){
        if(x.s == maxAmm) ok.pb(x.f);
    }
    sort(ALL(ok));
    F0R(i,(int)ok.size()){
        op(ok[i]);
    }
    return 0;
    // You should actually read the notes to self.
}

/* NOTES TO SELF:
    Int overflow? Array bounds?
    Edge cases? (n = 1, n = 0)
    Don't make segtrees and fenwick trees 0-based you idi0t
    Don't be dumbosity please pace yourself.
*/

Measured memory_bytes: 27264
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		List<Integer> list = new ArrayList<>();
		for(int i=1;i<=1000;i++) list.add(i*i);
		int n = in.nextInt();
		int d = in.nextInt();
		int[][] x = new int[n][d];
		for(int i=0;i<n;i++) {
			for(int j=0;j<d;j++) {
				x[i][j] = in.nextInt();
			}
		}
		int count = 0;
		for(int i=0;i<n;i++) {
			for(int j=i+1;j<n;j++) {
				int dist = 0;
				for(int k=0;k<d;k++) {
					dist += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
				}
				if(Collections.binarySearch(list,dist,(e1,e2)->e1-e2)>=0) {
					count++;
				}
			}
		}
		System.out.println(count);
		
		in.close();

	}

}


Measured memory_bytes: 26836
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int r, D, x;
    cin >> r >> D >> x;

    rep(i, 10) {
        cout << r * x - D << endl;
        x = r * x - D;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    int ans = 0, MAX = 0;
    rep(i, n) if (MAX <= h[i]) ans++, MAX = h[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

int main(){
    int n;
    cin >> n;
    int d[n];
    rep(i,n){
        cin >> d[i];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans+=d[i]*d[j];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
typedef long long ll;
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<pair<string, ll> > s(n);
    for(int i = 0;i < n;i++){
        string t;
        ll n;
        cin >> t >> n;
        s[i] = make_pair(t,n);
    }
    string key;
    cin >> key;
    ll ans = 0;
    bool flag = false;
    for(int i = 0;i < n;i++){
        if(flag){
            ans += s[i].second;
        }
        if(s[i].first == key){
            flag = true;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
using namespace std;


// ============union_find_tree===============
ll MAX_N = 200010;
vector<ll> par(MAX_N, -1);//MAX_N == num of node
vector<ll> tree_rank(MAX_N, 0);

void init(ll n)
{
  for (ll i = 0; i < n; ++i)
  {
    par.at(i) = i;
    tree_rank.at(i) = 0;
  }
}

ll find(ll x)
{
  if (par.at(x) == x)
  {
    return x;
  }
  else
  {
    return par.at(x) = find(par.at(x));
  }
}

void unite(ll x, ll y)
{
  x = find(x);
  y = find(y);
  if (x == y)
  {
    return;
  }
  if (tree_rank.at(x) < tree_rank.at(y))
  {
    par.at(x) = y;
  }
  else
  {
    par.at(y) = x;
    if (tree_rank.at(x) == tree_rank.at(y))
    {
      tree_rank.at(x)++;
    }
  }
}
// =======================================


int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M;
  cin >> N >> M;
  init(N + 10);
  for (ll i = 0; i < M; ++i) {
    ll a, b;
    cin >> a >> b;
    a -= 1;b -= 1;
    unite(a, b);
  }
  for (ll i = 0; i < N; ++i) {
    find(i);
  }
  vector<ll> num(N, 0);
  for (ll i = 0; i < N; ++i) {
    if (par.at(i) == -1) {
      continue;
    }
    num.at(par.at(i)) += 1;
  }
  ll ans = 0;
  for (ll i = 0; i < N; ++i) {
    ans = max(num.at(i), ans);
  }
  cout << ans << "\n";
}


Measured memory_bytes: 7940
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        String str = sc.next();
		int minDiff = Integer.MAX_VALUE;
        for (int i=0; i<str.length()-2; i++) {
            int threeDigitNum = Integer.parseInt(str.substring(i, i+3));
            int diff = Math.abs(753 - threeDigitNum);
            minDiff = Math.min(diff, minDiff);
        }
        System.out.println(minDiff);
    }
}

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

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

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int64 N, K;
  cin >> N >> K;
  if (K > (N-1)*(N-2)/2) {
    cout << -1 << endl;
    return 0;
  }
  cout << N-1+((N-1)*(N-2)/2-K) << endl;
  REP(i, N-1) cout << 1 << " " << i+2 << endl;
  int64 cnt = (N-1)*(N-2)/2;
  FOR(i, 1, N) {
    FOR(j, i+1, N) {
      if (cnt != K) {
        cout << i+1 << " " << j+1 << endl;
        cnt--;
      } else {
        break;
      }
    }
  }

}


Measured memory_bytes: 256
n,m=map(int,input().split())
card=[]
L=1
R=n
for i in range(m):
    card.append([int(i) for i in input().split()])
for j in card:
    if j[0]<=R:
        if L<=j[0]:
            L=j[0]
            
    else:
        print(0)
        quit()
    if L<=j[1]:
        if j[1]<=R:
            R=j[1]
            
    else:
        print(0)
        quit()
print(R-L+1)

Measured memory_bytes: 21156
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

int N,Z,W,A[2000];

int main()
{
	cin>>N>>Z>>W;
	rep(i,N) cin>>A[i];
	if(N==1) cout<<abs(A[0]-W)<<endl;
	if(N>=2)cout<<max(abs(A[N-1]-W),abs(A[N-1]-A[N-2]))<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;

ll dp[3][100005];
int main(){
	int n;
    cin>>n;
    int ans=0;
    while(ans==0){
        int tmp=n;
        bool flag=true;
        for(int i=2;i<=sqrt(n);i++){
            if(tmp%i==0){
                
                flag=false;
                break;
            }
            while(tmp%i==0){
                tmp/=i;
            }
        }
        if(flag){
            ans=n;
        }
        n++;
    }
    OUT(ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define ssort(a) sort(a.begin(), a.end())
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int a, b, q;
  cin >> a >> b >> q;
  vector<ll> s(a+1);
  vector<ll> sr(a+1);
  vector<ll> t(b+1);
  vector<ll> tr(b+1);
  vector<ll> x(q);
  rep(i, a){
    cin >> s[i];
    sr[a-i-1]=-s[i];
  }
  s[a]=INFll;
  sr[a]=INFll;
  rep(i, b){
    cin >> t[i];
    tr[b-i-1]=-t[i];
  }
  t[b]=INFll;
  tr[b]=INFll;
  rep(i, q){
    cin >> x[i];
  }
  rep(i, q){
    ll it1=*upper_bound(s.begin(), s.end(), x[i]);
    ll it2=-*upper_bound(sr.begin(), sr.end(), -x[i]);
    ll it3=*upper_bound(t.begin(), t.end(), x[i]);
    ll it4=-*upper_bound(tr.begin(), tr.end(), -x[i]);
    ll d1[2]={it1, it2};
    ll d2[2]={it3, it4};
    ll ans=INFll;
    ll num;
    rep(j, 2)rep(k, 2){
      num=abs(x[i]-d1[j])+abs(d1[j]-d2[k]);
      ans=min(ans, num);
    }
    rep(j, 2)rep(k, 2){
      num=abs(x[i]-d2[j])+abs(d1[k]-d2[j]);
      ans=min(ans, num);
    }
    cout << ans << endl;
  }

  return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
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()
{
    cout << fixed << setprecision(15);
    int A, B, C;
    cin >> A >> B >> C;
    cout << min(min(A+B, B+C), C+A) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long beki[35];
    beki[0] = 1;
    for(int i=1;i<35;i++){
        beki[i] = beki[i-1] * 2;
    }
    long a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    sort(a,a+n);
    map<long,int>m;
    for(int i=0;i<n;i++){
        m[a[i]]++;
    }
    int ans = 0;
    for(int i=n-1;i>0;i--){
        if(m[a[i]] > 0){
            long makeBeki = 0;
            // bool bekibeki = false;
            for(int j=34;j>0;j--){
                if(a[i] >= beki[j-1]){
                    makeBeki = beki[j];
                    break;
                }
            }

            // cout << a[i] << " "<<makeBeki<<endl;

            
            if(a[i] == makeBeki-a[i]){
                if(m[a[i]]>=2){
                    m[a[i]]-=2;
                    ans++;
                }
            }else{
                if(m[makeBeki-a[i]]>=1){
                    m[a[i]]--;
                    m[makeBeki-a[i]]--;
                    ans++;
                }

            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    llong n, h, w;
    cin >> n >> h >> w;
    llong ans=0;
    for(int i=0; i<n; ++i) {
        int a, b; cin >> a >> b;
        if (a >= h && b >= w) ++ans;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

uint_fast32_t scan(){
    uint_fast32_t a{};
    int c;
    while((c=getchar_unlocked()-'0')>=0) a=a*10+c;
    return a;
}

uint_fast64_t scan64(){
    uint_fast64_t a{};
    int c;
    while((c=getchar_unlocked()-'0')>=0) a=a*10+c;
    return a;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    ll k;
    n=scan();k=scan64();
    vector<int> a(n),f(n);
    for(auto&i:a) i=scan();
    for(auto&i:f) i=scan();
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    sort(f.begin(),f.end());
    ll l=-1,r=1e18,m;
    while(r-l>1){
        m=(l+r)>>1;
        ll s=0;
        fr(i,n) if(a[i]>m/f[i]) s+=a[i]-m/f[i];
        if(s>k) l=m;
        else r=m;
    }
    cout<<r<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define REP(I,N) for(int I=0;I<N;I++)
#define FOR(I,A,B) for(int I=A;I<=B;I++)
#define FORD(I,A,B) for(int I=A;I>=B;I--)
#define c(A) cin >> A
#define c2(A,B) cin >> A >> B
#define c3(A,B,C) cin >> A >> B >> C
#define c4(A,B,C,D) cin >> A >> B >> C >> D
#define c5(A,B,C,D,E) cin >> A >> B >> C >> D >> E
#define IS ios_base::sync_with_stdio(false); cin.tie(0);
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define db if(1)cerr
template<typename C> void MA(C& a,C b){if(a<b)a=b;}
template<typename C> void MI(C& a,C b){if(a>b)a=b;}

const int N = 2000+7;
int a[N];
int mini[N][N];

int main () {
	IS;
	
	int n,x;
	cin >> n >> x;

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

	for(int i=2;i<=n;i++) {
		for(int j=0;j<n;j++) {
			mini[j][(j+i-1)%n] = min(mini[j][(j+i-2+n)%n], a[(j+i-1)%n]);
		}
	}

	//for(int i=0;i<n;i++) for(int j=0;j<n;j++) cout << "mini[ " << i << "][" << j << "] = " << mini[i][j] << endl;

	ll res = 1e18;
	for(int i=0;i<=n;i++) {
		ll tempres = (ll)i*x;
		for(int j=0;j<n;j++) {
			tempres += mini[(j-i+n)%n][j];
		}
		res = min(res, tempres);
	}
	cout << res << endl;
}


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

int main(){
    int N;  cin >> N;
    vector<ll> A(N);
    for(int i=0; i<N; i++)
        cin >> A[i];
    
    ll ans = 0;
    for(int i=0; i<N; i++){
        ans += A[i]/2;
        A[i]%=2;
        if(i<N-1 && A[i] > 0 && A[i+1] > 0){
            A[i]--;  A[i+1]--;
            ans++;
        }
    }
    cout << ans << endl;
}


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

#define IOS cin.tie(0);ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vs      vector<string>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())
#define END cout<<"\n"

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)    for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 200;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//


signed main(){
    SCIN(s);
    CIN(Q);
    rep(i,Q){
        CIN(T);
        if(T==1)flag^=1;
        else if(T==2){
            CIN(F);SCIN(c);
            if(flag^(F==1))s.insert(0,c);
            else s+=c;
        }
    }
    if(flag)reverse(all(s));
    output_s(s);

    return 0;
}

Measured memory_bytes: 900
N = int(input())
H = list(map(int, input().split()))

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

for i in range(N-1):
    if H[i] > H[i+1]:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 63856
#include"bits/stdc++.h"
using namespace std;

#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 all(v) v.begin(), v.end()
using ll = long long;


int main() {
	int n;
	int a;
	cin >> n;
	vector<int> bu(n+1,-1);
	REP(i, n)cin >> bu[i];
	int button = 1,before=1;
	int cnt=0;
	while (1) {
		before = button;
		button = bu[button];
		bu[before] = -1;
		cnt++;
		if (button == 2) {
			cout << cnt << endl;
			break;
		}
		if (button == -1) {
			cout << -1 << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int t = sc.nextInt();
        int s = sc.nextInt();
        double ans = (double) d / (double) s;
        if (ans <= t) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35616
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(n==i*j){
                cout << "Yes";
                return 0;
            }
        }
    }
    
    cout << "No";
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define ll long long
#define ld long double
#define MAX (int)(7*pow(10,2) + 10)
#define pb(a) push_back(a)
// #define cout out
// #define cin in
ll inf = pow(10,9);
ll INF = inf;
ll modulo = inf;
double eps = 1e-10;
ifstream in;
ofstream out;

 
void deal(){
	ll n;
	cin>>n;
	string a;
	cin>>a;
	ll cnt[2] = {0,0};
	string dir = "RB";
	for(auto& f : a)
		cnt[dir.find(f)]++;
	if(cnt[0] > cnt[1])
		cout<<"Yes";
	else
		cout<<"No";
}



int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}



/*
	
*/

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

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

  int sum = 0;
  for (int i = l; i < l + n; i++) sum += i;

  if (l > 0)
    cout << sum - l << endl;
  else if (l <= 0 && l + n - 1 >= 0)
    cout << sum << endl;
  else if (l + n - 1 < 0)
    cout << sum - (l + n - 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
#define en "\n"
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
 
using namespace std;
const ll maxn=1e3+100,inf=1e18,LOG=23,mod=1e9 + 7;
 
#define int ll

int n, dp[maxn][20010], w[maxn], s[maxn], v[maxn], ind[maxn];

bool comp(int i, int j)
{
	return s[i] - w[j] > s[j] - w[i];
}

main()
{
	cin >> n;
	forn(1, i, n)
	{
		cin >> w[i] >> s[i] >> v[i];
		ind[i] = i;
	}
	sort(ind + 1, ind + 1 + n, comp);
	forn(1, i, n)
	{
		forn(0, solid, 10000)
		{
			dp[i][solid] = dp[i - 1][solid];
			if(solid <= s[ind[i]])
			{
				dp[i][solid] = max(dp[i][solid], dp[i - 1][solid + w[ind[i]]] + v[ind[i]]);
			}
		}
	}
	int ans = 0;
	forn(0, solid, 10000)
	{
		ans = max(ans, dp[n][solid]);
	}
	cout << ans;
}

Measured memory_bytes: 156928
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
const int mod = 1000000009;

int h,w,cnt[26],two,one;
string s;

int main(){
    I(h); I(w);
    REP(i,h){
        cin >> s;
        REP(j,w) cnt[s[j]-'a']++;
    }
    if (h%2 && w%2){
        one = 1;
        two = h/2+w/2;
    } else if (h%2){
        two = w/2;
    } else if (w%2){
        two = h/2;
    }
    REP(i,26){
        if (cnt[i]&1) one--;
        if (cnt[i]&2) two--;
    }
    if (one >= 0 && two >= 0 ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

inf=10**8

n,m=map(int,input().split())

A=[]
C=[]
dp=[inf]*(1<<n)
dp[0]=0

for _ in range(m):
  a,_=map(int,input().split())
  c=list(map(int,input().split()))
  A.append(a)
  tmp=0
  for i in c:
    tmp+=1<<(i-1)
  C.append(tmp)

for i in range(1<<n):
  for index,j in enumerate(C):
    dp[i|j]=min(dp[i|j],dp[i]+A[index])
ans=dp[-1]
if ans==inf:ans=-1
print(ans)

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n, k; cin >> n >> k;

    vector<ll> num(k, 0);

    for (ll i = 1; i <= n; ++i) {
        //1以上n以下の数値をkで割り、余った数をカウント
        ++num[i%k];
    }

    ll ans = 0;

    //a%kで全探索→調べる範囲は0〜k-1
    for (int a = 0; a < k; ++a) {
        ll b = (k - a) % k; //k-aがkになる場合があるため、kでmod
        ll c = (k - a) % k; //k-aがkになる場合があるため、kでmod

        if ((b + c) % k != 0) { //b+cも条件を満たしているか確認する
            continue;
        }

        ans += num[a] * num[b] * num[c];
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; i++)
int main(){
    int n,k; cin >> n >> k;
    ll odd = 0,even = 0;
    for(int i = 1; i <= n; i++){ //aについて考える
        if(2*i % k == 0){ //2a,2b,2cがkの倍数であることが必要
            if((2*i / k) % 2 != 0){ //2iをkで割った商が全て奇数
                odd++;
            }else{
                even++; //2iをkで割った商が全て偶数
            }
        }
    }
    cout << odd*odd*odd + even*even*even << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){
    string A;
    cin >> A;
    ll m[27];

    rep(i, 27){
        m[i] = 0;
    }
    rep(i, A.size()){
        m[A[i] - 'a']++;
    }
    ll ans = (A.size()*(A.size()-1))/2;
    rep(i, 27){
        ans -= (m[i]*(m[i]-1))/2;
    }
    cout << ans +1 << endl;
};

Measured memory_bytes: 640