akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef unordered_map<ll, ll> ump;

const ll mod = 1e9+7;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<ll> a(n);
	REP(i, n){cin >> a[i];}
	sort(a.begin(), a.end(), greater<int>());
	ll sum_a = 0;
	ll sum_b = 0;
	REP(i, n){
		if (i%2==0){sum_a += a[i];}
		else {sum_b += a[i];}
	}
	cout << sum_a - sum_b << endl;
}


Measured memory_bytes: 256
import sys
def input():
	return sys.stdin.readline().strip()

S = input()
target = 'keyence'

if S[0] != target[0]:
	if S[-7:] == target:
		print("YES")
	else:
		print("NO")
elif S[-1] != target[-1]:
	if S[0:7] == target:
		print("YES")
	else:
		print("NO")
else:
	num = 0
	i = 0
	while i < 7 and S[i] == target[i]:
		num += 1
		i += 1
	i = 0
	while i < 7 and S[-i-1] == target[-i-1]:
		num += 1
		i += 1
	if num >= 7:
		print("YES")
	else:
		print("NO")


Measured memory_bytes: 38384
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let S = rl();

    let mut red = 0;
    let mut blue = 0;
    for c in S.chars() {
        if c == '0' {
            red += 1;
        } else {
            blue += 1;
        }
    }

    println!("{}", min(red, blue) * 2);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define p pair<ll,ll>
#define pb push_back
#define mp make_pair
#define PI 3.14159265359

using namespace std;

int main(){

    string s;
    cin >> s;
    ll ans = 0;
    for(int i = 0; i < s.size() / 2;i++){
        if(s[i] != s[s.size() - 1 - i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    vector<int> A(N+1);
    vector<int> B(N+1);
    vector<int> C(N);
    rep(i,N+1){
        if(i == 0)continue;
        cin >> A[i];
    }
    rep(i,N+1){
        if(i == 0)continue;
        cin >> B[i];
    }    
    rep(i,N){
        if(i == 0)continue;
        cin >> C[i];
    }
    int ans = 0;
    int tmp = -1;

    rep(i,N+1){
        if(i == 0)continue;
        ans += B[A[i]];
        if(A[i] == tmp + 1){
            ans += C[tmp];
        }
        if(i != N)tmp = A[i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
N = int (input())
T,A = map(int,input().split())
H = list(map(int,input().split()))

ans = 999999999999999999999

for i in range(N):
    Average = T - H[i] * 0.006
    d = abs(A - Average)
    if d < ans:
        ans = d
        num = i + 1
print(num)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int k,a,b;

int main(){
  cin>>k>>a>>b;
  if(b<=a){
    cout << (k+1) << endl;
    return 0;
  }
  ll ans = k+1;
  ll n = 1;
  while(k>0 && n<a){
    k--; n++;
  }
  while(k>=2){
    k--; n -= a;
    k--; n += b;
  }
  while(k>0){
    k--; n++;
  }
  cout << max(ans,n) << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,Z,W = inpl()
aa = inpl()

if N == 1:
    print(abs(aa[0]-W))
else:
    print(max(abs(aa[-2]-aa[-1]),abs(aa[-1]-W)))


Measured memory_bytes: 4212
#include <bits/stdc++.h>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define int long long int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
 
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
 
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int mod = 1e9 + 7;

void solve() {
    int h, w;
    cin >> h >> w;
    char grid[h][w];
    for (int i = 0; i < h; i++) {
    	for (int j = 0; j < w; j++) {
    		cin >> grid[i][j];
    	}
    }
    int dp[h+1][w+1];
    memset(dp, 0, sizeof(dp));
    dp[1][1] = 1;
    for (int i = 1; i <= h; i++) {
    	for (int j = 1; j <= w; j++) {
    		if (i == 1 && j == 1)
    			continue;
    		if (grid[i-1][j-1] == '.')
    			dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
    	}
    }
    // for (int i = 1; i <= h; i++) {
    // 	for (int j = 1; j <= w; j++)
    // 		cout << dp[i][j] << " ";
    // 	cout << endl;
    // }
    cout << dp[h][w];
}
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	
	return 0;
}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll W, H, x, y; cin >> W >> H >> x >> y;
  if (2 * x == W && 2 * y == H) {
    cout << (double)W * H / 2.0 << " " << 1 << endl;
  }else {
    cout << (double)W * H / 2.0 << " " << 0 << endl;
  }

  return 0;
}



Measured memory_bytes: 3788
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	vector<pii > vp(n);
	REP(i,n){
		int x,l;
		cin>>x>>l;
		
		int a=x-l,b=x+l;
		vp[i]=pii(b,a);
	}
	sort(ALL(vp));
	
	int cnt=0;
	int tmp=-INF;
	REP(i,n){
		if(tmp<=vp[i].second){
			cnt++;
			tmp=vp[i].first;
		}
	}
	
	cout<<cnt<<endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

int main(){
  int h,w;
  cin>>h>>w;
  vector<string> vec(h);
  rep(i,h){
    cin>>vec[i];
  }

  rep(i,h){
    cout<<vec[i]<<endl<<vec[i]<<endl;
  }

  return 0;
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int lastmons = 1000000000;
		int monster[] = new int[n];
		for(int i=0;i<n;i++) {
			monster[i] = sc.nextInt();
		}
		/*
		for(int i=0;i<n-1;i++) {
			for(int j=i+1;j<n;j++) {
				int ans = euclide(monster[i], monster[j]);
				lastmons = Math.min(ans, lastmons);
			}
		}
		*/
		
		for(int i=0;i<n-1;i++) {
			int ans = euclide(monster[i], monster[i+1]);
			monster[i+1] = ans;
		}
		
		sc.close();
		System.out.println(monster[n-1]);
		
		
	}
	
	
	public static int euclide(int a, int b) {

		while(true) {
			if(a==b) {
				return a;
			}
			if(a>b) {
				a %= b;
				if(a==0) return b;
			}else {
				b %= a;
				if(b==0) return a;
			}
		}
	}

}


Measured memory_bytes: 50884
#include<iostream>
#include <string>
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#define ll long long int
#define ld long double
#define pb push_back
#define endl "\n"
#define mp make_pair
#define sz(v) (int)(v.size())
#define len(s) (int)(s.length())
#define M 1000000007
#define all(v) v.begin(),v.end()
#define fr(a,b,c) for(ll i=a;i<=b;i+=c)
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll inf = 9e18;
const ld pi = 2*acos(0.0); 
using namespace std;
ll power(ll a,ll n) 
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
const int N=1e6;
vector <ll> sieve(N,0); 
void si() 
{
    sieve[1]=1;
    for(int i=2;i<N;i++){
        if(sieve[i]==0){
            for(int j=i;j<N;j+=i){
                sieve[j]=i;
            }
        }
    }
}
int main(){
    ios;
    ll n,x,t;
    cin>>n>>x>>t;
    ll mul;
    if(n%x==0){
        mul=n/x;
    }
    else{
        mul=n/x+1;
    }
    cout<<mul*t<<endl;
    return 0;
}

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

/*int n;
  cin >> n;
  vector<int> h(n);*/

int main() {

    string s;
    int n;

    cin >> n >> s;

    for(int i=0;i<s.length();i++){
        for(char str='A';str<='Z';str++){
            int count=0;
            if(s[i] == str){
                if(str+n > 'Z'){
                    for(char st=str;st<='Z';st++){
                        str='A';
                        count++;
                    }
                }
                s[i] = str+(n-count);
                
                break;
            }
        }
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
def solve():
    x = int(input())

    min_ = x // 105
    max_ = x // 100

    for c in range(max_, max_ + 1):
        if 100 * c <= x <= 105 * c:
            return 1
    return 0


print(solve())

# 品物の個数 C が決まっていると、合計価格としてありうるものは 「100 × C 円以上 105 × C 円以下」 す
# べてになります。ですので、判定が簡単です。
# C = 1, 2, 3, …, X すべてに対して判定して、この中に 「ちょうど X 円の買い物をすることは可能」 と判定
# されたものがひとつでもあれば X 円の買い物ができ (その場合の答えは 「1」)、ひとつもなければどうやっ
# ても X 円の買い物ができません (その場合の答えは 「0」)。

# 範囲がすべて達成可能という考え方は、
# agc017bでも使ったが、意識できていない


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <deque>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0;i<N;++i) {
        cin >> A[i];
    }

    vector<int> S = A;
    sort(S.begin(), S.end());

    for (auto a : A) {
        if (a == S.back()) {
            cout << S[N-2] << endl;
        } else {
            cout << S.back() << endl;
        }
    }
}


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

int main() {
  int n,m;
  cin>>n>>m;
  char a[n][n],b[m][m];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
    char c;
    cin>>c;
    a[i][j]=c;
    }
  }
   for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
    char c;
    cin>>c;
    b[i][j]=c;
    }
  }
  bool ans;
  for(int i=0;i<n-m+1;i++){
    for(int j=0;j<n-m+1;j++){
      ans=true;
      for(int k=0;k<m;k++){
        for(int l=0;l<m;l++){
          if(a[i+k][j+l]!=b[k][l])ans=false;
        }
      }
      if(ans)break;
    }
    if(ans)break;
  }
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  if (a >= k)
    cout << k << endl;
  else if (a+b >= k)
    cout << a << endl;
  else
    cout << (a-(k-a-b)) << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <set>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <deque>
#include <memory.h>
#include <assert.h>
#include <cstring>
#include <cmath>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef double ld;
typedef pair<ll, ll> pll;

int main() {

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

	//ifstream cin("input.txt");
    //ofstream cout("output.txt");
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

	int n, k;
	cin >> n >> k;

	vector<int> cnt(n + 1);
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		++cnt[x];
	}

	vector<pii> v;
	for (int i = 1; i <= n; ++i) {
		if (cnt[i]) {
			v.pb({cnt[i], i});
		}
	}
	sort(all(v));
	if (sz(v) <= k) {
		cout << "0\n";
		return 0;
	}

	int ans = 0;
	for (int i = 0; i < sz(v) - k; ++i) {
		ans += v[i].first;
	}

	cout << ans << "\n";

}


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

dp=[[0]*n for _ in range(2)]

a=list(map(int,input().split()))
b=list(map(int,input().split()))

dp[0][0]=a[0]
dp[1][0]=a[0]+b[0]
for i in range(n-1):
    dp[0][i+1]=dp[0][i]+a[i+1]

for i in range(n-1):
    dp[1][i+1]=max(dp[0][i+1],dp[1][i])+b[i+1]
    
print(dp[1][n-1])


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

long long H, W;

int main()
{
	cin>>H>>W;
	if(H==1 || W==1) cout<<1<<endl;
	else if(H*W%2==1) cout<<H*W/2+1<<endl;
	else cout<<H*W/2<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#define H 500000

void maxHeapify(int *,int);
void buildMaxHeap(int *);

int A[H],n;

int main()
{
	int k,p,l,r,i;
	
	scanf("%d",&n);
	
	for(i=1;i<=n;i++){
		scanf("%d",&A[i]);
	}
	
	buildMaxHeap(A);
	
	for(i=1;i<=n;i++){
		printf(" %d",A[i]);
	}
	printf("\n");
	
	return 0;
}

void maxHeapify(int *A,int i)
{
	int l,r,largest,temp;
	
	l = 2*i;
	r = (2*i)+1;
	// 左の子、自分、右の子で値が最大のノードを選ぶ
	if(l <= n && A[l] > A[i]){
		largest = l;
	}
	else{
		largest = i;
	}
	
	if(r <= n && A[r] > A[largest]){
		largest = r;
	}
	
	if(largest != i){// i の子の方が値が大きい場合
		temp = A[i];
		A[i] = A[largest];
		A[largest] = temp;
		maxHeapify(A, largest); // 再帰的に呼び出し
	}
}

void buildMaxHeap(int *A)
{
	int i;
	
	for(i=n/2;i>0;i--){
		maxHeapify(A,i);
	}
}

Measured memory_bytes: 2552
#include <iostream>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
int main(){
    ll i,n,k,ans = 0;
    cin >> n >> k;
    for(i=k;i<=n + 1;i++){
        (ans += (n - i + 1)*i%mod + 1) %= mod;
    }
    cout << ans << endl;
}

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



signed main(){
    string s;
    cin >>s;
    int t=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='0')t++;
        else t--;
    }
    cout << s.length()-abs(t);
    return 0;
}

Measured memory_bytes: 512
import std.stdio;
import std.string;
import std.format;
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.concurrency;
import std.traits;
import std.uni;
import std.regex;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;

void main() {
  long N;
  scanln(N);
  long ans = 0;
  foreach(i; 1..N+1) {
    if (i%3!=0 && i%5!=0) ans += i;
  }
  ans.writeln;
}

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


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep);

  string line = readln.chomp;
  static if (__VERSION__ >= 2074) {
    line.formattedRead!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "line.formattedRead(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 2868
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>

using namespace std;

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

  cin >> a >> b >> c >> k;

  for (int i = 0; i < k; i++) {
    if (b <= a) {
      b *= 2;
    } else {
      c *= 2;
    }
  }

  if (a < b && b < c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3128
#include<cstdio>
#define ll long long
#define mod 1000000007
#define N 110000
int a[N],num[N],col[N],mrk[N],cnt[N],n,lng[N];
bool cir[N];
ll dp[N];
int main()
{
	scanf("%d", &n);
	ll ans=1;
	for (int i=1;i<=n;++i)
	{
		scanf("%d", &a[i]);
		++num[a[i]];
	}
	for (int i = 1; i <= n; i++)
	{
		if (col[i])
			continue;
		int x = i;
		for (; !col[x]; x = a[x])
			col[x] = i;
		if (col[x] != i)
			continue;
		for (;!cir[x];x=a[x])
			cir[x]=1;
	}
	for (int i = 1; i <= n; i++)
		if ((cir[i]&&num[i]>2)||(!cir[i]&&num[i]>1)) {printf("0");return 0;}
	for (int i=1;i<=n;++i){
		if (num[i]) continue;int x=i,tmp=0;
		while(!cir[x]) x=a[x],tmp++;lng[x]=tmp;
	}
	for (int i=1;i<=n;++i){
		if (!cir[i]) continue;int x=i,st=0,first=0,id=0,len=0;
		while (cir[x]){
			++id;cir[x]=0;
			if (lng[x]){
				if (!first){
					st=first=id;len=lng[x];x=a[x];continue;
				}else{
					int numm=(lng[x]<(id-st))+(lng[x]<=(id-st));
					(ans*=numm)%=mod;if (!ans) {printf("0");return 0;}st=id;x=a[x];continue;
				}
			}x=a[x];
		}if (first){
			int numm=(len<(id+first-st))+(len<=(id+first-st));
			(ans*=numm)%=mod;if (!ans) {printf("0");return 0;}
		}else cnt[id]++;
	}
	for (int i=1;i<=n;++i){
		dp[0]=1;if (!cnt[i]) continue;
		if (i>1&&(i%2)){
			for (int j=1;j<=cnt[i];++j) {
				dp[j]=dp[j-1]*2%mod;if (j>1) (dp[j]+=dp[j-2]*(j-1)*i%mod)%=mod;
			}
		}else{
			for (int j=1;j<=cnt[i];++j){
				dp[j]=dp[j-1];if (j>1) (dp[j]+=dp[j-2]*(j-1)*i%mod)%=mod;
			}
		}
		(ans*=dp[cnt[i]])%=mod;if (!ans){printf("0");return 0;}
	}printf("%lld",ans);
	return 0;
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = __INT_MAX__;               // 2^31 - 1
const long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

struct mint {
    // Preparation: MOD is already defined.
    ll value;

    mint(ll value = 0) : value((value % MOD + MOD) % MOD) {}

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint pow(mint m) const {
        return pow(m.value);
    }

    mint inv() const {
        ll a = value, b = MOD, u = 1, v = 0;
        while (b) {
            ll t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        return u;
    }

    mint &operator+=(const mint a) {
        if ((value += a.value) >= MOD) value -= MOD;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((value += MOD - a.value) >= MOD) value -= MOD;
        return *this;
    }
    mint &operator*=(const mint a) {
        (value *= a.value) %= MOD;
        return *this;
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

mint dp[100005][2];
int main() {
    string l;
    cin >> l;

    dp[0][0] = 1;
    rep(i, l.size()) {
        int D = l[i] - '0';
        if (D == 0) {
            dp[i + 1][0] = dp[i][0];
            dp[i + 1][1] = dp[i][1] * 3;
        } else {
            dp[i + 1][0] = dp[i][0] * 2;
            dp[i + 1][1] = dp[i][1] * 3 + dp[i][0];
        }
    }

    mint ans = dp[l.size()][0] + dp[l.size()][1];
    out(ans.value);
}


Measured memory_bytes: 2048
import numpy as np
import itertools

def d(i,j):
    return np.sqrt((X[i]-X[j])**2 + (Y[i]-Y[j])**2)

N = int(input())
X = []
Y = []
for _ in range(N):
    x, y = [int(i) for i in input().split()]
    X.append(x)
    Y.append(y)

L = [int(i) for i in range(N)]

ways = list(itertools.permutations(L, N))
sum_l = []
for i in range(len(ways)):
    sum = 0
    for j in range(N-1):
        sum += d(ways[i][j], ways[i][j+1])
    sum_l.append(sum)

print(np.average(np.array(sum_l)))


Measured memory_bytes: 18884
ABCD=input()
A,B,C,D=int(ABCD[0]),int(ABCD[1]),int(ABCD[2]),int(ABCD[3])
a,b,c,d,e,f,g,h=A+B+C+D,A+B+C-D,A+B-C+D,A-B+C+D,A+B-C-D,A-B+C-D,A-B-C+D,A-B-C-D
if a==7:print(str(A)+"+"+str(B)+"+"+str(C)+"+"+str(D)+"=7")
elif b==7:print(str(A)+"+"+str(B)+"+"+str(C)+"-"+str(D)+"=7")
elif c==7:print(str(A)+"+"+str(B)+"-"+str(C)+"+"+str(D)+"=7")
elif d==7:print(str(A)+"-"+str(B)+"+"+str(C)+"+"+str(D)+"=7")
elif e==7:print(str(A)+"+"+str(B)+"-"+str(C)+"-"+str(D)+"=7")
elif f==7:print(str(A)+"-"+str(B)+"+"+str(C)+"-"+str(D)+"=7")
elif g==7:print(str(A)+"-"+str(B)+"-"+str(C)+"+"+str(D)+"=7")
else:print(str(A)+"-"+str(B)+"-"+str(C)+"-"+str(D)+"=7")

Measured memory_bytes: 3064
require 'mathn'
s = gets.chomp
if s =~ /(\d+)\.(\d*)\((\d+)\)/
    a, b, c = $1, $2, $3
    d = 10 ** (b.size + c.size) - 10 ** b.size
    n = (a + b + c).sub(/^0*/, '').to_i - (a + b).sub(/^0*/, '').to_i
    x = n / d
    puts [x.numerator, x.denominator] * ?/
else
    s =~ /(\d+)\.(\d+)/
    d = 10 ** $2.size
    n = ($1 + $2).sub(/^0*/, '').to_i
    x = n / d
    puts [x.numerator, x.denominator] * ?/
end


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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
#define cout(s) cout<<"s"<<endl;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
 
/*CODE START HERE*/
int main() {
  string s ;
  cin >> s;
  forn(i,s.size()){
    forr(j,i+1,s.size()){
      if (s.at(i)==s.at(j)){
        cout <<  "no" << endl;;
      return 0 ;
      }
    }
  }
  cout << "yes" << endl ;
}

Measured memory_bytes: 3576
n,m,q = [int(x) for x in input().split()]
li = []
for i in range(q):
    li.append([int(x) for x in input().split()])
import itertools
num = range(1,m+1)
v = list(itertools.combinations_with_replacement(num,n))
ans = 0
for i in v:
    su = 0
    for j in li:
        if i[j[1]-1]-i[j[0]-1]==j[2]:
            su+=j[3]
    ans = max(ans,su)
print(ans)

Measured memory_bytes: 84560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#define rep(i, a, b) for (int(i) = (a); i < (b); i++)
using namespace std;

using ll = long long;

typedef pair<int, int> P;

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

ll pow_mod(ll x, ll y, ll mod)
{
	if (y == 0)
		return 1;

	if (y == 1)
		return x % mod;

	return (pow_mod(x, y - 1, mod) * x) % mod;
}

int h,w;
string s[1005];
bool notbla[1005][1005]={false};
int d[1005][1005];
vector<P> black;
int ans;

void bfs(){
	queue<P> que;
	int si=black.size();
	rep(i,0,si)que.push(P(black[i].first,black[i].second));
	while(que.size()){
		P p=que.front();que.pop();
		rep(i,0,4){
			int nx=p.first+dx[i];
			int ny=p.second+dy[i];
			if(0<=nx&&nx<h&&0<=ny&&ny<w&&notbla[nx][ny]){
				que.push(P(nx,ny));
				d[nx][ny]=d[p.first][p.second]+1;
				notbla[nx][ny]=false;
			}
		}
	}
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
	cin>>h>>w;
	rep(i,0,h)cin>>s[i];
	rep(i,0,h){
		rep(j,0,w){
			if(s[i][j]=='#'){
				black.push_back(P(i,j));
				notbla[i][j]=false;
			}else{
				notbla[i][j]=true;
			}
		}
	}
	bfs();
	rep(i,0,h){
		rep(j,0,w)ans=max(ans,d[i][j]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 20200
import java.util.*;
public class Main {
  public static void main(String[] args){
    
	Scanner sc = new Scanner(System.in);
	
	int iLine = sc.nextInt();
	long iBase = (long)sc.nextInt();
    iBase = iBase * iBase;

	long iValue1 = 0;
	long iValue2 = 0;
	long iTotal = 0;
	int iLoop = 0;
	int iCount = 0;

	for( iLoop = 0; iLoop < iLine; iLoop++ ){
		iValue1 = (long)sc.nextInt();
		iValue2 = (long)sc.nextInt();

		iValue1 = (long)Math.pow(iValue1,2);
		iValue2 = (long)Math.pow(iValue2,2);
		iTotal = iValue1 + iValue2;
      
		if(iBase >= iTotal){
			iCount++;
		}
	}
    System.out.println(iCount);
  }
}

Measured memory_bytes: 60736
N,M=map(int,input().split())
H=list(map(int,input().split()))
AB=[]
Dict={}
for i in range(N):
    Dict[i+1]=H[i]
for i in range(M):
    AB.append(list(map(int,input().split())))
    
ng=set()
for i in AB:
    a,b=i[0],i[1]
    if Dict[a]<=Dict[b]:
        ng.add(a)
    if Dict[b]<=Dict[a]:
        ng.add(b)
print(len(set(Dict.keys())-ng))

Measured memory_bytes: 50752
#!/usr/bin/env python3
import sys
import collections as cl
import math

def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    A,B = MI()
    for i in range(11000):
        if math.floor( i * 0.08 ) == A and math.floor(i * 0.1) == B:
            print(i)
            exit()

    print(-1)


main()


Measured memory_bytes: 65984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 105;
int a[N];
int main() {
	int n; cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + 1 + n);
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		for(int j = i + 1; j <= n; j++) {
			for(int k = j + 1; k <= n; k++) {
				if(a[i] + a[j] > a[k] && a[i] != a[j] && a[j] != a[k]) {
					ans++;
				}
			}
		}
	}
	cout << ans << "\n";
	return 0; 
}

Measured memory_bytes: 3632
#include <iostream>

int wei(int v)
{
    int s=0;
    while(v)s+=v%10,v/=10;
    return s;
}
int main()
{
    int n,x,y,s=0;
    std::cin>>n>>x>>y;
    
    for(int i=1;i<=n;i++)
    {
        int gg=wei(i);
        if(gg>=x&&gg<=y)s+=i;
    }
    std::cout<<s<<std::endl;
}

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

int main() {
 int n;
  cin>>n;
 vector<int> l(n);
  rep(i,n) cin>>l[i];
  int a,b,c;
  int ans=0;
  sort(all(l));
   ///bool huka=false;
  rep(i,n-2){
    a=l[i];
    for(int j=i+1;j<n-1;j++){
      b=l[j];
      for(int k=j+1;k<n;k++){
        c=l[k];
        if(c<a+b) ans++;
        else break;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define REP(var,init,cnt) for(int (var)=(init); (var)<=(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) ((flag)?(int)1:(int)0)
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

constexpr int MOD=1e9+7;

int main(void){
  int a,b; cin>>a>>b;
  cout<<a-b+1;
}












Measured memory_bytes: 256
D,G=map(int,input().split())
p=[0];c=[0]
for i in range(1,D+1):
    pi,ci=map(int,input().split())
    p.append(pi);c.append(ci)

ans=sum(p)
for k in range(1<<D):
    s=[i for i in range(1,D+1) if k>>(i-1)&1]
    t=sorted([j for j in range(1,D+1) if j not in s],reverse=True)

    ac=sum([p[i] for i in s])
    score=sum([100*i*p[i]+c[i] for i in s])

    for j in t:
        if score>=G:
            break
        q=(G-score+(j-1)*100)//(j*100)
        if q>=p[j]:
            ac+=p[j]-1
            score+=(j*100)*(p[j]-1)
        else:
            ac+=q
            score+=(j*100)*q
    if score>=G:
        ans=min(ans,ac)

print(ans)

Measured memory_bytes: 44252
// 22
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fors(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fors(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define forrs(_, x, n, s) for (int _ = x; _ > n; _ -= s)
#define forrn(_, x, n) forrs(_, x, n, 1)
#define rrep(_, n) forrn(_, n - 1, -1)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12
void _main(int tc) {
  int n, k;
  cin >> n >> k;
  assert(n >= 2);
  vector<li> h(n);
  rep(i, n) cin >> h[i];
  vector<li> mem(n, -1);
  mem[n - 1] = 0;
  mem[n - 2] = abs(h[n - 2] - h[n - 1]);

  function<int(int)> fcost = [&](int i) -> int {
    if (mem[i] != -1) return mem[i];
    mem[i] = (1 << 30);
    forn(j, i + 1, (i + 1) + min(k, n - 1 - i)) {
      mem[i] = min(mem[i], abs(h[i] - h[j]) + fcost(j));
    }
    return mem[i];
  };
  cout << fcost(0) << endl;

  // rrep(i, n - 2) {
  //   mem[i] = (1 << 30);
  //   forn(j, i + 1, (i + 1) + min(k, n - 1 - i)) {
  //     mem[i] = min(mem[i], abs(h[i] - h[j]) + mem[j]);
  //   }
  // }
  // cout << mem[0] << endl;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0);
  return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 11264
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
int main(){
	int R,G;
	while(~scanf("%d%d",&R,&G)){
		printf("%d\n",2*G-R);
	}
}

Measured memory_bytes: 256
from functools import*
M=10**9+7
@lru_cache(None)
def f(s):
    if s<3:return 0
    c=1
    for i in range(s-2):
        c+=f(i)
    return(sum(map(f,range(s-2)))+1)%M
print(f(int(input())))

Measured memory_bytes: 9816
#include <iostream>
using namespace std; 
int main(void){

  long long n;
  cin >> n;
  long long tmp;
  for(long long  i=1; i * i <= n; i++){
    if (n % i == 0) tmp = i;
  }
  cout << tmp + n / tmp - 2 << endl;
  return 0;
}


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

int main() {
	int n;
	cin>>n;
	int a = 0;
	int _n = n;
	for(;_n>0;_n/=10) {
		a += _n%10;
	}
	cout << ((n%a==0)?"Yes":"No") << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n, k := scanInt(), scanInt()
	a := make([]int, n+1)
	for i := 1; i <= n; i++ {
		a[i] = scanInt()
	}

	ps := make([]int, n+1)
	for i := 2; i <= n; i++ {
		ps[i] = -1
	}

	ans := make([]int, n+1)
	ans[0] = 1

	var b, r int
	p := 1
	for i := 1; i <= n; i++ {
		p = a[p]
		if i == k {
			fmt.Println(p)
			return
		}

		if ps[p] != -1 {
			b = ps[p]
			r = i - b
			break
		}
		ps[p] = i
		ans[i] = p
	}

	k -= b
	k %= r
	fmt.Println(ans[b+k])
}


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

using namespace std;

int main()
{
    int t;

    cin >> t;
    while (t--) {
        int n, k;

        cin >> n >> k;
        vector<int> data(n -1);
        int a, b;

        cin >> a;
        for (int i = 0; i < n - 1; ++i) {
            cin >> b;
            data[i] = b - a;
            a = b;
        }

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

        int ans = 0;
        for (int i = 0; i < n - k; ++i)
            ans += data[i];

        cout << ans << endl;
    }

    return 0;
}

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

class Dice {
public:
	int t = 1, b = 6, n = 5, e = 3, s = 2, w = 4, tmp, sum = 1;
	void north() {
		tmp = t;
		t = s;
		s = b;
		b = n;
		n = tmp;
	}
	void east() {
		tmp = t;
		t = w;
		w = b;
		b = e;
		e = tmp;
	}
	void west() {
		tmp = t;
		t = e;
		e = b;
		b = w;
		w = tmp;
	}
	void south() {
		tmp = t;
		t = n;
		n = b;
		b = s;
		s = tmp;
	}
	void left() {
		tmp = s;
		s = w;
		w = n;
		n = e;
		e = tmp;
	}
	void right() {
		tmp = s;
		s = e;
		e = n;
		n = w;
		w = tmp;
	}
	void add() {
		sum += t;
	}

};

int main() {
	int i, j, n;
	char com[6];

	while (1) {
		cin >> n;
		if (n == 0)break;
		Dice d;
		for (i = 0; i < n; i++) {
			cin >> com;
			switch (com[0]) {
			case 'N':
				d.north();
				break;
			case 'E':
				d.east();
				break;
			case 'S':
				d.south();
				break;
			case 'W' :
				d.west();
				break;
			case 'R':
				d.right();
				break;
			case 'L':
				d.left();
				break;
			}
			d.add();
		}
		cout << d.sum << endl;
	}



	return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
#define fori(i,s,n) for(ll i=s;i<=n;i++)
#define ford(j,s,n) for(ll i=n;i>=s;i--)
#define pb push_back
#define TEST int t; cin>>t; for(int T=1;T<=t;T++)
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s.back()!='s'){
        s.pb('s');   
    }
    else {
        s+="es";
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 3648
N = int(input())
A =[int(i) for i in input().split()]
ans = "APPROVED"
for i in range(N):
    if A[i] % 2 == 0:
        if A[i] % 3 != 0 and A[i] % 5 != 0:
            ans = "DENIED"
            print(ans)
            exit()
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
	#include <iostream>
	#include <string>
	#include <math.h>
	#include <vector>
	#include <signal.h> 
	#include <locale> 

#define fo(i,n) for(long long int i=0;i<n;i++)
#define fo1(i, n) for (long long int i = 1; i <= (long long int)(n); i++)
#define pb push_back
#define fill_vector(n,v) for(long long int i=0;i<n;i++){double temp;cin>>temp;v.push_back(temp); }
#define print_vector(n,v) for(long long int i=0;i<n;i++){cout<<v[i]<<"\n"; } 
#define sortv(v) sort(v.begin(), v.end())
#define sortvo(v) sort(v.begin(), v.end(),greater<long long int>())
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector< int>
#define vs vector<string>
#define y() cout<<"YES"<<"\n"
#define n() cout<<"NO"<<"\n"
#define logbase(x,y) {log10(y)/log10(x)}

typedef int long long ll;
using namespace std;

//freopen("input.txt", "r", stdin); 
//freopen("output.txt", "w", stdout);

//to convert string into int ;
/*string temp1;
stringstream degree(temp1);
int x = 0;
degree >> x;
cout<<x;*/
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
ll min_v(vi v,ll n)
{	sortv(v);
	return v[0];
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll sol(vi v,ll n,int sum)
{
	ll low=0,high=n-1,mid;
	while(low<=high)
	{   mid=low+(high-low)/2;
		if(v[mid]==sum)
		{mid++;
			return mid;}
		else if(v[mid]>sum)
		{
		 high=mid-1;}
		 else if(v[mid]<sum)
		 {low=mid+1;
			}
	}
	low++;
	return low;
	}
	

int main()
{ 
	fast;
	ll t=1;
	//cin>>t;
	while(t--)
	{
		ll n;
		cin>>n;
		vi v;
		fill_vector(n,v);
		vector<pair<ll,ll > > x;
		sortv(v); ll count=1;
		for(ll i=0;i<n-1;i++)
		{
			if(v[i]==v[i+1])
			{
				count++;}
			else
			{
				x.pb(make_pair(v[i],count));
				count=1;
			}
		}
		x.pb(make_pair(v[n-1],count));
		ll k=x.size();count=0;
		if(k<=2) {cout<<"0";return 0;}
		for(ll i=0;i<k-2;i++)
		{
			for(ll j=i+1;j<k-1;j++)
			{
				for(ll m=j+1;m<k;m++)
				{
					if(x[i].first+x[j].first<=x[m].first)
					{break;}
					else
					{count+=x[i].second*x[j].second*x[m].second;
						//cout<<count<<"\n";
						}
				}
			}
		
		}
		cout<<count;
	
	}
		return 0;
}



Measured memory_bytes: 3732
pub fn read_parameters<T>() -> Result<Vec<T>, String>
where
    T: std::str::FromStr,
{
    let mut line = String::new();
    std::io::stdin()
        .read_line(&mut line)
        .map_err(|err| format!("{:?}", err))?;

    let xs = line.trim().split_whitespace();
    let mut result = Vec::new();

    for x in xs {
        let ans = x.parse::<T>().map_err(|_| format!("{}", "parse error"))?;
        result.push(ans);
    }
    Ok(result)
}

fn main() {
    let a = read_parameters::<usize>().unwrap();
    let mut a = a[0];

    let h = a / 3600;
    a -= h * 3600;
    let m = a / 60;
    let s = a - m * 60;

    println!("{}:{}:{}", h, m, s);
}



Measured memory_bytes: 5028
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
void Main(){
    int r = read();
    printf("%d\n", r*r*3);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256