akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 60);

int main(){ 
  int n, k;
  cin >> n >> k;
  vector<int> p(n), c(n);
  rep(i,n) cin >> p[i], p[i]--;
  rep(i,n) cin >> c[i];

  vector<vector<int>> to(32, vector<int>(n, 0));
  vector<vector<ll>> sum(32, vector<ll>(n, 0));
  vector<vector<ll>> sum_max(32, vector<ll>(n, 0));

  for (int i = 0; i < n; i++) {
    to[0][i] = p[i];
    sum[0][i] = c[p[i]];
    sum_max[0][i] = max(0LL, (ll)c[p[i]]);
  }

  for (int i = 0; i < 30; i++) {
    for (int j = 0; j < n; j++) {
      to[i + 1][j] = to[i][to[i][j]];
      sum[i + 1][j] = sum[i][j] + sum[i][to[i][j]];
      sum_max[i + 1][j] = max(sum_max[i][j], sum[i][j] + sum_max[i][to[i][j]]);
    }
  }


  ll res = -INF;
  
  for (int i = 0; i < n; i++) {
    ll tmp = c[p[i]];
    ll d = k - 1;
    int cur = p[i];
    for (int j = 0; j <= 30; j++) {
      if ((d >> j) & 1) {
        res = max(res, tmp + sum_max[j][cur]);
        tmp += sum[j][cur];
        cur = to[j][cur];
      }
    }
    res = max(res, tmp);
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 6364
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int C[] = new int[N - 1];
		int S[] = new int[N - 1];
		int F[] = new int[N - 1];
		for(int i = 0; i < N - 1; i++) {
			C[i] = sc.nextInt();
			S[i] = sc.nextInt();
			F[i] = sc.nextInt();
		}
		
		for(int i = 0; i < N - 1; i++) {
			int time = 0;
			for(int j = i; j < N - 1; j++) {
				while((time - S[j]) % F[j] != 0) {
					time++;
				}
				if(time < S[j]) {
					time += S[j] - time;
				}
				time += C[j];
			}
			System.out.println(time);
		}
		System.out.println(0);
	}
}


Measured memory_bytes: 26444
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  string s;
  cin>>s;
  map<int, int> cnt;
  int cur = 0;
  ll ans = 0;
  REP(i, s.size()){
    if(s[i] == ')') cur++;
    else cur--;
    ans += cnt[cur];
    cnt[cur]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3380
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
 
int main() {

    int a;
    string s;
    cin>>a>>s;

    if(a>=3200) cout<<s<<endl;
    else    cout<<"red"<<endl;

 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;


int main(){
    ll N, M;
    cin >> N;
    cout << setprecision(10) << 2*N*3.1415926535;
}

Measured memory_bytes: 3784
#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 pb(a) push_back(a)

ll mod = 1e09;

vector<vector<ll>> vlist(51);

ll bfs(ll s){
  ll cnt = 1;
  ll visited[51] = {};
  queue<ll> q;
  q.push(s);
  visited[s] = 1;
  while(!q.empty()){
    ll t = q.front();
    q.pop();
    REP(i, vlist[t].size()){
      if(visited[vlist[t][i]] == 0){
        q.push(vlist[t][i]);
        cnt++;
        visited[vlist[t][i]]++;
      }
    }
  }
  return cnt;
}

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

  ll n, m;
  cin >> n >> m;
  ll a[m], b[m];
  REP(i, m){
    cin >> a[i] >> b[i];
  }

  ll ans = 0;

  REP(i, m){
    REP(k, 51) vlist[k].clear();
    REP(j, m){
      if(j != i){
        vlist[a[j]].pb(b[j]);
        vlist[b[j]].pb(a[j]);
      }
    }
    ll s = 1;
    if(bfs(s) != n) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for(int i=0;i<(n);++i)

using namespace std;
int main(){
    char a;
    cin >> a;
    if(a >= 'A' && a <='Z'){
        cout << 'A' << endl;
    }else{
        cout << 'a' << endl;
    }
}

Measured memory_bytes: 3588
import sys
range = xrange

def decomp(coupl, root = 0):
    n = len(coupl)
    visible_labels = [0] * n
    
    bfs = [root]
    for node in bfs:
        for nei in coupl[node]:
            coupl[nei].remove(node)
        bfs += coupl[node]

    for node in reversed(bfs):
        seen = seen_twice = 0
        for nei in coupl[node]:
            seen_twice |= seen & visible_labels[nei]
            seen |= visible_labels[nei]
        tmp = ~seen & -(1 << seen_twice.bit_length()) 
        label = tmp & -tmp
        visible_labels[node] = (label | seen) & -label
    
    return [(seen & -seen).bit_length() - 1 for seen in visible_labels]

inp = [int(x) for x in sys.stdin.read().split()]; ii = 0

n = inp[ii]; ii += 1
coupl = [[] for _ in range(n)]
for _ in range(n - 1):
    u = inp[ii] - 1; ii += 1
    v = inp[ii] - 1; ii += 1
    coupl[u].append(v)
    coupl[v].append(u)

print max(decomp(coupl))


Measured memory_bytes: 126320
#include<iostream>
using namespace std;
int main(){
  int hit,blo;
  int a[4],b[4];
  while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
    hit=0;
    blo=0;
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
	if(i==j && a[i]==b[j]) hit++;
	else if(a[i]==b[j]) blo++;
      }
    }
    cout<<hit<<' '<<blo<<endl;
  }
}

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1
from collections import deque

H,W=map(int,input().split())
sy,sx=map(int1,input().split())
gy,gx=map(int1,input().split())
S=[input() for _ in range(H)]
used=[[False]*W for _ in range(H)]
que=deque([(sy,sx)])
dy,dx=(1,0,-1,0),(0,1,0,-1)
for ans in range(10**6):
    warp=set()
    if not que:
        print(-1)
        exit()
    while que:
        y,x=que.popleft()
        if not used[y][x]:
            used[y][x]=True
            for k in range(4):
                ny,nx=y+dy[k],x+dx[k]
                if 0<=ny<H and 0<=nx<W and not used[ny][nx]:
                    if S[ny][nx]=='.':
                        que.append((ny,nx))
                    else:
                        warp.add((y,x))
    if used[gy][gx]:
        print(ans)
        exit()
    for y,x in warp:
        for i in range(-2,3):
            for j in range(-2,3):
                ny,nx=y+i,x+j
                if not (i==j==0) and 0<=ny<H and 0<=nx<W and not used[ny][nx] and S[ny][nx]=='.':
                    que.append((ny,nx))

Measured memory_bytes: 94804
use::std::cmp::min;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}




fn main() {
    input!{
        n:i32,
        a:i32,
        b:i32,
    }
    println!("{}",min(n*a,b));
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
typedef pair<int,int> pii;
#define mp make_pair
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=19,M=110;
int f[1<<N][N],n,a[N],b[N];
int lowbit(int x){return x&(-x);}
int S(int x){int ret=0;while(x){ret++;x^=lowbit(x);}return ret;}
int main()
{
	n=gi();
	for(int i=0;i<n;i++)a[i]=gi();for(int i=0;i<n;i++)b[i]=gi();
	for(int i=0;i<n;i++)if(i&1)swap(a[i],b[i]);
	int LIM=1<<n;LIM--;
	memset(f,63,sizeof(f));
	for(int i=0;i<n;i++)f[1<<i][i]=i;
	for(int i=0;i<LIM;i++)
		for(int j=0;j<n;j++)
			if(f[i][j]<f[0][1])
			{
				int now=S(i)&1,num=0;
				for(int k=0;k<n;k++)
					if(!(i>>k&1))
					{
						if((now&&a[j]>b[k])||(!now&&b[j]>a[k]))continue;
						f[i|(1<<k)][k]=min(f[i|(1<<k)][k],f[i][j]+k-num);
					}else num++;
			}
	int ans=1e9+10;
	for(int i=0;i<n;i++)ans=min(ans,f[LIM][i]);
	if(ans>1e5)ans=-1;printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 39168
s = input()
n = len(s)
ans = 0
for i in range(n):
    for j in range(i, n + 1):
        flag = 1
        for k in s[i:j]:
            if k not in ["A", "C", "G", "T"]:
                flag = 0
                break
        if flag:
            ans = max(ans, len(s[i:j]))
print(ans)

Measured memory_bytes: 3060
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

// vectorからindex番目の要素を削除する
template<typename T>
vector<T> remove(vector<T> A, ll index)
{
    A.erase(A.begin() + index);
    return A;
}

vector<ll> dfs(ll N, vector<ll> A){
    vector<ll> ret;
    if(N==1){
        if(A[0]==1){
            ret.push_back(1);
            return ret;
        }else{
            return ret;
        }
    }

    for(int i=N-1; i>=0; i--){
        if(A[i]==i+1){
            auto list = dfs(N-1, remove(A, i));        
            if(list.size()>0){
                list.push_back(A[i]);
                return list;
            }
            else{
                return ret;
            }
        }
    }

    // fail
    return ret;
}

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    auto list = dfs(N, A);

    if(list.size()==0){
        p(-1);
    }else{
        for(ll a : list){
            p(a);
        }
    }
    
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<string>

using namespace std;

#define REP(i,n) for(long long int (i)=0;(i) < (n);(i)++)
#define REV(i,n) for(long long int (i)=(n)-1;(i) > 0;(i)--)

int A,B,C;


int main(){
  int count= 0;

  cin >> A >> B >> C;

  /*A < B < C */
  if(A > B) swap(A,B);
  if(B > C) swap(B,C);
  if(A > B) swap(A,B);

  int x,y;
  /*x < y*/
  y = -(A-C);
  x = -(B-C);
  if(x%2 == 0 && y%2 == 0){
    count = x + (y-x)/2;
  }
  else if(x%2 == 1 && y%2 == 1){
    count = x + (y-x)/2;
  }
  else {
    count = x + 1 + (y-x+1)/2;
  }
  cout << count ;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<queue>
#define MAXN 100005
using namespace std;
int k;
struct Edge{
	int v,w,next;
};Edge e[MAXN<<1];
int head[MAXN],num=0;
int d[MAXN];
struct Node{
	int u,d;
};
priority_queue<Node> q;
bool operator<(const Node &a, const Node &b){
	return a.d>b.d;
}
void add(int u,int v,int w){
	e[++num].v =v;
	e[num].w =w;
	e[num].next =head[u];
	head[u]=num;
}
void dij(){
	for(int i=0;i<k;i++) d[i]=0x7fffffff; 
	d[1]=0;
	q.push((Node){1,d[1]});
	Node x;
	int u,v;
	
	while(!q.empty() ){
		x=q.top() ;
		q.pop() ;
		u=x.u ;
		if(x.d !=d[u]) continue;
		
		for(int i=head[u];i;i=e[i].next ){
			v=e[i].v ;
			if(e[i].w +d[u]<d[v]){
				d[v]=e[i].w +d[u];
				q.push((Node){v,d[v]});
			}
		}
	}
}
int main(){
	scanf("%d",&k);
	add(k-1,0,1);
	for(int i=1;i<k;i++){
		add(i,i+1,1);
		add(i,(i*10)%k,0);
	}
	dij();
	printf("%d",d[0]+1);
	return 0;
}

Measured memory_bytes: 3964
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int n, k, ans = 0;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        int h;
        cin >> h;
        if(h >= k)ans++;
    }
    cout << ans << endl;
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
//typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const int maxN = 1e5 + 5;

int h, w, r[90][90], b;
bool dp[81][81][7201];

int main() {
	ios_base::sync_with_stdio(0);
	cin >> h >> w;
	RI(i, h) {
		RI(j, w) {
			cin >> r[i][j];
		}
	}
	RI(i, h) {
		RI(j, w) {
			cin >> b;
			r[i][j] = abs(r[i][j] - b);
		}
	}
	dp[1][1][r[1][1]] = true;
	RI(i, h) {
		RI(j, w) {
			int x = 7200;
			FOR(k, 0, x) {
				if (i > 1) {
					if (k + r[i][j] <= 7200) {
						dp[i][j][k] |= dp[i - 1][j][k + r[i][j]];
					}
					dp[i][j][k] |= dp[i - 1][j][abs(k - r[i][j])];
				}
				if (j > 1) {
					if (k + r[i][j] <= 7200) {
						dp[i][j][k] |= dp[i][j - 1][k + r[i][j]];
					}
					dp[i][j][k] |= dp[i][j - 1][abs(k - r[i][j])];
				}
			}
		}
	}
	REP(i, 7201) {
		if (dp[h][w][i]) {
			cout << i;
			return 0;
		}
	}
	// dp[i][j][k] - czy da sie osiagnac roznice rowna k
	return 0;
}


Measured memory_bytes: 45824
/*input
4
*/
#include <bits/stdc++.h>
using namespace std;
#define TEMPLATE

#ifdef TEMPLATE
	typedef long long ll;
	typedef long double ld;
	typedef complex<ld> cd;

	typedef pair<int, int> pi;
	typedef pair<ll,ll> pl;
	typedef pair<ld,ld> pd;

	typedef vector<int> vi;
	typedef vector<vi> vii;
	typedef vector<ld> vd;
	typedef vector<ll> vl;
	typedef vector<vl> vll;
	typedef vector<pi> vpi;
	typedef vector<vpi> vpii;
	typedef vector<pl> vpl;
	typedef vector<cd> vcd;
	typedef vector<pd> vpd;
	typedef vector<bool> vb;
	typedef vector<vb> vbb;
	typedef std::string str;
	typedef std::vector<str> vs;

	#define x first
	#define y second
	#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

	const int MOD = 1000000007;
	const ll INF = std::numeric_limits<ll>::max();
	const int MX = 100101;
	const ld PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270L;

	template<typename T>
	pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
	template<typename T>
	pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
	template<typename T>
	T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
	template<typename T>
	T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }

	template<typename T>
	void print(vector<T> vec, string name = ""){
		cout << name;
		for(auto u: vec)
			cout << u << ' ';
		cout << '\n';
	}

#endif

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int R;
	cin >> R;
	cout << 3*R*R << endl;	
}

/* Look for:
* special cases (n=1?)
* overflow (ll vs int?)
* the exact constraints (multiple sets are too slow for n=10^6 :( ) 
* array bounds
*/
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    string S;
    cin >> N >> S >> K;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] != S[K-1]) S[i] = '*';
    }
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define MA 10e+18
int va=10e8+7;
ll val[200007]={0};
using namespace std;
//Conditional Operator (condition?true part:false part) eg : cout<<(y<=3?"YES":"NO")<<endl;
//string s(3,'1');
// if number of elements in array >10^5 then declare global array.
ll getmul(ll n){ll int k{0};while(n>0){k+=n%10;n=n/10;}return k;}//Sum OF n DIGITS 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t{1};
 //   cin>>t;
    while(t--){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        ll ans1=b*c;
        ll ans2=a*c;
        ll ans3=b*d;
        ll ans4=a*d;
        ans1=max({ans1,ans2,ans3,ans4});
        cout<<ans1<<endl;
    }
 return 0;
}

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

int main(){
    ll N;
    cin >> N;
    vector<ll> vec(N);
    rep(i,N){
        cin >> vec[i];
        vec[i] -= (i + 1);
    }
    sort(all(vec));
    ll len_vec = vec.size();
    if (len_vec % 2 == 1){
        ll b = vec[len_vec / 2];
        ll ans = 0;
        rep(i,N){
            ans += max(vec[i] - b, b - vec[i]);
        }
        cout << ans << endl;
    }
    else{
        ll a = vec[len_vec / 2];
        ll b = vec[(len_vec / 2) - 1];
        if ((a + b) % 2 == 0){
            ll c = (a + b)/ 2;
            ll ans = 0;
            rep(i,N){
                ans += max(vec[i] - c, c - vec[i]);
            }
            cout << ans << endl;
        }
        else{
            ll c = (a + b + 1) / 2;
            ll d = (a + b - 1) / 2;
            ll ans_c = 0;
            ll ans_d = 0;
            rep(i,N){
                ans_c += max(vec[i] - c, c - vec[i]);
                ans_d += max(vec[i] - d, d - vec[i]);
            }
            cout << min(ans_c, ans_d) << endl;
        }
    }
}


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

int main()
{
    int n;
    cin>>n;
    vector<long long int> arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr.begin(),arr.end(),greater<int>());
    long long int ans=arr[0];
    long long int count=1;
    if(count==n-1) {
        cout<<ans;
        return 0;
    }
    for(int i=1;i<n;i++){
        ans+=arr[i];
        count++;
        if(count==n-1) break;
        ans+=arr[i];
        count++;
        if(count==n-1) break;
    }
    cout<<ans;
}


Measured memory_bytes: 4808
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, m, l;
    cin >> n >> m >> l;
    int INF = 1001001001;
    vector<vector<int>> to(n, vector<int>(n, INF));
    rep(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        to[a][b] = c;
        to[b][a] = c;
    }
    rep(i, n)to[i][i] = 0;
    rep(k, n)rep(i, n)rep(j, n){
        to[i][j] = min(to[i][j], to[i][k] + to[k][j]);
    }
    vector<vector<int>> d(n, vector<int>(n, INF));
    rep(i, n)rep(j, n){
        if(to[i][j] <= l)d[i][j] = 1;
    }
    rep(i, n)d[i][i] = 0;
    rep(k, n)rep(i, n)rep(j, n){
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }

    int q;
    cin >> q;
    rep(i, q){
        int s, t;
        cin >> s >> t;
        s--; t--;
        if(d[s][t] == INF)cout << -1 << endl;
        else cout << d[s][t] - 1 << endl;
    }
    
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
  string s;
  cin >> s;
  for(int i=0;i<s.length()-1;i++){
    if(s[i] == s[i+1]){
      cout << "Bad" <<endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <chrono>
#include <cmath>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#include <atcoder/segtree>

using namespace std;
using namespace atcoder;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const int INF = 2000000009;
const ll INFL = 1e18 + 5LL;
const ld EPS = 1e-11;

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return 0;
}

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    segtree<int, op, e> seg(300001);
    for (int i = 0; i < n; ++i) {
        int minc = seg.prod(max(0, a[i] - k), min(300001, a[i] + k + 1)) + 1;
        //cout << a[i] << " " << minc << "\n";
        seg.set(a[i], minc);
    }

    cout << seg.all_prod() << "\n";

    return 0;
}

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

int main() {
    int N;
    cin>>N;
    vector<int>d (N);
    vector<int>list (102, 0);
    for(int i=0;i<N;i++){
        cin>>d.at(i);
        list.at(d.at(i))+=1;
    }
    int dan=0;
    for(int j=1;j<101;j++){
        if(list.at(j)>0){
            dan+=1;
        }
    }
    cout<<dan;
return 0;}
/*
g++ code.cpp
./a.out
*/

Measured memory_bytes: 256
from fractions import gcd

lcm = lambda a, b: a * b // gcd(a, b)

N, M, *A = map(int, open(0).read().split())

Y = A[0]
for a in A[1:]:
    Y = lcm(Y, a)
    if Y > 2 * M:
        print(0)
        quit()

print(M // (Y // 2) - (M // Y) if all((Y // a) % 2 for a in A) else 0)

Measured memory_bytes: 16148
#include<stdio.h>

long long count = 0;
int arr[500005];
int tempArr[500005];
void mergeSort(int l, int r){
	if(l == r) return;
	
	int mid = (l + r)/2;
	
	mergeSort(l, mid);
	mergeSort(mid + 1, r);
	
	int idx = l;
	int leftIdx = l;
	int toLeft = mid;
	int rightIdx = mid + 1;
	int toRight = r;
	
	while(leftIdx <= toLeft && rightIdx <= toRight){
		if(arr[leftIdx] < arr[rightIdx]){
			tempArr[idx++] = arr[leftIdx++];
		}
		else{
			tempArr[idx++] = arr[rightIdx++];
			count += (mid + 1) - leftIdx;
		}
	}
	
	while(leftIdx <= toLeft){
		tempArr[idx++] = arr[leftIdx++];
	}
	while(rightIdx <= toRight){
		tempArr[idx++] = arr[rightIdx++];
	}
	
	for(int i = l; i<=r; i++){
		arr[i] = tempArr[i];
	}
	
}

int main(){
	
	int n;
	scanf("%d", &n);
	for(int i = 0; i<n; i++){
		scanf("%d", &arr[i]);
	}
	
	mergeSort(0, n-1);
	
	printf("%lld\n", count);
	
	return 0;
}


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

using namespace std;
const int N = 200200;
map<pair<int, int>, int> cnt;

long long tolong(string s) {
        long long res = 0;
        for (auto c:s) {
                res = (res * 10) + c - '0';
        }
        return res;
}

pair<int, int> cnt25(long long x) {
        if (x == 0) return {0, 0};
        int a = 0;
        int b = 0;
        while (x % 2 == 0) {
                x /= 2;
                a++;
        }
        while (x % 5 == 0) {
                x /= 5;
                b++;
        }
        return {a, b};
}

void solve() {
        int n;
        cin >> n;
        long long ans = 0;
        for (int i = 1; i <= n; i++) {
                string s;
                cin >> s;
                int k = s.find('.');
                long long x = 0, y = 0;
                long long a = 0;
                long long b = 1;
                int cnt2 = 0;
                int cnt5 = 0;


                if (k == -1) {
                        a = tolong(s);
                        b = 1;
                } else {
                        a = tolong(s.substr(0, k));
                        int len = s.size() - k - 1;
                        y = tolong(s.substr(k + 1));
                        long long dec = 1;
                        while (len--) {
                                dec *= 10;
                        }
                        a = a * dec + y;
                        b = dec;
                }
                long long g = __gcd(a, b);
                a /= g;
                b /= g;

                auto f1 = cnt25(a);
                auto f2 = cnt25(b);
                cnt2 = f1.first - f2.first;
                cnt5 = f1.second - f2.second;
//                assert(-30 <= cnt2 && cnt2 <= 19);
//                assert(-13 <= cnt5 && cnt5 <= 6);

//                cout << cnt2 << ' ' << cnt5 << endl;
                for (auto x:cnt) {
                        int j = x.first.first;
                        int k = x.first.second;
                        if (j + cnt2 >= 0 && k + cnt5 >= 0) {
                                ans += x.second;
                        }
                }
                cnt[{cnt2, cnt5}]++;
        }
        cout << ans << endl;
}


int main() {
#ifdef QWERTY
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
#endif
        ios_base::sync_with_stdio(false);


        int t = 1;
//        cin >> t;

        for (int i = 1; i <= t; i++) {

//                cout << "Case #" << i << ':' << endl;
                solve();
        }


        return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using namespace std;
using i8t = std::int64_t;
using vi8t = std::vector<i8t>;
using vvi8t = std::vector<std::vector<i8t>>;
static const i8t i8t_max=numeric_limits<i8t>::max();
static const i8t i8t_min=numeric_limits<i8t>::min();
using u8t = std::uint64_t;
using vu8t = std::vector<u8t>;
#define F3(I,A,B) for(i8t I=A,I##_N=B;I<I##_N;I++)
#define F(I,N) F3(I,0,N)
#define FR(I,N) for(i8t I=N;I--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
template<typename T> T umax(T& ans,T const& value) {if(value>ans)ans=value;return ans;}
template<typename T> T umin(T& ans,T const& value) {if(value<ans)ans=value;return ans;}

int main() {
  R(X)R(Y)R(Z);
  swap(X,Y);
  swap(X,Z);
  cout<<X<<" "<<Y<<" " <<Z<<endl;
  return 0;
}


Measured memory_bytes: 256
import math

def do():
    cs=[[0 for i in range(10)]for j in range(10)]
    #cs[0][1] → 0を1にか
    INF=10000000
    node_num=10
    unsearch=list(range(node_num)) #サーチが終わっていないノードのリスト us[0][1]==True →0と1をつなぐノードは未探索
    cos=[INF]*node_num #頂点1からのコスト cos[2][4] →
    cos[1]=0
    #preveious_nodes=[-1]*node_num
    nums=[0]*10 #各数字の個数

    temp=list(map(int,input().split(" ")))
    H=temp[0]
    W=temp[1]
    for i in range(10):
        temp=list(map(int,input().split(" ")))
        for j in range(10):
            cs[j][i]=temp[j]

    for i in range(H):
        temp=list(map(int,input().split(" ")))
        for j in range(W):
            if temp[j]!=-1:
                nums[temp[j]]+=1

    def get_target_min_index(min_index,distance,unsearch):
        start=0
        while True:
            index=distance.index(min_index,start)
            found=index in unsearch
            if found:
                return index
            else:
                start = index+1

    while len(unsearch)!=0:
        posible_min_distance=INF
        for node_index in unsearch:
            if posible_min_distance > cos[node_index]:
                posible_min_distance=cos[node_index]
        target_min_index=get_target_min_index(posible_min_distance,cos,unsearch)
        unsearch.remove(target_min_index)
        target_edge=cs[target_min_index] #あるVからの距離の一覧

        for index,route_dis in enumerate(target_edge):
             #Vからの総てのノードに対して計算
             if route_dis !=0:
                 if cos[index] > cos[target_min_index] + route_dis:
                     cos[index]=cos[target_min_index] + route_dis


    result=0
    for i in range(10):
        result+=(nums[i]*cos[i])
    print (result)

        


if __name__=="__main__":
    do()

Measured memory_bytes: 3192
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::collections::HashMap;

fn main() {
    let _n = get!(usize);
    let mut mp = HashMap::new();
    for a in get!(String).split_whitespace().map(|n| n.parse::<usize>().unwrap()) {
        let v = mp.entry(a).or_insert(0);
        *v += 1;
    }
    let mut e = 0;
    let mut o = 0;
    for (_, n) in mp {
        if n%2 == 0 {
            e += 1;
        } else {
            o += 1;
        }
    }
    println!("{}", o + e/2*2);
}

Measured memory_bytes: 12540
#include <iostream>
using namespace std;
int n;
long long score[16][16];
long long dp[1<<16];
int main () {
	cin >> n;
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			cin >> score[i][j];
		}
	}
	for (int i=0; i<(1<<n); i++) {
		for (int j=0; j<n; j++) {
			if ((i & (1<<j)) == 0) continue;
			for (int k=j+1; k<n; k++) {
				if ((i & (1<<k)) == 0) continue;
				dp[i] += score[j][k]; 
			}
		}
	}
	for (int i=0; i<(1<<n); i++) {
		for (int j=i; j>0; j=i&(j-1)) {
			dp[i] = max(dp[i], dp[j]+dp[i^j]);
		}
	}
	cout << dp[(1<<n)-1] << endl;
}

Measured memory_bytes: 4136
#include<bits/stdc++.h>
// iteration and input/output stream
#define rep(i,a,b) for(int i = int(a);i<=int(b);i++)
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define printarr(x) rep(i,0,x.size()-1) cout<<x[i]<<" "; cout<<endl;
#define all(v) v.begin(),v.end()
 
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define tr(cont,it) \
for(decltype(cont.begin()) it = cont.begin(); it!= cont.end() ; it++)
 
#define endl "\n"
#define tc() int t; cin >> t ; while (t--)
//STL shortcuts
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define MP make_pair
 
// Error detection
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
using namespace std;
 
typedef long long int ll; // 64 bit integer
typedef unsigned long long int  ull; // 64 bit unsigned integer
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
 
inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }
 
#define MOD 1000000007
#define inf 4000000000000000000LL
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("err.txt","w",stderr);
    #endif
    SYNC
    int n,k;
    cin>>n>>k;
    unordered_map<int,int> m1;
    for (int i = 0; i < k; i++)
    {
        int x;
        cin>>x;
        for (int i = 0; i < x; i++)
        {
            int a;
            cin>>a;
            m1[a]++;
        }
    }
    int cnt =0;
    for (int i = 1; i <= n; i++)
    {
        if(!m1.count(i))
        {
            cnt++;
        }
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

void solve() {
	int n, m;
	cin >> n >> m;
	vector<pii> v;
	v.resize(n);
	for(int i = 0; i < n; i++) cin >> v[i].first >> v[i].second;
	sort(v.begin(), v.end());
	ll ret = 0;
	for(pii out: v) {
		ret += min(m, out.second) * (ll)out.first;
		m -= min(m, out.second);
	}
	cout << ret << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}

int main(void){
  fast_io
  ll h,n;cin>>h>>n;
  vector<ll> A,B;
  rep(i,n){
    ll a,b;cin>>a>>b;
    A.push_back(a);
    B.push_back(b);
  }
  ll dp[20005];
  rep(i,2e4+3){
    dp[i] = LINF;
  }
  dp[0] = 0;
  rep(i,h){
    rep(j,n){
      chmin(dp[i+A[j]], dp[i] + B[j]);
    }
  }
  ll ans = LINF;
  for(int i=h; i<h+1e4+2; i++){
    chmin(ans, dp[i]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))

ans = 1

if min(A) == 0:
  print(0)

else:
  for i in range(N):
    ans *= int(A[i])
    if ans > 10**18:
      print(-1)
      break
    elif i == N-1:
      print(ans)
      break

Measured memory_bytes: 21584
s=int(input())
a=[]
i=1
while len(a)==len(set(a)):
  if i==1:
    a.append(s)
    i=i+1
  else:
    if a[-1]%2==0:
      tori=a[-1]//2
      a.append(tori)
    else:
      tori=a[-1]*3+1
      a.append(tori)
print(len(a))

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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //



// --------- library end - //


int main(){

  ll A, B, C, K;
  cin >> A >> B >> C >> K;

  ll ans = 0;
  while (B <= A || C <= B){
    if (B <= A){
      B *= 2;
      ans++;
    }
    else if (C <= B){
      C *= 2;
      ans++;
    }
  }

  cout << ( ans <= K ? "Yes" : "No" ) << endl;

  
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>

using namespace std;

int main(void){
    string s;
    unsigned long long k;
    char buf[3];

    unsigned long long acnt=0, cnt[3] = {0};

    cin >> s;
    cin >> k;

    unsigned long long len = s.length();

    for(int i = 0; i<3; i++)
        buf[i] = s[i%len];

    for(unsigned long long i=1; i<len*3; i++){
        char ch = buf[1] - 'a';

        if(ch == buf[0] - 'a'){
            ch = (ch + 1) % 26;
            if(ch == buf[2] - 'a')
                ch = (ch + 1) % 26;
                
            cnt[2]++;
            if(i<len*2)
                cnt[1]++;
            if(i<len)
                cnt[0]++;
            //cout << "#";
        }

        //cout << buf[0] << buf[1] << ":" << (char)(ch+'a') << endl;

        buf[0] = ch + 'a';
        buf[1] = buf[2];
        buf[2] = s[(i+2)%len];
    }
    if(cnt[0]!=cnt[2]-cnt[1])
        acnt = (cnt[2]-cnt[1])*(k-1)+cnt[0];
    else{
        if(k%2)
            acnt = cnt[1]*(k/2)+cnt[0];
        else
            acnt = cnt[1]*(k/2);
    }
    

    cout  << acnt << endl;

    return 0;
}

Measured memory_bytes: 384
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = getLine >> replicateM 3 getLine >>= print . solve

solve :: [String] -> Int
solve [xs, ys, zs] = sum . map count $ zip3 xs ys zs
    where
        count (a, b, c) = len - 1
            where
                len = length . group $ sort [a, b, c]

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 636
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<numeric>
#include<climits>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
using namespace std;

int main(void) {
	int r, c;
	cin >> r >> c;
	vector<vector<int> > spreadsheet(r,vector<int>(c));

	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			cin >> spreadsheet[i][j];
		}
	}

	//横
	for (int i = 0; i < r; i++) {
		spreadsheet[i].push_back(accumulate(spreadsheet[i].begin(), spreadsheet[i].end(),0));
	}

	//縦
	vector<int> subtotal(c + 1);
	for (int i = 0; i < c + 1; i++) {
		for (int j = 0; j < r; j++) {
			subtotal[i] += spreadsheet[j][i];
		}
	}
	spreadsheet.push_back(subtotal);

	//表示
	for (int i = 0; i < r + 1; i++) {
		for (int j = 0; j < c + 1; j++) {
			if (j == c) {
				cout << spreadsheet[i][j] << endl;
			}else{
				cout << spreadsheet[i][j] << " ";
			}
		}
	}
}


Measured memory_bytes: 3240
import java.util.*;

class Main{
  static Scanner sc = new Scanner(System.in);
  public static void main(String[] args){
    int  n = sc.nextInt();
    List<Xy> l = new ArrayList<>(n);
    for(int i=0;i<n;i++){
      l.add(new Xy(sc.nextInt(),sc.nextInt()));
    }
    Collections.sort(l,(s1,s2)->Xy.hencom(s1,s2));
    
    double max=0;
    for(int i=0;i<n;i++){
      int rx=0;
      int ry=0;
      for(int j=0;j<n;j++){
        rx+=l.get(j).x;
        ry+=l.get(j).y;
        max=Math.max(Math.hypot(rx,ry),max);
      }
      Xy r=l.remove(0);
      l.add(r);
    }
    System.out.println(max);
  }
  static class Xy{
    int x;
    int y;
    Xy(int x,int y){
      this.x=x;
      this.y=y;
    }
    public String toString(){
      return "["+x+","+y+"]";
    }
    public static int hencom(Xy s1,Xy s2){
      return (int)Math.signum(Math.atan2(s1.y,s1.x)-Math.atan2(s2.y,s2.x));
    }
  }
}

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

//{{{
#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
// clang-format off
void _print() { cerr << "]\033[0m\n"; }
template <typename T> void __print(T x) { cerr << x; }
template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
#ifdef LOCAL
#define debug(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m["; _print(x)
#define debug_arr(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m" << (x) << "\033[0m\n"
#else
#define debug(x...)
#define debug_arr(x...)
#endif
// clang-format on
//}}}

int T;

const int mod = 1e9 + 7;
const int N = 10;

char g[N][N];
char gg[N][N];
int h, w, k;

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif

    while (cin >> h >> w >> k)
    {
        for (int i = 0; i < h; ++i)
        {
            scanf("%s", g[i]);
        }

        int ans = 0;

        for (int sti = 0; sti < (1 << h); sti++)
        {
            for (int stj = 0; stj < (1 << w); stj++)
            {
                memcpy(gg, g, sizeof(gg));

                for (int i = 0; i < h; i++)
                {
                    if (sti & (1 << i))
                    {
                        for (int j = 0; j < w; j++) gg[i][j] = 'R';
                    }
                }

                for (int j = 0; j < w; j++)
                {
                    if (stj & (1 << j))
                    {
                        for (int i = 0; i < h; i++) gg[i][j] = 'R';
                    }
                }

                int cnt = 0;
                for (int i = 0; i < h; i++)
                {
                    for (int j = 0; j < w; j++)
                    {
                        if (gg[i][j] == '#') cnt++;
                    }
                }

                if (cnt == k)
                {
                    ans++;
                }
            }
        }

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


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
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;}
const int inf = 1001001001;

int main() {
    string s;
    cin >> s;
    int now = 1;
    rep(i,s.size()) {
        now = 1-now;
        char c = s[i];
        if(now == 0) {
            if(!(c == 'R' || c == 'U' || c == 'D')) {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if(!(c == 'L' || c == 'U' || c == 'D')) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256