akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	string s, a;
	cin >> s;
	int64_t n = s.size() - 2, count = 1000, b;
	for (int i = 0; i < n; i++) {
		a = s.at(i);
		a += s.at(i + 1);
		a += s.at(i + 2);
		b = stoi(a);
		if (b < 753){
			count = min(count, 753 - b);
		}
		else if (b > 753) {
			count = min(count, b - 753);
		}
		else {
			count = 0;
			break;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iterator>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

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


#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

const int Nsize = 200001;
vector<long long> point(Nsize + 1, 0);
vector<vector<int>> tree(Nsize + 1, vector<int>(0));
vector<long long> ans(Nsize + 1, 0);

int add(int index) {
	int Nleaf = tree[index].size();
	ans[index] += point[index];
	//cout << "I am point " << index << endl;
	//cout << "I have " << Nleaf << " leaf" << endl;
	rep(i, Nleaf) {
		int next = tree[index][i];
		//cout << "leaf " << i << " = point " << next << endl;
		point[next] += point[index];
		add(next);
	}
	return 0;
}

int main() {
	int N, Q;
	int a, b, p, x;

	cin >> N >> Q;
	rep(i, N - 1) {
		cin >> a >> b;
		tree[a].pb(b);
	}

	rep(i, Q) {
		cin >> p >> x;
		point[p] += x;
	}
	add(1);

	cout << ans[1];
	for (int i = 2; i <= N; ++i) {
		cout << " " << ans[i];
	}

	return 0;
}

Measured memory_bytes: 25856
def solve():
    N = int(input())
    A = list(map(int,input().split()))
    A = [0] + A + [0]

    sm = 0
    for i in range(N+1):
        sm += abs(A[i] - A[i+1])

    ans = []
    for i in range(1,N+1):
        res = sm - (abs(A[i]-A[i-1])+abs(A[i+1]-A[i])) + abs(A[i+1]-A[i-1])
        ans.append(res)

    print(*ans,sep='\n')

if __name__ == '__main__':
    solve()

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

string S;

int main() {
    cin >> S;

    int ans = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == '1') ans++;
    }

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


Measured memory_bytes: 256
import java.util.stream.*;
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        System.out.println(Arrays.equals(IntStream.range(0, 3).map(i -> scanner.nextInt()).sorted().toArray(), new int[]{5, 5, 7}) ? "YES" : "NO");
    }
}

Measured memory_bytes: 27220
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int n, k;
int a[N];

int32_t main()
{
	IOS;
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	int ans = 0;
	for(int i = 1; i <= k; i++)
		ans += a[i];
	cout << ans;
	return 0;
}

Measured memory_bytes: 3656
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, const char* argv[]) {
  int a, b, c;

  cin >> a >> b;

  if(a < b){
    c = a;
    for (int i = 0; i < b-1; i++) {
      c = c * 10;
      c += a;
    }
    cout << c << endl;
  }else if(a > b){
    c = b;
    for (int i = 0; i < a-1; i++) {
      c = c * 10;
      c += b;
    }
    cout << c << endl;
  }else{
    c = b;
    for (int i = 0; i < a-1; i++) {
      c = c * 10;
      c += b;
    }
    cout << c << endl;
  }
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m;
int main() {
  cin >> n >> m;
  pair<ll,ll> p[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second;
  }
  sort(p,p+n);
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (p[i].second > m) {
      ans += m * p[i].first;
      break;
    } else {
      ans += p[i].second * p[i].first;
      m -= p[i].second;
    }
  }
  cout << ans << endl;
}

/*　【提出前に確認すること】
・コンパイルできるか
・テストケース試したか
・オーバーフローあるか
*/


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


int main (){
    vector<int> V1(2), V2(2);
    cin>>V1.at(0)>>V1.at(1)>>V2.at(0)>>V2.at(1);
    vector<int> Vec1(2), Vec2(2), Vec3(2);
    Vec1.at(0)=V2.at(0)-V1.at(0);
  	Vec1.at(1)=V2.at(1)-V1.at(1);
  	Vec2.at(0)=Vec1.at(1) * (-1);
  	Vec2.at(1)=Vec1.at(0);
  	//cout<<Vec2.at(0)<<Vec2.at(1)<<endl;
  	Vec3.at(0)=Vec2.at(1) * (-1);
  	Vec3.at(1)=Vec2.at(0);
  	cout<<V2.at(0)+Vec2.at(0)<<" "<<V2.at(1)+Vec2.at(1)<<" ";
  	cout<<V2.at(0)+Vec2.at(0)+Vec3.at(0)<<" "<<V2.at(1)+Vec2.at(1)+Vec3.at(1)<<endl;
  	
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int n; cin >> n;
    ll ans = (ll)n*(n+1)/2;
    pr(ans-n);
    return 0;}

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

vector<int>adj[51];
int visited[51];
int child[51];

void dfs(int node)
{
    visited[node]=1;

    for(int to : adj[node])
    {
        child[node]++;
        if(!visited[to])
            dfs(to);
    }
}

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

    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    for(int i=1;i<=n;i++)
        if(!visited[i])
        dfs(i);

   for(int i=1;i<=n;i++)
       cout<<child[i]<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
bool isPerfectSquare(long double x) {   
    long double sr = sqrt(x); 
    return ((sr - floor(sr)) == 0); 
} 
int32_t main(){
    SPEED;
    int n;
    cin >> n;
    int x = 2;
    while(1){
        x *= 2;
        if(x > n){
            x /= 2;
            break;
        }
    }
    if(n == 1) cout << 1 ;
    else cout << x ;
}


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

using ll = long long;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int n;
ll a[100005];
int main()
{
	std::cin >> n;
	for (int i = 0; i < n; ++i)
		std::cin >> a[i];

	std::sort(a, a + n);

	int ans = n;
	ll sum = a[0];
	for (int i = 1; i < n; ++i) {
		if (a[i] > 2 * sum) {
			ans = n - i;
		}
		sum += a[i];
	}

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


Measured memory_bytes: 1024
# DP(貰うDP)
N = int(input())

dp = [[0] * 3 for _ in range(N + 1)]
for i in range(N):
  a, b, c = map(int, input().split())
  dp[i + 1][0] = max(dp[i][1] + b, dp[i][2] + c)
  dp[i + 1][1] = max(dp[i][0] + a, dp[i][2] + c)
  dp[i + 1][2] = max(dp[i][0] + a, dp[i][1] + b)
print(max(dp[N]))


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf (1 << 21)
#define mod 1000000007

int main() {
    int N; cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++) cin >> L.at(i);
    sort(L.begin(), L.end());
    int ans = 0;
    for (int i = 1; i < N - 1; i++) {
        for (int j = 0; j < i; j++) {
            for (int k = i + 1; k < N; k++) {
                if (L.at(k) < L.at(i) + L.at(j))
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
a,b,k = map(int, input().split())
flag = 0
for i in range(k):
    if flag == 0:
        if a%2 == 1: a-= 1
        b += a//2
        a -= a//2
    if flag == 1:
     if b%2 == 1:b-= 1
     a += b//2
     b -= b//2
    if flag == 0: flag =1
    else:flag =0
print(a,b)


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main() {
	int i, count = 0;
	char w[10];
	char str[1000];

	scanf("%s", w);
	for (i = 0;i < strlen(w);i++) {
		w[i] = tolower(w[i]);
	}

	while (scanf("%s", str), strcmp(str, "END_OF_TEXT") != 0) {
		for (i = 0;i < strlen(str);i++) {
			str[i] = tolower(str[i]);
		}

		if (strcmp(w, str) == 0) {
			count++;
		}
	}

	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 552
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<set>
#include<map>
#include<ctime>
#include<iostream>

using namespace std;

int a,b,sum;

int main()
{
	scanf("%d%d",&a,&b);
	sum = a * b;
	if(sum % 2 == 0) printf("Even\n");
	else printf("Odd\n");
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int a,b;

int main(){
	cin >> a >> b;
	
	cout << a-b+1 << endl;
	
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N+1);
  int push=1;
  int cnt=0;
  for(int i=1; i<=N; i++) cin >> a.at(i);
  while(cnt<=N){
    push = a.at(push);
    if(push==2){
      cnt++;
      break;
    }
    else if(push==1){
      cnt = -1;
      break;
    }
    else if(push==a.at(push)){
      cnt = -1;
      break;
    }
    else cnt++;
  }
  if(cnt>=N) cnt = -1;
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 640
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque

def run():
    N, M = map(int, sysread().split())
    A = list(map(int, sysread().split()))
    queue = []
    for a in A:
        heappush(queue, (-a, 1))

    for i in range(M):
        B, C = map(int, sysread().split())
        heappush(queue, (-C, B))
    total = 0
    ans = 0
    while True:
        c, b = heappop(queue)
        c *= -1
        total += b
        if total > N:
            total -= b
            break
        ans += c * b
    ans += (N - total) * c
    print(ans)

if __name__ == "__main__":
    run()

Measured memory_bytes: 94836
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false); 
	int A, B, C, D, P; cin >> A >> B >> C >> D >> P;	
	cout << min(A*P, B + max(P - C, 0)*D) << endl;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int a{}, b{}, c{}; cin >> a >> b >> c;
  auto res = a * 10 + b + c;
  chmax(res, a + b * 10 + c);
  chmax(res, a + b + c * 10);

  cout << res << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        sc.nextLine();
        char[][] S = new char[H][W];
        for (int i = 0; i < H; i++) {
            String text = sc.nextLine();
            for (int j = 0; j < W; j++) {
                S[i][j] = text.charAt(j);
            }
        }
        sc.close();

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (S[i][j] == '.') {
                    int count = 0;
                    for (int a = -1; a <= 1; a++) {
                        if (i + a < 0 || H <= i + a) {
                            continue;
                        }
                        for (int b = -1; b <= 1; b++) {
                            if (j + b < 0 || W <= j + b) {
                                continue;
                            }
                            if ( S[i + a][j + b] == '#') {
                                count++;
                            }
                        }
                    }
                    S[i][j] = (char)(count+48);
                }
                System.out.printf("%c", S[i][j]);
            }
            System.out.printf("\n");
        }
    }
}

Measured memory_bytes: 23380
def main():
    N = int(input())
    if N == 3:
        ans = [2, 5, 63]
    else:
        ans = []
        lst = [2, 3, 4, 6, 8, 9, 10, 12]
        for i in range(N//8):
            ans += list(map(lambda x: x + i*12, lst))
        b = N//8
        m = N % 8
        for i in range(4):
            if m >= 2:
                ans += [b*12+lst[i], b*12+lst[6-i]]
                m -= 2
            elif m == 1:
                ans += [b*12+6]
                break
    print(*ans)


if __name__ == "__main__":
    main()


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

long gcd(long a, long b) {
  if (a < b) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}

int main() {
  long a, b;
  cin >> a >> b;
  long g = gcd(a, b);
  long p = 1;
  for (long i = 2; i * i <= g; i++) {
    if (g % i == 0) {
      p++;
      while (g % i == 0) g /= i;
    }
  }
  if (g > 1) p++;
  cout << p << endl;
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

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

int main ()
{
    fastio
    lli num ;
    cin >> num ;
    cout << 48 - num ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



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

int main() {
  string s;
  cin >> s;
  if(s == "Sunny"){
    cout << "Cloudy" << endl;
  }else if(s == "Cloudy"){
    cout << "Rainy" << endl;
  }else{
    cout << "Sunny" << endl;
  }

  return(0);
}

Measured memory_bytes: 3560
#include <stdio.h>

#define MAX 101

int main(){
  int n, a, b, u, k, adj[MAX][MAX], v;

  scanf("%d",&n);
  for(a = 0; a < n; a++){
    for(b = 0; b < n; b++){
      adj[a][b] = 0;
    }
  }
  
  for(a = 0; a < n; a++){
    scanf("%d%d",&u,&k);
    for(b = 0; b < k; b++){
      scanf("%d",&v);
      adj[u-1][v-1] = 1;
    }
  }

  for(a = 0; a < n; a++){
    printf("%d",adj[a][0]);
    for(b = 1; b < n; b++){
      printf(" %d",adj[a][b]);
    }
    printf("\n");
  }

  return 0;
  
}



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

namespace ConsoleApplication62
{
    class Program
    {
        static void Main()
        {
            int a = int.Parse(Console.ReadLine());
            for(int b = 0; b < a; b++)
            {
                int[] c = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (c[0] % c[1] != 0)
                {
                    Console.WriteLine(c[0]%c[1]);
                }
                else
                {
                    Console.WriteLine(c[1]);
                }
            }
        }
    }
}

Measured memory_bytes: 9588
//	-*- mode: C++ -*-
//	Matrix Multiplication

//		Write a program which reads a n×m matrix A and a m×l matrix B, and prints their product, a n×l matrix C. An element of matrix C is obtained by the following formula:

//		cij=∑k=1maikbkj
//		where aij, bij and cij are elements of A, B and C respectively.

//	Input
//		In the first line, three integers n, m and l are given separated by space characters

//		In the following lines, the n×m matrix A and the m×l matrix B are given.

//	Output
//		Print elements of the n×l matrix C (cij). Print a single space character between adjacent elements.

//	Constraints
//		1≤n,m,l≤100
//		0≤aij,bij≤10000
//	Sample Input
//		3 2 3
//		1 2
//		0 3
//		4 5
//		1 2 1
//		0 3 2
//	Sample Output
//		1 8 5
//		0 9 6
//		4 23 14

#include <iostream>
#include <vector>

int	main(int	argc,
		 char*	argv[])
{
    unsigned int	n	{0};
    unsigned int	m	{0};
    unsigned int	l	{0};

	std::cin >> n >> m >> l;

	std::vector<std::vector<unsigned int>>	a;
	std::vector<std::vector<unsigned int>>	b;
	std::vector<std::vector<unsigned long long>>	c;

	a.resize(n);
	b.resize(m);
	c.resize(n);

	for(unsigned int i = 0; i < n; i++){
		c[i].resize(l, 0);
		for(unsigned int j = 0; j < m; j++){
			unsigned int	ij	{0};
			std::cin >> ij;
			a[i].push_back(ij);
		}
	}

	for(unsigned int i = 0; i < m; i++){
		for(unsigned int j = 0; j < l; j++){
			unsigned int	ij	{0};
			std::cin >> ij;
			b[i].push_back(ij);
		}
	}

	for(unsigned int i = 0; i < n; i++){
		for(unsigned int j = 0; j < m; j++){
			for(unsigned int k = 0; k < l; k++){
				c[i][k]	+= a[i][j] * b[j][k];
			}
		}
	}

	for(auto ci : c){
		unsigned int	count	{0};
		for(auto cij : ci){
			count++;
			std::cout << cij;
			if(count < l){
				std::cout << ' ';
			}
			else{
				std::cout << '\n';
			}
		}
	}
    return 0;
}



Measured memory_bytes: 3228
# -*- coding: utf-8 -*-
from itertools import combinations
from math import sqrt

def solve():
    N, D = map(int, input().split())
    X = [list(map(int, input().split())) for _ in range(N)]
    res = 0
    for x,y in combinations(X,r=2):
        z = sum(map(pow, map(int.__sub__,x,y), [2]*D))
        r = sqrt(z)
        if round(r)**2 == z:
            res += 1
    return str(res)

if __name__ == '__main__':
    print(solve())


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

using namespace std;
int main()
{
    while(true){
        int m, i;
        int low = 1, high = 1500000, mid;
        int N = 0;
        cin >> m;
        cin >> i;
        
        if( i == 0 )
            break;
        
        vector<int> a(i);
        
        for(int j = 0 ; j < i ; j++)
            cin >> a[j];
        
        while(true){
            mid = ( low + high ) / 2;
            int l = 0;
            bool que = false;
            
            for(int k = 0 ; k < m ; k++){
                int tot = 0;
                
                while(true){
                    if( mid >= tot + a[l] ){
                        tot = tot + a[l];
                        if( l< i - 1 )
                            l++;
                        else{
                            que = true;
                            break;
                        }
                    }
                    else
                        break;
                }
                
                if( que == true )
                    break;
            }
            
            if( que == true )
                high = mid;
            else
                low = mid + 1;
            
            if( low == high ){
                N = low;
                break;
            }
        }
        
        cout << N <<endl;
    }
}

Measured memory_bytes: 2972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)

int main(){
	int q,c,x;
	string key;
	cin >> q;
	map<string,int> ma;
	while(q--){
		cin >> c >> key;
		if(c==1){
			cout << ma[key] << "\n";
		}else if(c==0){
			cin >> x;
			ma[key] = x;
		}else if(c==2){
			ma[key] = 0;
		}
	}
}


Measured memory_bytes: 27876
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <utility>
typedef long long lint;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define INF 1e18

int N, M;
int kazu [10] = {99999, 2, 5, 5, 4, 5, 6, 3, 7, 6}; // 0,1~9をつくるのにひつよう

int cost(int i)
{ // iを作るのに必要な本数
	return kazu[i];
}

signed main()
{

	cin >> N >> M;

	vector<int> A(M);
	rep(i, M) cin >> A[i];
	// input end
	int mini = INF;
	rep(i, M) mini = min(mini, A[i]);

	// N本で何桁作れるかテーブル
	vector<int> T(N + 10, -INF);
	// 作れる整数の最大値
	// cost <= N かつ num が最大
	// 桁数？
	// 計算
	// 64 bitsに収まらない ---> ans: string型
	int keta = 0;
	int mn = INF;
	for (auto a : A)
	{
		mn = min(mn, cost(a));
	}
	keta = N / mn; // b n u

//	cout << "ketasu: " << keta << endl;

	vector<int> ans;
	T[0] = 0; // 
	for (int i = 0; i <= N; i++)
	{
		for (auto num : A)  {
		// cost : cost(num).
		// 桁数のみ
		int use = cost(num);
		if (( i + use) <= N) 
			T[i+use] = max(T[i+use], (T[i] + 1));
		}
	}

	// ans.push_back(xxx);
	int n = N;
	while (n > 0) {
		int tmp = -INF;
		int herasu = 0;
		for (int i = 0; i < M; i++) { // 各文字
			//A[i], cost(A[i]), T[n-cost(A[i])] を用いる
			// A[i]が大きい && T[n]減らない
			if ((n - cost(A[i]) >= 0) && (T[n - cost(A[i])]) == (T[n] - 1)) {
				if (tmp < A[i]) {
					tmp = A[i];
					herasu = cost(A[i]);
//					cout << "n:" << n << "A[i]: " << A[i] << endl;
				}
			}
		}
			if (tmp > 0) {
				ans.push_back(tmp);
				n -= herasu;
			}
	}

	/*
	cout << "T: ";
	for (auto a : T)
		cout << a << ", ";
	cout << endl;
	*/

	for (auto a : ans)
		cout << a;
	cout << endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args)  {
		// 入力
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int x = scanner.nextInt();
		
		if(check(a, 100) && check(b, 100) && check(x, 200)) {
			if( a <= x && x <= (a+b) ) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		} else {
			System.out.println("NO");
		}
	}
	
	static boolean check(int input, int max) {
		return (0 <= input && input <=  max);
	}
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 100000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back



template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WG = vector< Edges< T > >;
using UG = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;


int n,m;
Edges<ll> es;
bool ans=false;



template< typename T >
vector< T > bellman_ford(Edges< T > &edges, int V, int s) {
  const auto lim = numeric_limits< T >::max();
  vector< T > dist(V, lim);
  dist[s] = 0;
  rep(i,V-1) {
    for(auto &e : edges) {
      if(dist[e.src] == lim) continue;
      dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
    }
  }  

  bool neg[2000]={};

  rep(i,V){
    for(auto &e:edges){
      if(dist[e.src]==lim) continue;
      if(dist[e.to]>dist[e.src]+e.cost){
        dist[e.to]=dist[e.src]+e.cost;
        neg[e.to]=true;
      }
      if(neg[e.src])
        neg[e.to]=true;
    }
  }
  if(neg[V-1])
    return vector<T> ();
  
  return dist;

}

int main(){
  cin>>n>>m;
  rep(i,m){
    int a,b,c;
    cin>>a>>b>>c;
    a--;
    b--;
    es.PB(edge<ll>(a,b,-c));
  }

  vector<ll> s = bellman_ford(es,n,0);
  if(s.empty())
    cout<<"inf"<<endl;
  else
    cout<<-s[n-1]<<endl;

}


Measured memory_bytes: 256
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define cin_desync()                                                           \
    do {                                                                       \
        ios_base::sync_with_stdio(false);                                      \
        cin.tie(0);                                                            \
    } while (0)

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

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

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

    int streak_length = 0;
    int prev = 0;
    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        int x;
        cin >> x;

        if (x != prev) {
            ans += streak_length / 2;
            prev = x;
            streak_length = 0;
        }

        streak_length++;
    }

    ans += streak_length / 2;

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<random>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,s[200],sum=0;
    cin>>n;
    rep(i,n){
        cin>>s[i];
        sum+=s[i];
    }
    sort(s,s+n);
    if(sum%10==0){
        rep(i,n){
            if(s[i]%10!=0){
                cout<<sum-s[i]<<endl;
                return 0;
            }
        }
        cout<<0<<endl;
    }
    else{
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
X,Y,A,B,C=gets.chomp.split(" ").map(&:to_i)
p_array=gets.chomp.split(" ").map(&:to_i).sort.reverse[0..(X-1)].reverse
q_array=gets.chomp.split(" ").map(&:to_i).sort.reverse[0..(Y-1)].reverse
r_array=gets.chomp.split(" ").map(&:to_i).sort.reverse

loop do
    if r_array.length == 0
        break
    elsif (p_array[0] || 0) > (q_array[0] || 0)
        if q_array[0] < r_array[0]
            q_array.shift
            q_array.push(r_array[0])
            r_array.shift
        else
            break
        end
    else
        if p_array[0] < r_array[0]
            p_array.shift
            p_array.push(r_array[0])
            r_array.shift
        else
            break
        end
    end
end

puts p_array.inject(&:+) + q_array.inject(&:+)


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

int main() { 	
 int A,C,D,E,F,G;
 string B;
 cin >>A;
 vector<int> vec1(A+1);
     for(int i=0;i<A;i++){
         cin >>D;
         F=i+1;
         vec1.at(D-1)=F;
     }
    for(int x=0;x<A;x++){
        cout <<vec1.at(x)<<" "; 
     }

      cout <<endl; 
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int> v;
    for(int i=0;i<3;i++){
        int x;
        scanf("%d",&x);
        v.push_back(x);

    }
    sort(v.begin(),v.end());
    int y= v[2]*10+v[1]+v[0];
    printf("%d\n",y);
    return 0;
}


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

void fnInput(vector<int>& rvnElm, vector<int>& rvnTrg)
{
  int nElmCnt, nTrgCnt;
  cin >> nElmCnt;

  rvnElm.resize(nElmCnt);
  for (int i = 0; i < nElmCnt; i++)
    cin >> rvnElm[i];

  cin >> nTrgCnt;

  rvnTrg.resize(nTrgCnt);
  for (int i = 0; i < nTrgCnt; i++)
    cin >> rvnTrg[i];
}

int fnRcsSch(int nPos, int nTrg, const vector<int>& cnrvnElm, vector<vector<int>>& rvvnDP)
{
  if (!nTrg)                    return 1;
  if (nPos == cnrvnElm.size())  return 0;
  if (nTrg < 0)                 return 0;
  if (rvvnDP[nPos][nTrg] != -1) return rvvnDP[nPos][nTrg];

  if (fnRcsSch(nPos + 1, nTrg, cnrvnElm, rvvnDP))
    return (rvvnDP[nPos][nTrg] = 1);
  else if (fnRcsSch(nPos + 1, nTrg - cnrvnElm[nPos], cnrvnElm, rvvnDP))
    return (rvvnDP[nPos][nTrg] = 1);
  else
    return (rvvnDP[nPos][nTrg] = 0);
}

void fnExhSch(const vector<int>& cnrvnElm, const vector<int>& cnrvnTrg)
{
  vector<vector<int>> vvnDP(21, vector<int>(2001, -1));
  
  for (int i = 0; i < cnrvnTrg.size(); i++)
  {
    int nTrg = cnrvnTrg[i];

    if (fnRcsSch(0, nTrg, cnrvnElm, vvnDP))
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnElm, vnTrg;

  fnInput(vnElm, vnTrg);
  fnExhSch(vnElm, vnTrg);

  return 0;
}

Measured memory_bytes: 3320
//#include <bits/stdc++.h>
#include<iostream>
#include<numeric>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//----------program from here----------

int ctoi(char c) {
  if('0'<=c && c <= '9') return c-'0';
  return 0;
}

int main(){
  int n=0,i=0;
  cin >> n >> i;
  cout << n-i+1 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <stdio.h>
using ll = long long;

int main() {
	int R, G, B, x;
	scanf("%d %d %d", &R, &G, &B);
	x = R * 100 + G * 10 + B;
	printf("%s\n", (x % 4 ? "NO" : "YES"));
}

Measured memory_bytes: 128
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <complex>

using namespace std;
typedef long long ll;


typedef complex<double> xy_t;
double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }

typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

vector<int> G[100005];
std::vector<P> tree[100010];

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

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define re(i,a,b) for(i=a;i<=b;i++)
#define pb push_back
#define lb lower_bound
#define ub upper_bound

ll i,j,k,ii,jj;
ll n,m,sum,num;
ll ans=0;
ll a,b,c,d,e,h,w;

ll x[500005],y[500005],z[500005];
string s,t;
bool flag;
bool check[100005];


int main(){
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a;
        ans+=a;
    }
    p(ans-n);
    
    return 0;
}


Measured memory_bytes: 6528
#ifdef DBG1
  #define LOCAL
#endif

#ifdef LOCAL
  #define _GLIBCXX_DEBUG
#endif

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifdef DBG1
    #define dbg(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dbg(...)
#endif

using namespace std;

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

bool solve() {
  int n;
  if (scanf("%d", &n) != 1) { return false; }
  vector <int> a(n), b(n);
  ll sumA = 0, sumB = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    sumA += a[i];
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &b[i]);
    sumB += b[i];
  }
  ll k = sumB - sumA;
  ll sum1 = 0, sum2 = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] < b[i] && (a[i] + b[i]) % 2 == 1) {
      k--;
      a[i] += 2;
      b[i] += 1;
    }
    if (a[i] > b[i]) {
      sum1 += a[i] - b[i];
    } else {
      sum2 += b[i] - a[i];
    }
  }
  assert(sum2 % 2 == 0);
  bool ok = (k >= 0 && sum1 <= k);
  printf("%s\n", ok ? "Yes" : "No");
  return true;
}

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

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

int main()
{
	int a[50101]={0};
	int i,j;
	int n,c;

	a[2]=1;
	for(i=3;i<=50100;i+=2){
		if(a[i]==2)
			continue;
		else if(a[i]==0){
			a[i]=1;
			for(j=i*2;j<=50100;j+=i)
				a[j]=2;
		}
	}
	while(scanf("%d",&n)!=EOF){
		for(i=n-1;i>1;i--){
			if(a[i]==1){
				printf("%d ",i);
				break;
			}
		}
		for(i=n+1;i<=50100;i++)
			if(a[i]==1){
				printf("%d\n",i);
				break;
			}
	}
	return 0;
}

Measured memory_bytes: 1392
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;

	int c;
	if (a == b)
	{
		c = a + b;
	}
	else
	{
		c = 2 * max(a, b) - 1;
	}

	cout << c << endl;
}

Measured memory_bytes: 256
a,b=map(int, input().split())
c,d=map(int, input().split())
start=c
end=d


  
  

for i in range(b-1):
  e,f=map(int, input().split())
  if e>=start:
    start=e
  if f<=end:
    end=f

if end>= start:
  out=end-start+1
else:
  out=0
  
  

print(out)
  

Measured memory_bytes: 3060
s = input()
h = s[:2]
t = s[2:]
def montheable(p):
    return '00' < p < '13'
if montheable(h) and montheable(t):
    print('AMBIGUOUS')
elif montheable(h):
    print('MMYY')
elif montheable(t):
    print('YYMM')
else:
    print('NA')

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


int main(){
    ll n;cin>>n;
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    map<ll,ll> mp;
    for(ll i=2;i*i<=n;i++){
        while(n%i==0){
            n/=i;
            mp[i]++;
        }
    }
    if(n!=1)mp[n]++;
    ll an=0;
    for(auto i:mp){
        ll cn=i.second;
        for(ll j=1;;j++){
            if(cn-j>=0){
                an++;
                cn-=j;
            }
            else break;
        }
    }
    cout<<an<<endl;
}

    









Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

struct union_find{
    VI par;

    void init(int n){
        par.resize(n);
        REP(i,n) par[i] = i;
    }

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

    bool same(int x, int y){
        return find(x) == find(y);
    }

    void merge(int x, int y){
        x = find(x);
        y = find(y);
        if (x == y) return;
        par[x] = y;
    }
};

struct edge{ int u, v, cost; };
VL em[4000], um[4000];
int ma[4000][4000];

bool comp(const edge &e1, const edge &e2){
    return e1.cost < e2.cost;
}

ll kruskal(vector<edge> &es, int n){
    sort(es.begin(), es.end(), comp);
    union_find uf;
    uf.init(n);
    ll res = 0;
    REP(i,es.size()){
        edge e = es[i];
        if (!uf.same(e.u, e.v)){
            uf.merge(e.u, e.v);
            res += e.cost;
            em[e.u].push_back(e.v);
            um[e.u].push_back(e.cost);
            em[e.v].push_back(e.u);
            um[e.v].push_back(e.cost);
        }
    }
    return res;
}

void dfs(int now, int past, ll x, int s){
    ma[s][now] = x;
    REP(i,em[now].size()){
        if (em[now][i] == past) continue;
        dfs(em[now][i], now, max(x, um[now][i]), s);
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<edge> es;
    while(m--){
        edge eg;
        scanf("%d %d %d", &eg.u, &eg.v, &eg.cost);
        eg.u--;
        eg.v--;
        es.push_back(eg);
    }

    ll sum = kruskal(es, n);

    REP(i,n) dfs(i, -1, 0, i);

    int q;
    cin >> q;
    while (q--){
        int s, t;
        scanf("%d %d", &s, &t);
        s--;
        t--;
        printf("%lld\n", sum - ma[s][t]);
    }

    return 0;
}


Measured memory_bytes: 70508
#include <iostream>
#include <tuple>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>

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

  std::vector<int> a_arr(3*N);
  for(int i = 0; i < 3*N; i++) std::cin >> a_arr[i];

  std::priority_queue<int, std::vector<int>, std::function<bool(int,int)>> left([&](int l, int r){return a_arr[l]>a_arr[r];}), right([&](int l, int r){return a_arr[l]>a_arr[r];});
  for(int i = 0; i < N; i++) left.push(i);

  std::vector<int> right_index(2*N);
  std::vector<int> remove_arr(3*N);
  for(int i = N; i < 3*N; i++) right_index[i-N] = i;
  std::sort(right_index.begin(), right_index.end(), [&](int l, int r){return a_arr[l]>a_arr[r];});
  for(int i = 0; i < N; i++){
    right.push(right_index[i]);
    remove_arr[right_index[i]] = 1;
  }
  long long sum_left = 0, sum_right = 0;
  for(int i = 0; i < N; i++) sum_left += a_arr[i];
  for(int i = N; i < 2*N; i++) sum_right += a_arr[right_index[i]];

  long long max_sum_diff = sum_left-sum_right;
  for(int th = N; th < 2*N; th++){
    if(remove_arr[th] == 0){
      int ri;
      while(true){
        ri = right.top();
        right.pop();
        if(ri > th) break;
      }
      remove_arr[ri] = 0;
      sum_right += a_arr[ri] - a_arr[th];
    }
    left.push(th);
    int li = left.top();
    left.pop();
    sum_left += a_arr[th] - a_arr[li];
    max_sum_diff = std::max(max_sum_diff, sum_left-sum_right);
  }

  std::cout << max_sum_diff << std::endl;

  return 0;
}



Measured memory_bytes: 4472
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct modint{
    using i64=int_fast64_t;
    i64 a;
    static constexpr i64 MOD=998244353;
    modint(){a=0;}
    modint(i64 a_){
        a=a_%MOD;
        if(a<0) a+=MOD;
    }
    modint inv()const{
        i64 n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y;
        y.a=a+x.a;
        if(y.a>MOD) y.a-=MOD;
        return y;
    }
    modint operator-(const modint& x){
        modint y;
        y.a=a-x.a;
        if(y.a<0) y.a+=MOD;
        return y;
    }
    modint operator*(const modint& x){
        modint y;
        y.a=(a*x.a)%MOD;
        return y;
    }
    modint operator/(const modint& x){
        modint y;
        y.a=(a*x.inv().a)%MOD;
        return y;
    }
    modint& operator+=(const modint& x){
        a+=x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint& operator-=(const modint& x){
        a-=x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    modint& operator*=(const modint& x){
        (a*=x.a)%=MOD;
        return *this;
    }
    modint& operator/=(const modint& x){
        (a*=x.inv().a)%=MOD;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    int_fast64_t a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(int_fast64_t a,int_fast64_t b){
    modint _;
    int_fast64_t n=1,A=a;
    while(b){
        if(b&1) (n*=A)%=modint::MOD;
        (A*=A)%=modint::MOD;
        b>>=1;
    }
    _.a=n;
    return _;
}

template <int n> struct COMB{
    vector<int_fast64_t> fc,ifc;
    COMB():fc(n),ifc(n){
        fc[0]=1;
        for(int i=1;i<n;++i) fc[i]=fc[i-1]*i%modint::MOD;
        int_fast64_t N=1,A=fc[n-1],b=modint::MOD-2;
        while(b){
            if(b&1) (N*=A)%=modint::MOD;
            (A*=A)%=modint::MOD;
            b>>=1;
        }
        ifc[n-1]=N;
        for(int i=n-1;i>=1;--i) ifc[i-1]=ifc[i]*i%modint::MOD;
    };
    modint operator()(int N,int R)const{
        if(N<0||R<0||N<R) return 0;
        return fc[N]*ifc[R]%modint::MOD*ifc[N-R];
    }
    modint operator[](int N)const{
        modint _;
        _.a=fc[N];
        return _;
    }
    modint operator()(int N)const{
        modint _;
        _.a=ifc[N];
        return _;
    }
};
COMB<10000010> comb;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    in>>n;
    modint ans=pwr(3,n);
    fr(i,n/2) ans-=comb(n,i)*pwr(2,i+1);
    cout<<ans<<endl;
}

Measured memory_bytes: 156544
#include<stdio.h>
#include<algorithm>
using namespace std;
int b[11000];
int c[11000];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%d",b+i);
		for(int i=0;i<a;i++)scanf("%d",c+i);
		std::sort(b,b+a);
		std::sort(c,c+a);
		int bl=0;
		int br=a;
		int cl=0;
		int cr=a;
		int bL=0;
		int bR=a-1;
		int cL=0;
		int cR=a-1;
		bool upd=false;
		do{
			upd=false;
			if(bL<=bR&&bl==b[bL]){
				cr--;bL++;upd=true;
			}
			if(cL<=cR&&cl==c[cL]){
				br--;cL++;upd=true;
			}
			if(bL<=bR&&br==b[bR]){
				cl++;bR--;upd=true;
			}
			if(cL<=cR&&cr==c[cR]){
				bl++;cR--;upd=true;
			}
		}while(upd);
		if(bL>bR&&cL>cR)printf("Yes\n");else printf("No\n");
	}
}

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

using namespace std;
typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H,W,N;
  cin >> H >> W >> N;
  int res = ceil( 1.0 * N / max(H, W));
  cout << res << endl;
  return 0;
}



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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define PB push_back
#define pb push_back
#define MP make_pair

#define sd(n) scanf("%lld", &n)
#define pdn(n) printf("%lld\n", n);
#define pds(n) printf("%lld ", n);
#define endl '\n'

#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define len(stuff) (int) stuff.size()

#define int long long
#define float long double 
#define ll long long
#define ld long double

using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const int inf = (int) 2e18;
const int upper = (int) 3e5 + 50;
const int M = (ll) 1e9 + 7;
const int mod = (ll) 998244353;
const double eps =  1e-8;

signed main () {
	start_routine();
	speed();
	#ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);	 
	// freopen("output.txt", "w", stdout);
	// freopen("errlog.txt", "w", stderr);
	#endif

	int a, b, c; cin >> a >> b >> c;
	if (c <= (a + b + 1)) {
		cout << (b + c);
	}
	else {
		cout << (b + (a + b + 1));
	}
 	end_routine();		
}


Measured memory_bytes: 256