akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long A, long long B, long long C, long long D){
  ll l = C*D/__gcd(C,D);
  cout << B-A+1-(B/C-(A-1)/C+B/D-(A-1)/D-(B/l-(A-1)/l)) << endl;
}

int main(){
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  long long C;
  scanf("%lld",&C);
  long long D;
  scanf("%lld",&D);
  solve(A, B, C, D);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <math.h>

using namespace std;

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)
#define SUMV(v)		(accumulate(v.begin(),v.end(),0.0))

#define INF 		2000000007
#define MOD			998244353

#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int ll;

//uint dp[MAX];
int S(int N){
	int suml=0;
	while(N){
		suml+=N%10;
		N/=10;
	}
	return suml;
}
 
int main(){
	int N;cin>>N;
 
	int s=S(N);
	if(N%s==0)cout << "Yes" << endl;
	else cout << "No" << endl;
 
 
	return 0;
}

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

vector<string> v;
int cost[10][10];
int dp[10][1<<10];
int N;
int dfs(int p,int bit){
	if( bit == (1<<N)-1 ) return 0;
	if( dp[p][bit] != -1 ) return dp[p][bit];
	int res = 1e9;
	for(int i = 0 ; i < N ; i++){
		if( bit >> i & 1 ) continue;
		res = min( dfs(i,bit|(1<<i)) + cost[p][i] ,res );
	}
	return dp[p][bit] = res;
}
string rec(int p,int bit){
	if( bit == (1<<N)-1 ) return "";
	string res = "~";
	for(int i = 0 ; i < N ; i++){
		if( bit >> i & 1 ) continue;
		if( dfs(p,bit) == dfs(i,bit|(1<<i)) + cost[p][i] ){
			res = min( v[i].substr(v[i].size()-cost[p][i]) + rec(i,bit|(1<<i)) ,res );
		}
	}
	return res;
}
int main(){
	while(cin >> N && N){
		memset(dp,-1,sizeof(dp));
		v.clear();
		v.resize(N);
		
		for(int i = 0 ; i < N ; i++)
			cin >> v[i];
		while(true){
			int flag = 0;
			vector<string> t;
			for(int i = 0 ; i < v.size() ; i++){
				for(int j = 0 ; j < v.size() ; j++){
					if( i != j ){
						if( v[i].find(v[j]) != -1 ){
							for(int k = 0 ; k < v.size() ; k++)
								if( j != k ) t.push_back(v[k]);
							v = t;
							goto end;
						}
					}
				}
			}
			break;
			end:;
		}
		for(int i = 0 ; i < v.size() ; i++){
			for(int j = 0 ; j < v.size() ; j++){
				if( i != j ){
					int m = min(v[i].size(),v[j].size());
					cost[i][j] = v[j].size();
					for(int k = m ; k > 0 ; k--){
						if( v[i].substr(v[i].size()-k) == v[j].substr(0,k) ){
							cost[i][j] = v[j].size() - k;
							break;
						}
					}
					//cout << v[i] << " " << v[j] << " " << cost[i][j] << endl;
				}
			}
		}
		N = v.size();
		int res = 1e9;
		for(int i = 0 ; i < v.size() ; i++){
			res = min<int>( dfs(i,(1<<i)) + v[i].size() , res );
		}
		string rres = "~";
		for(int i = 0 ; i < v.size() ; i++){
			if( dfs(i,(1<<i)) + v[i].size() == res ){
				rres = min( v[i] + rec(i,(1<<i)), rres);
			}
		}
		//cout << res << endl;
		cout << rres << endl;
		
		
	}
}

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

#define ll long long
#define endl "\n"

int main(){
	ll n, w; cin>>n>>w;
	vector<pair<ll, ll>> v(n);
	for(auto &i : v){
		cin>>i.first>>i.second;
	}
	sort(v.begin(), v.end());
	vector<ll> dp(w+1);
	for(int i = 1; i<=n; i++){
		for(int j = w; j >= v[i-1].first; j--){
			dp[j] = max(dp[j], v[i-1].second + dp[j-v[i-1].first]);
		}
	}
	cout<<dp[w]<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main () {
  
  // 入力
  
  int N, M;
  cin >> N >> M;
  
  Graph G(N);
  
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    G[a - 1].push_back(b - 1);
  }
  
  int S, T;
  cin >> S >> T;
  S--, T--;
  
  // BFS
  
  vector<vector<int>> step(3, vector<int>(N, -3));
  queue<pair<int, int>> que;
  
  step[0][S] = 0;
  que.push({0, S});
  
  while (!que.empty()) {
    
    pair<int, int> p = que.front();
    que.pop();
    int mod = p.first;
    int x = p.second;
    
    for (int nx : G[x]) {
      if (step[(mod + 1) % 3][nx] == -3) {
        step[(mod + 1) % 3][nx] = step[mod][x] + 1;
        que.push({(mod + 1) % 3, nx});
      }
    }
    
  }
  
  // 出力
  
  cout << step[0][T] / 3 << endl;
  
}

Measured memory_bytes: 7296
// Why am I so dumb? :c
#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair

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

#define fi first
#define se second

using namespace std;

typedef long long ll;

int arr[2005][2005];

int n, cost;

ll ans;

void solve() {
    scanf("%d %d", &n, &cost);

    for (int i = 1; i <= n; ++i) {
        scanf("%d", &arr[0][i]);
        ans += arr[0][i];
    }

    for (int i = 1; i < n; ++i) {
        ll cur = cost * 1ll * i;

        for (int j = 1; j <= n; ++j) {
            arr[i][j] = min(arr[0][j], arr[i - 1][(j > 1 ? j - 1 : n)]);
            cur += arr[i][j];
        }

        ans = min(ans, cur);
    }

    printf("%lld\n", ans);
}

int main() {
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    ll n,a,b;cin>>n>>a>>b;
    ll r,q;
    r=n/(a+b);
    q=n%(a+b);
    ll ans=r*a+min(q,a);
    cout<<ans<<endl;
    
    
    
    return 0;
}




Measured memory_bytes: 256
n,m = map(int,input().split())
n += 1
p = [1]*n
r = [0]*n
r[1] = 1
for i in range(m):
    x,y = map(int,input().split())
    if r[x]:
        r[y] = 1
        if p[x] == 1:
            r[x] = 0
    p[x] -= 1
    p[y] += 1
    
print(sum(r))

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

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

   int n; cin >> n;
   bool vis[n] = {};

   long long int k  = 7;
   int cnt = 1;
   bool found = true;
   while(k % n != 0){
        if(vis[k % n]){
                found = false;
                 break;

        }
        vis[k % n] = true;
        k *= 10;
        k += 7;
        k %=  n;
        ++cnt;

   }

   cout << (found? cnt: -1) << "\n";

    return 0;
}


Measured memory_bytes: 4580
n = gets.to_i
(1..n).map {|i|
    s, p = gets.split
    {'number' => i, 'city' => s, 'score' => p.to_i}
}.sort_by {|r|
    [r['city'], -r['score']]
}.each {|r|
    puts "#{r['number']}"
}


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

const int N = 100010;

typedef long long LL;

LL num[N]; int pos[N];

int main() {
    int n, s; scanf("%d%d", &n, &s);
    for (int i = 1; i <= n; i++) scanf("%d%lld", &pos[i], &num[i]);
    int l = 1, r = n, ls = 0; LL res = 0;
    for (int i = 1; i <= n; i++) {
        if (pos[l] > s) { res += pos[r] - s; break; }
        if (pos[r] < s) { res += s - pos[l]; break; }
        int nw;
        if (num[l] >= num[r]) nw = 1, num[l] += num[r];
        else nw = -1, num[r] += num[l];
        if (nw != ls) res += pos[r] - pos[l];
        ls = nw;
        if (nw == -1) l++; else r--;
    }
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    ll k, a, b;
    cin >> k >> a >> b;
    if(b - a <= 2){
        cout << 1+k << endl;
        return 0;
    }
    ll n = 1;
    rep(i, k){
        if(n >= a && i+1 < k)n+=b-a,i++;
        else n++;
    }
    cout << n << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String args[]){
    	Scanner scan = new Scanner(System.in);
      	int n = scan.nextInt();
      	int k = scan.nextInt();
      	int ans =0;
      while(n>0){
      	ans++;
        n/=k;
      }
      System.out.println(ans);
    }
}

Measured memory_bytes: 23252
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	
	static final int MOD = 998244353;
	static int A, B;
	
	static int[][] table;
	
	static int calc(int a, int b) {
		int ret = table[a][b];
		if (ret != -1) return ret;
		if (a == A && b == B) return table[a][b] = 1;
		long tmp  = 0;
		if (a > A) {
			tmp += b * (long)calc(a - 1, b);
			tmp %= MOD;
		}
		if (b > B) {
			tmp += a * (long)calc(a , b - 1);
			tmp %= MOD;
		}
		if (a > A && b > B) {
			tmp -= (a - 1) * (b - 1) * (long) calc(a-1, b-1);
			tmp %= MOD;
			tmp += MOD;
			tmp %= MOD;
		}
		return table[a][b] = (int) tmp;
	}
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		A = sc.nextInt();
		B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		table = new int[C + 1][D + 1];
		for (int i = 0; i <= C; i++) {
			Arrays.fill(table[i], -1);
		}
		out.println(calc(C, D));
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


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

using ll = long long;

int main() {
    ll n, k;
    cin >> n >> k;
    map<ll, ll> m;
    for (ll i = 0; i < n; i++) {
        ll a, b;
        cin >> a >> b;
        m[a] += b;
    }

    ll cnt = 0;
    for (auto x : m) {
        cnt += x.second;
        if (cnt >= k) {
            cout << x.first << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
bool sortbysec(const pair<ll,ll> &a, 
              const pair<ll,ll> &b) 
{ 
    return (a.second < b.second); 
} 

void solve()
{
	ll n;
	cin>>n;
	vector<pair<ll,ll>> a(n);
	for(ll i=0;i<n;i++)
		cin>>a[i].first>>a[i].second;
	sort(a.begin(),a.end(), sortbysec);
	ll cnt=0;
	for(ll i=0;i<n;i++)
	{
		cnt+=a[i].first;
		if(cnt>a[i].second)
		{
			cout<<"No";
			return;
		}
	}
	cout<<"Yes";
	return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}

Measured memory_bytes: 6348
#include <stdio.h>
#include <string.h>

int main(void)
{
	char a[10], b[10];

	scanf("%s %s", a, b);

	if (strcmp(a, "H") == 0 && strcmp(b, "H")==0 || strcmp(a, "D") == 0 && strcmp(b, "D") == 0)
	{
		puts("H");
	}
	else
	{
		puts("D");
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
std::vector<int> makeMod(std::vector<int> v) {
	for (int i = 1; i < (int)v.size(); ++i)
	{
		v[i] = v[i] % v[0];
	}
	return v;
}
std::vector<int> sortAndDestroy(std::vector<int> v){
	sort(v.begin(), v.end());
	while(true){
		if(v[0] == 0){
			v.erase(v.begin());
		}else{
			return v;
		}
	}
}
int main () {
	int N;
	cin >> N;
	std::vector<int> v(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	while((int)v.size() > 1){
		v = makeMod(v);
		v = sortAndDestroy(v);
	}
	cout << v[0] << endl;
}

Measured memory_bytes: 1024
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


a, b, k = LI()
res = []
for n in range(1, min(a, b) + 1):
    if not any([a % n, b % n]):
        res.append(n)

print(res[-k])


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int N;
  int a[110];
  cin>>N;
  for ( int i=0; i<N; ++i) cin>>a[i];
 sort(a, a + N, greater<int>()); 
    int alice=0;
  int bob=0;
  for (int i=0; i<N; i+=2) alice+=a[i];
  for (int i=1; i<N; i+=2) bob+=a[i];
  int ttt=alice-bob;
  cout<<ttt<<endl;
}
  

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

def main():

    n = int(input())
    n %= 100
    n %= 10
    if (n == 2 or n == 4 or n ==5 or n ==7 or n == 9):
        print('hon')
    elif(n == 3):
        print('bon')
    else:
        print('pon')

if __name__ == '__main__':
    main()


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

#define all(s) s.begin(), s.end()
#define vi vector<int>
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    int res = 0;
    while (n) n /= k, res++;
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
using namespace std;
#define ll long long int

int main(){
  string s; 
  cin >> s;
  int ans = 1000;
  for ( int i = 0; i + 2 < s.length(); ++i ) {
    int temp = 0;
    temp += ( s[i] - '0' ) * 100 + ( s[i + 1] - '0' ) * 10 + s[i + 2] - '0' ;
    //cout << temp << endl;
    ans = min( ans , abs( temp - 753 ) );
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	boolean [] isprime;
	int MAX = 1000000;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		eratos();
		while(true){
			int n = sc.nextInt();
			int x = sc.nextInt();
			if((n | x) == 0) break;
			int [] data = new int[n];
			for(int i = 0; i < n; i++){
				data[i] = sc.nextInt();
			}
			
			boolean [] dp = new boolean[x+1];
			dp[0] = true;
			int max = -1;
			for(int i = 0; i < n; i++){
				
				for(int j = 0; j <= x; j++){
					if(dp[j]){
						if(j + data[i] > x) continue;
						dp[j + data[i]] = true;
						if(isprime[j + data[i]]){
							max = Math.max(max, j + data[i]);
						}
					}
				}
			}
			System.out.println(max == -1 ? "NA" : max);
		}
	}
	
	private void eratos() {
		isprime = new boolean[MAX + 1];
		Arrays.fill(isprime, true);
		
		for(int i = 2; i * i <= MAX; i++ ){
			if(isprime[i]){
				for(int j = i + i; j <= MAX; j += i){
					isprime[j] = false;
				}
			}
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 16000
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

const int MAX_N = 86410;
vector<int> s(MAX_N),t(MAX_N),u(MAX_N);
#define double long double
bool ok(int N,int L,double m){
    double res = L + 0.0;
    double L2 = L + 0.0;
    rep(i,N){
        double change=(t.at(i)-s.at(i))*(m-u.at(i));
        res = min(L2,res+change);
        if(res < 0) return false;
        if(i == N-1){
	  res += (86400-t.at(i))*m;
	  break;
	}
        res += (s.at(i+1)-t.at(i))*m;
        res = min(L2,res);
    }
    if(res + 1e-10 > L) return true;
    double oneday = res;
    rep(i,N){
      if(i == 0) res += s.at(i)*m;
        double change=(t.at(i)-s.at(i))*(m-u.at(i));
        res = min(L2,res+change);
        if(res < 0) return false;
        if(i == N-1){
	  res += (86400-t.at(i))*m;
	  break;
	}
        res += (s.at(i+1)-t.at(i))*m;
        res = min(L2,res);
    }
    if(res < oneday) return false;
    return true;
}

int main() {
    int L;
    while(cin>>N>>L && N != 0){
        rep(i,N) cin>>s.at(i)>>t.at(i)>>u.at(i);
        //s.at(N) = s.at(0) + 86400;
        double lo = 1e-7, hi = 1e+6;
        while(hi-lo > 1e-13){
            double m = (hi+lo)/2.0;
            if(ok(N,L,m)) hi = m;
            else lo = m;
            //if(m<1.5) cout << hi << ' ' << lo << endl;
        }
        cout<<fixed;
        cout<<setprecision(10)<<lo<<endl;
    }
}



Measured memory_bytes: 3776
#include <stdlib.h>
#include <stdio.h>
#define P_KEY(i) (i / 2)
#define L_KEY(i) (i * 2)
#define R_KEY(i) (i * 2 + 1)

int main(int argc, char **argv) {
  int n, i;
  int *bh;

  scanf("%d", &n);
  bh = (int *) malloc(sizeof(int) * (n + 1));
  for (i = 1; i <= n; ++i) scanf("%d", &bh[i]);
  for (i = 1; i <= n; ++i) {
    printf("node %d: key = %d, ", i, bh[i]);
    if (P_KEY(i) >= 1) printf("parent key = %d, ", bh[P_KEY(i)]);
    if (L_KEY(i) <= n) printf("left key = %d, ", bh[L_KEY(i)]);
    if (R_KEY(i) <= n) printf("right key = %d, ", bh[R_KEY(i)]);
    printf("\n");
  }
  free(bh); exit(0);
}


Measured memory_bytes: 2104
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a = list(map(int, input().split()))
    if sum(a)>=22:
        print('bust')
    else:
        print('win')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
n = int(input())
F = [int("".join(input().split()), 2) for _ in range(n)]
P = [list(map(int, input().split())) for _ in range(n)]

max_ans = -float("inf")

for i in range(1, 1024):
	ans = 0
	for j in range(n):
		ans += P[j][list(str(bin(i & F[j]))).count("1")]
	if ans > max_ans:
		max_ans = ans

print(max_ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;
const int64_t INF = numeric_limits<long long>::max();
typedef int64_t ll;


int64_t solve(int N, const vector<int64_t> & x, const vector<int64_t> & y) {
    ll a = -1;
    ll b = -1;
    ll amin = INF;
    ll amax = -INF;
    ll bmin = INF;
    ll bmax = -INF;
    ll amini = -1;
    ll amaxi = -1;
    ll bmini = -1;
    ll bmaxi = -1;
    REP(i, N) {
        a = x[i] - y[i];
        b = x[i] + y[i];
        if (a < amin) {
            amin = a;
            amini = i;
        }
        if (a > amax) {
            amax = a;
            amaxi = i;
        }
        if (b < bmin) {
            bmin = b;
            bmini = i;
        }
        if (b > bmax) {
            bmax = b;
            bmaxi = i;
        }
    }
    return max(abs(x[amini] - x[amaxi]) + abs(y[amini] - y[amaxi]), abs(x[bmini] - x[bmaxi]) + abs(y[bmini] - y[bmaxi]));
}

// generated by online-judge-template-generator v4.6.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    constexpr char endl = '\n';
    int N;
    cin >> N;
    vector<int64_t> x(N), y(N);
    REP (i, N) {
        cin >> x[i] >> y[i];
    }
    auto ans = solve(N, x, y);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6356
//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 <exception>
#include <fstream>
#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>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

long long lcm(long long a, long long b) {
	return a * b / gcd(a, b);
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<int>a(N);
	vector<int>b(N);
	for (int i = 0; i < M; i++) {
		int p;
		string s;
		cin >> p >> s;
		p--;
		if (s == "AC") {
			a[p] = 1;
		}
		else if( a[p] != 1){
			b[p]++;
		}
	}
	int ansA = 0;
	int ansB = 0;
	for (int i = 0; i < N; i++) {
		if (a[i] == 1) {
			ansA++;
			ansB += b[i];
		}
	}
	cout << ansA << " " << ansB << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, n) for (int i = 0; i < n; i++)
#define EACH(i, n) for (auto &i: n)

int solv(int n) {
  vector<int> x(n);

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

  int minx = 0, mindist = -1;
  for (int p = 0; p <= 100; p++) {
    int sum = 0;
    for (int i = 0; i < n; i++) {
      sum += (p - x[i]) * (p - x[i]);
    }
    if (mindist == -1 || mindist > sum) {
      mindist = sum;
      minx = p;
    }
  }

  return mindist;
}

int main() {
  int n;

  cin >> n;
  cout << solv(n) << endl;

  return 0;
}


Measured memory_bytes: 256
//
// Created by jchen on 18-7-4.
//　　aoj　0118 深度优先搜索

//给一个三种字母组成的区域,判断有多少个区域
#include <iostream>

#define MAX_H 100
#define MAX_W 100

using namespace std;

int h, w;

char field[MAX_H][MAX_W];

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

void dfs(int x, int y, char t) {
    field[x][y]='a';
    for(int i=0;i<4;i++){
        int nx=x+a[i][0];
        int ny=y+a[i][1];

        if(nx>=0&&ny>=0&&nx<h&&ny<w&&field[nx][ny]==t){
            dfs(nx,ny,t);
        }
    }
}
//遍历过的部分全都换成'a'
int main(){

    while (cin>>h>>w){
        int res=0;
        if(h==0&&w==0)
            break;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>field[i][j];
            }
        }

        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(field[i][j]!='a'){
                    res++;
                    dfs(i,j,field[i][j]);
                }
            }
        }
        cout<<res<<endl;
    }
    return 0;
}







Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll N;
vector<ll> E[100000];
map<pll, ll> cnt;

pll dfs(ll v, ll p) {
  const ll mod1 = 1000000007;
  const ll mod2 = 1000000009;

  pll ret = pll(1, 1);
  for(ll u : E[v]) if(u != p) {
    pll x = dfs(u, v);
    (ret.fi += x.fi * 12345 % mod1) %= mod1;
    (ret.se += x.se * 12345 % mod2) %= mod2;
  }
  cnt[ret]++;

  return ret;
}

int main(void) {
  cin >> N;
  REP(i, 0, N - 1) {
    ll A, B; cin >> A >> B; A--; B--;
    E[A].push_back(B);
    E[B].push_back(A);
  }

  dfs(0, -1);

  ll ans = 0;
  for(auto p : cnt) {
    ll x = p.second;
    ans += x * (x - 1) / 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 22640
#include<iostream>
#include<string>

using namespace std;

int main() {
	string S;
	cin >> S;
	for (int i = 1; i < S.length(); i++)
	{
		if (S[i - 1] == S[i]) {
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = std::int64_t;
using u64 = std::uint64_t;
#define REP(i, n) for (int i = 0; i < (i64)(n); ++i)
#define ALL(x) std::begin(x), std::end(x)
#define SIZE(a) (int)((a).size())

template <class T>
bool chmax(T &a, T b) {
  return a >= b ? false : ((a = std::move(b)), true);
}
template <class T>
bool chmin(T &a, T b) {
  return a <= b ? false : ((a = std::move(b)), true);
}

template <typename T>
using V = std::vector<T>;
template <typename T>
std::vector<T> make_vec(size_t n, T a) {
  return std::vector<T>(n, a);
}
template <typename... Ts>
auto make_vec(size_t n, Ts... ts) {
  return std::vector<decltype(make_vec(ts...))>(n, make_vec(ts...));
}
template <typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &a) {
  for (auto &x : a) is >> x;
  return is;
}
template <typename Container>
std::ostream &pprint(const Container &a, std::string_view sep = " ",
                     std::string_view ends = "\n", std::ostream *os = nullptr) {
  if (os == nullptr) os = &std::cout;
  auto b = std::begin(a), e = std::end(a);
  for (auto it = std::begin(a); it != e; ++it) {
    if (it != b) *os << sep;
    *os << *it;
  }
  return *os << ends;
}
template <typename T, typename = void>
struct is_iterable : std::false_type {};
template <typename T>
struct is_iterable<T, std::void_t<decltype(std::begin(std::declval<T>())),
                                  decltype(std::end(std::declval<T>()))>>
    : std::true_type {};

template <typename T,
          typename = std::enable_if_t<is_iterable<T>::value &&
                                      !std::is_same<T, std::string>::value>>
std::ostream &operator<<(std::ostream &os, const T &a) {
  return pprint(a, ", ", "", &(os << "{")) << "}";
}
template <typename T, typename U>
std::ostream &operator<<(std::ostream &os, const std::pair<T, U> &a) {
  return os << "(" << a.first << ", " << a.second << ")";
}

#ifdef ENABLE_DEBUG
template <typename T>
void pdebug(const T &value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void pdebug(const T &value, const Ts &... args) {
  pdebug(value);
  std::cerr << ", ";
  pdebug(args...);
}
#define DEBUG(...)                                   \
  do {                                               \
    std::cerr << " \033[33m (L" << __LINE__ << ") "; \
    std::cerr << #__VA_ARGS__ << ":\033[0m ";        \
    pdebug(__VA_ARGS__);                             \
    std::cerr << std::endl;                          \
  } while (0)
#else
#define pdebug(...)
#define DEBUG(...)
#endif
using namespace std;

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

  V<int> c(n + 1);
  for (i64 x = 1; x <= n; ++x) {
    for (i64 y = 1; x * y < n; ++y) {
      c[x * y]++;
    }
  }
  i64 ans = 0;
  for (int i = 1; i < n; ++i) {
    ans += c[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 7136
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int k = 0;
    for (int i = a; i <= b; i++) {
        int d0 = i % 10;
        int d1 = i / 10 % 10;
        int d2 = i / 100 % 10;
        int d3 = i / 1000 % 10;
        int d4 = i / 10000 % 10;
        if (d0 == d4 && d1 == d3) k++;
    }

    cout << k << endl;

    return 0;
}

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

const int MOD = (int)1e9+7;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++)	cin >> a.at(i);

	sort(a.begin(),a.end(),greater<int>());
	int ans;
	for(int i=0;i<n-1;i++){
		if(a.at(i)*2>=a.at(0) && a.at(i+1)*2<=a.at(0)){
			if(a.at(i)==a.at(0))	ans=a.at(i+1);
			else{
				if(abs(a.at(i)*2-a.at(0))<abs(a.at(i+1)*2-a.at(0)))	ans=a.at(i);
				else	ans=a.at(i+1);
			}
		}
	}
	cout << a.at(0) << " " << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <tuple>
 
using namespace std;
 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define cina(s, n, a) for(int i = s; i < n; i++) cin >> a[i]
#define couta(n, a) for(int i = 0; i < n; i++) cout << a[i] << ' '
#define copy(s, n, a, b) for(int i = s; i < n; i++) b[i] = a[i]
#define yesno(ok) cout << (ok ? "YES" : "NO")
#define mod(a, b) (b + (a % b)) % b
#define MOD (ll)1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;


void solve(){
    ll x;
    cin >> x;
    ll l = 0, r = 1e9;
    while(r - l > 1){
        ll t = l + (r - l) / 2;
        if(t * t + t - 2 * x >= 0) r = t;
        else l = t;
    }
    cout << r;
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(int i = 1; i <= q; i++){
        solve();
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc075.contest.atcoder.jp/tasks/arc075_b>
問題文============================================================
 あなたが散歩していると、突然 N 体の魔物が出現しました。
 それぞれの魔物は 体力 という値を持ち、i 体目の魔物の出現時の体力は hi です。
 体力が 0 以下となった魔物は直ちに消滅します。
 
 幸い、あなたは熟練の魔法使いであり、爆発を引き起こして魔物を攻撃できます。
 一回の爆発では、以下のように魔物の体力を減らすことができます。
 
 生存している魔物を一体選び、その魔物を中心に爆発を引き起こす。
 爆発の中心となる魔物の体力は A 減り、その他の魔物の体力はそれぞれ B 減る。
 ここで、A と B はあらかじめ定まった値であり、A>B である。
 すべての魔物を消し去るためには、最小で何回の爆発を引き起こす必要があるでしょうか？
=================================================================

解説=============================================================

================================================================
*/
ll N,A,B;
vector<ll> h;

bool C(ll m){
    ll cnt = 0;
    ll dif = A - B;
    for(int i = 0; i < N;i++){
        ll X = h[i] - m*B;
        if(X <= 0) continue;
        cnt += (X + dif - 1)/dif;
    }
    return cnt <= m;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> A >> B;
    h.resize(N);
    for(auto &in:h) cin >> in;
    ll l = 0, r = INF;
    while(r - l > 1){
        ll m = (l + r)/2;
        if(C(m)){
            r = m;
        }else{
            l = m;
        }
    }
    cout << r << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define MOD 998244353
using namespace std;

int main() {
    int n, num[100005] = {};
    cin >> n;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        num[t]++;
        num[t + 1]++;
        num[t + 2]++;
    }
    sort(num, num + 100002, greater<int>());
    cout << num[0] << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int gcd(int a, int b) {
    if (a < b)swap(a, b);
    if (a % b == 0)return b;
    return gcd(b, a % b);
}
int main() {
    long long a, b;
    cin >> a >> b;
    cout << a * b / gcd(a, b) << endl;
}

Measured memory_bytes: 256
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let a: usize = sc.read();
    let b: usize = sc.read();
    let c: usize = sc.read();
    if c > a + b {
        println!("{}", a + b + 1 + b);
    } else {
        println!("{}", c + b);
    }
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
N = int(input())
tt = 0
xx = 0
yy = 0
z = [list(map(int, input().split())) for _ in range(N)]
for i in range(N):
    t, x, y = z[i]
    dt = t - tt
    dx = abs(x - xx)
    dy = abs(y - yy)
    if dt < dx + dy or (dt - (dx + dy)) % 2:
        print('No')
        exit()
    tt = t
    xx = x
    yy = y
print('Yes')

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

int main() {
  int a,b;
  cin >> a >> b;
  int ans = 0;
  if(a<10 && b <10) ans = a*b;
  else ans = -1;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int n, h;

int f(int d, int u){
	return d?(h+d):u;
}

int g(int d, int u){
	return d?d:(h+u);
}

int out[410];
int in[410];
int par[410];
int chk[410];

int r(int x){return (par[x]==x)?x:(par[x]=r(par[x])); }
void join(int a, int b){ par[r(a)]=r(b); }

void In(){
	scanf("%d%d",&n,&h);
	for(int i=1; i<2*h; ++i) par[i]=i;
	for(int i=1; i<=n; ++i){
		int a, b, c, d;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		int x = f(c, c+a);
		int y = g(d, d+b);
		join(x, y);
		out[x]++; in[y]++;
	}
}

bool check(){
	for(int i=1; i<=2*h-1; ++i){
		if(out[i] > in[i]){
			if(i > h) return 0;
			chk[r(i)]=1;
		}
		if(out[i] < in[i]){
			if(i <= h) return 0;
		}
	}
	for(int i=1; i<=2*h-1; ++i) if((out[i] || in[i]) && !chk[r(i)]) return 0;
	return 1;
}

int main()
{
	In();
	puts(check()?"YES":"NO");
	return 0;
}


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

bool prime(int n){
  bool y=true;
  if(n == 1){
    y = false;
  }
  else {
    for(int i=2;i<n;i++){
      if(n%i == 0){
        y = false;
        break;
      }
    }
  }
    return y;
}

int func(int n,int i){
  int ans = 0;
  if(prime(i)){
    if(n%i == 0 && i <= n){
      int k = n;
      while(k >0){
        ans++;
        k /= i;
        if(k%i != 0){
          break;
        }
      }
    }
  }
  return ans;
}
     
int main() {
  int n;
  cin >> n;
  ll ans = 1;
  vector<int> a(1001);
  for(int i=2;i<=n;i++){
    for(int j=2;j<=i;j++){
      a.at(j) += func(i,j);
    }
  }
  for(int i=1;i<1001;i++){
    ans *= (a.at(i) +1);
    ans %= 1000000007;
  }
  cout << ans << endl;  
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
class Main{
	public static void main(String[]args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		
		String str=br.readLine();
		int n=Integer.parseInt(str);
		
		
		String[] a=br.readLine().split(" ");
		int min=Integer.parseInt(a[0]),max=Integer.parseInt(a[0]);
		long sum=0;
		for(int i=0;i<n;i++){
			sum+=Integer.parseInt(a[i]);
			if(min>Integer.parseInt(a[i])){
				min=Integer.parseInt(a[i]);
			}
			if(max<Integer.parseInt(a[i])){
				max=Integer.parseInt(a[i]);
			}
		}
		System.out.println(min+" "+max+" "+sum);
	}
}

Measured memory_bytes: 28512
#include <iostream>
using namespace std;
typedef long long ll;
ll a,b,n,m,tot;
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a;
        tot+=a;
    }
    if(n-tot<0)cout<<-1<<endl;
    else cout<<n-tot<<endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;

/**
 * 解説どおりに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			long x = scanner.nextLong();
			long y = scanner.nextLong();
			System.out.println((Math.abs(x - y) <= 1) ? "Brown" : "Alice");
		}
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

const int INF = 1e9 + 5;

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

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

	vector<int> dp(n, INF);
	dp[0] = 0;

	for (int i = 0; i < n; i++)
	{
		for (int j : {i + 1, i + 2})
		{
			if (j < n)
			{
				dp[j] = min(dp[j], dp[i] + abs(arr[i] - arr[j]));
			}
		}
	}
	cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1024
mod = 10**9+7


def matmul(A, B):
    C = [[0] * len(B[0]) for _ in range(len(A))]
    for i in range(len(A)):
        for j in range(len(B[0])):
            for k in range(len(B)):
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % mod
    return C


def matpow(A, p):
    n = len(A)
    B = [[0] * n for _ in range(n)]
    for i in range(n):
        B[i][i] = 1
    while p > 0:
        if p & 1:
            B = matmul(B, A)
        A = matmul(A, A)
        p >>= 1
    return B


N, K = map(int, input().split())
adj = []
for _ in range(N):
    adj.append(list(map(int, input().split())))
mat = []
for col in range(N):
    tmp = []
    for row in range(N):
        tmp.append(adj[row][col])
    mat.append(tmp)

vec = [[1] * N]
ans = matmul(vec, matpow(mat, K))
print(sum(ans[0]) % mod)


Measured memory_bytes: 42280
import java.util.Scanner

fun main(args:Array<String>){
    val sc=Scanner(System.`in`)

    var a=sc.nextInt()
    var b=sc.nextInt()
    var c=sc.nextInt()
    var t:Int

    if (a<=b){
        t=a
        a=b
        b=t
    }
    if (a<=c){
        t=a
        a=c
        c=t
    }
    if (b<=c){
        t=b
        b=c
        c=t
    }

    println(a*10+b+c)
}

Measured memory_bytes: 31396
n = int(input())
nmax = 1000000000000001
alp = list("abcdefghijklmnopqrstuvwxyz")
ans = []
while n > 0:
    r = n%26
    if r == 0:
        r = 26
    n = (n-r)//26
    ans.append(alp[r-1])
print(''.join(ans[::-1]))



Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
 
int main() {  
  long int a, b, r, x, tmp;
  cin>>a>>b; 
  x = a * b;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  cout<<x/b<<endl;
  return 0;
}

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

int main(){
int n;
cin>>n;
long long s=0;
  for(int i=1;i<n+1;i++){
    if(i%3==0){
    }
    else if(i%5==0){
    }
    else
      s += i;
  }
 cout << s << endl;
}

Measured memory_bytes: 3636
from sys import stdin
n = int(stdin.readline().rstrip())
x = [int(_) for _ in stdin.readline().rstrip().split()]
xc = x.copy()
xc.sort()
ans = [xc[(len(xc)-1)//2], xc[len(xc)//2]]
for i in range(n):
    if x[i] < ans[1]:
        print(ans[1])
    elif x[i] >= ans[1]:
        print(ans[0])

Measured memory_bytes: 25228
using System;
using System.Collections.Generic;
using System.Linq;
// using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
            // List<long> kl=new List<long>(hs.Keys);
            // kl.Sort();
            // foreach(long k in kl){
            //     s[1]-=hs[k];
            //     if(s[1]<1){Console.WriteLine("{0}",k);break;}
            // }
            char[] c1 = s[0].ToCharArray();
            char[] c2 = s[1].ToCharArray();
            char[] c3 = s[2].ToCharArray();
            Console.WriteLine(c1[0].ToString().ToUpper()+c2[0].ToString().ToUpper()+c3[0].ToString().ToUpper());
        }
        //最小公倍数
        static long Lcm(long a, long b)
        {
            return a/Gcd(a,b)*b;
        }

        //最大公約数
        static long Gcd(long m, long n)
        {
            if(n==0)return m;
            return Gcd(n,m%n);
        }
    }
}

Measured memory_bytes: 13140