akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

#define M 1000002
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; ; }
int h2(int key){ return 1+key%(M-1); }

int find(char str[]){

  int i=0,k,n=0,a;
  a=getKey(str);
  while(i<M){
    k=(h1(a)+i*h2(a))%M;
    if(H[k][0]=='\0'){
      return 0;
    }
    if(strcmp(H[k],str)==0){
      n=1;
      return 1;
    }
    i++;
  }

}

int insert(char str[]){

  int i=0,k,a; 
  a=getKey(str);
  while(i<M){
    k=(h1(a)+i*h2(a))%M;
    if(H[k][0]=='\0'){
      strcpy(H[k],str);
      break;
    }
    i++;
  }
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)==1){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	bool *x = new bool[n];
	int unhappy = 0;
	int ans = 0;

	string str;
	cin >> str;

	rep(i, n){
		if(str[i] == 'L') x[i] = false;
		else x[i] = true;
	}

	rep(i, n){
		if(x[i] == false){
			if(i-1 >= 0 && x[i-1] == false) ans++;
			else unhappy++;
		}
		else{
			if(i+1 < n && x[i+1] == true) ans++;
			else unhappy++;
		}
	}

	rep(i, k){
		if(unhappy == 1) break;
		else if(unhappy == 2){
			ans++;
			unhappy--;
		}
		else{
			ans += 2;
			unhappy -= 2;
		}
	}

	cout << ans << "\n";

	delete x;
	return 0;
}

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



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    ll x;
//    x=1ll << 59;
//    ll y=(1ll << 59) - 1ll;
//    cout<<((double)(x)==(double)(x-1))<<endl;
    ll n,y;
    cin>>n>>y;
    //for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            for(int k=0;k<=n;k++){
                    ll i=n-j-k;
                ll s=10000ll*i+5000ll*j+1000ll*k;
                if(s==y&&(i+j+k)==n&&i>=0){
                    cout<<i<<" "<<j<<" "<<k<<endl;
                    return 0;
                }
                //                  cout<<i<<" "<<j<<" "<<k<<endl;
            }
        }
    //}
    cout<<"-1 -1 -1";
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
double dp[3002][3002];
double p[3002];
double func(int n, int t) {
    if(dp[n][t] != -1.0) {
        return dp[n][t];
    }
    if(n == t) {
        double ret = 1.0;
        for(int i = 0; i < n; i++) {
            ret *= p[i];
        }
        dp[n][t] = ret;
        return ret;
    }
    dp[n][t] = func(n - 1, t - 1) * p[n - 1] + func(n - 1, t) * (1.0 - p[n - 1]);
    return dp[n][t];
}
int main() {
    int n, i, j;
    scanf("%d", &n);
    for(i = 0; i < 3000; i++) {
        for(j = 0; j < 3000; j++) {
            dp[i][j] = -1.0;
        }
    }
    for(i = 0; i < n; i++) {
        scanf("%lf", &p[i]);
    }
    double ans = 0.0;
    for(i = n; i > n / 2; i--) {
        ans += func(n, i);
    } 
    printf("%.12lf\n", ans);

    return 0;
}

Measured memory_bytes: 70784
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC048B_Between_a_and_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long a = long.Parse(input[0]);
            long b = long.Parse(input[1]);
            long x = long.Parse(input[2]);

            long from = a / x;
            long to = b / x;

            if (a % x != 0)
            {
                from = a / x;
            }
            if (b % x != 0)
            {
                to = b / x + 1;
            }


            long result = to - from;
            if (a % x != 0 && b % x != 0)
            {
                result--;
            }
            if (a % x == 0 && b % x == 0)
            {
                result++;
            }

            Console.WriteLine(result);

        }
    }
}


Measured memory_bytes: 11220
# include <iostream>
# include <cstdio>
using namespace std;
const int N = 1e5 + 12;
int a[N],n;long long ret,tmp;
int ab(int x){return x > 0 ? x : -x;}
int main()
{
  scanf("%d",&n);
  for(int i = 1;i <= n;i++)scanf("%d",&a[i]);
  for(int i = 1;i <= n + 1;i++)ret += ab(a[i] - a[i - 1]);
  for(int i = 1;i <= n;i++)
  printf("%lld\n",ret - ab(a[i] - a[i - 1]) - ab(a[i + 1] - a[i]) + ab(a[i + 1] - a[i - 1]));
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#define llint long long
#define mod 1000000007
#define inf 100000000000000000

using namespace std;

llint n;
llint x[100005], y[100005];
char d[100005];
vector<double> vec;

void calc(){
	llint leftL = inf, leftR = inf, leftC = inf;
	for(int i = 1; i <= n; i++){
		if(d[i] == 'L') leftL = min(leftL, x[i]);
		else if(d[i] == 'R') leftR = min(leftR, x[i]);
		else leftC = min(leftC, x[i]);
	}
	if(leftL < inf && leftR < inf) vec.push_back(leftL - (leftL+leftR)*0.5);
	if(leftL < inf && leftC < inf) vec.push_back(leftL - leftC);
	if(leftR < inf && leftC < inf) vec.push_back(leftC - leftR);
}

double check(double t)
{
	double lx = inf, rx = -inf, ly = inf, ry = -inf;
	for(int i = 1; i <= n; i++){
		double nx = x[i], ny = y[i];
		if(d[i] == 'R') nx += t;
		if(d[i] == 'L') nx -= t;
		if(d[i] == 'U') ny += t;
		if(d[i] == 'D') ny -= t;
		lx = min(lx, nx), rx = max(rx, nx);
		ly = min(ly, ny), ry = max(ry, ny);
	}
	return (rx-lx) * (ry-ly);
}

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> x[i] >> y[i] >> d[i];
	
	vec.push_back(0);
	
	calc();
	for(int i = 1; i <= n; i++) x[i] *= -1;
	for(int i = 1; i <= n; i++) if(d[i] == 'L') d[i] = 'R'; else if(d[i] == 'R') d[i] = 'L';
	calc();
	for(int i = 1; i <= n; i++) x[i] *= -1;
	for(int i = 1; i <= n; i++) if(d[i] == 'L') d[i] = 'R'; else if(d[i] == 'R') d[i] = 'L';
	
	
	for(int i = 1; i <= n; i++) swap(x[i], y[i]);
	for(int i = 1; i <= n; i++){
		if(d[i] == 'L') d[i] = 'D';
		else if(d[i] == 'R') d[i] = 'U';
		else if(d[i] == 'D') d[i] = 'L';
		else if(d[i] == 'U') d[i] = 'R';
	}
	
	calc();
	for(int i = 1; i <= n; i++) x[i] *= -1;
	for(int i = 1; i <= n; i++) if(d[i] == 'L') d[i] = 'R'; else if(d[i] == 'R') d[i] = 'L';
	calc();
	for(int i = 1; i <= n; i++) x[i] *= -1;
	for(int i = 1; i <= n; i++) if(d[i] == 'L') d[i] = 'R'; else if(d[i] == 'R') d[i] = 'L';
	
	for(int i = 1; i <= n; i++) swap(x[i], y[i]);
		for(int i = 1; i <= n; i++){
		if(d[i] == 'L') d[i] = 'D';
		else if(d[i] == 'R') d[i] = 'U';
		else if(d[i] == 'D') d[i] = 'L';
		else if(d[i] == 'U') d[i] = 'R';
	}
	
	double ans = inf;
	for(int i = 0; i < vec.size(); i++){
		if(vec[i] < 0) continue;
		ans = min(ans, check(vec[i]));
	}
	printf("%.11f\n", ans);
	
	return 0;
}

Measured memory_bytes: 1920
abcd = input()
ans = 0
ok = False
for i in range(2 ** 3):
	if not ok:
		p = "0" * (3 - len(bin(i)[2:])) + bin(i)[2:]
		equals = ""
		for index, num in enumerate(abcd):
			equals += num
			if index != (len(abcd) - 1) and p[index] == "1":
				equals += "+"
			if index != (len(abcd) - 1) and p[index] == "0":
				equals += "-"
		if eval(equals) == 7:
			ok = True
			print(equals + "=7")

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

int main() {
  string s;
  int n;
  cin >> n >> s;
  
  for(int i = 0; i < s.size(); i++){
    if('Z'-s.at(i)>=n){
      s.at(i) = s.at(i) + n;
    }
    else{
     s.at(i) = ('A'-1) + (n - ('Z'-s.at(i)));
    }
  }
    
    cout << s << endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  rep(i, W+2) cout << '#';
  cout << endl;
  
  rep(i, H) {
    cout << '#';
    rep(i, W) {
      char px;
      cin >> px;
      cout << px;
    }
    cout << '#' << endl;
  }
  
  rep(i, W+2) cout << '#';
  cout << endl;
}

Measured memory_bytes: 256
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define pi 3.141592653589793
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll modd = (ll)1e9 + 7;
const int mod = 10000007;
/*#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}*/
void pr (int f)
{
    if(f==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}
map<int,int>mp;
multiset<string> st;
multiset<string> :: iterator it;

deque <char> q ;
int vis [1000];
int main()
{
   int n,l;
   cin>>n>>l;
   string s;
   while(n--)
   {
       cin>>s;
       st.insert(s);
   }
   string f="";
   for(it=st.begin();it!=st.end();++it)
   {
       f+=(*it);
   }
   cout<<f<<endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
string conv(string s){
  string answer="";
  answer.push_back(s[0]);
  REP(i,s.size()-1)
    if(s[i]=='a'||s[i]=='i'||s[i]=='u'||s[i]=='e'||s[i]=='o')
      answer.push_back(s[i+1]);
  while(answer.size()<51) answer.push_back('!');
  return answer;
}
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    vector<string> s(n);
    REP(i,n) cin >> s[i];
    REP(i,n) s[i]=conv(s[i]);
    bool flag=false;
    int answer=-1;
    REP(k,51){
      flag=true;
      REP(i,n){
	REP(j,i)
	  if(string(s[i].begin(),s[i].begin()+k)==
	     string(s[j].begin(),s[j].begin()+k))
	    flag=false;
      }
      if(flag){
	answer=k;
	break;
      }
    }
    cout << answer << endl;
    
  }
}

Measured memory_bytes: 3156
n = int(input())
p = list(map(int,input().split()))
cnt = 0
for i in range(len(p)):
    if p[i] == i+1:
        if p[i] == n:
            p[i-1],p[i] = p[i],p[i-1]
        else:
            p[i],p[i+1] = p[i+1],p[i]
        cnt += 1
print(cnt)


Measured memory_bytes: 14008
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

#define ll long long
const int maxN = 100005;
const ll INF = 1000000000000000000LL;

class TaskB {
private:
	Debugger debugger;

public:
	void solveOne(int it){
		string s, t;
		cin >> s >> t;
		int n = s.size();
		int ans = 0;
		for(int i = 0; i < n; i++){
			ans += s[i] != t[i];
		}
		cout << ans << endl;
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskB solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 3876
from itertools import combinations as cmbs
c = {"M":0,"A":0,"R":0,"C":0,"H":0}
for i in range(int(input())):
  si = input()
  if si[0] in c:
    c[si[0]] += 1
ans = 0
for i,j,k in cmbs(c.values(),r=3):
  t = i*j*k
  ans += t
print(ans)

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

int main(){
	string s,a="AZ";
	cin >> s;
	int inicio=0,fim=-1;
	bool achado=true;
	for (int i = 0; i < s.size(); ++i)
	{
		if(achado){
			if(s[i]==a[0]){
				inicio=i;
				achado=false;
			}
		}else{
			if(s[i]==a[1]){
				fim=i;
			}
		}
	}
	cout << (fim-inicio)+1;
}

Measured memory_bytes: 640
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,a,b = readInts()

if (b-a)%2==0:
	print((b-a)//2)
else:
	print(min(b-1,n-a,a+(b-a-1)//2,n-(a+b-1)//2))

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

int main(void) {
	int X, Y, Z;
	scanf("%d %d %d", &X, &Y, &Z);
	swap(X, Y);
	swap(X, Z);
	printf("%d %d %d", X, Y, Z);

	return 0;
}


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

main(){
	int n,a[100010],b[100010];
	long long ans;
	ans = 0;
	cin>>n;
	for(int i=1;i<=n+1;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		cin>>b[i];
	for(int i=1;i<=n;i++){
		b[i] -= a[i];
		if(b[i] >= 0){
			ans += min(a[i+1],b[i]) + a[i];
			a[i+1] -= min(a[i+1],b[i]);
		}
		else
			ans += (b[i]+a[i]);
	}
	cout<<ans<<endl;
	
} 

Measured memory_bytes: 1024
using System;
using System.Linq;

class AOJ {
  static void Main(string[] args)
  {
    int n;

    while (true) {
      n = int.Parse(Console.ReadLine());

      if (n == 0)
        break;

      int[] score = new int[n];

      for (int i = 0; i < n; i++)
        score[i] = int.Parse(Console.ReadLine());

      Console.WriteLine((score.Sum() - score.Max() - score.Min()) / (n - 2));
    }
  }
}

Measured memory_bytes: 9388
M, D = map(int, input().split())
cnt = 0
for m in range(1, M + 1):
    for d in range(22, D + 1):
        d1, d10 = int(str(d)[1]), int(str(d)[0])
        if d1 >= 2 and d1 * d10 == m:
            cnt += 1
print(cnt)

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

void swap(int &x, int &y) {
	int tmp;
	tmp = x;
	x = y;
	y = tmp;
}

int main() {
	int data1, data2;
	while(1) {
		cin >> data1 >> data2;
		if (data1 == 0 && data2 == 0) {
			break;
		}
		if (data1 > data2) {
			swap(data1, data2);
		}
		
		cout << data1 << " " << data2 << endl;
		
	}
	return 0;
}

Measured memory_bytes: 1160
n = int(input())
num = list(map(int, input().split()))
tmp = 0
if n%2 == 0:#偶数はn/2回swap
    for i in range(n//2):
        tmp = num[i]
        num[i] = num[-(i+1)]
        num[-(i+1)] = tmp


else:#奇数はn//2回swap
    for i in range(n//2):
        tmp = num[i]
        num[i] = num[-(i+1)]
        num[-(i+1)] = tmp

print(" ".join(map(str, num)))


Measured memory_bytes: 5592
object Main {
  def main(args: Array[String]): Unit = {
    val Seq(a, b, c): Seq[String] = io.StdIn.readLine().split(' ')

    if(a.toCharArray.last == b.toCharArray.head && b.toCharArray.last == c.toCharArray.head) println("YES")
    else println("NO")
  }
}

Measured memory_bytes: 25544
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

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

int main(){
  ll A,B;
  cin >> A >> B;
  ll p = gcd(A,B);
  ll ans = A/p*B;
  cout << ans  << endl;
}


Measured memory_bytes: 3144
program hex
  implicit none
  character(1) :: x, y
  read(*,*) x, y
  if (ichar(x) .lt. ichar(y)) then
    write(*,'(a)') "<"
  else if (ichar(x) .gt. ichar(y)) then
    write(*,'(a)') ">"
  else
    write(*,'(a)') "="
  end if
end program hex


Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 


int main(){

	string s;
	cin>>s;


	int n=s.size();
	s+="   ";

	for(int i=0;i<n;i++){
		if(s[i]==s[i+1]){
			cout<<i+1<<" "<<i+2<<endl;
			return 0;
		}
		if(s[i]==s[i+2]){
			cout<<i+1<<" "<<i+3<<endl;
			return 0;
		}
	}

	cout<<-1<<" "<<-1<<endl;

}

Measured memory_bytes: 512
#include<stdio.h>
int main(void){

int a,b,c,x,i=0;

scanf("%d %d %d",&a,&b,&c);

	for(x=a;x<=b;x++){
		if(c%x == 0){
			i++;
		}
	}
	printf("%d\n",i);
	
return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

vector<ll> dp(100, 0);

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A.at(i);
  bool up = true;
  ll money = 1000;
  ll stock = 0;
  rep(i, N-1){
    if(i == 0){
      if(A.at(0) < A.at(1)){
        stock += 1000/A.at(0);
        money -= A.at(0) * (1000/A.at(0));
      }
      else{
        up = false;
      }
    }
    else if(A.at(i) < A.at(i+1) && !up){
      stock += money / A.at(i);
      money -= A.at(i) * (money/A.at(i));
      up = true;
    }
    else if(A.at(i) > A.at(i+1) && up){
      money += A.at(i) * stock;
      stock = 0;
      up = false;
    }
  }
  money += A.at(N-1) * stock;
  cout << money << endl;  
}

Measured memory_bytes: 3628
#include<stdio.h>

int main()
{
	int n=1,x=1;
	int i,j,k;
	int y=0;
	while(1){
		scanf("%d %d",&n,&x);
		if(n==0 && x==0)
			break;
		for(i=1;i<=n;i++){
			for(j=i+1;j<=n;j++){
				for(k=j+1;k<=n;k++){
					if((i+j+k==x)&&(i!=j)&&(j!=k)&&(k!=i)){
						y++;
					}
				}
			}
		}
		printf("%d\n",y);
                y=0;
	}
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define MAX 400000
bool sosu[MAX]={1,1,0};
int main(){
	for(int i=2;i<MAX;i++)if(sosu[i]==0&&(i%7==1||i%7==6)){
	for(int j=i*2;j<MAX;j+=i)sosu[j]=1;
	}
	int n;
	while(cin>>n,n!=1){
		cout<<n<<":";
		rep(i,MAX){
			if(sosu[i]==0&&(i%7==1||i%7==6)&&n%i==0){
				cout<<" "<<i;
			}
		}
		cout<<endl;
	}
}
 

Measured memory_bytes: 1548
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	map<ll,ll>m;
	ll n,k,i,j;
	cin>>n>>k;
	for(i=1;i<=k;i++){
		ll x,y;
		cin>>x;
		for(j=0;j<x;j++)
			cin>>y,m[y]++;
	}
	ll ans=0;
	for(i=1;i<=n;i++)
		if(m[i]==0)ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
//string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;



int main(){
    cin>>N;
    vec a(N), b(N), xa(N), xb(N);
    rep(i,N) cin>>a[i];
    rep(i,N) cin>>b[i];
    rep(i,N) xa[i] = a[(i + 1)%N] ^ a[i];
    rep(i,N) xb[i] = b[(i + 1)%N] ^ b[i];
    rep(i,N) xa.push_back(xa[i]);
    vec table(N, 0);
    table[0] = -1;
    table[1] = 0;
    ll I = 2, J = 0;
    while(I < N) {
        if (xb.at(I - 1) == xb.at(J)) {
            table.at(I) = J + 1;
            ++I;
            ++J;
        } else if (J > 0) {
            J = table.at(J);
        } else {
            table.at(I) = 0;
            ++I;
        }
    }
    I = 0; J = 0;
    vector<bool> mdl(N * 2,false);
    ll s = N * 2;
    while(I < N * 2) {
        if (xa.at((I + J) % s) == xb.at(J)) {
            if (J == N - 1) {
                mdl.at(I) = true;
                I = I + J - table.at(J);
                J = table.at(J);
            } else {
                ++J;
            }
        } else {
            I = I + J - table.at(J);
            if (J > 0) {
                J = table.at(J);
            } else {
                J = 0;
            }
        }
    }
    rep(i,N){
        if(mdl[i]) {
            cout<<i<<' '<<ll(a[i]^b[0])<<endl;
        }
    }
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;
int L[300001], R[300001];
int main() {
  int64_t A, B, C; cin >> A >> B >> C;
  int64_t K; cin >> K;
  if (K % 2) {
    cout << B - A << "\n";
  } else {
    cout << A - B << "\n";
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)

int main(){
	int w[10],k[10];
	rep(i,10)cin>>w[i];
	rep(i,10)cin>>k[i];
	sort(w,w+10,greater<int>());
	sort(k,k+10,greater<int>());
	cout<<*w+w[1]+w[2]<<' '<<*k+k[1]+k[2]<<endl;
	return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    int ans=0;
    vector<int> p(n);
    for (int i=0;i<n;i++){
        cin >> p[i];
    }
    for (int i=1;i<n-1;i++){
        if ((p[i-1]<p[i] && p[i]<p[i+1]) || (p[i-1]>p[i] && p[i]>p[i+1])) ans += 1;
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

typedef complex<double> P;
int N, M;
P p[14];

constexpr double EPS = 1e-8;
int dp[1 << 14];
constexpr int INF = 100;
bool check(double r) {

	vector<int> b;
	for (int i : range(N)) {
		int bit = 0;
		for (int j : range(N)) {
			double d = abs(p[i] - p[j]);
			if (d < EPS)bit|=(1<<j);
		}
		b.push_back(bit);
	}
	for (int i : range(N)) {
		for (int j : range(N)){
			P v = p[i] - p[j];
			double d = abs(v);
			if (d < EPS || d>2*r + EPS)continue;
			P u(v.imag(),-v.real());
			u /= d;
			d /= 2;
			double dd = sqrt(r*r - d * d);
			u *= dd;
			P c = (p[i] + p[j]) / 2.0 + u;
			int bit = 0;
			for (int k : range(N)) {
				if (r - abs(p[k] - c) >= -EPS)bit |= (1 << k);
			}
			b.push_back(bit);
		}
	}
	for (int i : range(1 << N))dp[i] = INF;
	dp[0] = 0;
	for (int i : range(1 << N)) {
		for (auto &it : b) {
			chmin(dp[i | it], dp[i] + 1);
		}
	}
	return dp[(1 << N) - 1] <= M;
}
int main() {
	cout << fixed;
	cout << setprecision(10);
	cin >> N >> M;
	for (int i : range(N)) {
		double x, y;
		cin >> x >> y;
		p[i] = P(x, y);
	}
	double lb = EPS;
	double ub = 1e6;
	for (int i : range(100)) {
		const double mid = (lb + ub) / 2;
		(check(mid) ? ub : lb) = mid;
	}
	cout << ub << endl;
	return 0;
}



Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> T(n+1,0);
  vector<pair<int,int>> xy(n+1);
  xy.at(0) = make_pair(0,0);
  for(int i=1;i<n+1;i++){
    int t,x,y;
    cin >> t>> x >> y;
    T.at(i) = t;
    xy.at(i) = make_pair(x,y);
  }
  bool ok = true;
  for(int i=0;i<n;i++){
    int dx = abs(xy.at(i+1).first-xy.at(i).first);
    int dy = abs(xy.at(i+1).second-xy.at(i).second);
    int dt = T.at(i+1)-T.at(i);
    if(dt < dx+dy){
      ok = false;
    }else{
      if(dt%2 != (dx+dy)%2){
        ok = false;
      }
    }
  }
  if(ok) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}
        
      
      




Measured memory_bytes: 1408
package main

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

var sc = bufio.NewScanner(os.Stdin)

// utils
func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func max(a, b int) int {
	return int(math.Max(float64(a), float64(b)))
}

func min(a, b int) int {
	return int(math.Min(float64(a), float64(b)))
}

func abs(a, b int) int {
	return int(math.Abs(float64(a) - float64(b)))
}

//data types

type set map[int]struct{}

type pair struct {
	first  int
	second int
}

func main() {
	sc.Split(bufio.ScanWords)
	h, n := nextInt(), nextInt()
	sum := 0
	for i := 0; i < n; i++ {
		sum += nextInt()
	}
	if h <= sum {
		fmt.Print("Yes")
		return
	}
	fmt.Print("No")
}


Measured memory_bytes: 1152
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <iostream>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

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

ll H;

ll func(ll n) {
    if (n == 1)
        return 1;
    return func(n / 2) * 2 + 1;
}

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

    cin >> H;
    cout << func(H) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
int N= scan.nextInt();
        int M= scan.nextInt();
long H[]=new long[N];
int i=0;
int S[]=new int[N];
int i2=0;
while (i2<N){H[i2]=scan.nextLong();
i2=i2+1;}

while (i<M) {int A=scan.nextInt()-1;
int B=scan.nextInt()-1;

    if(H[A]>=H[B]){S[B]=S[B]+1;};
    if(H[B]>=H[A]){S[A]=S[A]+1;};

i=i+1;

}
int P=0;
int i1=0;

        while (i1<N) {if (S[i1]==0){P=P+1;

        };



            i1=i1+1;}

        System.out.println(P);


}

       }



Measured memory_bytes: 60632
#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
    _typer init = 0;
    char ch = getchar(), k = 0;
    for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
    for ( ; isdigit(ch); ch = getchar())
        init = (init << 3) + (init << 1) + (ch ^ 48);
    return k ? -init : init;
}
const ll N = 200005, INF = 1e9;
const ll Mod = 998244353;

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


int n;

struct NODE {
    int x, y;
    inline bool operator < (const NODE &__) const {
        return x < __.x || (x == __.x && y < __.y);
    }
} node[N];
int X[N], Y[N], Cntx[N];
int A[N], B[N], C[N], D[N];

int c[N];
void Add(int x, int k) {
    for ( ; x <= n; x += x & -x) c[x] += k;
}
int Que(int x) {
    int res = 0;
    for ( ; x > 0; x -= x & -x) res += c[x];
    return res;
}

ll Ans = 0;
ll Pow(ll x, int k) {
    ll res = x, ans = 1;
    while (k) {
        if (k & 1) ans = ans * res % Mod;
        res = res * res % Mod, k >>= 1;
    }
    return ans;
}
ll Get(int x) {
    return ((Pow(2, x) - 1) % Mod + Mod) % Mod;
}
ll Solve(int x) {
    ll tmp = 0, a, b, c, d;
    // cout << node[x].x << " " << node[x].y  << endl;
    // cout << A[x] << " " << B[x] << " " << C[x] << " " << D[x] << endl;
    a = Get(A[x]), b = Get(B[x]), c = Get(C[x]), d = Get(D[x]);
    (tmp = a * d % Mod + b * c % Mod) %= Mod;
    (tmp += a * b % Mod * d % Mod + a * c % Mod * d % Mod) %= Mod;
    (tmp += a * b % Mod * c % Mod + b * d % Mod * c % Mod) %= Mod;
    (tmp += a * b % Mod * c % Mod * d % Mod) %= Mod;
    // cout << x << " " << tmp << endl;
    (tmp *= 2) %= Mod;
    (tmp += a + b + c + d) %= Mod;
    (tmp += a * b % Mod + a * c % Mod) %= Mod;
    (tmp += b * d % Mod + c * d % Mod) %= Mod;
    // cout << x << " " << tmp << endl;
    return tmp + 1;
}

int main() {
    n = read<int>();
    rep (i, 1, n)
        X[i] = node[i].x = read<int>(), Y[i] = node[i].y = read<int>();

    sort(X + 1, X + n + 1);
    sort(Y + 1, Y + n + 1);
    X[0] = unique(X + 1, X + n + 1) - X - 1;
    Y[0] = unique(Y + 1, Y + n + 1) - Y - 1;
    sort(node + 1, node + n + 1);

    rep (i, 1, n) {
        node[i].x = lower_bound(X + 1, X + X[0] + 1, node[i].x) - X;
        node[i].y = lower_bound(Y + 1, Y + Y[0] + 1, node[i].y) - Y;
    }

    rep (i, 1, n) {
        A[i] = Que(node[i].y - 1);
        B[i] = i - A[i] - 1;
        Add(node[i].y, 1);
    }

    memset(c, 0, sizeof c);
    dep (i, n, 1) {
        C[i] = Que(node[i].y - 1);
        D[i] = n - i - C[i];
        Add(node[i].y, 1);
    }

    rep (i, 1, n) (Ans += Solve(i)) %= Mod;

    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 8064
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(){

  map<string,int> mp1,mp2;
  int N,M;
  cin >> N;
  string s;
  for(int i = 0;i < N;i++){
    cin >> s;
    mp1[s]++;
  }
  cin >> M;
  for(int i = 0;i < M;i++){
    cin >> s;
    mp2[s]++;
  }

  int mx = -10000;
  for(auto itr = mp1.begin();itr != mp1.end();itr++){
    mx = max(mx,(itr->second)-mp2[itr->first]);
  }

  if(mx < 0)cout << 0 << endl;
  else cout << mx << endl;

}

Measured memory_bytes: 256
import math
import copy

def trial_division(n):
    check = 0
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp+1):
        while n % num == 0:
            n /= num
            factor.append(num)
            check = 1
    #素数チェック
    if check == 0:
        factor.append(n)
    return factor

n = int(input())
ans = 1

div = []
for i in range(2,n+1):
    for j in trial_division(i):
        div.append(j)
        div = list(set(div))

for i in div:
    x = 0
    for j in range(i,n+1):
        num = j
        while num % i == 0:
            x += 1
            num /= i
    ans = (ans*(x+1))%(10**9+7)

print(ans)

Measured memory_bytes: 3572
#include<iostream>
#include<atcoder/all>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int n,m; cin >>n >>m;
  vector<li> a(n),b(m);
  rep(i,n) cin >>a[i];
  rep(i,m) cin >>b[i];
  vector<li> c=atcoder::convolution(a,b);
  for(li x:c) print(x);
}


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

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

    int cnt = 0;
    while (!(k < cnt)) {
        if (!(a < b)) {
            b *= 2;
            cnt++;
            continue;
        }
        if (!(b < c)) {
            c *= 2;
            cnt++;
            continue;
        }
        break;
    }

    cout << (k >= cnt ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){
    int a,b,i;
    char op;
    for(i=0;i<20000;i++){
        cin>>a>>op>>b;
        if(op=='+'){cout<<a+b<<endl;}
        else if(op=='-'){cout<<a-b<<endl;}
        else if(op=='*'){cout<<a*b<<endl;}
        else if(op=='/'){cout<<a/b<<endl;}
        else break;
    }
}


Measured memory_bytes: 3096
def main():
    count = 0
    frag = 0
    ans = 0
    N = int(input())
    d = []
    for i in range(N) :
        d1, d2 = map(int, input().split())
        d_temp = [d1,d2]
        if d1 == d2 and frag == 0:
            count += 1
            frag = 1
        elif frag == 1 and d1 == d2 :
            count += 1
            if count == 3 :
                ans = 1
        elif d1 != d2 :
            frag = 0
            count = 0

    if ans == 1 :
        print("Yes")
    else :
        print("No")

if __name__ == '__main__':
    main()

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,l,sum=0,a=1e9,b;
    cin>>n>>l;
    rep(i,n){
        sum+=l+i;
        if(abs(l+i)<a) a=abs(l+i),b=l+i;
    }
    cout<<sum-b;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int d = saori.saori_hayami();
		boolean flg = true;
		int num = 0;
		int ans = 0;
		while(flg){
			if(num >= n){
				flg = false;
				break;
			}
			num += 1;
			num +=  2*d;
			ans++;
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pi = pair<int, int>;
using vi = vector<int>;
using vii = vector<pi>;
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(0); cin.tie(NULL);
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x)sz(a))
#define present(t, x) (t.find(x) != t.end())
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define forall(it, a) for(decltype((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define what_is(x) cerr << #x << " is " << (x) << endl;
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) \
	for(long blockTime=(long)NULL;(blockTime==(long)NULL?(blockTime=clock())!=(long)NULL:false); \
	debug("%s:%.4fs\n",(d),(double)(clock()-blockTime)/CLOCKS_PER_SEC))
const int MOD = (int) 1e9 + 7;
const int FFTMOD = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1); // pi
const ld EPS = 1e-9; // epsilon
#define eb emplace_back
#define ef emplace_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int imin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int imax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}

//time__("program time")

int main(){

	fast_io;
	//solve();

	int n;
	cin >> n;

	vector<int>a(n,0),b(n,0);

	rep(i,0,n){
		cin >> a[i];
		b[i] = a[i]-i-1;
	}
	sort(all(b));

	function <uint64_t(int c)>sadness = [&](int c)->uint64_t{
		uint64_t sum = 0;
		rep(i,0,n){
			sum += abs(a[i]-(c+i+1));
		}

		return sum;
	};

	uint64_t ans = 0;
	if(n%2 != 0){
		ans = sadness(b[n/2]);
	}else{
		ans = sadness((b[n/2-1]+b[n/2])/2);
	}
	cout << ans << "\n";

return 0;
}


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

typedef pair<int, int> P;
typedef pair<string, P> Restaurant;

int main() {
    int n;
    cin >> n;
    Restaurant restaurants[n];
    for (int i = 0; i < n; i++) {
        string s;
        int p;
        cin >> s >> p;
        restaurants[i] = Restaurant(s, P(-p, i + 1));
    }
    sort(restaurants, restaurants + n);
    for (auto r: restaurants) {
        cout << r.second.second << endl;
    }
    return 0;
}


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

int main(){
    ll a, b, k;
    cin >> a;
    cin >> b;
    cin >> k;
    if(a >= k){
        a -= k;
        cout << a << " " << b << endl;
    }
    else
    {
        k -= a;
        a = 0;
        if(b >= k){
            cout << a << " " << b - k << endl;
        }
        else{
            cout << a << " " << 0 << endl;
        }
    }
    
}

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

int N;
#define M 55555
bool T[M + 1];

vector<int> A;

int main() {
  fill(T + 2, T + M + 1, true);
  for(int i = 2; i <= M; ++i) {
    if(T[i]) {
      if(i % 10 == 1) A.push_back(i);
      for(int j = 2 * i; j <= M; j += i) {
        T[j] = false;
      }
    }
  }
  cin >> N;
  for(int i = 0; i < N; ++i) cout << (i == 0 ? "" : " ") << A[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
dp = 13*[0]
dp[0] = 1
mod = 10**9+7

for s in S:
  if s=="?":
    dp = [sum(dp[4*(j-i)%13] for i in range(10))%mod for j in range(13)]
  else:
    dp = [dp[4*(j-int(s))%13] for j in range(13)]
    
print(dp[5])

Measured memory_bytes: 9180
N,A,B = map(int, input().split())
Nl = list(range(1, N+1))

def numSum(num):
  s = str(num)
  strnum = list(map(int, s))
  return sum(strnum)

sm = 0

for i in range(N):
  ns = numSum(Nl[i])
  if ns >= A and ns <= B:
    sm += Nl[i]
    
print(sm)

Measured memory_bytes: 3316
#include<stdio.h>
#include<stdlib.h>

int cmp(const int *a, const int *b){
  if(*a>*b)
  return 1;
  else if(*a<*b)
  return -1;
  else
  return 0;
}

int main(void){
    int n;
    int ans=0;
    int i,j;
    int tmp;
    int center;
    int idxright,idxleft;
    int right,left;
    int start;

    scanf("%d",&n);
    int d[n];
    for(i=0;i<n;i++){
      scanf("%d",&d[i]);
    }
    center=n/2;
    /*for(i=0;i<center;i++){
      for(j=i+1;j<center+1;j++){
        if(d[i]>d[j]){
          tmp=d[i];
          d[i]=d[j];
          d[j]=tmp;
        }
      }
    }

    for(i=center;i<n;i++){
      for(j=i+1;j<n;j++){
        if(d[i]>d[j]){
          tmp=d[i];
          d[i]=d[j];
          d[j]=tmp;
        }
      }
    }*/
    qsort(d,n,sizeof(int),(int (*)(const void *,const void *))cmp);

    idxright=center;
    idxleft=center-1;
    right=d[idxright];
    left=d[idxleft];

    ans=right-left;
    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 892
N,K,Q = map(int,input().split())
A = [0] * N
QList = []
for _ in range(Q):
    QList.append(int(input()))
for q in QList:
    A[q-1] += 1
for a in A:
    point = K - Q + a
    if point > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 8640
N = input()
before_number = N[0:1]
ans = 0
for i in range(len(N)-1):
    if before_number == N[i+1:i+2]:
        ans += 1
        if before_number == "1":
            before_number = "0"
        else:
            before_number = "1"
    else:
        before_number = N[i+1:i+2]
print(ans)

Measured memory_bytes: 3188
n = int(input())
edge = [[int(i) for i in input().split()] for j in range(n-1)]
graph = [[] for _ in range(n+1)]
for i in range(n-1):
    u, v, w = edge[i][0], edge[i][1], edge[i][2] % 2
    graph[u].append((v,w))
    graph[v].append((u,w))

color = [-1] * (n+1)
dist = [0] * (n+1)    
stack = [1]
color[1] = 0

while stack:
    x = stack.pop()
    cx = color[x]
    dx = dist[x]
    for y, w in graph[x]:
        if color[y] >= 0:
            continue
        dist[y] = dist[x] + w
        if dist[x] ^ dist[y] == 0:
            color[y] = color[x]
        else:
            color[y] = (color[x] + 1) % 2
        stack.append(y)
print('\n'.join([str(n) for n in color[1:]]))

Measured memory_bytes: 57744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

int ppow(int a,int b,int MOD){
	a %= MOD;
	ll res = 1;
	while(b){
		if(b & 1) res = (res * a) % MOD;
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

int main(void){
    ll n,p;
    cin >> n >> p;
    string s;
    cin >> s;
    if(p == 2 || p == 5){
        ll ans = 0;
        rep(i,n){
            if((s[i]-'0')%p == 0){
                ans += i+1;
            }
        }
        cout << ans << endl;
        return 0;
    }
    vector<int> cum(n+1,0);
    map<int,ll> dict;
    dict[0]++;
    for(ll i=n-1; i>=0; i--){
        cum[i] = (cum[i+1] + (s[i]-'0') * ppow(10,n-1-i, p)) % p;
        dict[cum[i]]++;
    }
    ll ans = 0;
    for(auto ob: dict){
        ll sec = ob.sc;
        ans += sec * (sec-1) /2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1796
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstring>
#include <cctype>
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
const double PI = 3.141592653589793238462643383279502884L;
const int LARGE_INT = 1000000007;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define repfn(i,a,cont,next) \
  for(auto i = (a); [=](){return(cont);}(); i = [=](){return(next);}())
#define repby(i,a,b,s) repfn(i,a,i<b,i+s)
#define repab(i,a,b) repby(i,a,b,1)
#define rep(i,b) repab(i,0,b)
#define pb push_back
#define sz(c) int((c).size())

int main(int argc, char **argv)
{
  repab(i, 1, 10) {
    repab(j, 1, 10) {
      printf("%dx%d=%d\n", i, j, i*j);
    }
  }
  return 0;
}

Measured memory_bytes: 1088