akhauriyash/Code-Regression huggingface dataset:
// 単一始点最短経路 ( ダイクストラ法 : 優先度付きキュー )
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

#include<queue>

using namespace std;

static const int MAX_N = 10000;
static const int INFTY = (1 <<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

class q_element
{
    public:
        // 各頂点のNo.と経路の値
        int vertex_num;
        int vertex_val;

        // コンストラクタ
        q_element(int a, int b)
        {
            vertex_num = a;
            vertex_val = b;
        };
};

// ">" のオーバーロード [ receive_val ] を基準に大小比較を行う
bool operator > (const q_element &q_element_1, const q_element &q_element_2)
{
    return q_element_1.vertex_val > q_element_2.vertex_val;
};

// q_elementクラスのオブジェクトを昇順にするためのキューの定義
std::priority_queue< q_element,
                     std::vector<q_element>,
                     std::greater<q_element> > pqEle;

// 隣接リストを作成する ( 頂点と重みの情報を格納する )
vector<q_element> v_Link[MAX_N + 1];

int n;

// ダイクストラ法を実施するメソッド( 優先度付きキュー )
int Dijkstra_priority_queue(int start_v);

int main(void)
{

    cin >> n;

    int k, c, u, v;
    q_element q_entity(0, 0);

    for(int i = 0; i < n; i++)
    {
        cin >> u >> k;

        for(int j = 0; j < k; j++)
        {
            cin >> v >> c;

            // 隣接リストの作成 ( 頂点と重みを設定する )
            q_entity.vertex_num = v;
            q_entity.vertex_val = c;

            v_Link[u].push_back(q_entity);
        }
    }

    // 優先度付きキューを用いたダイクストラ法
    Dijkstra_priority_queue(0);

    return 0;

}

// 優先度付きキューを用いたダイクストラ法を実施するメソッド
// start_v : スタートする頂点のNo.
int Dijkstra_priority_queue(int start_v)
{
    int u, v, minv;
    int d[MAX_N], p[MAX_N], color[MAX_N];

    for(int i = 0; i < n; i++)
    {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }

    // 初期値の設定 ( 頂点 : 0 を開始点とする)
    d[start_v] = 0;
    color[start_v] = GRAY;
    // キューに要素を入れる
    pqEle.push( q_element(start_v, 0) );

    while( !pqEle.empty() )
    {

        // 最小の値を持つ頂点を取り出す ( キューの先頭 )
        u = pqEle.top().vertex_num;
        minv = pqEle.top().vertex_val;
        pqEle.pop();

        // 訪問完了
        color[u] = BLACK;

        for(int v_num = 0; v_num < v_Link[u].size(); v_num++)
        {
            // 隣接リストから接続している要素を取得する
            v = v_Link[u][v_num].vertex_num;

            if( color[v] != BLACK )
            {
                // u → v の経路の中で, vのコストが最小のものが見つかれば更新する
                if( d[v] > d[u] + v_Link[u][v_num].vertex_val )
                {
                    // コストの記録
                    d[v] = d[u] + v_Link[u][v_num].vertex_val;
                    // 頂点 v の親を記録する
                    p[v] = u;
                    // 訪問状態の記録
                    color[v] = GRAY;

                    // キューに要素を入れる
                    pqEle.push( q_element(v, d[v]) );
                }
            }
        }
    }

    // 結果の表示
    for(int i = 0; i < n; i++)
    {
        cout << i << " " << ( d[i] == INFTY ? -1 : d[i] ) << endl;
    }

    return 0;
}



Measured memory_bytes: 7816
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int a = sc.nextInt(); //座標1移動したときの疲労度
		int b = sc.nextInt(); //TP

		int[] array = new int[n];
		for(int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}

		long sum = 0;
		for(int i = 1; i < n; i++) {
			long dist = array[i] - array[i - 1];
			if(dist * a >= b) {
				sum += b;
			} else {
				sum += dist * a;
			}
		}

		System.out.println(sum);

	}
}



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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> famod, simod, fimod;

void create_fact_mod(int num){
    famod[0] = 1;
    famod[1] = 1;
    for(int i=2; i<=num; i++){
        famod[i] = famod[i-1] * i % MOD;
    }
}

void create_seq_inv_mod(int num){
    simod[0] = 1;
    simod[1] = 1;
    for(int i=2; i<=num; i++){
        simod[i] = (MOD - MOD/i) * simod[MOD%i] % MOD;
    }
}

void create_fact_inv_mod(int num){
    fimod[0] = 1;
    fimod[1] = 1;
    for(int i=2; i<=num; i++){
        fimod[i] = fimod[i-1] * simod[i] % MOD;
    }
}

void create_mod_tables(int num){
    famod.resize(num+1);
    simod.resize(num+1);
    fimod.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return famod[n] * fimod[n-k] % MOD * fimod[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return famod[n] * fimod[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t mod_inv(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int main(){
    int N, M, K;
    cin >> N >> M >> K;
    create_mod_tables(N+M+K);

    int64_t sum = 1;
    int64_t c = power_mod(3, M+K);
    int64_t ans = c;
    for(int t=1; t<=M+K; t++){
        mul(c, mod_inv(3) * (N-1+t) % MOD * mod_inv(t) % MOD);
        mul(sum, 2);
        if(0 <= t-K-1) add(sum, MOD - comb_mod(t-1, t-K-1));
        if(M+1 <= t) add(sum, MOD - comb_mod(t-1, M));
        add(ans, c * sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 21376
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
  #define pb push_back
#define f first
#define s second
  #define MAXN 100005
using namespace std;
ll ans=0;
ll m;
void generate(ll n,int s,int f,int t){
	if(n>m) {
		return;
	}
	if(s>=1&&f>=1&&t>=1) {
		ans++;
	}
	generate(n*10LL+7LL,s+1,f,t);
	generate(n*10LL+5LL,s,f+1,t);
	generate(n*10LL+3LL,s,f,t+1);
}
int main()
{
	std::ios::sync_with_stdio(false);

	cin>>m;
	generate(0,0,0,0);
	cout<<ans<<endl;
	// cin.ignore(); must be there when using getline(cin, s)

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<bl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<bl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define present(c,x) ((c).find(x) != (c).end())
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll fast_exp(ll base, ll exp) {
    ll res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base)%MOD;
       base=(base*base)%MOD;
       exp/=2;
    }
    return res%MOD;
}
ll fib(ll n)
{
    if(n < 2)
        return n;
    ll a = 0,b = 1,ans;
    int i = 1;
    while(i < n)
    {
        ans = (a+b) % MOD;
        a = b;
        b = ans;
        i++;
    }
    return ans;
}
int main()
{
    fastio();
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans=0;
    if(a<k)
    {
        ans+=a;
        k-=a;
        if(b<k)
        {
            k-=b;
            ans-=k;
        }
    }
    else
    {
        ans+=k;
    }
    cout<<ans<<"\n";
    
    
    

}

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

using namespace std;

typedef long long ll;

#define p(x) cout << x << endl
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    vector<ll> hs(n);
    rep(i, n) { cin >> hs[i]; }

    bool able = true;
    rep(i, n) {
        if(n == 1) {
            break;
        }
        if(i == 0) {
            if((hs[i] - hs[i + 1]) >= 2) {
                able = false;
                break;
            }
            hs[i] -= 1;
        } else if(i == n - 1) {
            break;
        } else {
            if((hs[i] - hs[i + 1]) >= 2) {
                able = false;
                break;
            }
            if(hs[i - 1] < hs[i]) {
                hs[i] -= 1;
            }
            if(hs[i] > hs[i + 1]) {
                able = false;
                break;
            }
        }
    }

    if(able) {
        p("Yes");
    } else {
        p("No");
    }
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#define MAX 500000
#define SENTINEL 2000000000
   
int L[MAX/2+2], R[MAX/2+2];
int count = 0;
   
void merge(int [], int, int, int, int);
void mergeSort(int [], int, int, int);
   
int main(){
  int A[MAX], n, i;
   
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d", &A[i]);
  }
  mergeSort(A, n, 0, n);
  for(i = 0;i < n;i++){
    if(i) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", count);
  return 0;
}
   
void merge(int A[], int n, int left, int mid, int right){
  int n1, n2, i, j, k;
   
  n1 = mid - left;
  n2 = right - mid;
  for(i=0;i<n1;i++){
    L[i] = A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i] = A[mid+i];
  }
  L[n1] = R[n2] = SENTINEL;
  i = 0;
  j = 0;
  for(k=left;k<right;k++){
    count++;
    if(L[i] <= R[j]){
      A[k] = L[i++];
    }
    else A[k] = R[j++];
  }
}
   
void mergeSort(int A[], int n, int left, int right){
  int mid;
   
  if(left+1 < right){
    mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

Measured memory_bytes: 4508
s=list(input())
ss=s[:]
k=int(input())
if len(s)==1: 
    print(k//2)
elif len(set(ss))==1:
        print((k*len(s))//2)    
else:
    count1=0
    for i in range(len(s)-1):
        if s[i]==s[i+1]:
            s[i+1]='0'
            count1+=1
    count2=0
    ss=ss+ss
    for i in range(len(ss)-1):
        if ss[i]==ss[i+1]:
            ss[i+1]='0'
            count2+=1
    print(count1+(k-1)*(count2-count1))

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

int main() {
	set<int> s;
	int n;
	cin>>n;
	for(int i=0; i<n; i++)
	{
	    int p;
	    cin>>p;
	    s.insert(p);
	}
	if(s.size() != n)
	{
	    cout<<"NO";
	}
	else
	{
	    cout<<"YES";
	}
	return 0;
}

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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int H,W;
  cin >> H >> W;
  char x[H][W];

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> x[i][j];
    }
  }

  vector<bool> h(H,false);
  vector<bool> w(W,false);

  for(int i = 0; i < H; i++){
    // 行方向チェック
    for(int j = 0; j < W; j++){
      if(x[i][j] == '#'){
        h[i] = true; // i列目は残す
        break;
      }
    }
  }

  for(int j = 0; j < W; j++){
    // 列方向チェック
    for(int i = 0; i < H; i++){
      if(x[i][j] == '#'){
        w[j] = true; // j行目は残す
        break;
      }
    }
  }

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(h[i] && w[j]){
        cout << x[i][j];
      } 
    }
    if(h[i]) cout << endl;
  }
}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        var n = (1000 - rint() % 1000) % 1000;
        Write(n);
    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


Measured memory_bytes: 27472
N,M = map(int, input().split())
X = list(map(int,input().split()))
X.sort()
def solve():
    ans = 0
    if(N>=M):
        return print(ans)
    else:
        sub = []
        for i in range(M-1):
            sub_next = abs(X[i+1]-X[i])
            sub.append(sub_next)
        sub.sort()
        return print(sum(sub[0:M-N]))
solve()

Measured memory_bytes: 13968
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
#define pi 3.1415926


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

    

	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

const int N=0;



void solve(){
	string s;
	cin>>s;
	for(char c:s){
		if(c=='?')cout<<'D';
		else cout<<c;
	}
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SIEVE
		sieve();
	#endif
	#ifdef NCR
		init();
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 3784
#include <cstdio>
#include <algorithm>

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

int N, M, K, sx, sy;
char A[MN][MN];
int qx[MN * MN], qy[MN * MN], ql, qr;
int dis[MN][MN];
int Ans;

int main() {
	scanf("%d%d%d", &N, &M, &K), Ans = N;
	for (int i = 1; i <= N; ++i) {
		scanf("%s", A[i] + 1);
		for (int j = 1; j <= M; ++j) {
			dis[i][j] = -1;
			if (A[i][j] == 'S') sx = i, sy = j;
		}
	}
	dis[sx][sy] = 0, ql = qr = 1, qx[1] = sx, qy[1] = sy;
	while (ql <= qr) {
		int x = qx[ql], y = qy[ql]; ++ql;
		int di = std::min({x - 1, N - x, y - 1, M - y});
		Ans = std::min(Ans, 1 + (di + K - 1) / K);
		if (dis[x][y] == K) continue;
		for (int d = 0; d < 4; ++d) {
			int nx = x + dx[d], ny = y + dy[d];
			if (nx < 1 || nx > N || ny < 1 || ny > M || A[nx][ny] == '#' || ~dis[nx][ny]) continue;
			dis[nx][ny] = dis[x][y] + 1;
			++qr, qx[qr] = nx, qy[qr] = ny;
		}
	}
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 9764
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ASecurity solver = new ASecurity();
        solver.solve(1, in, out);
        out.close();
    }

    static class ASecurity {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] s = in.next().toCharArray();

            for (int i = 0; i + 1 < s.length; i++) {
                if (s[i] == s[i + 1]) {
                    out.println("Bad");
                    return;
                }
            }
            out.println("Good");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, K; 
  cin >> N >> K;

  cout << (int)pow(K-1, N-1)*K << "\n";

  return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{ int a,r,b[12],i=0,k=0;
 cin>>a;
 while(a!=0)
 {
 b[i]=a%10;
   a=a/10;
   i++;
 }
 if(i<=2)
 cout<<"Bad";
 else
 {for(i=0;i<4;i++)
 {if(b[i]==b[i+1])
   k++;}
 if(k==0)
   cout<<"Good";
 else
   cout<<"Bad";
 return 0;}}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

bool f(){
    int N; cin >> N;
    vi A(N);
    rep(i, N)cin >> A[i];
    int r = 0, c = 0;
    rep(i, N)smax(r, A[i]);
    vi C(N);
    rep(i, N){
        if(A[i] < (r+1) / 2)return false;
        if(A[i] == (r+1) / 2)c++;
        C[A[i]]++;
    }
    if(r % 2 == 1){
        if(c != 2)return false;
    } else{
        if(c != 1)return false;
    }
    for(int i = (r+1)/2+1; i <= r; ++i){
        if(C[i] < 2)return false;
    }
    return true;
}

int main(){
    puts(f() ? "Possible" : "Impossible");
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#define V 1000000
using namespace std;
int n, k, l, chk1[200020], chk[200020], a=1, b=1;
vector<int> L[200020], T[200020];
map< long long, int > cnt;
void dfs(int x, int y)
{
    chk[x] = y;
    for(int i = 0 ; i < L[x].size() ; i++ )
        if( !chk[L[x][i]] ) dfs(L[x][i], y);
}
void dfs2(int x, int y)
{
    chk1[x] = y;
    for(int i = 0 ; i < T[x].size() ; i++)
        if( !chk1[T[x][i]] ) dfs2(T[x][i], y);
}
int f(int x)
{

}
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>k>>l;
    for(int i = 0 ; i < k ; i++ )
    {
        int a, b;
        cin>>a>>b;
        L[a].push_back(b);
        L[b].push_back(a);
    }
    for(int i = 0 ; i < l ; i++ )
    {
        int a, b;
        cin>>a>>b;
        T[a].push_back(b);
        T[b].push_back(a);
    }
    for(int i = 1 ; i <= n ; i++ )
        if( !chk[i] ) dfs(i, a++);
    for(int i = 1 ; i <= n ; i++ )
        if( !chk1[i] ) dfs2(i, b++);
    for(int i = 1 ; i <= n ; i++ )
        cnt[(long long)chk[i]*V+chk1[i]]++;
    for(int i = 1 ; i <= n ; i++ )
        cout<<cnt[(long long)chk[i]*V+chk1[i]]<<(i==n?"\n":" ");
}


Measured memory_bytes: 27904
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
template<typename T>
bool all_same(vector<T> v1,vector<T> v2){
    sort(ALL(v1));
    sort(ALL(v2),greater<T>());
    return v1 == v2;
}
 
// g++ -std=c++11 prac.cpp
ll Max=-1e9,Min=1e9+1;
 
int main(){
    ll a,b,c,x=0,y=0,n,m,k,l,r,w,sum=0,sum2=0,ans=0;
    string s,t;
    bool f=true;
    cin >> n >> m >> a >> b;
    if(n!=a){
        cout << 1 << endl;
    }
    
    else cout << 0 << endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


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

  vector<int> l(n+1,0);
  vector<int> r(n+1,0);

  int ans=(1<<30);
  REP(i,n){
    if(s[i]=='W')l[i+1] = l[i]+1;
    else l[i+1] = l[i];
  }

  for(int i = n-1; i >=0; i--){
    if(s[i]=='E')r[i] = r[i+1]+1;
    else r[i] = r[i+1];
  }

  // l[i] : i 番目
  // r[i+1]: i番目
  REP(i,n){
    ans = min(l[i] + r[i+1], ans);
  }
  cout << ans << endl;
}



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

/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
 
 
ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/
/*
struct UnionFind{
    vector<int> par;
    vector<int> rank;
    vector<int> size;

    //こいつがいわゆるコンストラクタ
    //初期化している
    UnionFind(int N) : par(N),rank(N),size(N){
        for(int i=0;i<N;i++){
            par[i]=i;
            size[i]=1;
            rank[i]=0;
        }
    }

    int find(int x){
        if(x == par[x]) return x;
        return par[x] = find(par[x]);
    }


    void unite(int x, int y){
        int rx,ry;
        rx = find(x);
        ry = find(y);
        if(rx == ry){
            return;
        }
        else{
            if(rank[rx]<rank[ry]){
                par[rx]=ry;
                size[ry]+=size[rx];
            }
            else{
                par[ry]=rx;
                size[rx]+=size[ry];
                if(rank[rx]==rank[ry]){
                    rank[rx]++;
                }
            }
        }
    }


    bool same(int x,int y){
        return find(x) == find(y);
    }
};
*/
ll myabs(ll k){
    if(k<0){
        k=0-k;
    }
    return k;
}

int main(){
    ll N;
    cin>>N;
    vector<ll> x(N); 
    vector<ll> y(N);
    for(ll i=0;i<N;i++){
        cin>>x.at(i)>>y.at(i);
    }
    ll tmpa = 0;
    ll tmpb=0;
    ll tmpc = 0;
    ll tmpd = 0;
    // ll ans = 0;
    vector<ll> sa(N);
    vector<ll> wa(N);
    for(ll i=0;i<N;i++){
        sa.at(i)=x.at(i)-y.at(i);
        wa.at(i)=x.at(i)+y.at(i);
    }
    sort(sa.begin(),sa.end());
    tmpa = sa.at(0);
    reverse(sa.begin(),sa.end());
    tmpb = sa.at(0);
    tmpb = tmpb-tmpa;
    sort(wa.begin(),wa.end());
    tmpc = wa.at(0);
    reverse(wa.begin(),wa.end());
    tmpd = wa.at(0);
    tmpd = tmpd-tmpc;
    if(tmpd>tmpb){
        cout<<tmpd<<endl;
    }
    else{
        cout<<tmpb<<endl;
    }

    // for(ll i=0;i<N-1;i++){
    //     for(ll j=i+1;j<N;j++){
    //         tmpx = myabs(x.at(i)-x.at(j));
    //         tmpy = myabs(y.at(i)-y.at(j));
    //         tmp = tmpx + tmpy;
    //         if(ans<tmp){
    //             ans=tmp;
    //         }
    //     }
    // }
    // cout<<ans<<endl;
}

Measured memory_bytes: 9508
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define val first
#define place second
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18;
const int N = (int)2e5 + 100;
const int MAXA = (int)3e6;
pair<ll, int> arr[N];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // ifstream cin("input.txt");
    // ofstream cout("output.txt");


    ll w,h;
    cin >> w >> h;
    for(int i = 0;i < w;i++)cin >> arr[i].val,arr[i].place = 2;
    for(int i = 0;i < h;i++)cin >> arr[i + w].val,arr[i + w].place = 1;
    sort(arr,arr  + w + h);
    ll place1 = 0,place2 = 0;
    ll ans = 0;
    for(int i = 0;i < w + h;i++){
        if(arr[i].place == 1){
        ans += (max((w - place2 + 1), 0LL) * arr[i].val);
        place1++;
        }else{
        ans += (max((h - place1 + 1), 0LL) * arr[i].val);
        place2++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 6756
N = int(input())
abc = [list(map(int,input().split())) for i in range(N)]

dp = [[0 for _ in range(3)] for _ in range(N+1)]
dp[1][0] = abc[0][0]
dp[1][1] = abc[0][1]
dp[1][2] = abc[0][2]

for i in range(2,N+1):
    dp[i][0] = max(dp[i-1][1] + abc[i-1][0],dp[i-1][2] + abc[i-1][0])
    dp[i][1] = max(dp[i-1][0] + abc[i-1][1],dp[i-1][2] + abc[i-1][1])
    dp[i][2] = max(dp[i-1][0] + abc[i-1][2],dp[i-1][1] + abc[i-1][2])

print(max(dp[N]))

Measured memory_bytes: 47336
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0),cin.sync_with_stdio(0),cout.tie(0),cout.sync_with_stdio(0);
	int n;
	cin>>n;
	vector<int> v(n+1), m(n);
	for(int i=0;i<=n;i++)
		cin>>v[i];
	for(int i=0;i<n;i++)
		cin>>m[i];
	long long int res=0;
	for(int i=0;i<n;i++){
		int mi=min(m[i],v[i]);
		res+=mi;
		m[i]-=mi;
		v[i]-=mi;
		mi=min(m[i],v[i+1]);
		res+=mi;
		m[i]-=mi;
		v[i+1]-=mi;
	}
	cout<<res;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var ar = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var anss = new List<int>();

            int cd = 0;

            for(int i = 0; i < ar.Length-1; i++)
            {
                if (cd == 0)
                    cd = getCommonDividerS(ar[i + 0], ar[i + 1]);
                else
                    cd = getCommonDividerS(cd, ar[i + 1]);
            }

            anss.Add(cd);
            anss.Add(1);

            for (int v = 2; v < 100000000; v++)
            {
                if (v >= cd) break;
                if (cd % v == 0)
                {
                    anss.Add(v);
                }
            }
            anss.Sort();

            foreach (var v in anss)
            {
                Console.WriteLine(v);
            }
        }

        static int getCommonDividerS(int n, int m)
        {
            if (n > m)
                return getCommonDivider(n, m);
            else
                return getCommonDivider(m, n);
        }

        static int getCommonDivider(int n, int m)
        {
            if (m == 0) return n;
            int a = n % m;
            return getCommonDivider(m, a);
        }
    }
}

Measured memory_bytes: 6044
#include <iostream>
#include <vector>
#include <map>

using namespace std;

long long nr[100005];
bool ciur[3505];
vector <long long> prim;
map <long long , long long> M;
map <long long , long long> inv;
long long n;

long long put (long long cont , long long x){
    long long ret = 1;
    for (long long i=1; i<=cont; i++){
        ret *= x;
    }
    return ret;
}

void Ciur(){
    for (long long i=2; i<=3500; i++){
        if (ciur[i] == false){
            prim.push_back(i);
            for (long long j =i+i; j<=3500; j+=i){
                ciur[j] = true;
            }
        }
    }
}

void read(){
    cin>>n;
    for (long long i=1; i<=n; i++){
        cin>>nr[i];
    }
}

void norm(){
    for (long long i=1; i<=n; i++){
        long long cop = nr[i];
        for (auto &x : prim){
            if (x * x > nr[i]){
                break;
            }
            long long cont = 0;
            while (nr[i] % x == 0){
                cop /= x;
                nr[i] /= x;
                cont++;
            }
            nr[i] *= put(cont % 3 , x);
        }
        //inv_nr[i] = nr[i] * nr[i];
        M[nr[i]] ++;
        if (cop > 100000000){
            //cout<<"da"<<'\n';
            continue;
        }
        inv[nr[i]] = 1LL * nr[i] * nr[i];
        //cout<<nr[i]<<'\n';
    }
    //cout<<'\n';
}

void norm2(){
    for (auto &y : inv){
        for (auto &x : prim){
            if (1LL * x * x > y.second){
                break;
            }
            long long cont = 0;
            while (y.second % (1LL * x) == 0){
                y.second /= 1LL * x;
                cont++;
            }
            y.second *= 1LL * put(cont % 3 , x);
        }
        //cout<<"bla "<<y.first<<" "<<y.second<<'\n';
        //inv_nr[i] = nr[i] * nr[i];
        //cout<<y.first<<" "<<y.second<<'\n';
    }
}

void solve(){
    Ciur();
    read();
    norm();
    norm2();
    long long cont = n;
    for (auto &x : M){
        if (x.second == 0){
            continue;
        }
        //cout<<x.first<<" "<<x.second<<'\n';
        if (x.first == 1){
            cont -= x.second - 1;
        }
        else{
            //cout<<"min  "<<x.first<<" "<<x.second<<" "<<M[inv[x.first]]<<" "<<inv[x.first]<<'\n';
            cont -= min(x.second , M[inv[x.first]]);
            M[inv[x.first]] = 0;
        }
    }
    cout<<cont;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(NULL);

    solve();

    return 0;
}

Measured memory_bytes: 18048
import collections

N = int(input())
W = []
jud = 1

for _ in range(N):
    W.append(input())

c = collections.Counter(W)
ct = len(c)

for i in range(N-1):
    fst = W[i]
    fnl = W[i+1]
    if fst[-1] != fnl[0]:
        jud = 0

if ct != N:
    print("No")
elif jud == 0:
    print("No")
else: print("Yes")

Measured memory_bytes: 3316
#include<iostream>
#include<stack>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
	stack<int> S1;
	stack<pair<int,int> > S2;
	char ch;
	int sum=0;
	for(int i=0;cin>>ch;i++){
		if(ch=='\\')S1.push(i);
		else if(ch=='/' && S1.size()>0){
			int j=S1.top();S1.pop();
			sum+=i-j;
			int a=i-j;
			while(S2.size()>0 && S2.top().first>j){
				a+=S2.top().second;S2.pop();
			}
			S2.push(make_pair(j,a));
		}
			
	}
	vector<int> ans;
	while(S2.size()>0){
		ans.push_back(S2.top().second);S2.pop();
	}
	reverse(ans.begin(),ans.end());
	cout<<sum<<endl;
	cout<<ans.size();
	for(int i=0;i<ans.size();i++){
		cout<<" ";
		cout<<ans[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 100000000000
#define mod 1000000007
#define pll pair<long,long>
#define se second
#define fi first
#define pb push_back
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update>pllordered_set;


int main()
{
			ios_base::sync_with_stdio(false);
			cin.tie(NULL);
			ll n,m;
			cin>>n>>m;
			map<pair<ll,ll>,ll> edge;
			for(ll i=0;i<m;i++)
			{
				ll u,v;
				cin>>u>>v;
				edge[{u,v}]=1;
				edge[{v,u}]=1;
			}
			vector<ll> v1;
			for(ll i=1;i<=n;i++)
			{
				v1.pb(i);
			}
			ll cnt=0;
			do
			{
				ll c1=1;
				for(ll i=1;i<=n;i++)
				{
					if(edge[{v1[i],v1[i-1]}]==1)
						c1++;
				}
				if(c1==n)
					cnt++;
			}while(next_permutation(v1.begin()+1,v1.end()));
			cout<<cnt;
			
			
			
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;


int main(){
    int n;
    cin >> n;
    vector<ll>a(n),b(n),c(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n)cin>>c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll ans = 0;
    rep(i,n){
        ll x = b[i];
        ll u = lower_bound(a.begin(),a.end(),x)-a.begin();
        ll d = upper_bound(c.begin(),c.end(),x)-c.begin();
        ans += u*(n-d);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> df(N);
    vector<ll> db(N);
    df[0] = A[0];
    db[0] = A[N-1];
    rep(i, N-1) {
        df[i+1] = gcd(df[i], A[i+1]);
        db[i+1] = gcd(db[i], A[N-1-(i+1)]);
    }
    ll ma = 0;
    ma = max(ma, db[N-2]);
    ma = max(ma, df[N-2]);
    rep(i, N) {
        if (i - 1 >= 0 && N-1-i >= 0) {
            ma = max(ma, gcd(df[i-1], db[N-1-(i+1)]));
        }
    }
    print(ma);
    return 0;
}

Measured memory_bytes: 2560
import java.util.*;
public class Main{
public static void main(String arg[]){
	Scanner sc=new Scanner(System.in);
	int a=sc.nextInt();
	int count=0;
	int arr[]=new int[a];
	for(int i=0;i<a;i++)
		arr[i]=sc.nextInt();
	for(int i=0;i<a;i++){
		while(true){
			if(arr[i]%2==0){
				count++;
				arr[i]=arr[i]/2;
		}
		else break;
	}
	}
	System.out.println(count);
}
}

Measured memory_bytes: 36260
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int X;
	cin >> X;
	if (X == 7 || X == 5 || X == 3)cout << "YES";
	else cout << "NO";
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n;cin>>n;
    
    int result = 0;
    VI t(n);
    REP(i, n){
        cin >> t[i];
        result += t[i];
    }

    int m;cin>>m;
    REP(i, m){
        int p,x;cin>>p>>x;

        cout << result - (t[p-1]-x) << endl;
    }
  

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
#import numpy as np
#import math

#H1, M1, H2, M2, K = map(int, input().split())
# a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# c=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

N = int(input())
A = list(map(int, input().split()))
#T = input()

sum_a = sum(A)
count = 1
root_num = 1
count_leaf = 0

def calc_node_num(leaf_num, root_num, count_leaf, count):
    count_leaf += leaf_num
    next_root_num = min(root_num*2-leaf_num, sum_a-count_leaf)
    count += (next_root_num + leaf_num)
    return next_root_num, count_leaf, count
    

if (N==0)&(A[0]>0)&(A[0]<=1):
    print(A[0])
elif (N==0)&(A[0]==0):
    print(-1)
elif (N==0)&(A[0]>1):
    print(-1)
else:
    for i in range(1,N+1):
        root_num, count_leaf, count = calc_node_num(A[i], root_num, count_leaf, count)
        if A[0]>0:
            print(-1)
            break
        if (i<N)&(root_num==0):
            print(-1)
            break
        if root_num < 0:
            print(-1)
            break
    else:
        print(count)

Measured memory_bytes: 19904
#include<stdio.h>
#include<stdlib.h>
int a[200005],temp[200005];
int inc(const void *a, const void *b)
{
    return *(int*)a-*(int*)b;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    for(int i=0;i<n;i++)temp[i]=a[i];
    qsort(a,n,sizeof(int),inc);
    for(int i=0;i<n;i++)
    {
        if(temp[i]>=a[n/2])printf("%d\n",a[n/2-1]);
        else printf("%d\n",a[n/2]);
    }
}

Measured memory_bytes: 3820
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4") // wonderful

#include <bits/stdc++.h>
using namespace std;






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

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

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




    return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int[] A)
        {
            Array.Sort(A);
            return A[2] - A[0];
        }
        static void Main(string[] args)
        {
            int[] A = ReadInts();
            Console.WriteLine(Solve(A));
        }
    }
}


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

bool cmp(int a, int b)
{
    return a>b;
}

int main()
{
	int n;
  	cin>>n;
  	vector<int> cards(n,0);
  	int sum[4]={0};
  	for(int i=0 ; i<n ; ++i)
    {
		cin>>cards[i];
    }
  	sort(cards.begin(),cards.end(),cmp);
  	for(int i=0 ; i<n ; ++i)
    {
    	sum[i%2]+=cards[i];
    }
  	cout<<sum[0]-sum[1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    int n, k;
    cin >> n >> k;
    vector<int> arr(n);
    for(int i = 0; i < n; ++i){
        cin >> arr[i];
    }
    auto ok = [&arr, &k](int mx)->bool{
        ll cost = 0;
        for(int i = 0; i < (int)arr.size(); ++i){
            cost += (arr[i] + mx - 1) / mx - 1;
        }
        return cost <= k;
    };
    int left = 1;
    int right = *max_element(arr.begin(), arr.end());
    int ans = right;
    while(left <= right){
        int mid = left + (right - left) / 2;
        if(ok(mid)){
            ans = mid;
            right = mid - 1;
        }
        else {
            left = mid + 1;
        }
    }
    cout << ans << endl;
}

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

    solve();
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int r;
    cin >> r;
    cout << r * r << endl;
}

Measured memory_bytes: 3536
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;

signed main() {
	int N;
	cin >> N;
	vector<int>T(N);
	int sum = 0;
	rep(i, N) {
		cin >> T[i];
		sum += T[i];
	}
	int M;
	cin >> M;
	vector<int>P(M), X(M);
	rep(i, M)cin >> P[i] >> X[i];
	rep(i, M) {
		int ans = sum + X[i] - T[P[i] - 1];
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
mod = 10**9+7
n, a, b = map(int, input().split())
ans = pow(2, n, mod) - 1
nCa = 1
for i in range(n-a+1, n+1):
    nCa *= i
    nCa %= mod
for i in range(1, a+1):
    nCa *= pow(i, mod-2, mod)
    nCa %= mod
nCb = 1
for i in range(n-b+1, n+1):
    nCb *= i
    nCb %= mod
for i in range(1, b+1):
    nCb *= pow(i, mod-2, mod)
    nCb %= mod
ans -= (nCa + nCb)
ans %= mod
print(ans)

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

namespace ABC172
{

  class D
  {
  public:
    D() = default;
    ~D() = default;


    void Run()
    {
      int N = {};
      std::cin >> N;

      long long sum = 0;

      for (long long  i = 1; i <= N; ++i)
      {
        long long  max_k = N / i;
        sum += (i * (max_k + 1) * (max_k)) / 2;
      }

      std::cout << sum << std::endl;
    }
  };
}
int main()
{

  ABC172::D prob;
  prob.Run();

  return 0;
}



Measured memory_bytes: 3144
N = int(input())
l = list(map(int,input().split()))

for T in range(N-1):
    S1 = 0
    S2 = 0
    for i in range(T+1):
        S1 += l[i]
    for i in range(T+1,N):
        S2 += l[i]
    if T == 0:
        min = abs(S1-S2)
    elif abs(S1-S2) < min:
        min = abs(S1-S2)

print(min)


Measured memory_bytes: 3064
import bisect
N = int(input())
L = list(map(int, input().split()))
index = [-1 for i in range(2001)]
L.sort()

ans = 0
for i in range(N):
    for j in range(i+1,N):
        if index[L[i]+L[j]] == -1:
            index[L[i]+L[j]] = bisect.bisect_left(L, L[i]+L[j])
        ans += max(0, index[L[i]+L[j]]-j-1)
print(ans)

Measured memory_bytes: 43884