akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 1; i <= 9; i++)
            {
                for (int j = 1; j <= 9; j++)
                {
                    if (i*j==n)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
            }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13140
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 200000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int parent[2][MAX_N+1], depth[MAX_N+1];

int root(int a, int t){
  if(a==parent[t][a])return a;
  return parent[t][a]=root(parent[t][a], t);
}

void unite(int a, int b, int t){
  a=root(a, t);
  b=root(b, t);
  if(depth[a]>depth[b]){
    parent[t][b]=a;
  }else if(depth[b]>depth[a]){
    parent[t][a]=b;
  }else{
    parent[t][a]=b;
    depth[b]++;
  }
}

int main(){
  int n, k, l;cin>>n>>k>>l;
  rep(i, n){
    parent[0][i]=parent[1][i]=i;
    depth[i]=1;
  }
  rep(i, k){
    int p, q;cin>>p>>q;
    unite(--p, --q, 0);
  }
  rep(i, n)depth[i]=1;
  rep(i, l){
    int r, s;cin>>r>>s;
    unite(--r, --s, 1);
  }
  vector<ll> ids(n, 0LL);
  rep(i, n){
    rep(t, 2){
      if(t==0)ids[i]+=ll(root(i, t));
      else ids[i]+=ll(root(i, t))*(MAX_N+1LL);
    }
  }
  map<ll, int> cnt;
  rep(i, n){
    cnt[ids[i]]++;
  }
  rep(i, n){
    // cout<<ids[i]<<" ";
    cout<<cnt[ids[i]]<<" ";
  }
  cout<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 15872
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

#define INF (10000001)

typedef pair<int, int> Edge;

int main()
{
    priority_queue<Edge,vector<Edge>,greater<Edge> > pq;
    vector<vector<Edge> > e;
    vector<int> d;
    Edge etemp;
    int n,u,k,v,c;
    cin >> n;
    e.resize(n);
    d.resize(n);
    for(int i=0; i<n; ++i) {
        cin >> u >> k;
        for(int j=0; j<k; ++j) {
            cin >> v >> c;
            e[u].push_back(Edge{c,v});
        }
        d[u]=INF;
    }

    d[0]=0;
    for(auto x : e[0]) {
        pq.push(x);
    }
    while(!pq.empty()) {
        etemp=pq.top(); pq.pop();
        v=etemp.second;
        c=etemp.first;
        if(d[v]<c) continue;
        d[v]=c;
        for(auto x : e[v]) {
            if(d[x.second]<=c+x.first) continue;
            pq.push(Edge{c+x.first,x.second});
        }
    }
    for(int i=0; i<n; ++i) {
        cout << i << " " << d[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 11732
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) {
    return a < b ? b = a, true : false;
}
template<typename T> bool chmax(T a, T &b) {
    return a > b ? b = a, true : false;
}

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
vll sieve(ll n) {
    str flg(n + 1, '1');
    for (ll i = 2; i * i <= n; i++) {
        if (flg[i] == '0') continue;
        for (ll j = i * i; j <= n; j += i)
            flg[j] = '0';
    }
    vll res;
    for (ll i = 2; i <= n; i++)
        if (flg[i] == '1') res.push_back(i);
    return res;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

/*----------------------------------------------------------------*/

void solve();

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

    solve();
}
void solve() {
    str s;
    std::cin >> s;

    while (true) {
        s.erase(s.end() - 1);
        if (str(s.begin(), s.begin() + s.length() / 2) == str(s.begin() + s.length() / 2, s.end())) {
            std::cout << s.length() << '\n';
            break;
        }
    }
}


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

int main() {
  const int mod = 2019;
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  int n = s.size(), m10 = 1;
  vector<int> r(n + 1);
  for (int i = 0; i < n; i++) {
    r.at(i + 1) = (r.at(i) + (s.at(i) - '0') * m10) % mod;
    m10 = m10 * 10 % mod;
  }
  sort(r.begin(), r.end());
  int ans = 0, d = 1;
  for (int i = 0; i < n; i++) {
    if (r.at(i + 1) == r.at(i)) {
      ans += d;
      d++;
    } else {
      d = 1;
    }
  }
  cout << ans << endl;
}


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

int main(){
	ll n,d,c=0;
  cin>>n>>d;
  vector<ll> x(n),y(n);
  
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
    if((x[i]*x[i]+y[i]*y[i])<=d*d)c++;
  }
  cout<<c;
}

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

int main() {
    string s;
    cin >> s;
    bool a,b,c;
    a = false;
    b = false;
    c = false;
    for(int i=0;i<3;i++){
        if(s[i] == 'a'){
            a = true;
        }
        if(s[i] == 'b'){
            b = true;
        }
        if(s[i] == 'c'){
            c = true;
        }
    }
    if(a && b && c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
//***Little by little one travels far***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll a[100002];
int main()
{
  ll n,m,lcm=1;
  cin>>n>>m;

  forn(i,n){
    cin>>a[i];
    lcm=((lcm*(a[i]/2))/__gcd(lcm,a[i]/2));
  }

  ll l=lcm,f=1;

  forn(i,n){
    if((lcm/(a[i]/2))%2==0){
      f=0;
      break;
    }
  }

  if(f==0){
      cout<<"0";
      return 0;
  }

  ll k=((m/lcm)-1);
  if(k<0){
    cout<<"0";
    return 0;
  }
  else k=k/2;
  if(f==1) cout<<k+1;
  else cout<<k;
  //cout<<" "<<lcm<<" ";
}


Measured memory_bytes: 1024
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    void solve(Scanner sc, PrintWriter pw) {
        int a = sc.nextInt();
        int total = (a + 999) / 1000 * 1000;
        pw.println(total - a);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}


Measured memory_bytes: 35844
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
x = I()
for a in range(-1005,1005,1):
    for b in range(-1005,1005,1):
        if pow(a,5) - pow(b,5) == x:
            print(a,b)
            exit()


Measured memory_bytes: 9408
#include<iostream>
using namespace std;
int n,a[100];
//Ford-Fulkerson O(FE)
#include<algorithm>
#include<utility>
#include<vector>
#include<limits>
template<typename T>
struct MF{
	vector<vector<pair<pair<int,int>,T> > >G;
	vector<int>used;
	MF(int n_=0):G(n_),used(n_,0){}
	void add_edge(int from,int to,T cap)
	{
		G[from].push_back(make_pair(
			make_pair(to,G[to].size()),cap
		));
		G[to].push_back(make_pair(
			make_pair(from,G[from].size()-1),0
		));
	}
	T dfs(int u,int t,T f,int dfstime)
	{
		if(u==t)return f;
		used[u]=dfstime;
		for(pair<pair<int,int>,T>&e:G[u])
		{
			if(used[e.first.first]<dfstime&&e.second>0)
			{
				T d=dfs(e.first.first,t,min(f,e.second),dfstime);
				if(d>0)
				{
					e.second-=d;
					G[e.first.first][e.first.second].second+=d;
					return d;
				}
			}
		}
		return 0;
	}
	T max_flow(int s,int t)
	{
		T ret=0;
		for(int dfstime=1;;dfstime++)
		{
			T f=dfs(s,t,numeric_limits<T>::max(),dfstime);
			if(f>0)ret+=f;
			else break;
		}
		return ret;
	}
};
main()
{
	cin>>n;
	MF<long>mf(n+2);
	long ans=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]>=0)ans+=a[i],mf.add_edge(i+1,n+1,a[i]);
		else mf.add_edge(0,i+1,-a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i+i;j<=n;j+=i)mf.add_edge(i,j,numeric_limits<long>::max());
	}
	cout<<ans-mf.max_flow(0,n+1)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  char asd[60];
  for(int i= 0; i < N; i++){
    cin >> asd[i];
  }
  int ans = 0;
  for(int i= 0; i < N; i++){
   
    if(asd[i] == 'A' && asd[i+1] == 'B' && asd[i+2] == 'C'){
     ans++; 
       if(i+2 == N-1) break;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int n;
    cin>>n;

    n%=1000;
    if(n==0)n=1000;

    cout<<1000-n<<"\n";

    return 0;

}

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

#define int long long
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; }

const int MOD = 1e9+7;
int pow_mod(int n, int m){
	int ans = 1;
	while(m > 0){
		if(m & 1) ans = (ans * n) % MOD;
		n = (n * n) % MOD;
		m >>= 1;
	}
	return ans;
}

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

	int a = pow_mod(8, n);
	int b = (MOD + pow_mod(9, n) - a) % MOD * 2 % MOD;
	int ans = (MOD*2+pow_mod(10, n) - a - b) % MOD;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3588
h, w = gets.split.map(&:to_i)
grid = []
h.times do
  grid << gets.chomp.chars
end
memo = Array.new(h) { Array.new(w) }
h.times do |r|
  w.times do |c|
    next if memo[r][c] || grid[r][c] == "."
    visited_blacks = [[r, c]]
    visited_white_count = 0
    memo[r][c] = 0
    queue = [[r, c, true]]
    until queue.empty?
      current_r, current_c, approaching_white = queue.shift
      approaching = approaching_white ? "." : "#"

      if current_r > 0 && grid[current_r - 1][current_c] == approaching && !memo[current_r - 1][current_c]
        queue << [current_r - 1, current_c, !approaching_white]
        memo[current_r - 1][current_c] = 0
        if approaching_white
          visited_white_count += 1
        else
          visited_blacks << [current_r - 1, current_c]
        end
      end

      if current_r < h - 1 && grid[current_r + 1][current_c] == approaching && !memo[current_r + 1][current_c]
        queue << [current_r + 1, current_c, !approaching_white]
        memo[current_r + 1][current_c] = 0
        if approaching_white
          visited_white_count += 1
        else
          visited_blacks << [current_r + 1, current_c]
        end
      end

      if current_c > 0 && grid[current_r][current_c - 1] == approaching && !memo[current_r][current_c - 1]
        queue << [current_r, current_c - 1, !approaching_white]
        memo[current_r][current_c - 1] = 0
        if approaching_white
          visited_white_count += 1
        else
          visited_blacks << [current_r, current_c - 1]
        end
      end

      if current_c < w - 1 && grid[current_r][current_c + 1] == approaching && !memo[current_r][current_c + 1]
        queue << [current_r, current_c + 1, !approaching_white]
        memo[current_r][current_c + 1] = 0
        if approaching_white
          visited_white_count += 1
        else
          visited_blacks << [current_r, current_c + 1]
        end
      end
    end
    visited_blacks.each do |visited_r, visited_c|
      memo[visited_r][visited_c] = visited_white_count
    end
  end
end

puts memo.flatten.compact.inject(:+) || 0


Measured memory_bytes: 23488
import collections

N = int(input())
wordDict = {}
maxNum = 0
for i in range(N):
    word = input()
    if( word in wordDict ):
        wordDict[word] += 1
    else:
        wordDict[word] = 1
    
max_v = max(wordDict.values())
keys = [k for k, v in wordDict.items() if v == max_v]

keys.sort()

for word in keys:
    print(word)


Measured memory_bytes: 32480
#include<stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    long long int a[n];
    long long int sum = 0;
    for(int i=0; i<n; i++){
        scanf("%lld", &a[i]);
        sum += a[i];
    }
    long long int p = sum/2;
    long long int l = 0, r = sum;
    int x = -1;
    while(l < r){
        x++;
        l += a[x];
        r -= a[x];
    }
    long long int ans = 0;
    if(x == 0){
        ans = l-r;
    }else if(x == n-1){
        ans = a[x] - (l-a[x]);
    }else{
        long long int y = l-r, z = (r+a[x])-(l-a[x]);
        if(y < z){
            ans = y;
        }else{
            ans = z;
        }
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 1664
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }

alias Plan = Tuple!(int, "t", int, "x", int, "y");

bool calc(Plan[] plans) {
    int t = 0;
    int x = 0;
    int y = 0;

    foreach (p; plans) {
        int dt = p.t - t;
        int dx = abs(x - p.x);
        int dy = abs(y - p.y);

        if (dt < dx + dy) return false;
        if ((dt - (dx + dy)) % 2 != 0) return false;

        t = p.t;
        x = p.x;
        y = p.y;
    }
    return true;
}

void main() {
    int n = readint;
    Plan[] plans;
    for (int i = 0; i < n; i++) {
        auto txy = readints;
        plans ~= Plan(txy[0], txy[1], txy[2]);
    }

    writeln(calc(plans) ? "Yes" : "No");
}

Measured memory_bytes: 2428
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int n; ll z, w, a[2000];
LP memo[2000][2000][2];
bool used[2000][2000][2];
void init() {
	rep(i, 2000) {
		rep(j, 2000) {
			rep(k, 2) {
				used[i][j][k] = false;
			}
		}
	}
}
//x番目を見ていて、y番目が最後にとった位置、z番目の人の手番
LP dfs(int x,int y,int z) {
	if (used[x][y][z])return memo[x][y][z];
	LP res;
	if (z==0) {
		if (x == n - 1) {
			if (y > 0) {
				res = { a[x],a[y] };
			}
			else {
				res = { a[x],w };
			}
		}
		else {
			ll ma = 0;
			Rep(i, x, n - 1) {
				LP nex = dfs(i+1, i, 1);
				if (abs(nex.first - nex.second) > ma) {
					ma = abs(nex.first - nex.second);res = nex;
				}
			}
			if (y >= 0) {
				if (abs(a[n - 1] - a[y]) > ma) {
					res = { a[n - 1],a[y] };
				}
			}
			else {
				if (abs(a[n - 1] - w) > ma) {
					res = { a[n - 1],w };
				}
			}
		}
	}
	else {
		if (x == n - 1) {
			res = { a[y],a[x] };
		}
		else {
			ll mi = INF;
			Rep(i, x, n - 1) {
				LP nex = dfs(i + 1, i, 0);
				if (abs(nex.first - nex.second) < mi) {
					mi = abs(nex.first - nex.second); res = nex;
				}
			}
			if (abs(a[n - 1] - a[y]) < mi) {
				res = { a[y],a[n-1] };
			}
		}
	}
	memo[x][y][z] = res;
	used[x][y][z] = true;
	return res;
}
int main() {
	cin >> n;
	cin >> z >> w;
	rep(i, n) {
		cin >> a[i];
	}
	LP out = dfs(0, -1,0);
	cout << (ll)abs(out.first - out.second) << endl;
	return 0;
}

Measured memory_bytes: 131584
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a + n
#define prtarr(n,len) {for(int i=0;i<len;i++) cout<<n[i]<<" ";}
 
using namespace std;
 
typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;
using namespace std;
 
int n;
vll lists;
int main() {
    //freopen("input.txt", "r", stdin) ;
    //freopen("output.txt", "w", stdout) ;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    cin>>n;
    vll dp(n,0);
    ll sum=0;
    for(int i=0;i<n;i++){
        ll sub;
        cin>>sub;
        sum+=sub;
        lists.pb(sub);
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        if(i==0) dp[i]=sum;
        else dp[i]=(dp[i-1]-lists[i-1]);
    }
    for(int i=0;i<n-1;i++){
        ans+=((dp[i+1]%MOD)*lists[i])%MOD;
    }
    cout<<ans%MOD;
    return 0;
}

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

Measured memory_bytes: 3604
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top,S[1000];
void push(int x);
int pop(void);
int main(){
  int a,b;
  top=0;
  char s[100];
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }
    else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else{
      push(atoi(s));
    }
  }
  printf("%d\n",pop());
  return 0;
}

int pop(){
  top--;
  return S[top+1];
}

void push(int x){
  S[++top]=x;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MX = 1e10 + 10;;
unsigned long long fac[200001];

#include <math.h>
#define PI 3.14159265358979323846264338327950L

long long gcd(long long a, long long b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
long long lcm(long long a, long long b) {
    return (a * b) / gcd(a, b);
}
long long digits(long long m) {
    long long cnt = 0;
    while (m) {
        cnt++;
        m /= 10;
    }
    return cnt;
}

unsigned long long power(unsigned long long x, unsigned long long y){
    unsigned long long res = 1;
    x = x % MOD;

    while (y > 0) {
        // If y is odd, multiply x with result 
        if (y & 1)
            res = (res * x) % MOD;

        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % MOD;
    }
    return res;
}
unsigned long long modInverse(unsigned long long n) {
    return power(n, MOD - 2);
}

long long mxN = 2e5+1;
long long nCr(long long n, long long r) {
    if (r > n) return 0;
    return (fac[n] * modInverse(fac[r]) % MOD * modInverse(fac[n - r]) % MOD) % MOD;
}
int main() {
    memset(fac, 0, sizeof(fac));
    long long n, k;
    cin >> n >> k;
    fac[0] = 1;
    for (int i = 1; i < mxN; i++)
        fac[i] = (fac[i - 1] * i) % MOD;

    long long r = n - k;
    long long b = k;

    for (long long i = 1; i < k + 1; i++) {
        long long x = nCr(r + 1ll, i);
        long long y = nCr(b - 1ll, i - 1ll);
        long long ans = x * y; ans %= MOD;
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 5164
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
int main(){
    int n;
    while(cin >> n){
        if(n == 0) break;
        vector<pair<double,string> > vec;
        rep(j,n){
            string name;
            int price,A,B,C,to_flower,E,num,sell,flag;
            cin >> name >> price >> A >> B >> C >> to_flower >> E >> num >> sell >> flag;
            double sum_time = A+B+C+(to_flower+E)*flag;
            double income = num*sell*flag - price;
            double efficiency = income/sum_time;
            vec.push_back(make_pair(-efficiency,name));
        }
        sort(vec.begin(),vec.end());
        rep(i,vec.size()){
            //cout << vec[i].first << " ";
            cout << vec[i].second << endl;
        }
        cout << '#' << endl;
    }
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

#define INF 1e15

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vll a(n);
    rep(i,n) cin>>a[i];
    vector<vll> dp(n+1,vll(3,-INF));
    dp[0][1] = 0;
    dp[1][1] = 0, dp[1][2] = a[0];
    FOR(i,2,n)rep(j,3){
        int k = i/2+j-1;
        int j1 = k-(i-1)/2+1;
        int j2 = k-(i-2)/2;
        if (i&1 || j<2) dp[i][j] = max(dp[i-1][j1], dp[i-2][j2]+a[i-1]);
    }
    cout<<dp[n][1]<<"\n";
    return 0;
}


Measured memory_bytes: 15848
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
int main() {
	int a, b; std::cin >> a >> b;
	for (auto i = 1; i <= 11000; ++i) {
		const auto e = i * 8 / 100;
		const auto t = i / 10;
		if (a == e && b == t) {
			std::cout << i << '\n';
			return 0;
		}
	}
	std::cout << "-1\n";
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int h,w;
	int loop_h,loop_w;
	char str='\0';

	while(1) {
		scanf("%d %d",&h,&w);
		if ((h==0)&&(w==0)) {
			return 0;
		}

		for (loop_h=0 ; loop_h<h ; loop_h++) {
			if ((loop_h%2)==0) {
				str = '#';
			}
			else {
				str = '.';
			}
			for (loop_w=0 ; loop_w<w ; loop_w++) {
				printf("%c",str);
				if (str == '#') {
					str = '.';
				}
				else {
					str = '#';
				}
			}
			printf("\n");
		}
		printf("\n");
	}
}

Measured memory_bytes: 572
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc179
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int ans = 0;
            for (int A = 1; A <= N - 1; A++)
            {
                for (int B = 1; B <= ((N - 1) / A); B++)
                {
                    if (A * B < N)
                    {
                        ans++;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 27440
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

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

    int len = s.length();
    int ccnt = 0;
    int ucnt = 0;

    for (size_t i = 2; i < len - 1; i++)
    {
        char ch = s[i];
        if (ch == 'C')
        {
            ccnt++;
        }
    }

    for (size_t i = 0; i < len; i++)
    {
        char ch = s[i];
        if ('A' <= ch && ch <= 'Z')
        {
            ucnt++;
        }
    }

    string ans = "";
    if (s[0] == 'A' && ccnt == 1 && ucnt == 2)
    {
        ans = "AC";
    }
    else
    {
        ans = "WA";
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a,b) cout << (a) << " " << (b) << endl
#define rt0 return 0;
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{

    ll n;
    cin >>n;
    vll a(n);
    rep(i, n) cin >>a[i];
    ll r = INF;
    ll cnt = 0;
    
    rep(i, n) {
        if (a[i] < r) cnt++;
        r = min (r, a[i]);
    }
   mes(cnt);
}


Measured memory_bytes: 4832
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()


int main() {
	ll x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	ll x3, y3, x4, y4;
	x3 = x2 - (y2 - y1);
	y3 = y2 + (x2 - x1);
	x4 = x3 - (y3 - y2);
	y4 = y3 + (x3 - x2);

	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


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

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e933
#define INFL 1e18
#define MOD 1e9+7
#define pb push_back
#define MP make_pair
typedef long long ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main() {
    int n,W;cin>>n>>W;
    vector<int> v(n),w(n);
    vector<vector<int>> dp(n+1,vector<int>(W+1,0));
    
    rep(i,0,n)cin>>v[i]>>w[i];
    
    rep(i,0,n){
        rep(j,0,W+1){
            if(j<w[i])dp[i+1][j]=dp[i][j];
            else dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
        }
    }
    cout<<dp[n][W]<<endl;
    return 0;
}



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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2097162
#define inf 1e9
#define MOD 1000000007

int main()
{

    ll n;
    cin >> n;
    ll ans = 0;
    vector<ll> v1,v2;
    for(ll i = 0; i < n+1; i++)
    {

        ll x;
        cin >> x;
        v1.pb(x);
    }
    for(ll i = 0; i < n; i++)
    {

        ll x;
        cin >> x;
        v2.pb(x);
    }
    for(ll i = 0; i < v2.size(); i++)
    {

        ll mn = min(v2[i], v1[i]);
        v1[i]-=mn;
        v2[i]-=mn;
        ans+=mn;
        mn=min(v2[i],v1[i+1]);
        v2[i]-=mn;
        v1[i+1]-=mn;
        ans+=mn;
    }
    cout << ans;
}


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

if a <= 0 and b >= 0:
    print("Zero")
else:
    if a > 0 and b > 0:
        print("Positive")
    else:
        c = abs(b - a + 1)
        
        if c % 2 == 0:
            print("Positive")
        else:
            print("Negative")
     

Measured memory_bytes: 3064
n = int(input())
s = input()
a = [0]*26
al = 'abcdefghijklmnopqrstuvwxyz'
for i in range(n):
  a[al.index(s[i])] += 1
b = [0]*26
res = 0
for i in range(n):
  b[al.index(s[i])] += 1
  tmp = 0
  for j in range(26):
    if b[j] >= 1 and a[j] - b[j] >= 1:
      tmp += 1
  res = max(res, tmp)
print(res)

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

typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
const double pi = 3.141592653589793238;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

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


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

  int64_t sum = 0;
  for(int i = 1; i <= N; i++) {
    if(i % 3 == 0 || i % 5 == 0) continue;
    sum += i;
  }

  cout << sum << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;

void solve()
{
    ll n;
    cin >> n;
    ll a[n],b[n],c;
    for(ll i=0;i<n;i++)
    cin >> a[i] >> b[i];

    for(ll i=2;i<n;i++)
    {
        c=0;
        if(a[i]==b[i] && a[i-1]==b[i-1] && a[i-2]==b[i-2])c++;
        if(c)
        {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

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

    return 0;
}


Measured memory_bytes: 3500
#include <iostream>
#include <vector>
#include <algorithm>

typedef long long ll;

template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }

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

  ll N, M;
  std::cin >> N >> M;
  std::vector< ll > vx(M, 0LL);
  for (ll i = 0; i < M; i++) {
    std::cin >> vx[i];
  }
  std::sort(vx.begin(), vx.end());

  std::vector< ll > vl(M-1, 0LL);
  for (ll i = 0; i < M-1; i++) {
    vl[i] = vx[i+1] - vx[i];
  }
  std::sort(vl.begin(), vl.end());

  ll sum = 0;
  for (ll i = 0; i < M - N; i++) {
    sum += vl[i];
  }

  print(sum);
  return 0;
}


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

int main() {
    vector<vector<int>> A(3, vector<int>(3));
    vector<vector<bool>> X(3, vector<bool>(3, false));

    REP(i, 0, 3){
            cin>>A[i][0]>>A[i][1]>>A[i][2];
    }
    int N,b;
    cin>>N;

    REP(k, 0, N){
        cin>>b;
        REP(i, 0, 3){
            REP(j, 0, 3){
                if(A[i][j]==b){
                    X[i][j]=true;
                }
            }    
        }    
    }
    REP(i, 0, 3){
        if(X[i][0] && X[i][1] && X[i][2]){
            cout<<"Yes"<<endl;
            return 0;
        }
        
        if(X[0][i] && X[1][i] && X[2][i]){
            cout<<"Yes"<<endl;
            return 0;
        }

        if(X[0][0] && X[1][1] && X[2][2]){
            cout<<"Yes"<<endl;
            return 0;
        }

        if(X[0][2] && X[1][1] && X[2][0]){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
n, k, q = [int(x) for x in input().split()]
scores = {i: 0 for i in range(n)}

for i in range(q):
  a = int(input())
  scores[a-1] += 1

for score in scores.values():
  if k - q + score > 0:
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 15084
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main()
{
    int A,P;
    scanf("%d%d", &A, &P);
    int pie;
    pie = (3*A+P)/2;
    cout << pie <<endl;


    return 0;
}


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

using namespace std;
int main() {
  int n,k;
  cin >> n >> k;
  char c[n];

  for(int i = 0; i < n; i++){
    cin >> c[i];
  }
  
  for(int i = 0; i < n; i++){
    if(i == k-1){
      cout << (char)(c[i]+32);
      continue;
    }
    cout << c[i];
  }
  cout << endl;
}

  



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

int main() {
  int N;
  cin >> N;
  vector<int> cnt(N);

  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    while (A % 2 == 0) {
      A /= 2;
      cnt.at(i)++;
    }
  }
  auto minmax = std::minmax_element(cnt.begin(), cnt.end());
  cout << *minmax.first << endl;
}

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

int main() {
    int N,A,B;
    cin >> N >> A >> B;

    if (N*A < B){
        cout << N*A << endl;
    }else if (N*A < B){
        cout << B << endl;
    }else{
        cout << B << endl;
    }
        
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.Array
import Data.Array.ST
import Data.List
import qualified Data.Map as M
import qualified Data.Set as S
import Text.Printf

readInts :: IO [Int]
readInts = map read . words <$> getLine

main :: IO ()
main = do
  [n,m] <- readInts
  ass <- replicateM n readInts
  bs <- replicateM m readLn
  forM_ (solve ass bs) $ \c -> do
    print c

solve :: [[Int]] -> [Int] -> [Int] 
solve ass bs = map (sum . zipWith (*) bs) ass



Measured memory_bytes: 7544
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	string s;cin>>s;
	if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 256
n = int(input())

S = [i for i in range(1, 14)]
H = [i for i in range(1, 14)]
C = [i for i in range(1, 14)]
D = [i for i in range(1, 14)]

for i in range(n) :
    m, r=map(str, input().split())
    
    if m=="S":
        S.remove(int(r))
    elif m=="H":
        H.remove(int(r))
    elif m=="C":
        C.remove(int(r))
    else:
        D.remove(int(r))
        
if len(S)>0:
    for i in range(len(S)) :
        print("S",S[i])
if len(H)>0:
    for i in range(len(H)) :
        print("H",H[i])
if len(C)>0:
    for i in range(len(C)) :
        print("C",C[i])
if len(D)>0:
    for i in range(len(D)) :
        print("D",D[i])


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  int n;cin>>n;
  string a[n];
  for(int i=0;i<n;i++)
  {
    string s;cin>>s;a[i]=s;
  }
  sort(a,a+n);
  int c=1;
  for(int i=0;i<n-1;i++)
  {
    if(a[i]!=a[i+1]) c++;
  }
 // if(a[n-2]!=a[n-1]) c++;
  cout<<c;
}
  

Measured memory_bytes: 9920
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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


int main() {
    int n;
    cin>>n;
    int a[n];
    int v[n];
    REP(i,n) {
        cin >> a[i];
        v[i]=a[i]-i;
    }
    sort(v,v+n);

    int med = v[n/2];

    llong cry=0;

    REP(i,n) cry+=abs(v[i]-med);
    cout<<cry<<endl;

}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>

using namespace std;


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

	int d = 0;
	int count = 1;
	for (int i = 0; i < N; i++) {
		int L; cin >> L;
		d += L;
		if (d <= X) {
			count++;
		}
	}

	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

const int N=105;

int n,m,x,y,L[N][N],R[N][N];
char a[N][N];

short f[N][N][N][N],ans;

inline void fix(short &x,short y){
  if(x<y) x=y;
}

int main(){
  scanf("%d%d",&n,&m);
  for(int i=1;i<=n;i++){
    scanf("%s",a[i]+1);
    for(int j=1;j<=m;j++){
      if(a[i][j]=='E') x=i,y=j;
      L[i][j]=L[i][j-1]+(a[i][j]=='o');
      R[i][j]=R[i-1][j]+(a[i][j]=='o');
    }
  }
  memset(f,-0x7f,sizeof(f)); f[0][0][0][0]=0;
  for(int u=0;x-u>0;u++)
    for(int d=0;x+d<=n;d++)
      for(int l=0;y-l>0;l++)
	for(int r=0;y+r<=m;r++){
	  if(f[u][d][l][r]<0) continue;
	  short cur=f[u][d][l][r]; ans=max(ans,cur);
	  if(x-d>u+1 && x-u-1>0)
	    fix(f[u+1][d][l][r],cur+L[x-u-1][min(y+r,m-l)]-L[x-u-1][max(y-l-1,r)]);
	  if(x+u+d<n && x+d+1<=n)
	    fix(f[u][d+1][l][r],cur+L[x+d+1][min(y+r,m-l)]-L[x+d+1][max(y-l-1,r)]);
	  if(y+l+r<m && y+r+1<=m)
	    fix(f[u][d][l][r+1],cur+R[min(x+d,n-u)][y+r+1]-R[max(x-u-1,d)][y+r+1]);
	  if(y-r>l+1 && y-l-1>0)
	    fix(f[u][d][l+1][r],cur+R[min(x+d,n-u)][y-l-1]-R[max(x-u-1,d)][y-l-1]);
	}
  printf("%d\n",(int)ans);
  return 0;
}


Measured memory_bytes: 237696
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    cout << (N - 1) / 2 << endl;

    return 0;
}


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

int main(){

    string s;
    cin >> s;

    rep(i,3){
        if(s[i]==s[i+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }

    cout << "Good" << endl;


    return 0;
}

Measured memory_bytes: 256
//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ ) 
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
//#define inf 1LL<<62
typedef long long ll;
typedef double ld;
using namespace std;
const ll inf=1e9;
const ll MOD=1e9+7;
// ac cmtr;
const ll MAX_N = 1e5;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif
//---------------------------

ll dp[100005];

int main(){
    fastio;
    ll n,k;
    cin>>n>>k;
    vector <ll> v;
    f(i,0,n){
        ll num;
        cin>>num;
        v.pb(num);
    }
    dp[0]=0;
    f(i,1,n+1){
        dp[i]=inf;
    }
    f(i,1,k){
        for(int j=1;j<=i;j++){
            dp[i]=min(dp[i],dp[i-j]+abs(v[i]-v[i-j]));
        }
    }

    f(i,k,n){
        f(j,1,k+1){
            dp[i]=min(dp[i],dp[i-j]+abs(v[i]-v[i-j]));
        }
        
    }
    cout<<dp[n-1]<<endl;





    return 0;
}   



Measured memory_bytes: 1908
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main( )
{
    int cnt=0;
   int n,x;
   cin>>n;
   for(int i=1;i<=n;i++)
   {
       cin>>x;
       if(i%2==1 && x%2==1) ++cnt;
   }
   cout<<cnt<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
int main(void) {
    set<pair<int, int>> st,checked;
    ll h,w,n;
    cin>>h>>w>>n;
    rep(i,n){
        int a,b;cin>>a>>b;
        a--;b--;
        st.emplace(a,b);
    }
    vector<ll> count(10,0);
    function<int(int,int)> check = [&](int x,int y){
        if(x<2||y<2||x>=h||y>=w){return -1;}
        int cnt = 0;
        repr(i,-2,1){
            repr(j,-2,1){
                if(st.find(pair<int, int>(x+i,y+j))!=st.end()){
                    cnt++;
                }
            }
        }
        DEBUG{
            printf("cnt: %d\n",cnt);;
        }
        return cnt;
    };
    for(auto x:st){
        repr(i,-2,3){
            repr(j,-2,3){
                if(checked.find(pair<int, int>(x.first+i,x.second+j))==checked.end()){
                    int tmp = check(x.first+i,x.second+j);
                    if(tmp!=-1){
                        count[tmp]++;
                    }
                    checked.emplace(x.first+i,x.second+j);
                }
            }
        }
    }
    ll res0 = (h-2)*(w-2);
    repr(i,1,10){
        res0 -= count[i];
    }
    cout << res0 << endl;
    repr(i,1,10){
        cout << count[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 122112
import bisect

x = int(input())


def expo(n):
    expo_l = [1]
    for i in range(2, 101):
        j = 2
        while i ** j <= 1000:
            expo_l.append(i ** j)
            j += 1
    return expo_l


dic = expo(x)
dic = sorted(list(set(dic)))
index = bisect.bisect_right(dic, x)
print(dic[index - 1])


Measured memory_bytes: 3188