akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

ll gcd(ll a,ll b){
  if(a<b) swap(a,b);
  if(b==0)return a;
  return gcd(b,a%b);
}

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

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  ll l = 1;
  rep(i,N){
    ll x;cin >> x;
    l = lcm(l,x);
  }
// ll g = 1;
// ll l = 1;
// rep(i,N){
//   ll x;cin >> x;
//   g = gcd(l,x);
//   l *= (x/g);
// }
  cout << l << endl;
  return 0;
}


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

using namespace std;


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

    int M = max(a, b);
    int m = min(a, b);
    int ans = M - (m + W);
    if (ans < 0) ans = 0;

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

Measured memory_bytes: 256
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
for i in range(3):
  for j in range(3):
    for k in b:
      if a[j][i] == k:
            a[j][i] = 'o'
a1 = list(set(a[0]))
a2 = list(set(a[1]))
a3 = list(set(a[2]))
a4 = list(set((a[0][0],a[1][1],a[2][2])))
a5 = list(set((a[0][2],a[1][1],a[2][0])))
a6 = list(set((a[0][0],a[1][0],a[2][0])))
a7 = list(set((a[0][1],a[1][1],a[2][1])))
a8 = list(set((a[0][2],a[1][2],a[2][2])))
p = ['o']
A = [a1,a2,a3,a4,a5,a6,a7,a8]
for i in A:
    ans = 'No'
    if i == p:
        ans = 'Yes'
        break
print(ans)

Measured memory_bytes: 3064
S = str(input())
N = len(S)

con = []
border = []
for i in range(N - 1):
  if S[i] == "L" and S[i + 1] == "R":
    border.append(i)
  elif S[i] == "R" and S[i + 1] == "L":
    con.append(i)
  
border.append(N - 1)  

#print(border, con)    

ans = [0] * N
now = -1
for i in range(len(con)):
  #con[i] と con[i] + 1 に
  #now - border[i] の数があつまる。
  pp = border[i] - now
  if pp % 2 == 0:
    ans[con[i]] += pp / 2
    ans[con[i] + 1] += pp / 2
  else:
    if (con[i] - now) % 2 == 0:
      ans[con[i]] += (pp - 1) / 2
      ans[con[i] + 1] += (pp + 1) / 2     
    else:
      ans[con[i]] += (pp + 1) / 2
      ans[con[i] + 1] += (pp - 1) / 2       
  now = border[i]
  #print(pp, ans)  
  
  
for i in range(N):
  print(int(ans[i]), end = " ")
  
  
  


Measured memory_bytes: 17136
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        System.out.println( solve(a,b,c,d) );
    }

    private static String solve(int a, int b, int c, int d) {
        if( canTalk(a, b, d) && canTalk(b, c, d) || canTalk(a, c, d) ) {
            return "Yes";
        } else {
            return "No";
        }
    }

    private static boolean canTalk(int x, int y, int d) {
        return Math.abs(x - y) <= d;
    }
}


Measured memory_bytes: 21844
import numpy as np

h,w=list(map(int,input().split()))
s=np.zeros((h+2,w+2))

for i in range(1,h+1):
    input_=input()
    for j in range(1,w+1):
        if input_[j-1]=="#":
            s[i][j]=1
n=0
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j]==1:
            if (s[i-1][j]==0 and s[i+1][j]==0 and s[i][j+1]==0 and s[i][j-1]==0):
                n+=1
if n==0:
    print("Yes")
else:
    print("No")    
            

Measured memory_bytes: 12508
N, L = map(int,input().split())
A = [L+i for i in range(N)]
#print(A)
expect = sum(A)
minimum = float('inf')
for a in A:
    tmp = expect
    minimum = min(minimum,abs(sum(A)-(tmp-a)))
    if minimum == abs(sum(A)-(tmp-a)):
        ans = tmp-a
print(ans)

Measured memory_bytes: 9164
fun main(args: Array<String>) {
    val (a, b, c, d) = readLine()!!.split(' ').map(String::toLong)
    val po1 = b / c - (a - 1) / c
    val po2 = b / d - (a - 1) / d
    fun gcd(x: Long, y: Long): Long {
        val (y1, x1) = listOf(x, y).sorted()
        val po = x1 % y1
        return if (po == 0L) y1 else gcd(y1, po)
    }
    fun lcm(x: Long, y: Long): Long {
        val g = gcd(x, y)
        return g * (x / g) * (y / g)
    }
    val meu = lcm(c, d)
    val po3 = b / meu - (a - 1) / meu
    println((b - a + 1) - po1 - po2 + po3)
}


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

int hex_to_dec(char x){
  switch(x){
    case 'A':
      return 10;
    case 'B':
      return 11;
    case 'C':
      return 12;
    case 'D':
      return 13;
    case 'E':
      return 14;
    case 'F':
      return 15;
  }
}

int main(){
  char X,Y;
  cin >> X >> Y;
  int x = hex_to_dec(X);
  int y = hex_to_dec(Y);
  if(x > y) cout << '>';
  else if(x == y) cout << '=';
  else cout << '<';
  cout << "\n";
}


Measured memory_bytes: 256
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define repd(i,n) for(int (i)=n-1;(i)>=0;i--)
#define REPD(i,n) for(int (i)=n;(i)>0;i--) 
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int Maxn=200005;
const int Maxm=30;
const int H=31;
int n,match;
string s;
ll l,r;
ll hsh[Maxn],power[Maxn];
int cnt[Maxn][Maxm];
ll ans[Maxm];
vector<ll>L,R;

bool same(int pos){
	ll k1=hsh[pos-1],k2=hsh[n-1]-hsh[n-1-pos]*power[pos];
	return k1==k2;
}

vector<ll> add_ans(vector<ll>a,vector<ll>b){
	rep(i,26)a[i]+=b[i];
	return a;
}

pair<ll,vector<ll> > solve(ll l_len,vector<ll>L,ll r_len,vector<ll>R,ll rest){
	vector<ll>res(26);
	if(l_len+r_len<=rest){
		vector<ll>sum=add_ans(L,R);
		pair<ll,vector<ll> >ret=solve(l_len+r_len,sum,l_len,L,rest);
		rest=ret.fi;
		res=add_ans(res,ret.se);
	}
	if(l_len<=rest){
		res=add_ans(res,L);
		rest-=l_len;
	}
	return mk(rest,res);
}

int main(){
	ios::sync_with_stdio(false);
	cin>>s>>l>>r;
	l--;r--;
	s=s.substr(0,s.size()/2);
	n=sz(s);

	hsh[0]=s[0]-'a';power[0]=1;
	REP(i,n-1)hsh[i]=hsh[i-1]*H+s[i]-'a',power[i]=power[i-1]*H;
	REP(i,n-1)if(same(i))match=max(match,i);

	rep(i,n){
		rep(j,26){
			if(j==s[i]-'a')cnt[i][j]=!i?1:cnt[i-1][j]+1;
			else cnt[i][j]=!i?0:cnt[i-1][j];
		}
	}

	if(match==0){
		rep(i,26){
			ans[i]+=(ll)cnt[n-1][i]*(ll)(r/(ll)n)+(ll)cnt[r%(ll)n][i];
			if((l-1)>=0)ans[i]-=(ll)cnt[n-1][i]*(ll)((l-1)/(ll)n)+(ll)cnt[(l-1)%(ll)n][i];
		}
		rep(i,26)cout<<ans[i]<<" ";
		return 0;
	}
	
	else{
		L.resize(26);R.resize(26);
		rep(i,26)R[i]=cnt[match-1][i];
		rep(i,26)L[i]=cnt[n-1][i]-cnt[match-1][i];
		pair<ll,vector<ll> >ans_R=solve(n-match,L,match,R,r);
		pair<ll,vector<ll> >ans_L=solve(n-match,L,match,R,l-1);
		rep(i,26){
			ans[i]+=ans_R.se[i]+cnt[ans_R.fi][i];
			ans[i]-=ans_L.se[i]+cnt[ans_L.fi][i];
		}
		rep(i,26)cout<<ans[i]<<" ";
		return 0;
	}
}
/*
vgxgpuamkvgxgvgxgpuamkvgxg
1 1000000000000000000
*/ 

Measured memory_bytes: 15568
n=int(input())
a1_list=[int(i) for i in input().split()]
a2_list=[int(i) for i in input().split()]

tmp_sum=a1_list[0]+sum(a2_list)
ans=tmp_sum
for i in range(1,n):
    tmp_sum=tmp_sum+a1_list[i]-a2_list[i-1]
    ans=max(ans,tmp_sum)

print(ans)

Measured memory_bytes: 3064
x,k,d=map(int,input().split())
x=abs(x)
a=x//d
if k<a:
    print(x-k*d)
else:
    if x-a*d<abs(x-(a+1)*d):
        if (k-a)%2==1:
            print(abs(x-(a+1)*d))
        else:
            print(x-a*d)
    else:
        if (k-a-1)%2==1:
            print(x-a*d)
        else:
            print(abs(x-(a+1)*d))

Measured memory_bytes: 9036
l=list(map(int,input().split()))
if l[0]==0 or l[3]==0 or l[4]==0:
  print((l[0]//2)*2+(l[3]//2+l[4]//2)*2+l[1])
else:
  print(max((l[0]//2)*2+(l[3]//2+l[4]//2)*2+l[1],((l[0]-1)//2)*2+((l[3]-1)//2+(l[4]-1)//2)*2+l[1]+3))

Measured memory_bytes: 61880
#include<stdio.h>
int main(void)
{
	int n,i,x,y,cnt,cnt2,z;
	scanf("%d",&n);
	x=0;
	y=0;
	cnt=0;
	cnt2=0;
	z=0;
	if(n<=81){
		for(i=1;i<=9;i++){
			x=n/i;
			y=n%i;
			if(y==0){
				if(x>=1&&x<=9){
					z++;
				}
				else cnt2++;
			}
			else {
				cnt++;
				x=0;
				y=0;
			}
		}
	}
	if(n>81||cnt+cnt2==9){
		printf("No\n");
	}
	if(z>=1)	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define ea(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// abs 絶対値, rtsq ルート, pow(a, n) aのn乗, int 2*10^9

int main() {
  int N, p = 1, q = 1;
  ci(N);
  ve<int> P(N), Q(N);
  rep(i, N){
    ci(P.at(i));
  }
  rep(i, N){
    ci(Q.at(i));
  }
  rep(i, N){
    int a = 1;
    repi(j, 1, N - i){
      a *= j;
    }
    int b = 0, c = 0;
    rep(j, i){
      if(P.at(j) < P.at(i)){
        b++;
      }
      if(Q.at(j) < Q.at(i)){
        c++;
      }
    }
    p += a * (P.at(i) - b - 1);
    q += a * (Q.at(i) - c - 1);
  }
  co(abs(p - q));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 1e18;
const ll fact_table = 5000000;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
vector<ll> R[550010];
vector<pair<ll, double> > tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<"\n";
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 998244353;
//ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,f,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];
ll dp[5005][5005];
char s[500005];
char t[500005];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> s >> t;
    pu(t);
    p(s);
    return 0;
}















Measured memory_bytes: 39296
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
constexpr double EPS = 1e-6;

/* http://is2011.2-d.jp/moin/moin.cgi/amylase/icpc#A.2BUYYwbk6kcLk- */
// primitives
typedef long double Real;
typedef complex<Real> Point;
typedef pair<Point, Point> Line;
typedef pair<Point, Real> Circle;
typedef vector<Point> Poly;
Real eps = 1e-6;

vector<Point> CCintersect(Circle c, Circle d) {
    vector<Point> ret;
    const Real dist = abs(c.first - d.first);
    const Real cr = c.second;
    const Real dr = d.second;

    if (dist > cr + dr) return ret;
    if (dist < abs(cr - dr)) return ret;

    const Real s = (cr + dr + dist) / 2.;
    const Real area = sqrt(s * (s - cr) * (s - dr) * (s - dist));
    const Real h = 2 * area / dist;

    Point v = d.first - c.first; v /= abs(v);
    const Point m = c.first + sqrt(cr * cr - h * h) * v;
    const Point n = v * Point(0, 1);

    ret.push_back(m + n * h);
    ret.push_back(m - n * h);
    return ret;
}

signed main() {

    int N, K;
    cin >> N >> K;

    vector<Circle> circles;
    rep(i, 0, N) {
        int x, y, c;
        cin >> x >> y >> c;
        circles.emplace_back(Point(x, y), c);
    }

    auto check = [&](double mid) -> bool {
        vector<Point> cand;
        rep(i, 0, N) {
            Circle c1(circles[i].first, mid / circles[i].second);
            cand.emplace_back(circles[i].first);
            rep(j, i + 1, N) {
                Circle c2(circles[j].first, mid / circles[j].second);
                auto ret = CCintersect(c1, c2);
                for (auto& e: ret) cand.emplace_back(e);
            }
        }
        for (auto& c: cand) {
            int cnt = 0;
            rep(i, 0, N) {
                double dst = abs(c - circles[i].first);
                if (dst <= mid / circles[i].second + eps) ++cnt;
            }
            if (cnt >= K) return true;
        }
        return false;
    };

    double ok = 1e10, ng = 0;
    rep(_, 0, 100) {
        double mid = (ok + ng) / 2;
        (check(mid) ? ok : ng) = mid;
    }
    cout << fixed << setprecision(20) << ok << endl;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c;
	cin>>a>>b>>c;
	if (a<0)
		a=abs(a);
	if (b>=a/c)
	{
		if ((b-a/c)%2==0)
		{
			cout<<a%c<<endl;
		}
		else
		{
			cout<<c-(a%c)<<endl;
		}
	}
	else
	{
		cout<<a-b*c<<endl;
	}
	return 0;
}


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

#define ll long long

void solve(){
	int a; cin>>a;
	cout<<(a + a * a + a * a * a)<<endl;
}

int main(){
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int t = 1;// cin>>t;
        while(t--){
                solve();
        }
}


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

#define MAX 100009
#define INF 99999999
#define MIN -99999999
#define in(a,b)  ( (b).find(a) != (b).end())
#define clr(a,b) memset((a), (b), sizeof((a)))
#define pb       push_back
#define all(a)   a.begin(), a.end()
#define mp       make_pair
#define ll	long long
#define FI	first
#define SE second

using namespace std;
int n;
string a,b;
vector<ll> tab;
void g(){
  for(int i=0; i<MAX; i++){
    tab.pb(i*i);
  }
}
bool f(ll val){
  for(ll v: tab){
    if(val == v) return true;
  }
  return false;
}
int main() {

  g();
  cin >> a >> b;
  string s = a+b;
  if(f(stol(s))) cout << "Yes" << endl;
  else cout << "No" << endl;
  return  0;
}


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

using namespace std;

#define ll long long
#define ld long double
#define ff first
#define ss second
#define rsz resize
#define ins insert 
#define mp make_pair
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define ft front() 
#define bk back()
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define deb(x) cout<<#x<<" "<<x<<'\n';
#define rep(i,a,b) for (int i = (a); i < (b); ++i)

const ll mod = 1e9+7; // 998244353;
const ll inf = 1e18; 
const ld pie = acos((ld)-1);

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



int main(){
    
	int n;
	scanf("%d",&n);
	vector<pair<int,int>> a(n);
	for(int i=0;i<n;++i){
		int x,y;
		scanf("%d%d",&x,&y);
		a[i]={x,y};
	}
	int cnt=0;
	for(int i=0;i<n;++i){
		
		if(cnt>=3){
			puts("Yes");
			return 0;
		}

		if(a[i].ff==a[i].ss){
			cnt++;
		}else{
			if(cnt>=3){
				puts("Yes");
				return 0;
			}else{
				cnt=0;
			}
		}
	}

	if(cnt>=3){
		puts("Yes");
		return 0;
	}

	puts("No");
	return 0;

	/*STUFF TO LOOK:	
		1. Check the constraints
		2. Corner cases(n==0||n==1)
		3. Variables in loops
		4. Make sure two ints aren’t multiplied to get a long long
		5. Don't use scanf or printf while using ios_base
		6. using the local variable of the same name when global variable was required to be used
	*/
}


Measured memory_bytes: 3632
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
minV = 10**8
ans = 0

for i in range(n):
    temp = t - h[i] * 0.006
    if abs(temp - a) < minV:
        minV = abs(temp - a)
        ans = i + 1

print(ans)


Measured memory_bytes: 3060
a, b = map(int, input().split())

def small(a,b):
    return a < b
def big(a,b):
    return a > b
def equal(a,b):
    return a == b
if small(a,b):
    print("a < b")
elif big(a,b):
    print("a > b")
elif equal(a,b):
    print("a == b")


Measured memory_bytes: 5600
import numpy as np
 
n = int(input())
arr = np.array([int(i) for i in input().split()])
mod = 10 ** 9 + 7
ans = 0
 
for i in range(60):
    #一桁目が1か0か調べて1の個数をカウント
    c1 = np.count_nonzero(arr & 1) 
    #1の個数×0の個数(XORだから)
    ans += 2 ** i * c1 * (n - c1)
    #桁をシフト
    arr =arr >> 1

print(ans % mod)

Measured memory_bytes: 48856
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
struct edge {
    int to; 
    int weight;
    edge(int t, int w) : to(t),weight(w) {}
};
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){

    int n; cin >> n;
    vector<pair<int,int>> ro(n);
    rep(i,n){
        int x,l; cin >> x >> l;
        ro.at(i) = make_pair(x+l,x-l);
    }
    sort(all(ro));
    int cnt;
    int lim ;
    lim = ro.at(0).first;
    cnt = 1;
    for(int i = 1; i < n; i++){
        if(ro.at(i).second >= lim){
            lim = ro.at(i).first;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
ans = {}
ans[[[0, 1], [1, 0], [1, 1]]] = "A"
ans[[[1, 0], [2, 0], [3, 0]]] = "B"
ans[[[0, 1], [0, 2], [0, 3]]] = "C"
ans[[[1,-1], [1, 0], [2,-1]]] = "D"
ans[[[0, 1], [1, 1], [1, 2]]] = "E"
ans[[[1, 0], [1, 1], [2, 1]]] = "F"
ans[[[0, 1], [1,-1], [1, 0]]] = "G"

arr = $stdin.read.split("\n")

m = arr.size
i = 0
while i < m
  pos = []
  8.times{|j|
    tmp = arr[i].split("")
    8.times{|k|
      if tmp[k] == "1"
        pos << [j, k]
      end
    }
    i += 1
  }
  1.upto(3){|j|
    pos[j][0] -= pos[0][0]
    pos[j][1] -= pos[0][1]
  }
  pos.shift
  puts ans[pos]
  i += 1
end

Measured memory_bytes: 8908
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

using namespace std;

#define pb push_back
typedef long long ll;
typedef complex<int> P;

struct st{
	ll t;
	int s;
	int d;
	
	st(){}
	st(ll t,int s,int d): t(t), s(s), d(d){}
	
	bool operator< (const st &s) const{
		return this->t < s.t;
	}
};

bool solve(){
	int n, m;
	cin>> n>> m;
	if(n==0 && m==0) return false;
	
	vector<st> vst;
	for(int i=0;i<m;i++){
		ll t; int s, d;
		cin>> t>> s>> d;
		vst.pb(st(t, s-1, d-1));
	}
	sort(vst.begin(), vst.end());
	
	vector<bool> com(n);
	fill(com.begin(), com.end(), false);
	com[0] = true;
	for(int i=0;i<m;i++){
		if(com[vst[i].s]) com[vst[i].d] = true;
	}
	
	cout<< count(com.begin(), com.end(), true)<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	while(solve());

	return 0;
}

 

Measured memory_bytes: 1852
#include<iostream>
using namespace std;
typedef long long ll;

/*
int main() {
    int N;
    ll T, A, t = 1, a = 1;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> T >> A;
        if (T >= t && A >= a) {
            t = T, a = A;
        }
        else if (T >= t && A < a) {
            a = A * ((a + A - 1) / A);
            t = (a / A) * T;
        }
        else if (T < t && A >= a) {
            t = T * ((t + T - 1) / T);
            a = (t / T) * A;
        }
        else {
            if ((t + T - 1) / T < (a + A - 1) / A) {
                t = T * ((a + A - 1) / A);
                a = A * ((a + A - 1) / A);
            }
            else {
                t = T * ((t + T - 1) / T);
                a = A * ((t + T - 1) / T);
            }
        }
    }
    cout << t + a << endl;
    return 0;
}
*/

int main() {
    int N;
    ll T, A, t = 1, a = 1;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> T >> A;
        ll n = max((t + T - 1) / T, (a + A - 1) / A);
        t = T * n, a = A * n;
    }
    cout << t + a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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 ALL(a) a.begin(),a.end()
typedef long long ll;
#define INF 1<<30

int main()
{
    ll N,A,B;
    cin >> N >> A >> B;
    ll count = A*(N/(A+B));
    //cout << count << endl;
    if(N%(A+B)>0&&N%(A+B)<=A)count += N%(A+B);
    if(N%(A+B)>0&&N%(A+B)>A)count += A;
    cout << count << endl;
    return 0;
}

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

int N, u, v, a, b, t[100010], m[100010], ans;
vector<int> g[100010];
int main() {
    cin >> N >> u >> v;
    for(int i = 0; i < N - 1; i++) {
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    queue<int> q;
    q.push(v);
    t[v] = 1;
    int s = 2, f = 1;
    while(!q.empty()) {
        int c = q.front();q.pop();f--;
        for(int d : g[c]) {
            if(!t[d]) {
                t[d] = s;
                q.push(d);
            }
        }
        if(!f) s++, f = q.size();
    }
    q.push(u);
    s = 2, f = 1;
    while(!q.empty()) {
        int c = q.front();q.pop();f--;
        for(int d : g[c]) {
            if(!m[d]) {
                m[d] = s;
                q.push(d);
            }
        }
        if(!f) s++, f = q.size();
    }
    for(int i = 1; i <= N; i++) {
        f = 0;
        for(int d : g[i]) {
            if(t[d] > t[i]) f = 1;
        }
        if(f && m[i] <= t[i]) ans = max(ans, t[i]);
    }
    cout << max(ans - 1, 0);
}

Measured memory_bytes: 6656
#include <stdio.h>

int main(void)
{
	int n, x, y, z;
	int sum, sum2;
	
	while (1) {
		scanf("%d", &n);
		if (n == 0) {
			break;
		}
		sum = 0;
		sum2 = 0;
		for (z = 0; z < n; z++) {
			scanf("%d %d", &x, &y);
			if (x > y) {
				sum += (x + y);
			}
			else if (x == y) {
				sum += x;
				sum2 += y;
			}
			else {
				sum2 += (x + y);
			}
		}
		printf("%d %d\n", sum, sum2);
	}
	
	return (0);
}

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

int main() {
  int n,m;
  cin >>n>>m;
  if(n<=m){
    cout <<"unsafe"<<endl;
  }else{
    cout <<"safe"<<endl;
  }
}

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

const int MOD = 1000000007;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

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

    vector<lint> S(N);
    S[0] = A[0];
    for (int i = 1; i < N; i++) S[i] = S[i-1] + A[i];

    lint res = 1;

    for (int i = 0; i < N-1; i++) {
        if (S[i] * 2 >= A[i+1]) res++;
        else res = 1;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1408
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main {
    public static void main(String[] args) throws IOException {
       Scanner in = new Scanner(System.in);
       int a = in.nextInt();
       int b = in.nextInt();
       System.out.printf("%d %d\n", a*b, 2*a+2*b);
    }
}

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

int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end(), greater<int>());

	int alice = 0, bob = 0;
	for (int i = 0; i < n; i++)
	{
		if (i % 2 == 0) alice += a[i];
		else bob += a[i];
	}

	cout << alice - bob << endl;
}

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

int main(){
  int w,h,x,y;
  cin>>w>>h>>x>>y;
  cout<<((double)w*h)/2<<" ";
  if(2*x==w&&2*y==h) cout<<1<<endl;
  else cout<<0<<endl;
}
  


Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for (int i = 0;i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
  int N,Y;
  cin >> N >> Y;
  int a=-1,b=-1,c=-1;
  for(int i=0;i<=N;i++){ //一万円札の枚数i
        for(int j=0;i+j<=N;j++){ //五千円札の枚数j
      if(Y == i*10000+j*5000+(N-i-j)*1000){
        a = i; b = j; c = N - i - j;
        break;
      }
    }
  }
  cout << a << " " << b << " " << c << endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll r,c; cin>>r>>c;
    vector<vector<ll>> a(r+1,vector<ll>(c+1,0));
    ll sum=0;
    rep(i,r)rep(j,c){
        cin>>a[i][j];
        sum+=a[i][j];
    }
    rep(i,r){
        rep(j,c){
            a[i][c]+=a[i][j];
        }
    }
    rep(i,c){
        rep(j,r){
            a[r][i]+=a[j][i];
        }
    }
    a[r][c]=sum;
    rep(i,r+1)rep(j,c+1){
        cout<<a[i][j];
        if(j!=c)cout<<" ";
        else cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3156
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

ll dp[4][maxN];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int k;
	cin >> k;
	dp[0][0] = 1;
	for(int u = 1; u <= 3; u++) {
		for(int i = 0; i <= k; i++)
			for(int j = 1; j <= k; j++) {
				auto g = __gcd(i, j);
				dp[u][g] += dp[u - 1][i];
			}
	}
	ll ans = 0;
	for(int i = 1; i <= k; i++) ans += i * dp[3][i];
	cout << ans << '\n';
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+1000;
const ll mod=1e9+7;

ll fac[N],inv[N];
ll fast(ll x,ll n) {
    ll ans=1;
    for(;n;n>>=1,x=x*x%mod)
        if(n&1) ans=ans*x%mod;
    return ans;
}
ll init(){
    fac[0]=fac[1]=1;
    for(int i=2;i<N;i++) fac[i]=fac[i-1]*i%mod;
    inv[N-1]=fast(fac[N-1],mod-2);
    for(int i=N-2;i>=0;i--) inv[i]=(inv[i+1]*(i+1))%mod;
}
ll C(ll n,ll m) {
    if(n<0||m<0||m>n)return 0;
    if(!m||m==n) return 1;
    return ((fac[n]*inv[m]%mod*inv[n-m])%mod);
}

int main() {
    init();ll ans=0;
    ll n,k;cin>>n>>k;
    for(int i=0;i<=min(n-1,k);i++) {
        ll temp=C(n,i); ll t=n-i;
        temp=temp*C(n-1,t-1)%mod;
        //printf("temp=%lld\n",temp);
        ans=(ans+temp)%mod;
    }
    cout<<ans;
}


Measured memory_bytes: 15872
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val s = sc.nextLine()
    for (i in 0 until 26) {
        val c = 'a' + i
        if (!s.contains(c)) {
            println(c)
            return
        }
    }
    println("None")
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 31392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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; }


int main(){
    ll a,b,c,d; cin>>a>>b>>c>>d;
    ll i=0;
    while(a>0 && c>0){
        if(i==0){
            c-=b; i=1;
        }else{
            a-=d; i=0;
        }
    }
    if(a<=0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3632
N, K = gets.chomp.split.map(&:to_i)

trees = []
N.times do
    trees.push gets.chomp.to_i
end
trees.sort!

diffs = []
(N - K + 1).times do |i|
    diffs.push trees[i + K - 1] - trees[i]
end

puts diffs.min

Measured memory_bytes: 4640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = int.Parse(ReadLine());
        if(n >= 1800)
            WriteLine(1);
        else if(n >= 1600)
            WriteLine(2);
        else if(n >= 1400)
            WriteLine(3);
        else if(n >= 1200)
            WriteLine(4);
        else if(n >= 1000)
            WriteLine(5);
        else if(n >= 800)
            WriteLine(6);
        else if(n >= 600)
            WriteLine(7);
        else if(n >= 400)
            WriteLine(8);
    }
}


Measured memory_bytes: 17552
N = int(input())
A = list(map(int, input().split()))
acd = A[0] <= A[1]
lst = [A[0]]
i = 1
while i < N:
    if acd:
        if A[i-1] > A[i]:
            lst.append(A[i-1])
            acd = 0
    else:
        if A[i-1] < A[i]:
            lst.append(A[i-1])
            acd = 1
    i += 1
if A[N-2] <= A[N-1]:
    lst.append(A[N-1])
if len(lst) == 1:
    print(1000)
    exit()
if lst[0] > lst[1]:
    lst = lst[1:]
if len(lst) < 2:
    X = 1000
else:
    X = 1000
    for i in range(0, len(lst), 2):
        c = X//lst[i]
        X -= c*lst[i]
        X += c*lst[i+1]
print(X)

Measured memory_bytes: 62044
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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


int main(){
  
  ll n; string str; cin >> n >> str;
  
  ll cnt = 0;
  
  std::ios::fmtflags curret_flag = std::cout.flags();
	
	for(ll i=0; i < 1000; i++){
      //123の頭に5個0を詰めて8桁にする
	std::ostringstream ss;
	ss << std::setw(3) << std::setfill('0') << i << "\n";
	std::string s(ss.str());
 
      ll now = 0;
    for(ll j=0; j < n; j++){
      if(str[j] == s[now]){
        now++;
        if(now == 3){
          cnt++;
          break;
        }
      }
    }
    }
	// 戻し
	std::cout.flags(curret_flag);
      
      cout << cnt << endl;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll H[25];
    rep(i,0,N) cin >> H[i];
    ll ans = 0;
    rep(i,0,N){
        bool ok = true;
        rep(j,0,i){
            if(H[i] < H[j]) ok = false;

        }
        if(ok) ans++;
    }
    print(ans);
    
    
}

Measured memory_bytes: 256
// BEGINNING WITH NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
// ATCODER BEGINNERS PROBLEMS 
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.flush();
	int n;
    cin >> n;
  	cout<<"ABC"<<n;
	return 0;
	// Bye Bye 2019
}

Measured memory_bytes: 256
N = int(input())
x = []
y = []
t = []
distance = []
x.append(0)
y.append(0)
t.append(0)

for i in range(N):
    STR = input().split()
    t.append(int(STR[0]))
    x.append(int(STR[1]))
    y.append(int(STR[2]))

dis = 0
flag = True
for i in range(1,N+1):
    time = t[i] - t[i-1]
    dis = abs(x[i] -x[i-1])+abs(y[i] - y[i-1])
    #print(time)
    #print(dis)
    if time != dis :
        if time < dis:
            #print("time<dis")
            flag = False
        elif time - dis > 0 and (time-dis) %2 == 1:
            #print("time%2")
            flag = False

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 11780
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let vec: Vec<usize> = (0..5).map(|_| read()).collect();
    for (i, &v) in vec.iter().enumerate() {
        if i + 1 != v {
            println!("{}", i + 1);
        }
    }
}


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

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

	int n, ans = 0;
	cin >> n;
	for(int i = 1; i <= n; ++i){
		int a;
		cin >> a;
		if(i%2 != 0 && a % 2 != 0)
			ans++;
	}
	
	cout << ans;

	return 0;
	
}


Measured memory_bytes: 3640
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prinp(p) cout<<p.first<<" "<<p.second<<endl
#define prinv(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1e9+7,MAX = 1e6+5;
const ll INF = 1e18+5;

ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}

int main()
{
	int n;
	cin>>n;
	cout<<((powN(10,n)-powN(9,n)-powN(9,n)+powN(8,n))%MOD+MOD)%MOD<<endl;
}

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

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

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

    vector<int> B(N);
    for (int i = 0; i < N; i++) {
        B.at(i) = A.at(i) - i - 1;
    }

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

    int median = 0;
    if (N % 2 == 0) {
        median = (B.at(N / 2 - 1) + B.at(N / 2)) / 2;
    }
    else {
        median = B.at(N / 2);
    }

    long long sum = 0;
    for (int i = 0; i < N; i++) {
        sum += abs(B.at(i) - median);
    }

    cout << sum << endl;
}

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll k;
    string s;
    cin >> k >> s;
    if(s.size() <= k) cout << s << endl;
    else {
        string tmp = s.substr(0, k);
        cout << tmp << "..." << endl;
    }
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 3632
lis = list(str(input()))
count = 0

for i in range (len(lis)):
  if i%2 ==0:
    if lis[i] == "L":
      count+=1
  else:
    if lis[i] == "R":
      count +=1
if count >=1:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 1005  //check the limits, man
int ad[N][N];
int sz[N];
int main()
{
    int n,i,j,x,f,a;
    in(n);
    twod(ad,i,j,n,n-1);
    rep(i,n)
    {
        rep(j,n-1)
            ad[i][j]--;
    }
    x=0,f=1;
    int y;
    queue<int> pq;
    rep(i,n)
        pq.push(i);
    queue<int> temp;
    vi vis(n,1);
    while(!pq.empty())
    {
        y=0;
        while(!pq.empty())
        {
            i=pq.front(),pq.pop();
            if(sz[i]<n-1)
            {
                a=ad[i][sz[i]],vis[i]=0;
                if(sz[a]<n-1 && ad[a][sz[a]]==i)
                {
                    y=1,vis[i]=1;
                    temp.push(i);
                    if(!vis[a])
                        vis[a]=1,temp.push(a);
                }
            }
        }
        if(y==0)
            break;
        while(!temp.empty())
            a=temp.front(),sz[a]++,temp.pop(),pq.push(a);
        x++;
    }
    f=0;
    rep(i,n)
        if(sz[i]<n-1)f=1;
    if(f)
        x=-1;
    out(x);
}


Measured memory_bytes: 4224
#[allow(unused_imports)]
use std::cmp;

// Input macro from 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)*) => {
    #[allow(unused_mut)]
    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")
  };
}

const MOD: i64 = 1e9 as i64 + 7;

fn main() {
  input! {
    n: usize,
    a: [[i32; n]; n]
  }
  let mut dp = vec![0i64; 1 << n];
  dp[0] = 1;
  for ws in 1usize .. 1 << n {
    let m = ws.count_ones() as usize - 1;
    for w in 0 .. n {
      if ws & (1 << w) != 0 && a[m][w] == 1 {
        dp[ws] += dp[ws ^ (1 << w)];
        if dp[ws] > MOD {
          dp[ws] -= MOD;
        }
      }
    }
  }
  println!("{}", dp[(1 << n) - 1]);
}


Measured memory_bytes: 20732
import java.util.Scanner;

public class Main {
	static int[][] graph;
	static int time;
	static int[] d,f;
	static boolean[] visited;
	
	static void visit(int node) {
		if(!visited[node]) {
			visited[node] = true;
			d[node] = time++;
			for(int i=1;i<d.length;i++) {
				if(graph[node][i]==1)
					visit(i);
			}
			f[node] = time++;
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n= sc.nextInt();
			if(n==0)break;
			time = 1;
			graph = new int[n+1][n+1];
			d = new int[n+1];
			f = new int [n+1];
			visited = new boolean[n+1];
			for(int i=0;i<n;i++) {
				int s = sc.nextInt();
				int k = sc.nextInt();
				for(int j=0;j<k;j++) {
					graph[s][sc.nextInt()] =1;
				}
			}
			for(int i=1;i<=n;i++)
				visit(i);
			for(int i=1;i<=n;i++)
				System.out.println(i+" "+d[i]+" "+f[i]);
		}
	}

}



Measured memory_bytes: 28824
// "header" {{{
#pragma GCC optimize("Ofast")

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define int int64_t
#define double long double
#define Fixed fixed << setprecision(10)
#define moke_pair make_pair

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int64_t mod1 = 1000000007;
constexpr int64_t mod2 = 998244353;

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

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class T,class U> using umap = unordered_map<T,U>;

inline int64_t updiv(int64_t n,int64_t d){ return ((n + d -1) / d); }
inline int square(int a){ return a * a; }
// }}}

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

    int n,q;
    string s;
    cin >> n >> q >> s;
    vector<bool> flg(n+5);
    vector<int> sum(n+5);

    rep(i,n-1){
        if(s[i] == 'A' && s[i+1] == 'C'){
            flg[i+1] = true;
            sum[i+1]++;
        }
        sum[i+2] += sum[i+1];
    }

    rep(i,q){
        int l,r;
        cin >> l >> r;

        cout << sum[r] - sum[l-1] - flg[r] << '\n';
    }


    return 0;
}


Measured memory_bytes: 1872