akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.buffer.readline
class SkewHeap:
  def __init__(self, init_val = None):
    self.val = init_val
    self.left = None
    self.right = None
    self.root = None
  def heapmeld(self, h1, h2):
    if h1 == None: return h2
    if h2 == None: return h1
    if h1.val > h2.val:
      h1.val, h1.left, h1.right, h2.val, h2.left, h2.right = h2.val, h2.left, h2.right, h1.val, h1.left, h1.right
    h1.right = self.heapmeld(h2, h1.right)
    h1.left, h1.right = h1.right, h1.left
    return h1
  def heappop(self):
    res = self.root.val
    self.root = self.heapmeld(self.root.left, self.root.right)
    return res
  def heappush(self, x):
    h = SkewHeap(x)
    self.root = self.heapmeld(self.root, h)
  def heaptop(self):
    return self.root.val
N, M = map(int, input().split())
a = list(map(int, input().split()))
h = SkewHeap()
res = 0
for e in a:
  h.heappush(-e)
for _ in range(M):
  h.heappush(-(-h.heappop() // 2))
for _ in range(N):
  res -= h.heappop()
print(res)



Measured memory_bytes: 115776
from itertools import product
A=int(input())
B=int(input())
C=int(input())
X=int(input())
ans=0
for a,b,c in product(range(0,A+1),range(0,B+1),range(0,C+1)):
  if X==500*a+100*b+50*c:
    ans+=1
print(ans)

Measured memory_bytes: 39536
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//using ll=long long;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//dp注意点
//問題の種類	 初期化する値	 備考
//最小化問題 	INF	
//最大化問題	    -INF	 テーブル全体で 00 以上の値しかとらないことがわかっていれば −1−1 でもいいですし、00 でもいい場合もあります
//数え上げ問題	00	
//確率問題	      00	
//Yes/No 判定問題	False
/*-------------ここまで---------------------------------------------*/

/*signed*/int main() {
    string s;
    cin >> s;
    for (int i = 1; i < 4; ++i) {
        if (s[i] == s[i - 1]){
            cout << "Bad" << endl;
            return 0;
    }
    }
    cout << "Good" << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;
	map<int,int> mp = {};
	rep(i,0,n){
		int a;
		cin >> a;
		mp[a]++;
	}
	
	int ans = 0;
	map<int,int> mp2 = mp;
	for(auto itr = mp.begin() ; itr != mp.end() ; itr++ ){
		//cout << itr->first << endl;
		int num = itr->second + mp2[itr->first + 1] + mp2[itr->first-1];
		ans = max(ans , num);
	}	
	P(ans);
	ret 0;
}

Measured memory_bytes: 7680
def make_divisors(n):
    divisors = {}
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors[i + n//i] = (i,n//i)

    #divisors.sort()
    score_sorted = sorted(divisors.items(), key=lambda x:x[0])
    return score_sorted

N = int(input())
num_dict = make_divisors(N)
print(num_dict[0][0]-2)

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

int main() {
  int m,d;cin>>m>>d;
  int cnt=0;
  for(int i=1;i<=m;i++)for(int j=22;j<=d;j++){
    if((j/10)*(j%10)==i&&j%10!=1)cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3544
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int **graph;
int n;

int *d;
int *f;
int time;

void _dfs(int idx) {
    d[idx] = ++time;

    for(int j = 0; j < n; j++) {
        if(graph[idx][j] && d[j] == 0) {
            _dfs(j);
        }
    }

    f[idx] = ++time;
}

void dfs() {
    for(int i = 0; i < n; i++) {
        if(f[i] == 0) {
            _dfs(i);
        }
    }
}

int main(void) {

    scanf("%d", &n);
    graph = malloc(n * sizeof(int*));
    for(int i = 0; i < n; i++) {
        graph[i] = malloc(n * sizeof(int));
        memset(graph[i], 0, n * sizeof(int));
    }
    d = malloc(n * sizeof(int));
    memset(d, 0, n * sizeof(int));
    f = malloc(n * sizeof(int));
    memset(f, 0, n * sizeof(int));

    for(int i = 0; i < n; i++) {
        int uIdx;
        int deg;
        scanf("%d %d", &uIdx, &deg);
        for(int j = 0; j < deg; j++) {
            int vIdx;
            scanf("%d", &vIdx);
            graph[uIdx - 1][vIdx - 1] = 1;
        }
    }

    dfs();
    
    for(int i = 0; i < n; i++) {
        printf("%d %d %d\n", i + 1, d[i], f[i]);
    }

    for(int i = 0; i < n; i++) {
        free(graph[i]);
    }
    free(graph);
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  map<int, int> a;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    a[x]++;
  }
  int ans = 0;
  for (auto x : a) {
    if (x.second > x.first) ans += (x.second - x.first);
    else if (x.second < x.first) ans += x.second;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7952
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			int[] array = new int[N];
			
			for(int i = 0; i < N; i++) {
				array[i] = sc.nextInt();
			}
			
			int r = 0, xor = 0;
			
			long answer = 0;
			for(int l = 0; l < N; l++) {
				
				while(r < N && (xor & array[r]) == 0) {
					xor ^= array[r];
					r++;
				}
				
				//System.out.println(l + " " + r);
				answer += (r - l);
				xor ^= array[l];
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

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

	int N; cin >> N;
	
	int ans=0, mnum = INT_MAX;
	int x;
	rep(i, N) {
		cin >> x;
		if (x<mnum) {
		 ++ans;
		 mnum = x;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  string ret;
  int x = max({a, b, c});
  int y = min({a, b, c});
  if ((x == 7) && (y == 5) && ((a + b + c) - (x + y) == 5)) {
    ret = "YES";
  } else {
    ret = "NO";
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	int A,B,C,K;	cin>>A>>B>>C>>K;
	while(B<=A){
		B*=2;
		K--;
		if(K<0){
			cout<<"No"<<endl;
			return 0;
		}
	}
	while(C<=B){
		C*=2;
		K--;
		if(K<0){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


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

int main()
{
	int r, g, b;

	cin >> r >> g >> b;

	if ((100 * r + 10 * g + 1 * b) % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
S = str(input())

# dp[i][j] := i文字目（1-index)まで割り算した余りがjになるような'?'の置き換えが何通りあるか。
dp = [[0]*13 for _ in range(100001)]

S_length = len(S)
MOD = 1000000007
dp[0][0] = 1  # dpの初期化。0文字目までの割り算の余りが0になるような置き換えが1通りあると考える。

# 今、計算をしているのがi文字目, dpのiは1-indexだが、Sへのアクセスは0インデックスで行う
for i in range(1, S_length+1):
    for remain in range(13):  # i-1文字目まで計算した余りを決め打ちしているループ変数remain
        if S[i-1] == '?':  # i文字目が'?'であったらそれぞれをjに置き換えて計算
            for j in range(10):
                next_remain = (remain*10+j) % 13  # (i-1)文字目までの余りがremainで，i文字目の'?'に置き換えた場合の，i文字目まで計算した余り

                # dpの遷移
                dp[i][next_remain] += dp[i-1][remain]
                dp[i][next_remain] %= MOD
        else:
            next_remain = (remain*10 + int(S[i-1])) % 13
            # dpの遷移
            dp[i][next_remain] += dp[i-1][remain]
            dp[i][next_remain] %= MOD

print(dp[S_length][5])  # 答えはS_length文字目(つまり最後の文字)まで計算した余りが5になるような'?'の置き換えが何通りあるか


Measured memory_bytes: 61916
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    static String[] chr = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" };
    static Queue<String> queue = new PriorityQueue<>();

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<String> list = new ArrayList<>();
        dfs(n, list, 'a');
    }

    static void dfs(int n, List<String> list , char mx) {
        if (list.size() == n) {
            System.out.println(convertListToString(list));
            return;
        }
        for (char c = 'a' ; c <= mx; c++) {
            list.add(String.valueOf(c));
            dfs(n, list, (c == mx ? (char) (mx + 1) : mx));
            list.remove(list.size() - 1);
        }
    }

    static String convertListToString(List<String> list) {
        StringBuilder sb = new StringBuilder();
        for (String x : list) {
            sb.append(x);
        }
        return sb.toString();
    }

}

Measured memory_bytes: 47972
#include <iostream>
#include <cstdio>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <string>
#include <ctype.h>

using namespace std;

void solve()
{
	string s;
	getline(cin, s);
	for (int i = 0; i < s.size(); ++i)
	{
		if ('a' <= s[i] && s[i] <= 'z')
		{
			cout << char(toupper(s[i]));
		}
		else if ('A' <= s[i] && s[i] <= 'Z')
		{
			cout << char(tolower(s[i]));
		}
		else
		{
			cout << s[i];
		}
	}
	cout << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1176
N, M, X, Y = map(int, input().rstrip().split())
x = [int(_) for _ in input().rstrip().split()]
y = [int(_) for _ in input().rstrip().split()]

Flag = False
for z in range(X+1, Y+1):
    if max(x) < z and min(y) >= z:
        Flag = True

if Flag:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3060
/*@author hussein zayed ;
    ___  ___
   |\  \|\  \
   \ \  \_\  \
    \ \   ___ \USSEIN
     \ \  \\ \ \
      \ \__\\ \_\
       \|__| \|__|
****************************************
*/

#include <bits/stdc++.h>
using namespace std;
#define fr for(int i=0;i<n;++i)
#define fr1 for(int i=1;i<=n;++i)
#define cinA for(int i=0;i<n;++i){cin>>arr[i];}
#define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
#define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
#define ll long long
#define lnarray sizeof(arr)/sizeof(*arr)
#define vi vector<int>
#define vs vector<string>
void Fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int RD()
{
    int i ;
    cin>>i;
    return i;
}

inline float RF()
{
    float i ;
    cin>>i;
    return i;
}

inline double RDO()
{
    double i ;
    cin>>i;
    return i;
}

inline string RS()
{
    string i ;
    cin>>i;
    return i;
}

inline ll RLL()
{
    ll i ;
    cin>>i;
    return i;
}

int cm[200000];

ll sumSet(ll n)
{
    return (1ll*n*(n+1))/2;
}
string s;


bool isPrime(int n)
{
    if(n==1)
        return false;
    for(int i=2; i*i<=n; ++i)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int sumDigit(int n){
int sum =0;
  while (n != 0)
    {
        sum+= + n % 10;
        n = n / 10;
    }
    return sum;
}

ll power2(int n){
  ll ans=(1<<n);
  return ans;
}

ll sumpow2(ll n){
 ll sum=(n*(n+1)*(2*n-1))/6;
 return sum;
}

int main(){
    Fast();
//freopen("output.txt" , "w" , stdout);
//freopen("wall.in" , "r" , stdin);
int n=RD();
    ll arr[n];
    cinA
    int  cont = 0;
    bool flg = true;
    while (flg == true) {
        fr {
            if (arr[i] % 2 == 0) {
                arr[i] /= 2;
            } else {
                flg = false;
            }
        }
        if (flg == true)
        cont++;
    }

    cout <<cont<<"\n";

    return 0;
 }








Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

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

    int h, w;
    cin >> h >> w;
    vector< string > field(h, string(w, '.'));
    queue< pair<int, int> > q;
    rep (i, h)
    {
        rep (j, w)
        {
            cin >> field[i][j];
            if (field[i][j] == '#') q.push(pair<int, int>{i, j});
        }
    }

    int ans = -1;
    int dy[] = {-1, 0, 1, 0};
    int dx[] = {0, -1, 0, 1};
    while (!q.empty())
    {
        ++ans;
        int s = q.size();
        rep (j, s)
        {
            pair<int, int> p = q.front(); q.pop();
            int y = p.first;
            int x = p.second;
            rep (i, 4)
            {
                int ny = y + dy[i];
                int nx = x + dx[i];
                if (IN(0, h, ny) && IN(0, w, nx) && field[ny][nx] != '#')
                {
                    q.push(pair<int, int>{ny, nx});
                    field[ny][nx] = '#';
                }
            }
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 9488
using System;

namespace std {
    class Test {
         static void Main(string[] args){
            var input = Console.ReadLine();
            var n = int.Parse(input);
        var anInstanceofMyClass = new Test();
       
           for(int i = 3; i <= n; i++) {
               
                if(anInstanceofMyClass.Mul_of_3(i) == true || anInstanceofMyClass.Mul_with_3(i) == true) {
                    Console.Write(" " +  i);
                } 
           
           }
             Console.WriteLine("");

        }
        public bool Mul_of_3(int i) {
          return i % 3 == 0;　//   3の倍
        }
        public bool Mul_with_3(int i) {
            int num = i;
            for (; num != 0; ) {
               
                if (num % 10 == 3) return true;
                num /= 10;
            }

            return false;
        }
        public int Digit(int num) {
            int digit = 1;
            for (int i = num; i >= 10; i /= 10) {
                digit++;
            }
            return digit;
}
    }
}


Measured memory_bytes: 8268
//file_name:ABC58_D.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    ll mod = 1000000007;
    int n,m;
    scanf("%d%d",&n,&m);
    ll x[n] = {};
    rep(i,n){
        scanf("%lld",&x[i]);
    }
    ll y[m] = {};
    rep(i,m){
        scanf("%lld",&y[i]);
    }
    ll yoko = 0;
    ll now = x[0];
    ll wa = 0;
    srep(i,1,n){
        yoko += (x[i]-now)*i;
        yoko += wa;
        wa += (x[i]-now)*i;
        now = x[i];
        yoko %= mod;
        wa %= mod;
    }



    ll ans = 0;

    wa = 0;
    now = y[0];
    srep(i,1,m){
        ans += (((y[i]-now)*i+wa)%mod)*yoko;
        ans %= mod;
        wa += (y[i]-now)*i;
        wa %= mod;
        now = y[i];
    }

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



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

int main(){
    long long int a,b,c,k;
    cin >> a>>b>>c>>k;
    
    if(a>=k){
        cout << k << endl;
    }else if(a<k && k<=a+b){
        cout << a << endl;
    }else{
        cout << a - (k-a-b) << endl;
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
int dp[N],a[N];
int n,k;
int play(int l){
    if(dp[l]!=-1)   return dp[l];
    if(l==0)        return 0;
    int state = 0;
    for(int i=1;i<=n;i++){
        if(a[i]>l)  continue;
        if(play(l-a[i]) == 0){
            state = 1;
            break;
        }
    }
    return dp[l] = state;
}
int main(){
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++)    scanf("%d",&a[i]);
    memset(dp,-1,sizeof dp);
    if(play(k)) printf("First\n");
    else        printf("Second\n");
    return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long

const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;

struct UnionFind {
    vector<int> d;
    UnionFind(int n): d(n,-1) {}
    int root(int x) {
        if (d[x] < 0) return x;
        return d[x] = root(d[x]);
    }
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x,y);
            d[x] += d[y];
            d[y] = x;
            return true;
        }
    bool same(int x, int y) { return root(x) == root(y); }
    int size(int x) { return -d[root(x)];}
};

int deg[100005];
vector<int> to[100005];

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;
        --a; --b;
        deg[a]++;
        deg[b]++;
        uf.unite(a,b);
    }
    for(int i = 0; i < k; i++){
        int c, d; cin >> c >> d;
        --c; --d;
        to[c].push_back(d);
        to[d].push_back(c);
    }
    for(int i = 0; i < n; i++){
        int ans = uf.size(i) - 1 - deg[i];
        for (int u : to[i]) {
            if (uf.same(i,u)) --ans;
        }
        printf("%d%c", ans, i == n - 1 ? '\n' : ' ');
    }

    return 0;
}


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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;

bool isPrime[maxn];
vector< int >primes;

void sieve(){
    memset(isPrime, 1 , sizeof(isPrime));

    isPrime[0]=isPrime[1]=0;

    for(int i=3 ; i*i<=maxn ; i+=2){
        if(isPrime[i]){
            for(ll k=i*1LL*i ; k<=maxn ;k+=i){
                isPrime[k]=0;
            }
        }
    }

    primes.pb(2);
    for(int i=3 ; i<=maxn ; i+=2){
        if(isPrime[i]){
            //cout <<i<<" ";
            primes.pb(i);
        }
    }
    //cout << endl;
}

ll divisors(int n){


    ll ans=1LL;
    for(int i=0 ; i<primes.size() && primes[i]<=n ; i++){
        int p=primes[i];

        ll cnt=0LL;
        while(p<=n){
            cnt = cnt + (n/p);
            p = p*primes[i];
        }

        ans = (ans * (cnt+1)%MOD)%MOD;
    }

    return ans;
}


int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    sieve();

    int n;
    cin >> n;

    cout << divisors(n) << endl;

    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b && a!=c || a==c && a!=b || b==c && a!=b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 384
from heapq import heapify, heappop, heappush
N=int(input())
A=list(map(int, input().split()))

class MaxHeap:
    def __init__(self, li):
        self.hp = []
        for e in li:
            heappush(self.hp, -e)

    def push(self, x):
        heappush(self.hp, -x)

    def pop(self):
        ret = heappop(self.hp)
        ret *= -1
        return ret

    def seak(self):
        return -self.hp[0]

    def sum(self):
        return -sum(self.hp)

A1=A[:N]
A2=A[N:2*N]
A3=A[2*N:]

heapify(A1)
A1_sum=sum(A1)
A1_li=[A1_sum]
for a in A2:
  heappush(A1, a)
  p=heappop(A1)
  A1_sum+=a-p
  A1_li.append(A1_sum)
  
A3_sum=sum(A3)
A3=MaxHeap(A3)

A3_li=[A3_sum]
for a in A2[::-1]:
  A3.push(a)
  A3_sum+=a
  p=A3.pop()
  A3_sum-=p
  A3_li.append(A3_sum)
  
A3_li=A3_li[::-1]  
ans=False
for a1, a3 in zip(A1_li, A3_li):
  if not ans:
    ans=a1-a3
  else:
    ans=max(ans, a1-a3)
print(ans)

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back

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

    ll N = SZ(S);
    mat dp(N+1, vec(13, 0));
    S = "0" + S;
    
    if(S[1] == '?') {
        REP(i,0,10) dp[1][i] = 1;
    }
    else dp[1][S[1]-'0'] = 1;
    REP(i,2,N+1) {
        if(S[i] == '?') {
            REP(j,0,13) {
                REP(k,0,10) {
                    dp[i][(10*j+k)%13] += dp[i-1][j];
                    dp[i][(10*j+k)%13] %= MOD;
                }
            }
        }
        else {
            REP(j,0,13) {
                dp[i][(10*j+(S[i]-'0'))%13] += dp[i-1][j];
                dp[i][(10*j+(S[i]-'0'))%13] %= MOD;
            }
        }
    }

    PR(dp[N][5]);

    return 0;
}

/*



*/

Measured memory_bytes: 13696
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    intmax_t N;
    char S[4001];
    intmax_t rs[4001] = {}, gs[4001] = {}, bs[4001] = {};
    size_t rn = 0, gn = 0, bn = 0;
    intmax_t ans = 0;

    scanf("%jd", &N);
    scanf("%s", S);

    if (S[0] == 'R') {
        rn++;
        rs[0]++;
    } else if (S[0] == 'G') {
        gn++;
        gs[0]++;
    } else if (S[0] == 'B') {
        bn++;
        bs[0]++;
    }

    for (size_t i = 1; i < N; i++) {
        rs[i] = rs[i - 1];
        gs[i] = gs[i - 1];
        bs[i] = bs[i - 1];
        if (S[i] == 'R') {
            rn++;
            rs[i]++;
        } else if (S[i] == 'G') {
            gn++;
            gs[i]++;
        } else if (S[i] == 'B') {
            bn++;
            bs[i]++;
        }
    }

    for (size_t i = 0; i < N; i++) {
        if (S[i] == 'R') {
            for (size_t j = i + 1; j < N; j++) {
                if (S[j] == 'G') {
                    ans += bn - bs[j];
                    if ((j + (j - i) < N) && (S[j + (j - i)] == 'B'))
                        ans--;
                } else if (S[j] == 'B') {
                    ans += gn - gs[j];
                    if ((j + (j - i) < N) && (S[j + (j - i)] == 'G'))
                        ans--;
                }
            }
        } else if (S[i] == 'G') {
            for (size_t j = i + 1; j < N; j++) {
                if (S[j] == 'R') {
                    ans += bn - bs[j];
                    if ((j + (j - i) < N) && (S[j + (j - i)] == 'B'))
                        ans--;
                } else if (S[j] == 'B') {
                    ans += rn - rs[j];
                    if ((j + (j - i) < N) && (S[j + (j - i)] == 'R'))
                        ans--;
                }
            }
        } else if (S[i] == 'B') {
            for (size_t j = i + 1; j < N; j++) {
                if (S[j] == 'R') {
                    ans += gn - gs[j];
                    if ((j + (j - i) < N) && (S[j + (j - i)] == 'G'))
                        ans--;
                } else if (S[j] == 'G') {
                    ans += rn - rs[j];
                    if ((j + (j - i) < N) && (S[j + (j - i)] == 'R'))
                        ans--;
                }
            }
        }
    }

    printf("%jd\n", ans);

    return 0;
}


Measured memory_bytes: 2252
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define ss second
#define mod 100000000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl

#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int,int> &a,
             const pair<int,int> &b)
{
    if(a.ff == b.ff) {
        return (b.ss < a.ss);
    }
    return (a.ff<b.ff);
}
bool prime[1000];
void SieveOfEratosthenes(int n) 
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.

    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
void showq(queue <pii> gq) 
{ 
    queue <pii> g = gq; 
    while (!g.empty()) 
    { 
        cout  << g.front().ff << " " << g.front().ss << ","; 
        g.pop(); 
    } 
    cout << '\n'; 
} 
int f[1001][1001];
int32_t main()
{
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    /********************* From here ***********************/
    int h,w;
    cin >> h >> w;
    queue<pii >q;
    int cnt = 0;
    rep(i, 0, h){
        rep(j, 0, w){
            char c;
            cin >> c;
            if(c == '#'){
                f[i][j] = 1;
                q.push(mp(i, j));
                cnt++;
            }
        }
    }
    int ans = 0;

    while(cnt<h*w){
        ans++;
        int s = q.size();
        rep(i, 0, s){
            pii fr = q.front();
            q.pop();
            int x = fr.ff;
            int y = fr.ss;

            rep(j, 0, 4){
                int nx = x+dx[j];
                int ny = y+dy[j];
                if(nx>=0 && ny>=0 && nx<h && ny<w &&f[nx][ny]==0){
                    f[nx][ny] = 1;
                    q.push(mp(nx, ny));
                    cnt++;
                }
            }

            //trace4(x, y, ans, cnt);
        }
    }

    cout << ans << endl;
}



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

int main(){
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

	int n,k;
	cin >> n >> k;
	int a[n],dp[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
		dp[i]=INT_MAX;
	}
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=1;j<=k;j++)
			if(i+j<n) dp[i+j]=min(dp[i+j],abs(a[i+j]-a[i])+dp[i]);
	}
	cout << dp[n-1];	


 
 
	
 
}

Measured memory_bytes: 1024
import numpy as np
def dist(y, z):
    y = np.array(y)
    z = np.array(z)
    return (sum((y - z) **2)) ** (0.5)

def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

def resolve():
    N, D = list(map(int, input().split()))
    X = []
    for _ in range(N):
        X.append(list(map(int, input().split())))
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            if is_integer(dist(X[i], X[j])):
                ans+=1
    print(ans)
    return
resolve()

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

int main(){
    int N;
    cin >> N;
    string str = to_string(N);
    if(str[str.size()-1] == '3'){
        cout << "bon" << endl;
        return 0;
    }else if(str[str.size()-1] == '2' || str[str.size()-1] == '4' || str[str.size()-1] == '5' || str[str.size()-1] == '7' || str[str.size()-1] == '9'){
        cout << "hon" << endl;
        return 0;
    }else {
        cout << "pon" << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int a,b;
    string name;
    for(int i=0; i<9; i++){
        cin >> name >> a >> b;
        cout << name << " "<< a+b <<" "<< a*200+b*300 <<endl;
    }
    
}



Measured memory_bytes: 3040
#include <stdio.h>
#define TMAX 100001
#define THALF 50000

void fill(int *p, int T, int d)
{
	int i;
	for(i=0; i<T; i++){
		*(p+i) = d;
	}
}
void stak(int *p, int head, int end, int d)
{
	int i;
	for(i=head; i<end; i++){
		*(p+i) += d;
	}
}

int main(void){
    int N, T, t[TMAX], entry, exit, d, sw, max=0, i, j;
    scanf("%d%d", &N, &T);
	scanf("%d%d", &entry, &exit);
	sw = (THALF > exit-entry ? 1 : 2);
	switch(sw){
		case 1:
			fill(t, T, 0);
			stak(t, entry, exit, 1);
			for(i=1; i<N; i++){
				scanf("%d%d", &entry, &exit);
				stak(t, entry, exit, 1);
    		}
		    for(j=0; j<T; j++){
		        max = (max < *(t+j) ? *(t+j) : max);
		    }
			break;
		case 2:
			fill(t, T, N);
			stak(t, 0, entry, -1);
			stak(t, exit, T, -1);
			for(i=1; i<N; i++){
				scanf("%d%d", &entry, &exit);
				stak(t, 0, entry, -1);
				stak(t, exit, T, -1);
			}
			for(j=0; j<T; j++){
				max = (max < *(t+j) ? *(t+j) : max);
			}
			break;
		default:
			break;
	}
    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 992
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  vector<Int> t(n),d(n);
  for(Int i=0;i<n;i++) cin>>t[i]>>d[i],t[i]--;
  {
    using P = pair<Int, Int>;
    vector<P> vp;
    for(Int i=0;i<n;i++) vp.emplace_back(d[i],t[i]);
    sort(vp.rbegin(),vp.rend());
    for(Int i=0;i<n;i++) tie(d[i],t[i])=vp[i];    
  }
  
  priority_queue<Int, vector<Int>, greater<Int> > pq;

  Int res=0;
  vector<Int> used(n,0);
  for(Int i=0;i<k;i++){
    if(used[t[i]]) pq.emplace(d[i]);
    used[t[i]]=1;
    res+=d[i];
  }
  Int cnt=0;
  for(Int i=0;i<n;i++) cnt+=used[i];

  Int ans=res+cnt*cnt;
  for(Int i=k;i<n;i++){
    if(used[t[i]]) continue;
    if(pq.empty()) break;
    used[t[i]]=1;
    cnt++;
    res-=pq.top();pq.pop();
    res+=d[i];
    chmax(ans,res+cnt*cnt);
  }  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
const double eps = 1e-9;

int n,l;
string s, aux = "";
vector<string>v;

int32_t main()
{
	cin >> n >> l;
	for(int i=0; i<n; i++)
	{
		cin >> s;
		v.push_back(s);
	}
	
	sort(v.begin(), v.end());
	
	for(auto w : v)
		aux += w;
		
	cout << aux << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#define INF 999999
#define fst first
#define snd second
#define MAX 32
using namespace std;
typedef pair<int,int> P;
typedef unsigned long long ll;

int w,h,d[MAX][MAX],dx[4]={1,0,-1,0},dy[4]={0,1,0,-1},sx,sy;
char maze[MAX][MAX];
	
void bfs(){
	int i,j;
	queue<P> que;
	for(i=0;i<h;i++)for(j=0;j<w;j++)d[i][j]=0;
	que.push(P(sx,sy));
	while(que.size()){
		P p=que.front();
		que.pop();
		if(maze[p.fst][p.snd]=='#'||d[p.fst][p.snd])continue;
		d[p.fst][p.snd]=1;
		for(i=0;i<4;i++){
			int nx=p.fst+dx[i],ny=p.snd+dy[i];
			if(0<=nx&&nx<h&&0<=ny&&ny<w){
				que.push(P(nx,ny));
			}
		}
	}
}
	
int main(){
	int i,j,t;
	while(1){
		scanf("%d %d",&w,&h);
		getchar();
		if(w==0&&h==0)break;
		t=0;
		for(i=0;i<MAX;i++)for(j=0;j<MAX;j++)maze[i][j]='\0';
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				scanf("%c",&maze[i][j]);
				if(maze[i][j]=='@'){
					sx=i;
					sy=j;
				}
			}
			getchar();
		}
		bfs();
		for(i=0;i<h;i++)for(j=0;j<w;j++)t+=d[i][j];
		printf("%d\n",t);
	}
}

Measured memory_bytes: 1220
O = input()
E = input()
Ol = len(O)
El = len(E)
alllen = Ol + El
num = 0
num_2 = 0
pw = ""
for i in range(alllen):
  if i % 2 == 0:
    pw+=O[num]
    num+=1
  else:
    pw+=E[num_2]
    num_2+=1
print(pw)


Measured memory_bytes: 8984
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
using namespace std ;

#define MAXN 500007

int st ;
int n ;
int a[ MAXN ] ;

set < pair < int , int > > s[ MAXN ] ;

void input ( ) {
    scanf ( "%d" , &st ) ;
    n = (1<<st) ;
    int i ;
    for ( i = 0 ; i < n ; i ++ ) {
        scanf ( "%d" , &a[ i ] ) ;
    }
}

void solve ( ) {
    int i , j , t ;
    for ( i = 0 ; i < n ; i ++ ) {
        s[ i ].insert ( make_pair ( a[ i ] , i ) ) ;
    }
    for ( i = 0 ; i < n ; i ++ ) {
        for ( j = 0 ; j < st ; j ++ ) {
            if ( (i&(1<<j)) != 0 ) { continue ; }
            for ( auto it = s[ i ].begin ( ) ; it != s[ i ].end ( ) ; it ++ ) {
                s[ (i|(1<<j)) ].insert ( (*it) ) ;
            }
            while ( s[ (i|(1<<j)) ].size ( ) > 2 ) {
                s[ (i|(1<<j)) ].erase ( s[ (i|(1<<j)) ].begin ( ) ) ;
            }
        }
    }
    int ans = 0 ;
    for ( i = 1 ; i < n ; i ++ ) {
        int cur = 0 ;
        if ( s[ i ].size ( ) >= 2 ) {
            auto it = s[ i ].begin ( ) ;
            cur = (*it).first ;
            it ++ ;
            cur += (*it).first ;
        }
        if ( ans < cur ) { ans = cur ; }
        printf ( "%d\n" , ans ) ;
    }
}

int main ( ) {
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 52224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = int.Parse(ReadLine());
        var a = ReadLine().Split().Select(x => int.Parse(x) / 400).ToArray();
        var color = new bool[8];
        var wild = 0;
        for(int i = 0; i < n; i++)
        {
            if(a[i] < 8)
                color[a[i]] = true;
            else
                wild++;
        }
        var min = color.Count(x => x == true);
        var max = min + wild;
        if(min == 0 && max != 0)
            min = 1;
        WriteLine($"{min} {max}");
    }
}



Measured memory_bytes: 19044
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> v(n + 1, 1LL << 60);
    REP(i, 1, n) {
        cin >> v[i];
    }
    ll ans = 0;
    REP(i, 0, n) {
        ans += min(v[i], v[i + 1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

int main() {
  int N;
  double d, x;

  scanf("%d%lf%lf", &N, &d, &x);

  double res = 0;

  while (N) {
    res += d + (N - 0.5) * x;
    d += d / N + 5 * x / 2.0 / N;
    x += 2 * x / N;
    N--;
  }

  printf("%.10lf\n", res);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

void swap(int *a, int *b) {
  int tmp;

  tmp = *a;
  *a = *b;
  *b = tmp;
}

void sort(int *array) {
  int i, j;

  for (i = 0; i < 3; i++)
    for (j = i + 1; j < 3; j++)
      if (array[i] < array[j])
        swap(&array[i], &array[j]);
}

char *discriminateTriangle(int *array) {
  if (array[0] * array[0] == array[1] * array[1] + array[2] * array[2])
    return "YES";
  else
    return "NO";
}

int main(void) {
  int buf[5];
  int input[3];
  int i, n;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d %d %d", &input[0], &input[1], &input[2]);
    sort(input);
    printf("%s\n", discriminateTriangle(input));
  }
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> mon(n+1);
  for(int i=0; i<n+1; ++i){
    cin >> mon.at(i);
  }
  long long ans=0;
  for(int i=0; i<n; ++i){
    int b;
    cin >> b;
    if(b <= mon.at(i)){
      ans += b;
    } else {
      if(b >= mon.at(i)+mon.at(i+1)){
        ans += mon.at(i)+mon.at(i+1);
        mon.at(i+1) = 0;
      } else {
        ans += b;
        mon.at(i+1) -= b - mon.at(i);
      }
    }
    //cout << ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<cstdlib>
#include<cstring>

typedef struct tree{
    struct tree *parent;
    struct tree *child;
    struct tree *next; // element next to child
    int order;
    int depth;
    char kind[14];
} TREE;

int CulcDepth(TREE*);

int main(){
    int i, j, n, NOFchild, curorder, order, nextorder;
    TREE *T , Nil, *tmp;
    
    scanf("%d", &n);
    T = (TREE *)malloc(sizeof(TREE) * n);
    
    // input
    for (i = 0; i < n; i++) {
        scanf("%d %d", &curorder, &NOFchild);
        T[curorder].order = curorder;
        strcpy(T[curorder].kind, "leaf");
        T[curorder].child = NULL;
        T[curorder].depth = -1;
        if (NOFchild == 0) {
            continue;
        }
        
        strcpy(T[curorder].kind, "internal node");
        // 一つ目の子nodeを接続
        scanf("%d", &order);
        T[curorder].child = &T[order];
        T[order].parent = &T[curorder];
        if (NOFchild == 1) {
            T[curorder].child->next = NULL;
            continue;
        }
        // 二つ目
        scanf("%d", &nextorder);
        T[curorder].child->next = &T[nextorder];
        T[nextorder].parent = &T[curorder];
        if (NOFchild == 2) {
            T[curorder].child->next->next = NULL;
            continue;
        }
        
        // 三つ目以降
        order = nextorder;
        for (j = 0; j < NOFchild-2; j++) {
            scanf("%d", &nextorder);
            T[order].next = &T[nextorder];
            T[nextorder].parent = &T[curorder];
            order = nextorder;
        }
        T[nextorder].next = NULL;
        
    }
    
    Nil.order = -1;
    // rootnodeとNilnodeを接続
    // parent == NULLのnodeはroot node
    for (i = 0; i < n; i++) {
        if (T[i].parent == NULL) {
            strcpy(T[i].kind, "root");
            Nil.child = &T[i];
            T[i].parent = &Nil;
            break;
        }
    }
    
    // depth求める
    T[i].depth = 0; // root node
    CulcDepth(T[i].child);
    
    
    
    // output
    for (i = 0; i < n; i++) {
        printf("node %d: ", i);
        
        printf("parent = %d, ", T[i].parent->order);
        
        printf("depth = %d, ",T[i].depth);
        
        printf("%s, ", T[i].kind);
        
        printf("[");
        if (T[i].child != NULL) {
            for (tmp = T[i].child; tmp != NULL; tmp = tmp->next) {
                printf("%d", tmp->order);
                //printf(" /test/ ");
                if(tmp->next == NULL){
                    break;
                }
                printf(", ");
            }
        }
        printf("]");
        
        printf("\n");
    }
    
    
    free(T);
    return 0;
}

int CulcDepth(TREE *T){
    if (T == NULL) {
        return 0;
    }
    T->depth = T->parent->depth + 1;
    CulcDepth(T->child);
    CulcDepth(T->next);
    
    return 0;
}


















Measured memory_bytes: 8636