akhauriyash/Code-Regression huggingface dataset:
use input::Input;
use std::collections::HashSet;

fn main() {
    let mut input = Input::new();

    let n: usize = input.parse();
    let mut st = HashSet::new();
    for _ in 0..n {
        st.insert(input.parse::<String>());
    }
    println!("{}", st.len());
}

#[allow(dead_code)]
mod input {
    use std::io::{stdin, BufRead, StdinLock};

    pub struct Input<'a> {
        memory: Vec<String>,
        reader: StdinLock<'a>,
    }

    impl<'a> Input<'a> {
        pub fn new() -> Self {
            Self {
                memory: Vec::new(),
                reader: Box::leak(Box::new(stdin())).lock(),
            }
        }
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            self.reader.read_line(&mut s).expect("read_line failed.");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            if self.memory.len() == 0 {
                let s = self.read_line();
                self.memory = s.split_whitespace().map(String::from).rev().collect();
            }
            self.memory.pop().unwrap().parse().ok().unwrap()
        }
    }
}


Measured memory_bytes: 15308
#include <iostream>
using namespace std;
bool has3(int x){
    while(x){
        if ( x % 10 ==3) return true;
        x /= 10;
    }
    return false;
}
void call(int n){
    for ( int x = 1; x <=n; x++){
        if (x % 3 == 0 || has3(x) ){
            cout << " " << x;
        }
    }
    cout << endl;
}
int main() {
    int n;
    cin >> n;
    call(n);

    return 0 ;

}


Measured memory_bytes: 3100
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007LL;
int main() {
	ll A, B, C, K;
	cin >> A >> B >> C >> K;
	if (K % 2 == 0) {
		cout << A - B << endl;
	}
	else {
		cout << B - A << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>


int main(){

  int a,b,i,s;

  while(scanf("%d %d",&a,&b)!=EOF){
    s=a+b;
    for(i=0;s!=0;i++){
      s/=10;
    }
    printf("%d\n",i);
  }
  return 0;
}

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

int main(){
  int n,m,sum=0;
  cin>>n;
  m=n;
  int a;
  while(n>0){
    a=n%10;
    sum+=a;
    n=n/10;
  }
  if(m%sum==0)
    cout<<"Yes"<<endl;
  else cout <<"No"<<endl;
}

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

using namespace std;

struct node
{
	int num,ls,rs;
	node(int _num)
	{
		num=_num;
		ls=-1;
		rs=-1;
	}
};

typedef vector<node> Tree;

Tree T;

void insert(int t,int n)
{
	
	if(T.size()==0)
	{
		T.push_back(node(n));
		return ;
	}
	//printf("%d %d %d\n",t,T[t].num,n);
	if(T[t].num>n)
		if(T[t].ls==-1)
		{
			T[t].ls=T.size();
			T.push_back(node(n));
		}
		else insert(T[t].ls,n);
	else
		if(T[t].rs==-1)
		{
			T[t].rs=T.size();
			T.push_back(node(n));
		}
		else insert(T[t].rs,n);
}

void Preorder(int t)
{
	if(t==-1) return;
	printf(" %d",T[t].num);
	Preorder(T[t].ls);
	Preorder(T[t].rs);
}

void Inorder(int t)
{
	if(t==-1) return;
	Inorder(T[t].ls);
	printf(" %d",T[t].num);
	Inorder(T[t].rs);
}

void print()
{
	Inorder(0);
	printf("\n");
	Preorder(0);
	printf("\n");
}

int main()
{
	int n;
	scanf("%d",&n);
	while(n--)
	{
		char s[10];
		scanf("%s",s);
		if(s[0]=='i')
		{
			int t;
			scanf("%d",&t);
			insert(0,t);
		}
		else print();
	}
}

Measured memory_bytes: 9000
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	
 	int a,b,c;
 	scanf("%d %d %d",&a,&b,&c);
 	set<int>s;
 	s.insert(a),s.insert(b),s.insert(c);

 	if(sz(s)==2)printf("Yes\n");
 	else	printf("No\n");
}		


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        for (int i = 1;i<=9;i++){
            for (int k = 1;k<=9;k++) {
                System.out.println(i + "x" + k + "=" + i*k);
            }
        }
    }
}



Measured memory_bytes: 24072
def fa(): #final answer
    global ans
    print(ans)
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
N = getN()
K= getN()

xs = getList()

ans = 0
for i in range(N):
    x = xs[i]
    dis= 2*min(x, abs(K-x))
    ans += dis

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[6] = {0,1,0,-1,1,-1};
const int vy[6] = {1,0,-1,0,1,1};




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

    ll n,k,q;
    cin >> n >> k >> q;
    k -= q;
    vector<int> a(n,k);
    rep(i,q){
        int x;
        cin >> x;
        x--;
        a[x]++;
    }
    int ans = 0;
    rep(i,n){
        if(a[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 1024
using System;
    using System.Collections.Generic;
    using static System.Console;
    using System.Linq;


class Program
{

    static void Main(string[] Args) {
        var Nx = new List<string>(ReadLine().Split(' ')).Select(ele => Int32.Parse(ele)).ToList();
        var a = new List<string>(ReadLine().Split(' ')).Select(ele => Int32.Parse(ele)).ToList();
        int Result = 0;

        while (true) {
            int min = a.Min();
            if (min <= Nx[1]) {
                a.Remove(min);
                Nx[1] -= min;
                Result++;
            } else break;
            if(a.Count() == 0) {
                if (Nx[1] != 0) Result--;
                break;
            }
        }

        WriteLine(Result);

        ReadLine();
    }
}

Measured memory_bytes: 13280
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        for(int i=0;i<N;i++){
            arr[i] = sc.nextInt();
        }
        int ans = 0;
        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                ans += arr[i]*arr[j];
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  int x;
  cin>>x;
  if(x>=2400){
    cout<<1<<endl;
    return 0;
  }
  for(int i=0;i<25;i++){
    for(int j=0;i+j<25;j++){
      for(int k=0;i+j+k<25;k++){
        for(int l=0;i+j+k+l<25;l++){
          for(int m=0;i+j+k+l+m<25;m++){
            for(int n=0;i+j+k+l+m+n<25;n++){
              if(i*100+j*101+k*102+l*103+m*104+n*105==x){
                cout<<1<<endl;
                return 0;
              }
            }
          }
        }
      }
    }
  }
  cout<<0<<endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

typedef pair<int,int> pii;

int main() {
	int N, M;
	cin >> N >> M;
	vector<pii> rope;
	vector<int> p;
	vector<long long> sum0;
	vector<long long> sum1;

	for(int i = 0; i < N; i++) {
		int s, t;
		cin >> s >> t;
		rope.push_back(pii(s,t));
	}
	for(int i = 0; i < M; i++) {
		int p_;
		cin >> p_; p.push_back(p_);
	}
	p.push_back(0);
	sort(p.begin(), p.end());
	p.push_back(1e9+7);
	long long s0, s1;
	s0 = s1 = 0;
	for(int i = 1; i < p.size(); i++) {
//		cout << p[i] << endl;
		sum0.push_back((i%2 ? (p[i] - p[i-1]) : 0) + s0);
		sum1.push_back((i%2 ? 0 : (p[i] - p[i-1])) + s1);
		s0 += sum0.back() - s0;
		s1 += sum1.back() - s1;
	}
	sum0.push_back(1e9+7);
	sum1.push_back(1e9+7);

	/*
	for(int i = 0; i < sum0.size(); i++) {
		cout << sum0[i] << " " << sum1[i] << endl;
	}
	// */

	long long res = 0;
	for(int i = 0; i < rope.size(); i++) {
		vector<int>::iterator iter0, iter1;
		if(rope[i].first < rope[i].second) {
			iter0 = upper_bound(p.begin(), p.end(), rope[i].first);
			iter1 = lower_bound(p.begin(), p.end(), rope[i].second);
			iter1--;
			if(iter0 - iter1 != 1) {
				res += *iter0 - rope[i].first;
//				cout << res << endl;
				if((iter0-p.begin())%2) {
					res += sum0[iter1-p.begin()-1] - sum0[iter0-p.begin()-1];
//					cout << res << endl;
				}
				else {
					res += sum1[iter1-p.begin()-1] - sum1[iter0-p.begin()-1];
//					cout << res << endl;
				}
				if((iter0-p.begin())%2 != (iter1-p.begin())%2) {
					res += rope[i].second - *iter1;
//					cout << res << endl;
				}
			}
			else {
				res += rope[i].second - rope[i].first;
//				cout << res << endl;
			}
		}
		else {
			iter0 = lower_bound(p.begin(), p.end(), rope[i].first);
			iter1 = upper_bound(p.begin(), p.end(), rope[i].second);
			iter0--;
			if(iter1 - iter0 != 1) {
				res += rope[i].first - *iter0;
//				cout << res << endl;
				if(!((iter0-p.begin())%2)) {
					res += sum0[iter0-p.begin()-1] - sum0[iter1-p.begin()-1];
//					cout << res << endl;
				}
				else {
					res += sum1[iter0-p.begin()-1] - sum1[iter1-p.begin()-1];
//					cout << res << endl;
				}
				if((iter0-p.begin())%2 != (iter1-p.begin())%2) {
					res += *iter1 - rope[i].second;
//					cout << res << endl;
				}
			}
			else {
				res += rope[i].first - rope[i].second;
//				cout << res << endl;
			}
		}
//		cout << "-----" << endl;
	}

	cout << res << endl;
}

Measured memory_bytes: 4948
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

ll x[202020];
ll sum[202020];

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

	ll N, X;
	cin >> N >> X;
	for (int i = 0; i < N; i++)cin >> x[i];
	reverse(x, x + N);
	for (int i = 0; i < N; i++)sum[i + 1] = sum[i] + x[i];

	ll ans = inf;
	for (int k = 1; k <= N; k++) {
		ll temp = 0;
		ll j = 0;
		int ok = 1;
		while(j*k < N){
			j++;
			if (j == 1) {
				temp += 5LL * (sum[j*k] - sum[(j - 1LL)*k]);
			}
			else {
				temp += (2LL * j + 1LL)*(sum[min(j*k,N)]-sum[(j-1LL)*k]);
			}
			if (temp > 2e15) {
				ok = 0;
				break;
			}
		}
		if (!ok)continue;
		temp += k * X;
		ans = min(ans, temp);
	}
	ans += N*X;
	puts(ans);

	return 0;
}



Measured memory_bytes: 3456
package main

import "fmt"

func isPalindrome(S string) bool{
	var ll = len(S)
	for i:=0;i<=ll/2;i++ {
		if S[i] != S[ll - 1  - i] {
			return false
		}
	}
	return true
}

func main(){
	var S string
	fmt.Scanf("%s",&S)
	ll := len(S)
	la := (ll - 1) / 2
	lb := (ll+3) / 2
	S1 := S[0:la]
	S2 := S[lb-1:ll]

	if isPalindrome(S) && isPalindrome(S1) && isPalindrome(S2) {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No ")

}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const int INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n,m_a,m_b;
	cin >> n >> m_a >> m_b;
	vector<int> a(n+1),b(n+1),c(n+1);
	for(int i = 1; i <= n; i++){
		cin >> a[i] >> b[i] >> c[i];
	}

	int dp[41][401][401] = {0};

	for(int i = 0; i <= 40; i++){
		for(int j = 0; j <=400; j++){
			for(int k = 0; k <= 400; k++){
				dp[i][j][k] = INF;
			}
		}
	}

	dp[0][0][0] = 0;
	for(int i = 1; i <= 40; i++){
		for(int j = 400; j >= 0; j--){
			for(int k = 400; k >= 0; k--){
				if(j-a[i]>=0 && k-b[i]>=0){
					dp[i][j][k] = min(dp[i-1][j-a[i]][k-b[i]]+c[i],dp[i-1][j][k]);
				}else{
					//dp[i][j][k] = min(dp[i][j][k],dp[i-1][j][k]);
					dp[i][j][k] = dp[i-1][j][k];
				}
			}
		}
	}

	int ans = INF;
	for(int j = 1; j <= 400; j++){
			for(int k = 1; k <= 400; k++){
				if(k*m_a == j*m_b && dp[n][j][k] < ans) ans = dp[n][j][k];
			}
		}

	if(ans == INF) cout << -1 << endl;
	else cout << ans << endl;

	return 0;
}

Measured memory_bytes: 25984
(defun read-n (n)
  (loop :repeat n
        :collect (read)))

(let* ((n (read))
       (m (read))
       (c (read))
       (bases (read-n m)))
  (princ
    (loop :repeat n
          :when (< 0 (+ c (loop :as b
                                :in bases
                                :sum (* b (read)))))
          :sum 1)))



Measured memory_bytes: 6504
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 11;
struct ddd{
    int w, id;
    bool operator < (const ddd &a) const{
        return w < a.w;
    }
}st[N];
int n;
int main(){
    cin>>n;
    for(int i = 1;i <= n; i++){
        scanf("%d", &st[i].w);
        st[i].id = i;
    }   
    sort(st + 1, st + 1 + n);
    for(int i = 1;i <= n; i++){
        printf("%d ", st[i].id);
    }
    puts("");
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>

using namespace std;

int a[3];
bool ans;
int main()
{
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    ans = false;
    if(a[0] == a[1] && a[0] != a[2]) ans = true;
    if(a[1] == a[2] && a[1] != a[0]) ans = true;
    if(ans)cout << "Yes"<<endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
def solve():
    ans = 0

    B = A[:]
    V = [False] * n

    B.sort()
    for i in range(n):
        T[B[i]] = i
    for i in range(n):
        if V[i]:
            continue
        cur = i
        S = 0
        m = 10000  # 10**4
        an = 0
        while True:
            V[cur] = True
            an += 1
            v = A[cur]
            m = min(m, v)
            S += v
            cur = T[v]
            if V[cur]:
                break
        ans += min(S + (an - 2) * m, m + S + (an + 1) * s)
    return ans


if __name__ == '__main__':
    n = int(input())
    A = [int(i) for i in input().split()]
    s = min(A)
    s = min(s, 10000)
    T = [0] * (max(A)+1)
    ans = solve()
    print(ans)


Measured memory_bytes: 5784
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int n,m,k,ans;

main(){
	cin>>n;
	int a[n];
	rep(i,n){
		cin>>a[i];
	}
	rep(i,n){
		int t;cin>>t;
		a[i]-=t;
	}
	rep(i,n){
		ans+=max(0ll,a[i]);
	}
	dans;
}





Measured memory_bytes: 256
parseLine(str) = parse.(Int, split(str))

function solve()
    N, K = parseLine(readline())
    A = parseLine(readline())
    cycle = Vector{Int}()
    cur = A[1]; length = 0
    seen = zeros(Bool, N)
    while true
        seen[cur] == true && break
        seen[cur] = true
        push!(cycle, cur)
        length += 1
        cur = A[cur]
    end
    start = findfirst(isequal(cur), cycle)
    C = length - start + 1
    ai = (K <= length) ? K : start+(K-start)%C
    println(cycle[ai])
end

solve()

Measured memory_bytes: 203272
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/math/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

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

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  boost::for_each(vc, [&os, &vc](T value) {
    os << value << '\n';
    });
  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)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  //string S{}; std::cin >> S;

  ui N{}; cin >> N;
  typedef pair<ui, ull> Branch;
  typedef vector<Branch> BranchList;
  typedef vector<BranchList> Node;

  Node nodes(N);
  vector<int> nodes_color(N, -1);
  rep(0, N - 1)
  {
    ui node1{}, node2{};
    ull weight{};
    cin >> node1 >> node2 >> weight;
    --node1; --node2;

    nodes[node1].push_back(Branch{ node2, weight });
    nodes[node2].push_back(Branch{ node1, weight });
  }

  std::queue<ui> mqueue;

  auto push_next = [&nodes_color, &mqueue](BranchList ls, int current_color){
    boost::for_each(ls, [&nodes_color, &mqueue, &current_color](Branch bc) {
      if (nodes_color[bc.first] != -1)
      {
        return;
      }

      if (bc.second % 2 == 0)
      {
        nodes_color[bc.first] = current_color;
      }
      else
      {
        nodes_color[bc.first] = !current_color;
      }
      mqueue.push(bc.first);
      });
  };

  nodes_color[0] = 0;
  push_next(nodes[0], 0);

  while (!mqueue.empty())
  {
    ui it = mqueue.front();
    mqueue.pop();
    push_next(nodes[it], nodes_color[it]);
  }

  using std::cout;
  cout << nodes_color << '\n';
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 8320
from sys import stdin

n = int(stdin.readline().rstrip())
p = list(map(int,stdin.readline().split()))

counter=0
for i in range (1, n-1, 1):
  if (p[i-1] > p[i] and p[i] >= p[i+1]) or (p[i-1] <= p[i] and p[i] < p[i+1]):
    counter+=1
print(counter)    

Measured memory_bytes: 38384
#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;
template<typename T> using VP = vector<pair<T, T>>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }
#pragma endregion

template<typename T> void Eratosthenes(const T N, std::vector<T>& prime) {
    std::vector<bool> is_prime(N + 1, true);
    for (T i = 2; i <= N; i++) {
        if (is_prime[i]) {
            for (T j = 2 * i; j <= N; j += i) is_prime[j] = false;
            prime.emplace_back(i);
        }
    }
}

signed main()
{
    int n;
    cin >> n;
    const int amax = static_cast<int>(1e6);
    V<bool> is_prime(amax+1, false);
    set<int> same;
    REP(i, n) {
        int a;
        cin >> a; 
        if (is_prime[a]) same.insert(a);
        is_prime[a] = true;
    }
    if (is_prime[1]) {
        if (same.find(1) != same.end()) {
            col(0);
        }
        else col(1);
        return 0;
    }
    
    int ans = 0;
    for (int i = 2; i <= amax/2; i++) {
        if (is_prime[i]) {
            for (int j = 2 * i; j <= amax; j += i) is_prime[j] = false;
        }
    }
    RBF(s, same) is_prime[s] = false;

    for (int i = 2; i <= amax; i++) {
        if (is_prime[i]) ans++;
    }

    col(ans);
    return 0;
}


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

int N;
string S;
int main() {
	cin >> N >> S;
	int t = 0, m = 0;
	for (int i = 0; i < N; ++i) {
		if (S[i] == '(') {
			++t;
		}
		else {
			--t;
			m = min(m, t);
		}
	}
	for (int i = 0; i > m; --i) {
		cout << '(';
	}
	cout << S;
	for (int i = 0; i < t - m; ++i) {
		cout << ')';
	}
	cout << endl;
}

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

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

    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: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().ToCharArray();
            var t = Console.ReadLine().ToCharArray();

            var count = Enumerable.Range(0, s.Length).Count(i => s[i] == t[i]);
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define REPZ(i, z, n) for(decltype(n) i = (z); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(all(v)))
#define MIN(v) (*min_element(all(v)))
#define INF 1000000000000 //1E+12
#define MOD 1000000007    //合同式の法

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

typedef long long ll;
typedef unsigned long long ul;
// 1s間で可能なループ回数2E+8回
// intの最大値2147483647~2E+9
// long longの最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<> push_back
// 連想配列map<key,value> insert,
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 setprecision()
// to_string<->stoi
// stoll(longlong)
// stod(double)
// 大文字65-90(-32)
// 小文字97-122(+32)
using namespace std;
int main(){
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  string s; cin >> s;
  bool a=false,b=false;
  for(char i:s){
    a = (i=='A' or a);
    b = (i=='B' or b);
  }
  if(a and b) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair
#define debug_vec(x, n) cout << (#x) << ": "; for(int i = 0; i < n; i++) cout << x[i] << (i == n - 1 ? "\n" : " ");

typedef long long ll;
typedef long double ld;

void solve(){
    ll x;
    cin >> x;
    ll n = 100;
    ll c = 0;
    while(n < x){
        n += (n / 100);
        c++;
    }
    cout << c << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}



Measured memory_bytes: 3612
import math
import sys
from functools import lru_cache
sys.setrecursionlimit(10**6)
t=int(input())
for i in range(t):
  n,a,b,c,d=map(int,input().split())
  @lru_cache(maxsize=None)
  def f(n):
    if n==0:
      return 0
    if n==1:
      return d
    else:
      x=n*d
      
      q,r=divmod(n,2)
      if r==0:
        x=min(x,f(q)+a)
      else:
        x=min(x,f(q)+a+d,f(q+1)+a+d)
      
      q,r=divmod(n,3)
      if r==0:
        x=min(x,f(q)+b)
      elif r==1:
        x=min(x,f(q)+b+d,f(q+1)+b+d*2)
      else:
        x=min(x,f(q)+b+d*2,f(q+1)+b+d)
      
      q,r=divmod(n,5)
      if r==0:
        x=min(x,f(q)+c)
      elif r==1:
        x=min(x,f(q)+c+d,f(q+1)+c+d*4)
      elif r==2:
        x=min(x,f(q)+c+d*2,f(q+1)+c+d*3)
      elif r==3:
        x=min(x,f(q)+c+d*3,f(q+1)+c+d*2)
      else:
        x=min(x,f(q)+c+d*4,f(q+1)+c+d)
      
      return x
  
  print(f(n))

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

int main(){
    int N, Q;  cin >> N >> Q;
    string S;  cin >> S;
    vector<int> cnt(N+1, 0);
    for(int i=2; i<=N; i++){
        if(S.substr(i-2, 2) == "AC"){
            cnt[i]++;
        }
        cnt[i] += cnt[i-1];
        // cout << i << " " << cnt[i] << endl;
    }

    while(Q--){
        int l, r;  cin >> l >> r;
        int ans = cnt[r] - cnt[l-1];
        if(l-2 >= 0 && S.substr(l-2, 2) == "AC") ans--;
        cout << ans << endl;
    }
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
int main(){
	char s[10];
	scanf("%s",s);
	int i,l,cnt=0,ccnt=0;
	l=strlen(s);
	for(i=0;i<l;i++){
			if(s[i]<95)cnt++;
		}
		//printf("%d\n",cnt);
		if(cnt!=2){
		printf("WA\n");
		return 0;
	}
	if(s[0]!='A'){
		printf("WA\n");
		return 0;
	}

	if(s[0]=='C' || s[1] =='C' || s[l-1]== 'C'){
		printf("WA\n");
		return 0;
	}
	for(i=2;i<l-1;i++){
		if(s[i]=='C')ccnt++;
	}
	if(ccnt!=1){
		printf("WA\n");
		return 0;
	}
	printf("AC\n");
	
	return 0;
}	



Measured memory_bytes: 128
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<char>>A(N, vector<char>(N));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> A[i][j];
		}
	}
	vector<vector<char>>B(M, vector<char>(M));
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < M; j++) {
			cin >> B[i][j];
		}
	}
	for (int i = 0; i <= N - M; i++) {
		for (int j = 0; j <= N - M; j++) {
			int check = 0;
			for (int k = 0; k < M; k++) {
				for (int l = 0; l < M; l++) {
					if (B[k][l] == A[k + i][l + j]) {
						check++;
					}
				}
			}
			if (check == M * M) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}


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

int main(){
    long N;
    cin >> N;
    
    long ans_10 = 1, ans_9 = 2, ans_8 = 1;
    
    for (unsigned long i = 0; i < N; i++) {
        ans_10 *= 10;
        ans_10 %= ((unsigned long) pow(10, 9) + 7);
        
        ans_9 *= 9;
        ans_9 %= ((unsigned long) pow(10, 9) + 7);
        
        ans_8 *= 8;
        ans_8 %= ((unsigned long) pow(10, 9) + 7);
    }
    
    long ans = 1;
    ans = ans_10- ans_9 + ans_8;
    if (ans < 0) {ans += (unsigned long) pow(10, 9) + 7;}
    
    cout << ans << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=1e9+7;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}





int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,k;
    cin>>n>>k;
    vector<ll>a(n),f(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>f[i];
    }
    sort(a.begin(),a.end());
    sort(f.rbegin(),f.rend());
    ll l=0;
    ll r=1000000000010;
    while(l<=r){
        ll mid=l+(r-l)/2;
        ll ans=0;
        for(int i=0;i<n;i++){
            ans+=max(ll(0),a[i]-(mid/f[i]));
        }
        if(ans<=k){
            r=mid-1;
        }
        else{
            l=mid+1;
        }
    }
    cout<<r+1<<endl;
    return 0;
    }


Measured memory_bytes: 3456
import Data.List
import Control.Monad
check :: [Int] -> [[Int]] -> Int
check s x = if null x /= True then check (intersect s (head x)) (tail x) else length s 
main :: IO()
main=do
 t<-map read.words<$>getLine
 a<-map (map read.words)<$>replicateM (head t) getLine
 print$check (tail (head a)) (map tail(tail a))

Measured memory_bytes: 1148
#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <string>

int main()
{
  int l;
  std::cin >> l;
  double ans = l * l * l / 27.0;
  //std::cout << ans;
  printf("%f", ans);

  return 0;
}


Measured memory_bytes: 256
N=int(input())
a=sorted(list(map(int,input().split())))
n=a[-1]
tmp=0
if n%2==0:
  ideal=n//2
  for i in range(N-1):
    if abs(ideal-tmp)>abs(ideal-a[i]):
      tmp=a[i]
else:
  ideal1=(n-1)//2
  ideal2=ideal1+1
  for i in range(N-1):
    if abs(ideal1-tmp)>abs(ideal1-a[i]) or abs(ideal2-tmp)>abs(ideal2-a[i]):
      tmp=a[i]
print(' '.join([str(n),str(tmp)]))

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

int main() {
  
  int n,k ;
  cin>>n>>k ;
  int x[n] ;

  for (int i = 0; i < n; i++) cin >> x[i] ;

  int ans = 0 ;
  for (int i = 0; i < n ; i++)
  {
      int tmp = min(x[i]-0,abs(k-x[i])) ;
      ans += tmp*2 ;
  }
  
  cout << ans << endl ;

 return 0 ;

}

Measured memory_bytes: 256
N, M = [int(_) for _ in input().split()]
P = [0] * (N + 1)
for i in range(M):
    a, b = [int(_) for _ in input().split()]
    if a == 1:
        P[b] |= 2
    if b == N:
        P[a] |= 1
if any([p==3 for p in P]):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 6296
#include <bits/stdc++.h>
#define LL long long int
#define Max(x, y) (x > y ? x : y)
#define Min(x, y) (x < y ? x : y)
#define Abs(x) ( (x) > 0 ? (x) : -(x) )
#define Swap(x,y) do{x = x ^ y; y = x ^ y; x = x ^ y;}while(0)
#define IO_BOOST                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0)
#define setp(x) fixed << setprecision(x)
#define INF 0x3f3f3f3f
#define Lowbit(x) ((x) & (-x))
#define Pii pair<int, int>
#define x first
#define y second
#define MOD ((int)1e9+7)
using namespace std;

int n, m;
char mp[2000][2000];
int dp[2000][2000];
void solve(){
    for(int i = 1 ; i <= n ; i++){
        if( mp[i][1] == '.' ) dp[i][1] = 1;
        else break;
    }
    for(int i = 1 ; i <= m ; i++){
        if( mp[1][i] == '.' ) dp[1][i] = 1;
        else break;
    }    
    for(int i = 2 ; i <= n ; i++){
        for(int j = 2 ; j <= m ; j++){
            if( mp[i][j] == '.' ){
                dp[i][j] = ( dp[i-1][j] + dp[i][j-1] ) % ((int)1e9+7);
            }
        }
    }
    cout << dp[n][m] << '\n';
}
int main(){
    IO_BOOST;
    cin >> n >> m;
    for(int i = 1 ; i <= n ; i++){
        for(int j = 1 ; j <= m ; j++){
            cin >> mp[i][j];
        }
    }
        
    solve();

}

Measured memory_bytes: 12544
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

long long int gcd(long long int a, long long int b) {
	if (a < b)swap(a, b);
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

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

	cin >> N;
	string s;
	cin >> s;
	map<pair<string,string>,long long  int>fm;
	for (int i = 0; i < 1 << N; i++) {
		string ss;
		string st;
		for (int j = 0; j < N; j++) {
			if (i >> j & 1)ss.push_back(s[j]);
			else st = s[j] + st;
		}
		fm[{ss, st}]++;
	}
	map<pair<string, string>,long long  int>sm;
	for (int i = 0; i < 1 << N; i++) {
		string ss;
		string st;
		for (int j = 0; j < N; j++) {
			if (i >> j & 1)ss.push_back(s[2 * N - j - 1]);
			else st = s[2 * N - j - 1] + st;
		}
		sm[{ss, st}]++;
	}
	long long int ans = 0;
	for (auto i : fm) {
		ans += i.second*sm[i.first];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 103424
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

int N;
int id[1010][1010];
vvi A,G;

int getId(int i,int j) {
  if(i>j) {
    swap(i,j);
  }
  return id[i][j];
}
bool visited[501000];
bool calced[501000];
int dp[501000];

int dfs(int k) {
  if(visited[k]) {
    if(!calced[k]) return -1;
    return dp[k];
  }
  visited[k] = true;
  dp[k] = 1;
  rep(i,sz(G[k])) {
    int t = G[k][i];
    int res = dfs(t);
    if(res==-1) return -1;
    chmax(dp[k],res+1);
  }
  calced[k] = true;
  return dp[k];
}
  
int main() {
  cin >> N;
  A = vvi(N,vi(N-1));
  rep(i,N) {
    rep(j,N-1) {
      cin >> A[i][j];
      A[i][j]--;
    }
  }
  int c=0;
  rep(i,N) {
    rep(j,N) {
      if(i<j) {
        id[i][j] = c;
        c++;
      }
    }
  }
  G = vvi(c);
  rep(i,N) {
    rep(j,N-2) {
      G[getId(i,A[i][j])].push_back(getId(i,A[i][j+1]));
    }
  }
  int ans = 0;
  rep(i,c) {
    int res = dfs(i);
    if(res==-1) {
      cout << -1 << endl;
      return 0;
    }
    chmax(ans,res);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 38400
/*
oruegg19 - Arundhati Bhattacharya
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<unsigned ll>
#define mp make_pair
#define F first
#define S second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const unsigned ll l=1000000007;
const int MAX_=2000;
int T;

void solve(int t)
{
  int n;
  cin >> n;

  vll a(n), b(n), c(n);

  for(int i=0; i<n; i++)
  {
    cin >> a[i] >> b[i] >> c[i];
  }

  for(int i=1; i<n; i++)
  {
    a[i] += max(b[i-1],c[i-1]);
    b[i] += max(a[i-1],c[i-1]);
    c[i] += max(a[i-1],b[i-1]);
  }

  cout << max(max(a[n-1],b[n-1]),c[n-1]) << endl;
}



int main()
{
  IOS
  int t,testCases;
  testCases=1;

  while(testCases--)
  {
    t=1;
    // cin >> t; //comment this in case of singular test case
    T = t;
    while(t--)
    {
      // cout << "HERE" << endl;
      solve(t);
    }
  }
  return 0;

}



Measured memory_bytes: 2560
import java.util.*;
 
public class Main { 
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		for(int i=0; i<s.length(); i++){
			if(s.charAt(i) != t.charAt(i)){
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 26960
# Min, Max and Sum

amount = int(input())
numbers = [int(i) for i in input().rstrip().split()]

minimum = 1000000
maximum = -1000000
total = 0
for number in numbers:
    if number < minimum:
        minimum = number
    if number > maximum:
        maximum = number
    total += number

print(minimum, maximum, total)



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

namespace aizu1
{
    public class Solution
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] A = Array.ConvertAll<string, int>(Console.ReadLine().Split(' '), int.Parse);
            int q = int.Parse(Console.ReadLine());
            int[] M = Array.ConvertAll<string, int>(Console.ReadLine().Split(' '), int.Parse);
            string res = "";

            for(int j=0;j<q;j++)
            {
                if (CanSumUp(A, M[j], 0,n)) res += "yes\n";
                else res += "no\n";
            }

            Console.Write(res);
        }

        public static bool CanSumUp(int[] list, int sum, int index, int n)
        {
            if (sum == 0) return true;

            if (index == n) return false;

            return CanSumUp(list, sum - list[index], index + 1,n) || CanSumUp(list,sum,index+1,n); 
        }
    }
}

Measured memory_bytes: 8888
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

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

  int N,K; cin >> N >> K;
  vector<int> h(N); cin >> h;

  vector<LLI> dp(N,1e18);
  dp[0] = 0;

  REP(i,N){
    REPE(j,K){
      if(i+j<N) dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
    }
  }

  cout << dp[N-1] << endl;
  

  
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N,vector<int>(0));
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G.at(a).push_back(b);
  }
  int S, T;
  cin >> S >> T;
  S--;
  T--;
  vector<int> dist(N,-1);
  vector<vector<bool>> come(N,vector<bool>(3,false));
  dist.at(S) = 0;
  come.at(S).at(0) = true;
  queue<int> Q;
  Q.push(S);
  bool end = false;
  while(Q.size() && !end){
    int x = Q.front();
    int y = dist.at(x);
    Q.pop();
    
    queue<int> q;
    q.push(x);
    int cnt = 0;
    int num = 1;
    int m = q.size();
    while(q.size()){
      int z = q.front();
      q.pop();
      cnt++;
      for(int i=0; i<G.at(z).size(); i++){
        if(num <= 2 && !come.at(G.at(z).at(i)).at(num)){
          q.push(G.at(z).at(i));
          come.at(G.at(z).at(i)).at(num) = true;
        }
        else if(num == 3){
          q.push(G.at(z).at(i));
        }
      }
      if(cnt == m){
        if(num == 3){
          while(q.size()){
            int a = q.front();
            q.pop();
            if(dist.at(a) == -1){
              dist.at(a) = y+1;
              Q.push(a);
              if(a == T){
                end = true;
              }
            }
          }
        }
        else{
          num++;
          cnt = 0;
          m = q.size();
        }
      }
    }
  }
  
  /*for(int i=0; i<N; i++){
    cout << dist.at(i) << " ";
  }*/
  cout << dist.at(T) << endl;
}

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

int main(){

  int n,m,ans_cnt=0;
  string blue[100],red[100];

  cin >> n;
  for(int i = 0; i < n; i++) cin >> blue[i];
  cin >> m;
  for(int j = 0; j < m; j++) cin >> red[j];

  for(int i = 0; i < n; i++){
    int cnt = 0;

    for(int j = 0; j<n; j++){
      if(blue[i] == blue[j]) cnt++;
    }
    for(int j = 0; j<m; j++){
      if(blue[i] == red[j]) cnt--;
    }

    ans_cnt = max(ans_cnt,cnt);
  }

  cout << ans_cnt << endl;

  return 0;
}

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

int main(){
  long long int n;
  cin >> n;
  long long int k=1;
  long long int x=n;
  while(x>=10){
    x/=10;
    k++;
  }
  
  long long int ans=1000;
  long long int a=1;
  for(long long int i=0;i<k-2;i++) a*=10;
  
  for(long long int i=0;i<k-1;i++){
    ans=min(ans,max(753-n/a%1000,n/a%1000-753));
    a/=10;
  }
  cout << ans << endl;
}

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

int main() {
	int n;
	cin>>n;
	bool is7 = false;
	while(n) {
		int d = n%10;
		if(d == 7) {
			is7 = true;
			break;
		}
		n = n / 10;
	}
	if(is7) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 3632
def add_list(buf, new_lists, removals):
    l = len(buf)
    if l >= k:
        sbf = sorted(buf)
        removals.extend(sbf[:l - k + 1])
        new_lists.append(buf)


n, k, q = map(int, input().split())
aaa = list(map(int, input().split()))
srt = sorted(set(aaa))
lists = [aaa]
ans = float('inf')
for a in srt:
    new_lists = []
    removals = []
    for lst in lists:
        buf = []
        for b in lst:
            if a > b:
                add_list(buf, new_lists, removals)
                buf = []
            else:
                buf.append(b)
        add_list(buf, new_lists, removals)
    if len(removals) < q:
        break
    removals.sort()
    ans = min(ans, removals[q - 1] - a)

print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
    int n,a;

    cin>>n>>a;
    if(n%500-a<=0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

ll cnt[3][33];
ll D[33][33];


int main(){

    ll N, C;
    cin >> N >> C;
    for(ll f = 1; f <= C; f++){
        for(ll t = 1; t <= C; t++){
            cin >> D[f][t];
        }
    }
    for(ll y = 1; y <= N; y++){
        for(ll x = 1; x <= N; x++){
            ll c;
            cin >> c;
            cnt[(x + y) % 3][c]++;
        }
    }
    ll ans = 1000000000LL;
    for(ll a = 1; a <= C; a++){
        for(ll b = 1; b <= C; b++){
            if(a == b)continue;
            for(ll c = 1; c <= C; c++){
                if(b == c)continue;
                if(a == c)continue;
                ll to[3] = {a, b, c};
                ll tmp = 0;
                for(ll i = 0; i < 3; i++){
                    for(ll j = 1; j <= C; j++){
                        tmp += D[j][to[i]] * cnt[i][j];
                    }
                }
                ans = min(ans, tmp);
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

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

Measured memory_bytes: 3560