akhauriyash/Code-Regression huggingface dataset:
#include<complex>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<vector>
#include<map>
#include<sstream>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<deque>
#include<queue>
#include<climits>
#include<list>
#include<stack>
#include<ctime>
#define all(n) n.begin(),n.end()
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define INF (1<<27)
#define EPS 1e-10
#define equals(a,b) (fabs((a)-(b)) < EPS)

using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef unsigned long long ull;
typedef long long ll;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int V[4] = {10,50,100,500};
int C[4],I[4],R[4],A[4];
int pay;
const int T[4] = {INT_MAX,INT_MAX,INT_MAX,INT_MAX};

void ret(int sum){
  int A = sum;
  for(int i=3;i>=0;i--){
    int t = min(A/V[i],T[i]);
    A -= t*V[i];
    R[i] = t;
  }
}

int main(){
  bool first = false;
  while(cin >> pay && pay){
    rep(i,4)cin >> C[i];
    int pre = INT_MAX;
    A[0] = A[1] = A[2] = A[3] = -1;
    rep(i,C[0]+1){//10
      rep(j,C[1]+1){//50
	rep(k,C[2]+1){//100
	  rep(l,C[3]+1){//500
	    int sum = i*10+j*50+k*100+l*500;
	    if(sum < pay)continue;
	   
	    I[0] = i,I[1] = j,I[2] = k,I[3] = l;
	    ret(sum-pay);	    
	    int total = 0;
	    bool ok = true;
	    rep(m,4){
	      total += C[m] - I[m] + R[m];
	      //if(I[m] != R[m])ok = false;
	      assert(C[m] >= I[m]);
	    }	    

	    if(total < pre){
	      rep(m,4)A[m] = I[m];
	      pre = total;
	    }	    

	  }
	}
      }
    }

    if(first)cout << endl;
    first = true;
    rep(i,4){
      if(A[i] == 0)continue;
      cout << V[i] << " " << A[i] << endl;
    }


  }
return 0;
}



/*
Way to check the time of processing speed

clock_t start,end;
start = clock();

------function-------

end = clock();
cout << setiosflags(ios::fixed) << setprecision(10) << (double)(end-start)/CLOCKS_PER_SEC << endl;


*/

Measured memory_bytes: 1164
//
// Created by yamunaku on 2019/12/29.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    vector<int> dp(1 << n, false);
    rep(i, 1 << n){
        int sum = 0;
        rep(j, n) if(i & (1 << j)) sum += a[j];
        if(sum == k){
            dp[i] = true;
        }
    }
    rep(i, n){
        rep(j, 1 << n){
            if(j & (1 << i)){
                dp[j] |= dp[j ^ (1 << i)];
            }
        }
    }
    int ans = 0;
    rep(i, 1 << n){
        if(!dp[i]){
            int tmp = 0;
            rep(j, n) if(i & (1 << j)) tmp++;
            ans = max(ans, tmp);
        }
    }
    cout << n - ans << endl;
    return 0;
}


Measured memory_bytes: 7064
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, r[500]; long double x[501];
int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d", &r[i]);
    for(int i = 0; i < n; i++) {
        x[i] = r[i];
        for(int j = 0; j < i; j++) {
            long double dist = sqrtl((r[j] + r[i]) * (r[j] + r[i]) - (r[j] - r[i]) * (r[j] - r[i]));
            x[i] = max(x[i], x[j] + dist);
        }
    }
    long double ret = 0.0;
    for(int i = 0; i < n; i++) {
        ret = max(ret, x[i] + r[i]);
    }
    printf("%.9Lf\n", ret);
    return 0;
}

Measured memory_bytes: 2756
import java.util.*;

public class Main {
    public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      String line = sc.nextLine();
      String[] hedderInfo = line.split("\\s+");
      
      sc.close();
      
      int present = 100;                         // プレゼント対象整数
      int answer = 1;                            // 出力する数
      int D = Integer.parseInt(hedderInfo[0]);   // 割る回数
      int N = Integer.parseInt(hedderInfo[1]);   // 掛ける回数
      
      for (int i = 0; i < D; i++) {
        answer = answer * present;
      }
      
      if (N == present) {
        N = N + 1;
      }

      System.out.println(answer * N);
    }

}


Measured memory_bytes: 21716
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort()
q.sort()
L=p[a-x:a]+q[b-y:b]+r
L.sort()
L.reverse()
print(sum(L[0:x+y]))

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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 

#define int long long
#define mod 998244353
#define pb push_back
#define S second
#define F first
#define INF 1e18
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n" \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x) \
  int x;     \
  cin >> x;  \
  while (x--)

int32_t main() {

  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n,k;
  cin >> n >> k;
  vector<pair<int,int>> v(k);
  for(auto &i: v)
    cin >> i.F >> i.S;
  int bit[n + 3];
  memset(bit,0,sizeof bit);
  bit[1] = 1;
  for(int i = 1; i <= n; ++i) {
    if(i >= 3)
      bit[i] = (bit[i]%mod + bit[i-1]%mod ) %mod;
    for(auto j: v) {
      if(i + j.F <= n)
        bit[i + j.F] = (bit[i + j.F] % mod + bit[i] % mod) % mod;
     
      if(i + j.S + 1 <= n)
        bit[i + j.S + 1] = (bit[i + j.S + 1] - bit[i] + mod) % mod; 
    }  
  }
  cout << bit[n];
  return 0;
}


Measured memory_bytes: 5200
//
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
#define vec vector 


void solve(){
    int n;
    cin >> n;
    while(n != 0){
        int pop = n % 10;
        if(pop == 7){
            cout << "Yes" << endl;
            return;
        }
        n /= 10;
    }
    cout << "No" << endl;
}

int main(){
    solve();
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  string s;
  cin >> s;
  
  ll ans = INF;

  ll h = 0;
  ll n = s.size();
  for (int i = 0; i < n; i++){
    if (i % 2 == (s[i] - '0'))
      h++;
  }
  ans = min(ans, h);
  
  h = 0;
  for (int i = 0; i < n; i++){
    if ((i + 1) % 2 == (s[i] - '0'))
      h++;
  }

  ans = min(ans, h);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias pred)(int n) {
    foreach(i; 0..n) pred();
}
auto rep(alias pred, T = typeof(pred()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = pred();
    return res;
}

void main() {
    int N = readln.chomp.to!int;
    int[] ary = readln.split.to!(int[]).map!"a-1".array;
    int ans = 0;
    foreach(i, a; ary) {
        if (i == ary[a]) ans++;
    }
    writeln(ans/2);
}


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

int n;
double a[3000];
double dp [3000][3000];

// prototype
double p (int , int);

int main()
{
    cin >> n;
    for (int i=0; i<n; ++i)
        for (int j=0; j<n; j++)
            dp [i][j] = -1;
    for (int i=0; i<n; ++i)
        cin >> a[i];
    double prob = 1;
    prob *= p (0 , 0);
    cout << fixed << setprecision (9) << showpoint << prob;


    return 0;
}

double p (int heads , int i)
{
    if (i == n)
        {
            if (heads >n-heads)
                return 1;
            else
                return 0;
        }
    if (dp [i][heads] != -1)
        return dp [i][heads];

    double x = a[i]*p(heads+1 , i+1);
    x += (1-a[i])*p(heads , i+1);

    return dp [i][heads] = x;

}


Measured memory_bytes: 70784
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }



int main() {
	int n, l;
	cin >> n >> l;
	vector<int> x(n);
	int ans = 0;
	rep(i, n) {
		x[i] = l + i;
		ans += x[i];
	}
	int c = INF;
	rep(i, n) {
		if (abs(x[i]) < abs(c)) {
			c = x[i];
		}
	}
	cout << ans - c << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

string setTwelve(int n1, int n2){
	string str1="000000";
	for(int i=5; n1; i--){
		str1[i] += n1%10;
		n1 /= 10;
	}
	string str2="000000";
	for(int i=5; n2; i--){
		str2[i] += n2%10;
		n2 /= 10;
	}
	return str1+str2;
}

int main(){
	int n, m;
	cin >> n >> m;
	vector<tuple<int, int, int, string> > c;
	for(int i=0; i<m; i++){
		int a, b;
		cin >> a >> b;
		c.emplace_back(a, b, i, "");
	}
	sort(c.begin(), c.end());
	int p=1, y=1;
	for(int i=0; i<m; i++){
		if(get<0>(c[i])!=p){
			p=get<0>(c[i]);
			y=1;
		}
		get<3>(c[i]) = setTwelve(p,y);
		swap(get<0>(c[i]),get<2>(c[i]));
		y++;
	}
	sort(c.begin(), c.end());
	for(int i=0; i<m; i++)
		cout << get<3>(c[i]) << endl;
	return 0;
}

Measured memory_bytes: 9200
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define L(i,u) for (int i=head[u]; i!=0; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
typedef long long ll;
using namespace std;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 303;
char s[N];
int n,k,f[N][N][N];
inline void umax(int &a, int b) {a=a>b?a:b;}
int main() {
	scanf("%s",s+1); read(k); n=strlen(s+1);
	rep(i,1,n) f[i][i][0]=1; int ans=0;
	rep(l,-1,n-1) rep(i,1,n) {
		int j=i+l; if (j>n) break;
		rep(K,0,k) {
			int v=f[i][j][K]; umax(ans,v);
			umax(f[i][j+1][K],v); umax(f[i-1][j][K],v);
			umax(f[i-1][j+1][K+(s[i-1]!=s[j+1])],v+2);
		}
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 108800
# -*- coding: utf-8 -*-
import sys

N,*A = map(int, sys.stdin.buffer.read().split())

S = [0 for _ in range(10**6+1)]
T = [0 for _ in range(10**6+1)]

for a in A:
  S[a] += 1

count = 0
for i in range(1,10**6+1):
  if T[i] == 1:
    continue
  if S[i] == 0:
    continue
  if S[i] == 1:
    count += 1
  for j in range(10**6//i+1):
    T[i*j] = 1

print(count)

Measured memory_bytes: 36444
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		Dice dice1 = new Dice();
		Dice dice2 = new Dice();

		dice1.createDice(in.readLine().split(" "));
		dice2.createDice(in.readLine().split(" "));

		dice1.check(dice2);
	}
}

class Dice {
	public int on, tw, th, fo, fi, si;

	public Dice() {

	}

	public Dice(int on, int tw, int th, int fo, int fi, int si) {
		this.on = on;
		this.tw = tw;
		this.th = th;
		this.fo = fo;
		this.fi = fi;
		this.si = si;
	}

	void createDice(String[] data) {
		int[] diceNums = new int[6];
		for (int i = 0; i < data.length; i++) {
			diceNums[i] = Integer.parseInt(data[i]);
		}
		on = diceNums[0];
		tw = diceNums[1];
		th = diceNums[2];
		fo = diceNums[3];
		fi = diceNums[4];
		si = diceNums[5];
	}

	void check(Dice otherDice) {
		boolean result = false;
		int checkTimes = 0;
		while (checkTimes <= 29) {
			while (checkTimes <= 5) {
				result = this.match(otherDice);
				if (result)
					break;
				checkTimes++;
				if (checkTimes == 5) {
					otherDice.north();
				} else {
					otherDice.rightSpin();
				}
			}

			while (checkTimes <= 10) {
				result = this.match(otherDice);
				if (result)
					break;
				checkTimes++;
				if (checkTimes == 10) {
					otherDice.west();
				} else {
					otherDice.rightSpin();
				}
			}

			while (checkTimes <= 15) {
				result = this.match(otherDice);
				if (result)
					break;
				checkTimes++;
				if (checkTimes == 15) {
					otherDice.north();
				} else {
					otherDice.rightSpin();
				}
			}

			while (checkTimes <= 20) {
				result = this.match(otherDice);
				if (result)
					break;
				checkTimes++;
				if (checkTimes == 20) {
					otherDice.west();
				} else {
					otherDice.rightSpin();
				}
			}

			while (checkTimes <= 25) {
				result = this.match(otherDice);
				if (result)
					break;
				checkTimes++;
				if (checkTimes == 25) {
					otherDice.north();
				} else {
					otherDice.rightSpin();
				}
			}

			while (checkTimes <= 29) {
				result = this.match(otherDice);
				if (result)
					break;
				checkTimes++;
				otherDice.rightSpin();
			}
			if (result)
				break;
		}

		if (result) {
			System.out.println("Yes"); // ?????´??????
		} else {
			System.out.println("No"); // ?????´?????????
		}
	}

	boolean match(Dice otherDice) {
		if (this.on == otherDice.on && this.tw == otherDice.tw
				&& this.th == otherDice.th && this.fo == otherDice.fo
				&& this.fi == otherDice.fi && this.si == otherDice.si) {
			return true;
		}
		return false;
	}

	void rightSpin() {
		int temp = tw;
		tw = fo;
		fo = fi;
		fi = th;
		th = temp;
	}

	public void north() {
		int temp = on;
		on = tw;
		tw = si;
		si = fi;
		fi = temp;
	}

	public void east() {
		int temp = on;
		on = fo;
		fo = si;
		si = th;
		th = temp;
	}

	public void west() {
		int temp = on;
		on = th;
		th = si;
		si = fo;
		fo = temp;
	}

	public void south() {
		int temp = on;
		on = fi;
		fi = si;
		si = tw;
		tw = temp;
	}
}

Measured memory_bytes: 17096
function main(input) {
  const args = input.split(' ');
  const N = parseInt(args[0], 10);
  
  if (N % 2 == 0) {
    console.log(N / 2);
  } else {
    console.log(Math.ceil(N / 2));
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29528
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
 
int main(){
  int n,q;
  cin >> n;
  map<int,int> A;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    A[a]+=1;
  }
  long sum = 0;
  for(auto x : A) {
    sum += x.first*x.second;
  }
 
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int b,c;
    cin >> b >> c;
 
    sum += A[b]*(c-b);
    A[c] += A[b];
    A.erase(b);
 
    cout <<sum << endl;
  }
  return 0;
}

Measured memory_bytes: 6024
#include <stdio.h>

long long int gcd(long long int m,long long int n){
    if(n==0)
        return m;
    else
        return gcd(n,m%n);
}

int main(){
    long long int a,b;
    scanf("%lld %lld",&a,&b);
    printf("%lld",a*b/gcd(a,b));
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  string s1, s2; cin >> s1 >> s2;
  vector<ll> dp(n+1);
  dp[0] = 1;
  int i = 0;
  while(i < n) {
    if(s1[i] != s2[i]) {
      if(i==0) dp[i+1] = dp[i+2] = 6;
      else if(s1[i-1] != s2[i-1]) dp[i+1] = dp[i+2] = dp[i] * 3 % mod;
      else dp[i+1] = dp[i+2] = dp[i] * 2 % mod;
      i += 2;
    } else {
      if(i==0) dp[i+1] = 3;
      else if(s1[i-1] != s2[i-1]) dp[i+1] = dp[i];
      else dp[i+1] = dp[i] * 2 % mod;
      i++;
    }
  }
  cout << dp[n] << "\n";
  return 0;
}


Measured memory_bytes: 3564
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<string> S, T;
  in<int> A, B;
  in<string> U;
  
  if (S == U)
    A--;
  if (T == U)
    B--;



  cout << A << " " << B << endl;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(0) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}


Measured memory_bytes: 256
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N;
ll a[200000];

void init()
{
}

ll func(int b)
{
    ll ret = 0;
    REP(i, N){
        ret += abs(a[i] - b);
    }
    return ret;
}

void solve()
{
    ll ans;
    REP(i, N) a[i] -= i+1;
    sort(a, a+N);
    if(N % 2 == 0) ans = min(func(a[N/2]), func(a[N/2+1]));
    else ans = func(a[N/2]);
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) cin >> a[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


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

typedef long long ll;
using namespace std;

int main(void){
    int H, N;
    cin >> H >> N;
    ll A[N], B[N];
    for(int i  = 0; i < N; i++){
        cin >> A[i] >> B[i];
    }
    
    ll dp[20010];
    for(int i = 0; i < 20010; i++)dp[i] = (1LL<<61)-1;
    dp[0] = 0;
    for(int i = 0; i < 10010; i++){
        for(int j = 0; j < N; j++){
            dp[i+A[j]] = min(dp[i+A[j]], dp[i]+B[j]);
        }
    }
    ll ans = 1LL<<61;
    for(int i = H; i < 20010; i++) ans = min(ans, dp[i]);
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <unordered_map>
#define maxn 100005
#define mod 1000000007
using namespace std;
typedef long long LL;
int main()
{
    int n,r;
    scanf("%d%d",&n,&r);
    if(n>=10)
        printf("%d",r);
    else
        printf("%d",r+100*(10-n));
    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>


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

int main(){
    int n; cin >> n;
    vector<int> L(n);
    rep(i,n) cin >> L[i];
    
    sort(L.begin(), L.end());
    int ans = 0;
    rep(b,n){
        rep(a,b){
            int ab = L[a]+ L[b];
            int r = lower_bound(L.begin(), L.end(), ab) - L.begin();
            int l = b + 1;
            
            ans += r-l;
        }
    }
    
    cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>

int main () {
  long long N;
  std::cin >> N;
  long long answer = 0;
  long long sub;
  long long iterator = 0;
  long long subsub = 0;
  for (int i = 0; i < N; i++) {
    std::cin >> sub;
    if (sub % 2 == 0 ) {
      subsub = 0;
      while (true) {
        if (sub % 2 == 0) {
          subsub ++;
          sub = sub / 2;
        }
        else {
          // a[iterator] = subsub;
          answer = answer + subsub;
          break;  
        }
      }
    }  
  }  

  std::cout << answer << std::endl;
  

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;



int main(void) {
  int n,m;
  cin >> n >> m;
  cout << n*(n-1)/2 + m*(m-1)/2 << endl;
}






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

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    if (s.length() == 2) {
        cout << s << endl;
    }else{
        vrev(s);
        cout << s << endl;
    }
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_d

#include "algorithm"
#include "cmath"
#include "functional"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll M;
  cin >> M;

  // 操作を行うと、
  // 1. 繰り上がりがある時： 桁数はそのままに、 digitSum が 9 減る
  // 2. 繰り上がりが無い時： 桁数が 1 減り、 digitSum はそのまま
  // よって、ある数に行える操作の回数は （桁数 - 1） + (digitSum-1) / 9

  ll digit = 0;
  ll digitSum = 0;

  rep(i, M) {
    ll d, c;
    cin >> d >> c;

    digit += c;
    digitSum += c * d;
  }

  ll res = (digit - 1) + (digitSum - 1) / 9;

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pp push_back
#define ff first
#define ss second

using namespace std;

ll t,n,m,r,l,h,i,x[100001],y[100001],z,g,a,b,c,d[101][100001],k,q;
vector <ll> v;
vector <pair <ll,ll> > vv;
queue <pair <ll,ll> > qq;
pair <ll,ll> p;
map <ll,ll> mp,mpp;
set <ll> se;
set <ll> :: iterator it;
string s;
char cc;

ll dp(ll ii , ll w)
{
    if(w>k)
        return 0;
    if(d[ii][w]!=-1)
        return d[ii][w];
    ll z=0;
    for(ll j=ii+1;j<=n;j++)
        z=max(dp(j,w+x[j]),z);
    return d[ii][w]=z+y[ii];
}

int main()
{
    ios::sync_with_stdio(0);
    cin >> n >> k;
    for(i=1;i<=n;i++)
        cin >> x[i] >> y[i];
    memset(d,-1,sizeof(d));
    cout << dp(0,0);
    return 0;
}


Measured memory_bytes: 80128
K = int(input())
MAX = pow(10,6)+10
#keta = 1
now = 0
SET = set([])
for i in range(MAX):
  now = (now*10+7)%K
  if now == 0:
    print(i+1)
    exit()
  else:
    if now in SET:
      print(-1)
      exit()
    else:
      SET.add(now)

Measured memory_bytes: 77900
import java.util.Scanner;
public class Main{
	public static void main(String [] agrs){
		Scanner sc = new Scanner(System.in);
		int n,r;
		while(true){
			n = sc.nextInt();
			int [] number = new int [n];
			for(int i=0; i<n; i++){
				number[i] = n-i;
			}
			r = sc.nextInt();
			if(r==0 && n == 0)break;
			for(int i=0; i<r; i++){
				int p = sc.nextInt()-1;
				int c = sc.nextInt();
				int [] temp = new int[p];
				for(int j=0;j<p;j++)temp[j] = number[j];
				for(int j=0;j<c;j++)number[j] = number[j+p];
				for(int j=0;j<p;j++)number[j+c] = temp[j];
			}
			System.out.println(number[0]);
		}
	}
}

Measured memory_bytes: 30400
n,m,Q = map(int,input().split())
lr = [list(map(int,input().split())) for _ in range(m)]
lr.sort(key=lambda x:(x[0],x[1]))
ans = [[0]*(n+1) for _ in range(n+1)]
now = 0
for i in range(1,n+1):
  j = 1
  while True:
    if now < m:
      if lr[now][1] == j and lr[now][0] == i:
        ans[i][j] += (ans[i][j]==0)*(ans[i][j-1]) + 1
        now += 1
      else:
        j += 1
        if j <= n:
          ans[i][j] = ans[i][j-1]
        else:
          break
    else:
      j += 1
      if j <= n:
        ans[i][j] = ans[i][j-1]
      else:
        break
ans2 = [[0]*(n+1) for _ in range(n+1)]
for i in range(1,n+1):
  for j in range(1,n+1):
    if i == 1:
      ans2[i][j] = ans[i][j]
    else:
      ans2[i][j] = ans2[i-1][j] + ans[i][j]
for i in range(Q):
  p,q = map(int,input().split())
  print(ans2[q][q]-ans2[p-1][q])

Measured memory_bytes: 105944
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<long long>a(n);
    map<int,int>dic;
    for(int i=0;i<n;i++){
        cin>>a[i];
        dic[a[i]]++;
    }
    int ans=0;
    map<int,int>::iterator it;
    for(auto it=dic.begin();it!=dic.end();it++){
        if((it->second)%2!=0){
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 998244353
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
struct edge{//グラフに使うヤツ
    ll from,to,cost;
};
typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

ll n,m;
vector<vector<edge> > graph;
ll dp[105][105];
bool used[105][105];

void warshall_floyd(){
    for (ll k=0;k<n;k++){
        for (ll i=0;i<n;i++){
            for (ll j=0;j<n;j++){
                if (dp[i][j]>dp[i][k]+dp[k][j]){
                    dp[i][j]=dp[i][k]+dp[k][j];
                }
            }
        }
    }
}

vector<edge> dist;

int main() {
    cin >> n >> m;
    graph=G(n);
    for (ll i=0;i<n;i++){
        for (ll j=0;j<n;j++){
            if (i==j){
                dp[i][j]=0;
            }else{
                dp[i][j]=INF;
            }
        }
    }
    for (ll i=0;i<m;i++){
        ll a,b,c;
        cin >> a >> b >> c;
        a--;
        b--;
        dp[a][b]=c;
        dp[b][a]=c;
        edge e;
        e.from=a;
        e.to=b;
        e.cost=c;
        dist.push_back(e);
        e.from=b;
        e.to=a;
        e.cost=c;
        dist.push_back(e);
    }
    warshall_floyd();
    ll ans=0;
    for (ll i=0;i<dist.size();i++){
        bool flag=false;
        for (ll j=0;j<n;j++){
            for (ll k=0;k<n;k++){
                if (dp[j][dist[i].from]+dist[i].cost+dp[dist[i].to][k]==dp[j][k]){
                    flag=true;
                }
            }
        }
        if (!(flag)){
            ans++;
        }
    }
    cout << ans/2 << endl;
    return 0;
}



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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

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

int go(int x)
{
    int res = 0;
    int temp = 1;
    
    while(temp <= x)
    {
        res++;
        x-=temp;
        temp++;
    }
    
    return res;
}


void solve()
{
   int n;
    cin >> n;
    
   map<int,int> mp;
    
   for(int i=2;(i*i) <= n ;i++)
   {
       while(n%i == 0)
       {
           mp[i]++;
           n/=i;
       }
   }
    
   if(n > 1) mp[n]++; 
    
   int res = 0;
    
   for(auto x : mp) res+=go(x.S);
    
   cout << res;
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 3664
#include <stdio.h>

int main() {
  int A, B, X, ans, a = 0, b = 0;
  scanf("%d %d %d", &A, &B, &X);

  if ( X % 500 != 0 ) X += 500 - X%500;

  if ( A < B ) {
    a = X/1000 + ((X%1000>0)?1:0);
  } else if ( A > 2*B ){
    b = X/500;
  } else {
    a = X/1000; X %= 1000;
    b = X/500;
  }

  printf("%d\n", A*a + B*b);

  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <cstdio>

using namespace std;

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

int main() {
	int n;
	float x[4], y[4];
	bool flag;
	cin >> n;
	REP(i,n) {
		flag = true;
		REP(j,4)
			cin >> x[j] >> y[j];
		REP(j,2) {
			if (x[(j*2+1)%4] == x[(j*2)%4] && x[((j+1)*2+1)%4] != x[((j+1)*2)%4])
				flag = false;
			if (y[(j*2+1)%4] == y[(j*2)%4] && y[((j+1)*2+1)%4] != y[((j+1)*2)%4])
				flag = false;
		}
		if (flag && !(x[1] == x[0] && x[3] == x[2] || y[1] == y[0] && y[3] == y[2])) {
			if ((y[1]-y[0])/(x[1]-x[0]) != (y[3]-y[2])/(x[3]-x[2]))
				flag = false;
		}

		if (flag)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 1192
void main() {
	auto N = ri;
	auto arr = iota(N).array.map!(v => rs.to!dstring).array;
	auto arr2 = arr.sort().group.array.sort!((a, b) => a[1] > b[1]).array;
	ulong l = arr2[0][1];
	dstring[] res;
	foreach(v; arr2) {
		if(v[1] == l) res ~= v[0];
	}
	res.sort().each!writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 41596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

void solve(){
    ll h,w;cin>>h>>w;
    vector<string> s(h);
    rep(i,h)cin>>s[i];

    ll cnt=0;
    rep(i,h)rep(j,w){
        if(s[i][j]=='#')cnt++;
    }

    vvl d(h,vl(w));
    d[0][0]=1;
    queue<pl> q;
    q.push(pl(0,0));
    while(!q.empty()){
        pl p=q.front();q.pop();
        rep(i,4){
            ll ny=p.first+D4[i],nx=p.second+D4[i+1];
            if(ny<0||nx<0||ny>=h||nx>=w||s[ny][nx]=='#'||d[ny][nx])continue;
            d[ny][nx]=d[p.first][p.second]+1;
            q.push(pl(ny,nx));
        }
    }
    cout<<(d[h-1][w-1]?h*w-d[h-1][w-1]-cnt:-1)<<endl;
}

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


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

using ll = long long;

using namespace std;

int n, m;
vector<int> G[1010], ans, trace;
int from[1010];

void bfs(int i) {
    queue<int> q;
    fill(from, from+n, -1);
    q.push(i);
    while (!q.empty()) {
        int f = q.front(); q.pop();
        for (auto g:G[f]) {
            if (g == i) {
                trace = vector<int>();
                trace.push_back(i + 1);
                while (f != i) {
                    trace.push_back(f + 1);
                    f = from[f];
                }
                if (ans.size() == 0 || ans.size() > trace.size()) swap(ans, trace);
                return;
            }
            if (from[g] >= 0) continue;
            q.push(g);
            from[g] = f;
        }
    }
}

int main() {
    cin >> n >> m;
    for (int i=0, a, b; i<m; i++) {
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
    }
    for (int i=0; i<n; i++) bfs(i);
    if (ans.size() == 0)
        cout << -1 << '\n';
    else {
        cout << ans.size() << '\n';
        for (auto ai:ans) cout << ai << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 5e3 + 10,mod = 1e9 + 7;

int to[N << 1],nex[N << 1],beg[N],fac[N],inv[N],sz[N],Maxsz[N],dp[2][N];
int e,rt,n;

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

inline void Add(int &x,int y) {
	if((x += y) >= mod) x -= mod;
}

inline void add(int x,int y) {
	to[++e] = y,nex[e] = beg[x],beg[x] = e;
}

inline int fpm(int a,int b) {
	int res = 1;
	while(b) {
		if(b & 1) res = 1ll * res * a % mod;
		a = 1ll * a * a % mod,b /= 2;
	}
	return res;
}

inline void init(int Lim) {
	fac[0] = 1;
	For(i,1,Lim) fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[Lim] = fpm(fac[Lim],mod - 2);
	Fordown(i,Lim,1) inv[i - 1] = 1ll * inv[i] * i % mod;
}

inline void dfs_rt(int x,int fa) {
	sz[x] = 1,Maxsz[x] = 0;
	for(int i = beg[x];i;i = nex[i]) {
		if(to[i] == fa) continue;
		dfs_rt(to[i],x);
		sz[x] += sz[to[i]];
		chkmax(Maxsz[x],sz[to[i]]);
	}
	chkmax(Maxsz[x],n - sz[x]);
	if(Maxsz[x] < Maxsz[rt]) rt = x;
}

inline int C(int a,int b) {
	return 1ll * fac[a] * inv[b] % mod * inv[a - b] % mod;
}

inline int A(int a,int b) {
	return 1ll * fac[a] * inv[a - b] % mod;
}

int main() {

	n = read();
	init(n + 5);
	For(i,1,n - 1) {
		int x = read(),y = read();
		add(x,y),add(y,x);
	}

	Maxsz[0] = n + 1;
	dfs_rt(1,0),dfs_rt(rt,0);
	int cnt = 0;
	For(i,1,n) if(Maxsz[i] == Maxsz[rt]) cnt++;
	if(cnt == 2) return printf("%d\n",fpm(fac[n / 2],2)),0;

	int Sum = 0,Nex = 0,Cur = 1;
	dp[Cur][0] = 1;
	for(int i = beg[rt];i;i = nex[i]) {
		memset(dp[Nex],0,sizeof(dp[Nex]));
		For(j,0,Sum) For(k,0,sz[to[i]])
			Add(dp[Nex][j + k],1ll * dp[Cur][j] * C(sz[to[i]],k) % mod * A(sz[to[i]],k) % mod);
		Sum += sz[to[i]],swap(Cur,Nex);
	}
	int ans = 0;
	For(i,0,n)
		ans = (ans + (i & 1 ? -1ll : 1ll) * fac[n - i] * dp[Cur][i]) % mod;

	printf("%d\n",(ans + mod) % mod);

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;

int main()
{
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a + b) * h / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int i,x,n,q,a,v,aaa=0,vvv=0,vv[9000],f[1000000],prev[1000000],next[1000000];
int main(void){
	scanf("%d %d",&n,&q);
	for(i=0;i<n;i++){f[i]=0;prev[i]=(n+i-1)%n;next[i]=(n+i+1)%n;}
	for(i=1;i<9000;i++)vv[i]=-1;
	vv[0]=0;

	for(;q>0;q--){

		scanf("%d %d",&a,&v);a--;
		x=f[a];

		if(vv[x]==a){if(next[a]!=a)vv[x]=next[a]; else vv[x]=-1;}
		next[prev[a]]=next[a];
		prev[next[a]]=prev[a];

		f[a]+=v;x+=v;

		if(vv[x]<0){
			prev[a]=a;
			next[a]=a;
			vv[x]=a;
		}
		else{
			i=vv[x];
			if(a<vv[x])vv[x]=a;
			else {do{i=next[i];}while(a>i && i!=vv[x]);}
			prev[a]=prev[i];
			next[a]=i;
			next[prev[i]]=a;
			prev[i]=a;
		}

		if(v>0){if(x>vvv || (x==vvv && a<aaa)){vvv=x;aaa=a;}}
		else if(a==aaa){
			for(i=vvv; vv[i]<0 && i>0 ;i--);
			vvv=i;aaa=vv[i];
		}

		printf("%d %d\n",aaa+1,vvv);
		//for(i=0;i<n;i++)printf("%d %d %d\n",f[i],prev[i],next[i]);
		//for(i=0;i<10;i++)printf("%3d",vv[i]);printf("\n");

	}

	return 0;
}

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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	int tot;
	if(n&1){
		tot = n;
	}
	else	tot = n+1;
	vector<pair<int,int> > ans;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(i+j!=tot)
				ans.emplace_back(i,j);
	cout<<ans.size()<<'\n';
	for(auto it:ans)
		cout<<it.first<<' '<<it.second<<'\n';
}


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

int main(){
  int n;
  cin >> n;
  string s = to_string(n);
  int ct = s.size();
  int res = 0;
  if (ct == 1){
  	cout << n << endl;
  	return 0;
  }
  if (ct & 1){
    string tmp = "";
    for (int i = 0; i < ct - 1; ++i) tmp += '9';
    ct -= 2;
    res += n - stoi(tmp);
  }
  else {
  	ct--;
  }
  for (int i = 1; i <= ct; i += 2){
    res += pow(10, i - 1) * 9;
  }
  cout << res << endl;
}

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

using namespace std;

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

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

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

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

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

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

  int H;
  while (cin >> H, H) {
    vector<vector<int>> board(H, vector<int>(5, 0));
    rep(i, H) rep(j, 5) cin >> board[i][j];
    bool end = false;
    int ans = 0;
    while (true) {
      //手順1
      int sum = 0;
      rep(i, H) {
        int pid = 0, cnt = 1;
        FOR(j, 1, 5) {
          if (board[i][pid] == board[i][j])
            cnt++;
          else {
            if (3 <= cnt) break;
            pid = j;
            cnt = 1;
          }
        }
        if (3 <= cnt) {
          sum += cnt * board[i][pid];
          FOR(j, pid, pid + cnt) board[i][j] = 0;
        }
      }

      if (sum == 0) break;
      ans += sum;
      //手順2
      bool end = true;
      while (end) {
        end = false;
        for (int i = H - 1; 0 <= i; i--) {
          rep(j, 5) {
            if (i == 0) continue;
            if (board[i][j] == 0) {
              if (board[i - 1][j] != 0) {
                board[i][j] = board[i - 1][j];
                board[i - 1][j] = 0;
                end = true;
              }
            }
          }
        }
      }
    }
    cout << ans << "\n";
  }

  return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int mod = 1000000007;


int main(){
    string S;
    cin >> S;
    int n = S.size();
    bool flag = false;

    // 回文を判定する
    for(int i = 0; i < n / 2; i++){
        if(S[i] != S[n - 1 - i]){
            flag = true;
            break;
        }
    }
    if(flag){
        cout << "No" << endl;
        return 0;
    }
    // 前半の回文を判定する
    int half_length = n / 2;
    for(int i = 0; i < half_length / 2; i++){
        if(S[i] != S[half_length - 1 - i]){
            flag = true;
            break;
        }
    }
    if(flag){
        cout << "No" << endl;
        return 0;
    }

    for(int i = 0; i < half_length / 2; i++){
        if(S[half_length + 1 + i] != S[n - 1 - i]){
            flag = true;
            break;
        }
    }
    if(flag){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    return 0;
}


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

int main(){
int A, B, C, D;
cin >> A >> B >> C >> D;
int R1 = A*B;
int R2 = C*D;
if (R1 >= R2) {
    cout << R1 << endl;
}
else if (R1 < R2) {
    cout << R2 << endl;
}
}

Measured memory_bytes: 256
import java.util.BitSet

val MAX_NUM = 100000

fun main(args: Array<String>) {
    val Q = readInputLine().toInt()
    
    val primes = BitSet(MAX_NUM + 1)
    primes.flip(2, MAX_NUM)

    for (i in 2..MAX_NUM) {
        if (primes[i]) {
            for (j in i * 2..MAX_NUM step i) {
                primes[j] = false
            }
        }
    }

    val like = BitSet(MAX_NUM + 1)
    
    for (i in 0..MAX_NUM) {
        if (primes[i] && primes[(i + 1) / 2]) {
            like.set(i)
        }
    }
    
    val cntArr = IntArray(MAX_NUM + 1)
    
    for (i in 1..MAX_NUM) {
        if (like[i]) {
            cntArr[i] = cntArr[i - 1] + 1
        } else {
            cntArr[i] = cntArr[i - 1]
        }
    }
    
    for (i in 1..Q) {
        val (l, r) = readInputLine().split(" ").map { it.toInt() }
        
        println(cntArr[r] - cntArr[l - 1])
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 56756
fn solve(s: String) -> u8 {
    let mut tmp = 0;
    let mut result = 0;
    let v = vec!('A', 'C', 'G', 'T');

    for c in s.chars() {
        if v.contains(&c) {
            tmp += 1;
        } else {
            result = std::cmp::max(result, tmp);
            tmp = 0;
        }
    }

    std::cmp::max(result, tmp)
}

fn main() {
    let s = read_1();

    println!("{}", solve(s));
}

fn read_1() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().to_string()
}


Measured memory_bytes: 2136