akhauriyash/Code-Regression huggingface dataset:
n = int(input())
ans = [0 for _ in range(10001)]
for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            v = i*i+j*j+k*k+i*j+j*k+k*i
            if v<=10000:
                ans[v]+=1

for i in range(n):
    print(ans[i+1])

Measured memory_bytes: 9416
import java.io.*;
import java.util.*;

public class Main {
	void run() {
		int k = in.nextInt();
		int n = (k + 3) / 4 * 2;
		out.println(n);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				int c = (i + j) % n;
				if (c + n < k && i % 2 == 1) {
					c += n;
				}
				if (k == 1) {
					c = 0;
				}
				out.print(c + 1);
				if (j == n - 1) {
					out.println();
				} else {
					out.print(" ");
				}
			}
		}
	}

	static MyScanner in;
	static PrintWriter out;

	public static void main(String[] args) throws IOException {
		boolean stdStreams = true;
		String fileName = Main.class.getSimpleName().replaceFirst("_.*", "").toLowerCase();
		String inputFileName = fileName + ".in";
		String outputFileName = fileName + ".out";
		
		Locale.setDefault(Locale.US);
		BufferedReader br;
		if (stdStreams) {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		} else {
			br = new BufferedReader(new FileReader(inputFileName));
			out = new PrintWriter(outputFileName);
		}
		in = new MyScanner(br);
		int tests = 1;//in.nextInt();
		for (int test = 0; test < tests; test++) {
			//out.print("Case #" + (test + 1) + ": ");
			new Main().run();
		}
		br.close();
		out.close();
	}
	
	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		MyScanner(BufferedReader br) {
			this.br = br;
		}
		
		void findToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		
		String next() {
			findToken();
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 37696
while True:
    h = input()
    h_list = list(h)
    
    if h == '-':
        break
    count = int(input())
    for j in range(count):
        count1 = int(input())
        for i in range(0,count1):
            h_list.append(h_list[0])
            h_list.remove(h_list[0])
            
            length = int(len(h_list))
    for i in range(length):
        print("{}".format(h_list[i]),end="")
    print("")


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

#define ll long long
#define pb push_back
#define N 1000000007
#define nmax 200001
#define pll pair<ll,ll>
#define fill_nums(A,n) for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}

ll extended_gcd(ll a, ll b, ll &x, ll &y) {
	if(a==0) {
		x = 0;
		y = 1;
		return b;
	}

	ll x1,y1;
	ll gcd = extended_gcd(b%a,a,x1,y1);

	x = y1 - (b/a)*x1;
	y = x1;

	return gcd;
}

ll solve(vector<vector<ll>> &dp, vector<vector<ll>> &adj, ll idx, ll mask) {

	ll n = adj.size();
	if(mask==0)
		return 1;

	if(dp[idx][mask]!=-1)
		return dp[idx][mask];

	ll res = 0;

	for(ll i=0;i<n;i++) {
		if((mask & (1<<i)) != 0 && adj[idx][i]) {
			res = (res + solve(dp,adj,idx-1,mask^(1<<i)))%N;
		}
	}

	dp[idx][mask] = (res+N)%N;
	return dp[idx][mask];
}

int main() {
    
   	ll n; cin>>n;
   	vector<vector<ll>> adj(n,vector<ll>(n,0));

   	for(int i=0;i<n;i++) 
   		for(int j=0;j<n;j++)
   			cin>>adj[i][j];
   	
   	ll s = (1<<n);
   	vector<vector<ll>> dp(n, vector<ll>(s,-1));

   	cout<<solve(dp,adj,n-1,(1<<n)-1)<<endl;

	return 0;
}


 

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

int main() {
    int a, b, ans;
    
    cin >> a >> b;
    ans = 0;
    for ( int i = 1; i < b-a; i++ ) {
        ans+=i;
    }
    
    cout << ans - a << endl;
    return (0);
}


Measured memory_bytes: 3612
import numpy as np

N = int(input())
XY = np.array([[int(x) for x in input().split()] for _ in range(N)],dtype=np.int64)
X = XY[:,0]
Y = XY[:,1]

command = np.array([''] * N,dtype=object)

def solve(k,X,Y,arms,command):  
  # |X|+|Y| <= 2^{k+1} のときに、2^kを使って
  # |X|+|Y| <= 2^kに書き直す
  if k == -1:
    return solve_final(X,Y,arms,command)
  # 絶対値が大きい方を操作
  bl_X = (np.abs(X) > np.abs(Y))
  bl_Y = ~bl_X
  negative_X = (X < 0)
  negative_Y = (Y < 0)
  L = bl_X & negative_X
  R = bl_X & (~negative_X)
  D = bl_Y & negative_Y
  U = bl_Y & (~negative_Y)
  command[L] += 'L'
  command[R] += 'R'
  command[D] += 'D'
  command[U] += 'U'
  p = (1<<k)
  arms.append(p)
  X[L] += p
  X[R] -= p
  Y[D] += p
  Y[U] -= p
  return solve(k-1,X,Y,arms,command)

def solve_final(X,Y,arms,command):
  s = np.abs(X) + np.abs(Y)
  bl0 = (s == 0).all()
  bl1 = (s == 1).all()
  if bl0:
    return arms,command
  elif not bl1:
    return None,None
  # |X| + |Y| = 1が保証されている
  arms.append(1)
  L = (X == -1)
  R = (X == 1)
  D = (Y == -1)
  U = (Y == 1)
  command[L] += 'L'
  command[R] += 'R'
  command[D] += 'D'
  command[U] += 'U'
  return arms,command

arms,command = solve(35,X,Y,[],command)

if arms is None:
  print(-1)
else:
  print(len(arms))
  print(' '.join([str(x) for x in arms]))
  print('\n'.join(command))

Measured memory_bytes: 12936
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int a, b, c;
  scanf("%d %d %d\n", &a, &b, &c);
  if (a + b == c || b + c == a || c + a == b) {
    printf("Yes\n");
  }
  else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    cin>>n;
    vector<ll> r(n,0);
    vector<ll> a(n);
    for(int i=0; i<n; i++){
        cin>>a[i];
        r[0] += (i&1 ? -a[i] : a[i]);
    }
    for(int i=0; i<n-1; i++){
        r[i+1] = 2*(a[i] - r[i]/2);
    }
    for(int i=0; i<n; i++) cout<<r[i]<<" ";
    return 0;
}


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

int main(){
  int N,K,i,min;
  cin >> N >> K;
  int h[N];
  K = K-1;
  for(i = 0; i < N; i++){
    cin >> h[i];
  }
  sort(h,h+N);
  min = h[K]-h[0];
  for(i = 1; i <= N-(K+1) ;i++){
    if(min > h[i+K]-h[i]){
      min = h[i+K]-h[i];
    }
  }
  cout << min <<endl;
}

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

int main(){
  while(1){
  int n,m;
  cin>>n>>m;
  if(!n&&!m)break;
  int a[20010]={};
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<m;i++)cin>>a[i+n];
  
  sort(a,a+n+m+1);
  
  int ans=0;
  for(int i=1;i<=n+m;i++) ans=max(ans,a[i]-a[i-1]);
  cout <<ans<<endl;
  

  }

  return 0;
}

Measured memory_bytes: 1256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs


int main() {
  string s[] = { "Sunny", "Cloudy", "Rainy" } ;
  string t;
  cin >> t;
  for (i64 i = 0; i < 3; ++i) {
    if (t == s[i]) cout << s[(i + 1) % 3] << endl;
  }
  return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N;
    cin >> N;
    int T, A;
    cin >> T >> A;
    vector<int> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }

    double ma = 1e30;
    int j = 0;
    for (int i = 0; i < N; i++) {
        if (ma > fabs(A - (T - H[i] * 0.006))) {
            ma = fabs(A - (T - H[i] * 0.006));
            j = i;
        }
    }

    cout << j  + 1 << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>//accumulateを使うためにインクルード

using namespace std;

int main(){
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    s1[0] = toupper(s1[0]);
    s2[0] = toupper(s2[0]);
    s3[0] = toupper(s3[0]);
    cout << s1[0] << s2[0] << s3[0] << endl;
    return 0;
}

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

int main(){
 int n; cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    a[i]--;
    b.at(a.at(i)) = i+1;
    
  }
  for(int i=0;i<n;i++){
    cout << b.at(i);
    if(i == n-1){
      cout << endl;
    }
    else{
      cout << ' ';
    }
  }
}


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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;

int main(){
   int x,y,z; cin>>x>>y>>z;
   cout<<z<<" "<<x<<" "<<y<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <locale>
int main() {

  std::string s1;
  std::string s2;
  std::string s3;

  std::cin >> s1 >> s2 >> s3;

  std::cout << std::toupper(s1[0], std::locale())
            << std::toupper(s2[0], std::locale())
            << std::toupper(s3[0], std::locale()) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b,c;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    bool correct = true;
    if(a >= b || b>=c || a>=c)
        correct = false;
    if (!correct){
        printf("No\n");
    } else{
         printf("Yes\n");
    }

    return 0;
}


Measured memory_bytes: 2604
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力

import math
A, B, H, M = map(float, input().split())
# 文字列の入力
#s = input()
#開業されたN個要素を受け付ける
#list = [input() for i in range(N)]
#input_list = [list(map(int, input().split())) for i in range(N)]
A_kakudo = 360* (H/12 + M/720)
#print(A_kakudo)
B_kakudo = 360* (M/60)
#print(B_kakudo)

AB_kakudo = abs(A_kakudo - B_kakudo)
#print(AB_kakudo)
ans = A**2 + B**2 - 2*A*B*math.cos(math.radians(AB_kakudo))
#print(ans)
ans = math.sqrt(ans)
print(ans)


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

int main() {
  int N;//4桁の整数
  cin >> N;
  
  int a,b,c,d;//4,3,2,1桁目の整数
  
  a = N / 1000;
  b = (N - a * 1000) /100;
  c = (N - a * 1000 - b * 100 )/10;
  d = N - a * 1000 - b*100 - c*10;
 
  if ( (a == b) && (b == c) || (b == c) && (c == d) ){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
    
  
}

Measured memory_bytes: 256
#include <iostream>
//#include <vector>
//#include <map>
//#include <set>
//#include <algorithm>
#include <climits>

using namespace std;

int main()
{
    int n, a;
    float t;
    cin >> n;
    cin >> t >> a;

    float h;
    cin >> h;
    float diff = (t - h * 0.006f) - a;
    if (diff < 0) diff = -diff;
    int index = 0;
    for (int i = 1; i < n; i++)
    {
        cin >> h;
        float temp = (t - h * 0.006f);
        float d = temp - a;
        if (d < 0) d = -d;
        if (d < diff)
        {
            index = i;
            diff = d;
        }
    }
    cout << index + 1 << endl;

    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A,P;
    cin>>A>>P;
    cout << (3*A+P)/2<<"\n";
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use ascii::AsciiChar;
use ascii::AsciiStr;
use itertools::Itertools as _;
use permutohedron::LexicalPermutation as _;
use petgraph::algo::dijkstra;
use petgraph::algo::min_spanning_tree;
use petgraph::data::FromElements;
use petgraph::graph::NodeIndex;
use petgraph::graph::UnGraph;
use petgraph::unionfind::UnionFind;
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;
use proconio::marker::Usize1;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use superslice::Ext as _;

#[fastout]
fn main() {
    input! {
        orig_N: usize,
        mut As: [i64; orig_N],
    }

    // どこかに境界線があるはず。ある強さ以上のモンスターは生き残る可能性があり、
    // ある強さ未満のモンスターはどうやっても生き残れない

    // 2分探索しつつ、「このモンスター生き残れますか」のクエリをO(N)くらいで回答できればよさそう。

    // 2分探索でis_ngを持つために、絶対に絶滅するモンスターを便宜的に投入しておく。
    // 必ず死ぬので、答えの値が大きくなることは無い。
    As.push(0); // 0しか吸収できないが、他のモンスターは1以上なので必ず死ぬ
    let N = orig_N + 1;
    As.sort();

    // 自分より弱いモンスターを全て食ってその和の大きさになるので、累積和を使うと効率が良い
    let mut acc = vec![0i64; N + 1];
    for i in 0..N {
        acc[i + 1] = acc[i] + As[i];
    }

    let mut is_ok = N - 1;
    let mut is_ng = 0;

    while is_ok - is_ng > 1 {
        let mid = (is_ok + is_ng) / 2;

        // とりあえず次のモンスターを食えるなら、少なくともmidは境界ではない。ではどちら?
        if As[mid + 1] <= 2 * acc[mid + 1] {
            // eprintln!("{} can eat {} : {} <= 2 * {}", mid, mid+1, As[mid+1], acc[mid+1]);

            // 敵をiとしてループを回し、倒していく
            let mut can_win = true;
            for i in mid + 1..N {
                if As[i] > 2 * acc[i] {
                    can_win = false;
                }
            }

            if can_win {
                is_ok = mid;
            } else {
                is_ng = mid;
            }
        } else {
            // eprintln!("{} is ng", mid);
            is_ng = mid;
        }
    }

    // dbg!(&As);
    // dbg!(&acc);
    // dbg!(is_ok);
    // dbg!(is_ng);

    println!("{}", N - (is_ng + 1));
}


Measured memory_bytes: 4464
import sys


def subset(a):
    for n in range(2**len(a)):
        yield [a[i] for i in xrange(len(a)) if (n >> i) & 1 == 1]


weights = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]

for line in sys.stdin:
    w = int(line)
    for s in subset(weights):
        if sum(s) == w:
            print ' '.join(map(str, s))

Measured memory_bytes: 4252
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int a, b, c;

bool solve() {
    if ((a == b && a != c) ||
        (c == b && a != b) ||
        (a == c && b != c)) {
        return true;
    }
    return false;
}

void input() {
    cin >> a >> b >> c;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << (solve()?"Yes":"No") << endl;
}


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

struct SCC {
    int N;
    vector<vector<int> > g, gr, g2i, t;
    vector<bool> visited;
    vector<int> i2g;
    stack<int> order;

    SCC(){}
    SCC(int n){init(n);}
    void init(int n){
        N = n;
        g.clear();
        g.resize(N);
        gr.clear();
        gr.resize(N);
        visited.resize(N);
        i2g.resize(N);
    }
    void add_edge(int u, int v) {
        g[u].emplace_back(v);
        gr[v].emplace_back(u);
    }

    void dfs(int x) {
        if (visited[x]) return;
        visited[x] = true;
        for (int i : g[x]) dfs(i);
        order.push(x);
    }

    void rdfs(int x, int k) {
        if (i2g[x] != -1) return;
        i2g[x] = k;
        for (int i : gr[x]) rdfs(i, k);
    }

    void build() {
        fill(visited.begin(), visited.end(), false);
        fill(i2g.begin(), i2g.end(), -1);
        for (int i = 0; i < N; i++) dfs(i);
        int p = 0;
        while (!order.empty()) {
            rdfs(order.top(), p++);
            order.pop();
        }
    }
};

int main(){
    int V, E, Q;
    cin >> V >> E;
    SCC scc(V);
    for(int i=0;i<E;i++){
        int a, b;
        cin >> a >> b;
        scc.add_edge(a,b);
    }
    scc.build();
    cin >> Q;
    for(int i=0;i<Q;i++){
        int a, b;
        cin >> a >> b;
        cout << int(scc.i2g[a] == scc.i2g[b]) << endl;
    }
    return 0;
}


Measured memory_bytes: 4108
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll INF = 1e9;
const ll LINF = ll(1e18) + 1;
const ll MOD = 1000000007;
const ll dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const ll Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (ll i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, m;
vector<ll> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    ll sum=0;
    ll maxi;
    for (ll i = 0; i <= n; i++)
    {
        sum+=i;
        if(sum>=n){
            maxi=i;
            break;
        }
    }
    rep(i,maxi+1){
        if(i==0||i==sum-n)continue;
        cout<<i<<"\n";
    }
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll a, b;
    cin >> a >> b;
    if(a * b % 2) cout << "Odd";
    else cout << "Even";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int numberOfFiveHundredYen = sc.nextInt();
		int numberOfOneHundredYen = sc.nextInt();
		int numberOfFiftyYen = sc.nextInt();
		int fee = sc.nextInt();
		int count = 0;
		
		for(int i = 0; i <= numberOfFiveHundredYen; i++) {
			for(int j=0; j<= numberOfOneHundredYen; j++) {
				for(int k=0; k <= numberOfFiftyYen; k++){
					int amountOfPay = 500 * i + 100 * j + 50 * k;
					if(amountOfPay == fee) {
						count++;
					}
				}
			}
		}
		
		System.out.println(count); 

		
	}
}

Measured memory_bytes: 26708
import sys


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    ans = 0
    for i in range(1, 1000):

        lo = 1
        hi = n + 1
        while hi - lo > 1:
            mid = (hi + lo) // 2
            if i * mid >= n:
                hi = mid
            else:
                lo = mid
        if lo < i:
            break
        else:
            ans += (lo - i) * 2 + 1
    print(ans)


if __name__ == "__main__":
    main()


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

typedef struct{int num[6];}dice;

bool compare(dice A[], int i, int j){
    if (A[j].num[0] == A[i].num[0] && A[j].num[1] == A[i].num[1] &&
        A[j].num[2] == A[i].num[2] && A[j].num[3] == A[i].num[3] &&
        A[j].num[4] == A[i].num[4] && A[j].num[5] == A[i].num[5]){
            return true;
        }
    else return false;
}

bool simulation(dice A[], int i, int j){
    int u, v, w;
    bool a = false;
    for(int k = 0; k < 4; k++){
        u = A[i].num[0];
        A[i].num[0] = A[i].num[1];
        A[i].num[1] = A[i].num[5];
        A[i].num[5] = A[i].num[4];
        A[i].num[4] = u;
        for(int l = 0; l < 4; l++){
            v = A[i].num[0];
            A[i].num[0] = A[i].num[2];
            A[i].num[2] = A[i].num[5];
            A[i].num[5] = A[i].num[3];
            A[i].num[3] = v;
            for(int m = 0; m < 4; m++){
                w = A[i].num[1];
                A[i].num[1] = A[i].num[2];
                A[i].num[2] = A[i].num[4];
                A[i].num[4] = A[i].num[3];
                A[i].num[3] = w;
                if(compare(A, i, j) == true){
                    a = true;    
                }
            }
        }
    }
    return a;
}

int main(){
    int n;
    bool a;
    dice A[200];
    cin >> n;
    for(int x = 0; x < n; x++){
        for(int y = 0; y < 6; y++){
            cin >> A[x].num[y];
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            a = simulation(A, i, j);
            if(a == true) break;
        }
        if(a == true) break;  
    }
    
    if(a == true){
        cout << "No" << endl;
    }else if(a == false){
        cout << "Yes" << endl;
    }
    return 0;
}


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

int n, k;
int arr[500010];
int v[500010];
int ans[500010];

int f(int s, int e) {
    if(s == e) return 0;

    int m = s+e>>1;
    f(s, m);
    f(m+1, e);

    vector<int> a(m-s+1), b(e-m), ret;
    int mn = 10000000;
    for(int i=m; i>=s; i--) {
        mn = min(mn, v[i]);
        a[i-s] = mn;
    }

    for(int i=m+1; i<=e; i++) {
        b[i-m-1] = v[i];
    }

    int idx1 = s, idx2 = m+1;

    for(int i=0; i < e-s+1; i++) {
        if(idx1 > m) {
            ret.push_back(v[idx2++]);
        }
        else if(idx2 > e) {
            ret.push_back(v[idx1++]);
        }
        else if(a[idx1-s] >= b[idx2-m-1] + k) {
            ret.push_back(v[idx2++]);
        }
        else {
            ret.push_back(v[idx1++]);
        }
    }

    for(int i=s; i<=e; i++) {
        v[i] = ret[i-s];
    }
}

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

    cin >> n >> k;

    for(int i=0; i<n; i++) {
        cin >> arr[i];
        v[arr[i]] = i;
    }

    f(1, n);

    for(int i=1; i<=n; i++) {
        ans[v[i]] = i;
    }

    for(int i=0; i<n; i++) {
        cout << ans[i] << "\n";
    }
}


Measured memory_bytes: 11504
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
p=0
for i in range(n):
    p+=b[a[i]-1]
    if a[i-1]+1==a[i] and i!=0:
        #print(i)
        p+=c[a[i]-2]
print(p)

Measured memory_bytes: 3064
import java.util.Scanner;
   
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int l = sc.nextInt();
    int A[][] = new int[n][m];
    int B[][] = new int[m][l];
    long C[][] = new long[n][l];
   
    for(int x = 0; x < n; x++){
      for(int y = 0; y < m; y++){
        A[x][y] = sc.nextInt();
      }
    }
    for(int x = 0; x < m; x++){
      for(int y = 0; y < l; y++){
        B[x][y] = sc.nextInt();
      }
    }
    for(int x = 0; x < n; x++){
      for(int y = 0; y < l; y++){
        C[x][y] = 0;
        for(int z = 0; z < m; z++){
          C[x][y] = (A[x][z]*B[z][y])+C[x][y];
        }
        if(y == l-1){
          System.out.println(C[x][y]);
        }else{
          System.out.print(C[x][y]+" ");
        }
      }
    }
  }
}


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

int main(){
    vector<int> num(3, 0);
    int k;
    for(int i = 0; i < 3; i++){
        cin >> num[i];
    }
    cin >> k;

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

    int ans = 0;
    ans = num[2] * pow(2, k) + num[1] + num[0];
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))

ans = []

i = 1
adjacent = 1

while i < n:
  if a[i] == a[i - 1]:
    adjacent += 1
  else:
    ans.append(adjacent // 2)
    adjacent = 1
  i += 1
  
ans.append(adjacent // 2)
print(sum(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
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(){

	lli n;
	cin>>n;

	cout<<(n/500)*1000 + ((n%500)/5)*5<<endl;

    return 0;
}

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

#define MINF -1e8

int a[4] = {0, 0, -1, 1};
int b[4] = {-1, 1, 0, 0};

int ss[50][50];
int d[50][50];
priority_queue<pair<int, pair<int, int> > > pq;

void search(int h, int w){
  pq.push(make_pair(0, make_pair(0, 0)));
  d[0][0] = 0;

  while(!pq.empty()){
    pair<int, pair<int, int> > u = pq.top(); pq.pop();
    pair<int, int> v = u.second;

    if (u.first < d[v.first][v.second]) continue;

    for (int i = 0; i < 4; i++){
      if (v.first + a[i] < 0 || v.first + a[i] >= h) continue;
      if (v.second + b[i] < 0 || v.second + b[i] >= w) continue;
      if (ss[v.first + a[i]][v.second + b[i]] == 0) continue;
      if (d[v.first + a[i]][v.second + b[i]] < u.first - 1){
        d[v.first + a[i]][v.second + b[i]] = u.first - 1;
        pq.push(make_pair(d[v.first + a[i]][v.second + b[i]], make_pair(v.first + a[i], v.second + b[i])));
      }
    }
  }
}


int main(){
  int h, w;
  int count = 0;
  scanf("%d %d", &h, &w);
  for (int i = 0; i < h; i++){
    char str[50];
    scanf("%s", str);
    for (int j = 0; j < w; j++){
      if (str[j] == '.') {
        ss[i][j] = 1;
        count++;
      }
      else ss[i][j] = 0;
      d[i][j] = MINF;
    }
  }

  search(h, w);

  if (d[h-1][w-1] == MINF){
    printf("-1\n");
  } else printf("%d\n", count + d[h-1][w-1] - 1);

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(ll i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

int seen[200001] = { false };
int a[200001] = { 0 };
int ans[200001] = { 0 };
void dfs(int v, int sum,whei(int)&G) {
	seen[v] = true;
	ans[v] = sum;
	for (auto x : G[v]) {
		if (seen[x])continue;
		dfs(x, sum + a[x], G);
	}
}

int main() {
	int n, h, w;
	int ans = 0;
	cin >> n >> h >> w;
	rep(i, 0, n) {
		int H, W;
		cin >> H >> W;
		if (H >= h && W >= w)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# Nを取得
n = int(input())

# Xiを取得
xs = list(map(int, input().split()))

# 昇順にソートしたXiを取得
xs_sorted = sorted(xs)

# Xiの個数およびその1/2の値を取得
l = len(xs_sorted)
l_mid = int(l / 2)

# iが全体の1/2より小さい時、大きい時の中間値をそれぞれ取得
xs_mid_1 = xs_sorted[l_mid - 1]
xs_mid_2 = xs_sorted[l_mid]

# 結果を出力
for x in xs:
    if x < xs_mid_2:
        print("{}".format(xs_mid_2))
    else:
        print("{}".format(xs_mid_1))


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

int main() {
    int n;
    cin >> n;
    int num[4] = {n / 1000, (n / 100) % 10, (n / 10) % 10, n % 10};
    int sum;
    char op[3];
    bool match = false;
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < 2; k++) {
                op[0] = '+', op[1] = '+', op[2] = '+';
                sum = num[0];
                if (i == 1) op[0] = '-';
                if (j == 1) op[1] = '-';
                if (k == 1) op[2] = '-';
                for (int l = 0; l < 3; l++) {
                    if (op[l] == '+') sum += num[l + 1];
                    else
                        sum -= num[l + 1];
                }
                if (sum == 7) {
                    match = true;
                    break;
                }
            }
            if (match) break;
        }
        if (match) break;
    }
    cout << num[0];
    for (int i = 0; i < 3; i++) cout << op[i] << num[i + 1];
    cout << "=7" << endl;
    return 0;
}

Measured memory_bytes: 3612
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int H=stdIn.nextInt();
		int W=stdIn.nextInt();
		Deque<Integer> X=new ArrayDeque<Integer>();
		Deque<Integer> Y=new ArrayDeque<Integer>();
		boolean map[][]=new boolean[H][W];
		boolean visit[][]=new boolean[H][W];
		int min[][]=new int[H][W];
		for(int i=0;i<H;i++){
			String a=stdIn.next();
			for(int j=0;j<W;j++){
				char b=a.charAt(j);
				if(b=='#')
					map[i][j]=true;
			}
		}
		X.add(0);Y.add(0);visit[0][0]=true;
		if(map[0][0])
			min[0][0]=1;
		while(X.size()>0){
			int x=X.poll();
			int y=Y.poll();
			int cout=min[y][x];
			if(x+1<W){
				if(map[y][x]==false&&map[y][x+1])
					cout++;
				if(visit[y][x+1]&&min[y][x+1]>cout)
					min[y][x+1]=cout;
				if(visit[y][x+1]==false){
					min[y][x+1]=cout;
					visit[y][x+1]=true;
					X.add(x+1);Y.add(y);
				}
			}
			cout=min[y][x];
			if(y+1<H){
				if(map[y][x]==false&&map[y+1][x])
					cout++;
				if(visit[y+1][x]&&min[y+1][x]>cout)
					min[y+1][x]=cout;
				if(visit[y+1][x]==false){
					min[y+1][x]=cout;
					visit[y+1][x]=true;
					X.add(x);Y.add(y+1);
				}
			}
		}
		System.out.println(min[H-1][W-1]);
	}
}


Measured memory_bytes: 23172
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<ll,int>pi;

const int N=100005;

int n,m,st[N],tp,col[N],cnum[2];
vector<int>e[N],vcr;
bool ist[N],in[N],vis[N];

void dfs(int x,int fa){
	if(ist[x]){
		int p=tp;
		while(st[p]!=x)vcr.pb(st[p]),in[st[p]]=true,p--;
		vcr.pb(x);in[x]=true;
	}
	if(vis[x])return;
	st[++tp]=x,ist[x]=true,vis[x]=true,cnum[col[x]=!col[fa]]++;
	for(int v:e[x])if(v!=fa)dfs(v,x);
	st[tp--]=0,ist[x]=false;
}

template<class T>inline T abs_(T x){return x<0?-x:x;}

pi dp(int x,int fa){
	pi a={0,col[x]?1:-1};
	for(int v:e[x])if(v!=fa&&!in[v]){
		pi b=dp(v,x);
		a.fi+=b.fi+abs_(b.se);a.se+=b.se;
	}
	return a;
}

void work1(){
	if(cnum[0]!=cnum[1])puts("-1"),exit(0);
	printf("%lld\n",dp(1,0).fi);
}

void work2(){
	int len=vcr.size();
	bool even=len%2==0;
	if(even&&cnum[0]!=cnum[1])puts("-1"),exit(0);
	vector<int>arr;
	ll ans=0,now=0;
	for(int p:vcr){
		pi a=dp(p,0);
		if(even)arr.pb(now);else arr.pb(a.se);
		ans+=a.fi;now+=a.se;
	}
	if(!even){
		if(now<0){
			now=-now;
			for(int i=0;i<arr.size();i++)arr[i]=-arr[i];
		}
		int p=0;
		while(col[vcr[p]]!=col[vcr[(p+1)%len]])p++;
		ans+=now>>1,arr[p]-=now>>1,arr[(p+1)%len]-=now>>1;
		int q=(p+1)%len;now=0;
		do ans+=abs_(now+=arr[q]),q=(q+1)%len;while(q!=p);
	}else{
		nth_element(arr.begin(),arr.begin()+(arr.size()/2),arr.end());
		ll x=arr[arr.size()/2];
		for(int p:arr)ans+=abs_(p-x);
	}
	printf("%lld\n",ans);
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,u,v;i<=m;i++)scanf("%d%d",&u,&v),e[u].pb(v),e[v].pb(u);
	if(n%2==1)puts("-1"),exit(0);
	dfs(1,0);
	if(vcr.size()==0)work1(),exit(0);
	work2();
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll A, P;
    cin >> A >> P;
    cout << (A * 3 + P) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
use proconio::input;

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

fn main() {
    input! {
        s: String
    }
    let mut max=0;
    let mut prev=false;
    for c in  s.chars(){
        if c=='R'{
            if prev{
                max+=1;
            }
            else{
                max=1;
            }
            prev=true;
        }
        else{
            prev=false;
        }
    }
    println!("{}",max);
}


Measured memory_bytes: 2172
#include <bits/stdc++.h>  
#include <memory>
using namespace std;  
#define INF 0x3f3f3f3f  
typedef long long ll;  
const int N =  10005;  
const int M = 1001;
#define FI first
#define SE second
typedef pair<int, int>pii;
int mod = 1000000007;
char s[N];
int main()  
{  

   // ios::sync_with_stdio(0);
    while (~scanf("%s", s))
    {
      printf("%s\n", s[0] == s[2]?"Yes":"No");
    }
   return 0;
}  

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int a[110];
int main()
{
	int n,m,ans=0,tot=0;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;++i){scanf("%d",&a[i]);tot+=a[i];}
	for(int i=1;i<=n;++i)if(a[i]*4*m>=tot)++ans;
	if(ans>=m)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
// ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<vector>
using namespace std;
int main()
{
    int a;
    cin >> a;
    vector<int> m(a);
    int ans = 0;
    for (int i = 0; i < a; i++)
    {
        cin >> m[i];
        if ((m[i] % 2 != 0) && ((i+1) % 2 != 0))
            ans++;
    }
   
   
    cout << ans;
    return 0;


}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


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

int main(){
    int n,a,min=1000001,max=-10000001;
    long sum=0;
    cin >> n;
    
    for (int i=0 ; i<n ;i++){
        cin >> a;
        if (min > a){
            min=a;
        }
        if (max < a){
            max=a;
        }
        sum += a;
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>

long long n;

void solve(long long x) {
	if (x != 0) {
		int d = x % 26;
		if (d == 0) solve (x / 26 - 1);
		else solve(x / 26);
		if(d == 0) putchar('z');
		else putchar(d+'a'-1);
	}
}

int main() {
	scanf("%lld", &n);
	solve(n);
	return 0;
}

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

struct Node {
  int parent, left, right;
};

int inorder(Node nodes[], int i) {
  if (nodes[i].left != -1) {
    inorder(nodes, nodes[i].left);
    cout << " ";
  }
  cout << i;
  if (nodes[i].right != -1) {
    cout << " ";
    inorder(nodes, nodes[i].right);
  }
}

int postorder(Node nodes[], int i) {
  if (nodes[i].left != -1) {
    postorder(nodes, nodes[i].left);
    cout << " ";
  }
  if (nodes[i].right != -1) {
    postorder(nodes, nodes[i].right);
    cout << " ";
  }
  cout << i;
}

int preorder(Node nodes[], int i) {
  cout << i;
  if (nodes[i].left != -1) {
    cout << " ";
    preorder(nodes, nodes[i].left);
  }
  if (nodes[i].right != -1) {
    cout << " ";
    preorder(nodes, nodes[i].right);
  }
}

int main() {
  int n;
  cin >> n;
  Node nodes[n];
  for (int i = 0; i < n; i++) {
    nodes[i].parent = -1;
  }
  for (int i = 0; i < n; i++) {
    int index, left, right;
    cin >> index;
    cin >> left;
    cin >> right;
    nodes[index].left = left;
    nodes[index].right = right;
    if (left != -1) {
      nodes[left].parent = index;
    }
    if (right != -1) {
      nodes[right].parent = index;
    }
  }
  int root;
  for (int i = 0; i < n; i++) {
    if (nodes[i].parent == -1) {
      root = i;
      break;
    }
  }
  cout << "Preorder" << endl;
  cout << " ";
  preorder(nodes, root);
  cout << endl;
  cout << "Inorder" << endl;
  cout << " ";
  inorder(nodes, root);
  cout << endl;
  cout << "Postorder" << endl;
  cout << " ";
  postorder(nodes, root);
  cout << endl;
  return 0;
}



Measured memory_bytes: 3124
#include<iostream>
using namespace std;
int T,num[20],flag,numa[20],numb[20];

void dfs(int t,int ta,int tb)
{
    if(flag)
        return ;
    if(t>=10)
    {
        flag=1;
        return ;
    }
    if(num[t]>numa[ta])
    {
        numa[ta+1]=num[t];
        dfs(t+1,ta+1,tb);
        if(flag)
            return ;
    }
    if(num[t]>numb[tb])
    {
        numb[tb+1]=num[t];
        dfs(t+1,ta,tb+1);
    }
}

int main()
{
    cin>>T;
    while(T--)
    {
        flag=0;
        numa[0]=0,numb[0]=0;
        for(int i=0;i<10;++i)
            cin>>num[i];
        dfs(0,0,0);
        if(flag)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
}


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

using namespace std;

const int N = 1e5 + 5, M = 1e2 + 2;

long long n, w, rem[N], cost[N], take, leave;

long long mem[M][N] = {};

int main()
{
	scanf("%lld %lld", &n, &w);
	for(int i = 0 ; i < n; ++i)	scanf("%lld %lld", rem + i, cost + i);
	
	for(int i = n - 1; i >= 0; --i)
	{
		for(int r = 0; r <= w; ++r)
		{
			if(r + rem[i] > w)
				take = 0;
			else
				take = mem[i + 1][r + rem[i]] + cost[i];
			
			leave = mem[i + 1][r];
			mem[i][r] = max(take, leave);
		}
	}
			printf("%lld\n", mem[0][0]);
	return 0;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define N 200005
ll inf = 1e14;
ll mod = 1e9 + 7;
char en = '\n';

ll abs1(ll x) {
  if (x < 0)
    return -x;
  return x;
}
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

// Convex hull,maximum
bool Q;
struct Line {
  mutable ll k, m, p;
  bool operator<(const Line &o) const { return Q ? p < o.p : k < o.k; }
};
struct LineContainer : multiset<Line> {
  ll div(ll a, ll b) { return a / b - ((a ^ b) < 0 && a % b); }
  bool isect(iterator x, iterator y) {
    if (y == end()) {
      x->p = inf;
      return false;
    }
    if (x->k == y->k)
      x->p = x->m > y->m ? inf : -inf;
    else
      x->p = div(y->m - x->m, x->k - y->k);
    return x->p >= y->p;
  }
  void add(ll k, ll m) {
    auto z = insert({k, m, 0}), y = z++, x = y;
    while (isect(y, z))
      z = erase(z);
    if (x != begin() && isect(--x, y))
      isect(x, y = erase(y));
    while ((y = x) != begin() && (--x)->p >= y->p)
      isect(x, erase(y));
  }
  ll query(ll x) {
    //   cout<<endl<<jk<<endl;
    assert(!empty());
    Q = 1;
    auto l = *lower_bound({0, 0, x});
    Q = 0;
    //     cout<<l.k<<" h "<<l.m<<endl;
    return l.k * x + l.m;
  }
};

LineContainer obj;
// usage if want minimum,then if y=mx+c ,convert it to equation y'=-mx-c,and
// then do the below,only at last res=-obj.query(xi) adding line
// y=mx+c->obj.add(m,c) querying-> obj.query(x)

// sample problem: https://www.codechef.com/JULY18A/problems/PDELIV/
// sample solution: https://www.codechef.com/viewsolution/19132562

ll dp[N];
ll arr[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n, c;
  cin >> n >> c;
  for (ll i = 1; i <= n; i++)
    cin >> arr[i];

  memset(dp, 0, sizeof(dp));

  obj.add(2 * arr[1], -arr[1] * arr[1] - dp[1]);

  for (ll i = 2; i <= n; i++) {
    dp[i] = -obj.query(arr[i]) + arr[i] * arr[i] + c;
    obj.add(2 * arr[i], -arr[i] * arr[i] - dp[i]);
  }
  cout << dp[n] << en;

  return 0;
}


Measured memory_bytes: 15872
import java.util.*;

public class Main {
    long MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }
        long[] c = new long[n];
        for (int i = 0; i < n; i++) {
            c[i] = a[i] - b[i];
        }
        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += c[i];
        }
        if (sum < 0) {
            System.out.println("-1");
            return;
        }
        Arrays.sort(c);
        int r = n - 1;
        boolean ru = false;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (c[i] >= 0)
                break;
            ans++;
            while (r >= 0) {
                if (!ru) {
                    ru = true;
                    ans++;
                }
                if (c[i] + c[r] >= 0) {
                    long tmp = c[i] + c[r];
                    c[i] = 0;
                    c[r] = tmp;
                    break;
                } else {
                    c[i] = c[i] + c[r];
                    ru = false;
                    r--;
                }
            }
        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 66848
N = int(input())
cost= input().split()
cost = [int(i) for i in cost]
ans_list =[abs(cost[0] - cost[1])]
count = 1
while len(ans_list) != N-1:
  if count == 1:
    one_step = ans_list[count-1] + abs(cost[count] - cost[count+1])
    two_step = abs(cost[count-1] - cost[count+1])
    ans_list.append(min(one_step,two_step))
  else:
    one_step = ans_list[count-1] + abs(cost[count] - cost[count+1])
    two_step = ans_list[count-2] + abs(cost[count-1] - cost[count+1])
    ans_list.append(min(one_step,two_step))
  count += 1
print(ans_list.pop())

  
  
  

Measured memory_bytes: 14056
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <iostream>
using namespace std;

string s;

int main() {
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		for (int j = i + 1; j < s.size(); j++){
			if (s[i] == 'C' && s[j] == 'F') {
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 256
n = int(input())
count = 0

def make753(s):
    global count
    if int(s) > n:
        return 0
    if all(s.count(i) > 0 for i in '753'):
        count += 1
    for i in '753':
        make753(s + i)
    return count
        
print(make753('0'))

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

ans = 0
x = 0
for i in range(N):
    if A[i] >= (B[i] + x):
        ans += B[i] + x
        x = 0
    if A[i] <= x:
        ans += A[i]
        x = B[i]
    elif A[i] < (B[i] + x):
        ans += A[i]
        x = B[i] - (A[i] - x)
else:
    if A[N] >= x:
        ans += x
    else:
        ans += A[N]

print(ans)

Measured memory_bytes: 18624