akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int n=s.size();
	ll ans=0;
	rep(i,n)range(j,i,n){
		ll v=stoll(s.substr(i,j-i+1));
		ll l=1ll<<max(0,i-1);
		ll r=1ll<<max(0,n-j-2);
		ans+=v*l*r;
	}
	puta(ans);
	return 0;
}


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

using namespace std;

void test()
{
    char ch;
    cin>>ch;
    
    if(ch >=65 && ch<=90)
        cout<<"A";
    else
        cout<<"a";
}

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

        test();

    return 0;
}


Measured memory_bytes: 3632
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String s = sc.next();
      long k = sc.nextLong();
      for(int i = 0;i < s.length();i++){
      	if(s.substring(i,i+1).equals("1")&&k==i+1){
        	System.out.println(1);
            return;
        }
        else if(!(s.substring(i,i+1).equals("1"))){
        	System.out.println(s.substring(i,i+1));
            return;
        }
      }
      System.out.println(1);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s; cin >>s;
  if(s.size()%2==1){
    cout<<"No"<<endl;
    return 0;
  }else{
    for(int i=0;i<s.size()/2;i+=2){
      if(s[i]=='h'&&s[i+1]=='i'){
        cout<<"Yes"<<endl;
        return 0;
      }else{
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  return 0;
}     

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	vector<pii> ans;
	REP(i, N) {
		int a, b;
		cin >> a >> b;
		ans.push_back(make_pair(a, b));
	}
	cin >> N;
	REP(i, N) {
		int a, b;
		cin >> a >> b;
		ans.push_back(make_pair(a, b));
	}
	SORT(ans);
	REP(i, ans.size()) {
		
		if (i != 0) {
			if (ans[i].first == ans[i - 1].first&&ans[i].second == ans[i - 1].second) {
				continue;
			}
		}
		if (i != 0)cout << " ";

		cout << ans[i].first << ":";
		if (ans[i].second < 10)cout << 0;
		cout<<ans[i].second;
		
	}
	cout << endl;
	return 0;
}




Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI 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(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

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> void puts_all(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void puts_all(const T &value, const Args&... args){std::cout << value << " ";puts_all(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}
template <typename T> auto make_vector(int n, int m, int l, const T &value){return make_vector<vector<T>>(n, m, vector<T>(l, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;


int main(){
  string s;
  while(cin >> s){
    vector<int> N;
    N.push_back(0);
    for(auto x : s) N.push_back(x - '0');
    N.push_back(0);

    auto dp = make_vector<LLI>(N.size()+1, 2, INT_MAX);
    const int LOWER = 0;
    const int UPPER = 1;

    dp[0][0] = 0;

    REP(i,N.size()){
      const auto x = N[i];
      REP(j, 2){
        if(dp[i][j] == INT_MAX) continue;

        auto y = x + 1;
      
        if(j == LOWER){
          chmin(dp[i+1][LOWER], dp[i][LOWER] + min(x, 1 + 10 - x));
          chmin(dp[i+1][UPPER], dp[i][LOWER] + min(y, 1 + 10 - y));
        }else{
          chmin(dp[i+1][LOWER], dp[i][UPPER] + min(1 + x, 10 - x));
          chmin(dp[i+1][UPPER], dp[i][UPPER] + min(1 + y, 10 - y));
        }
      }
    }
    
    int ans = dp[N.size()][LOWER];    

    puts_all(ans);
  }
  
  return 0;
}


Measured memory_bytes: 59924
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(int i=0;i<(int)n;++i)
#define _rep1(i,k,n) for(int i=k;i<(int)n;++i)
#define _rep2(i,k,n,d) for(int i=k;d>0?i<(int)n:i>(int)n;i+=d)
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

void solve(){
    ll n, q; cin >> n >> q;
    ll sqrtn = (ll)sqrt(n);
    vector<ll> C(n);
    rep(i, n){
        cin >> C[i];
        C[i]--;
    }
    vector<ll> left(q), right(q);
    rep(i, q){
        cin >> left[i] >> right[i];
        left[i]--;
    }

    vector<ll> order(q);
    iota(order.begin(), order.end(), 0);
    sort(order.begin(), order.end(), [&](ll i, ll j){
        if(left[i] / sqrtn != left[j] / sqrtn) return left[i] < left[j];
        else return right[i] < right[j];
    });

    vector<ll> ans(q), counter(n);
    ll l = 0, r = 0, score = 0;
    rep(j, q){
        ll i = order[j];
        // i 番目の query を処理する
        while(l < left[i]){
            counter[C[l]]--;
            if(counter[C[l]] == 0) score--;
            l++;
        }
        while(l > left[i]){
            l--;
            if(counter[C[l]] == 0) score++;
            counter[C[l]]++;
        }
        while(r < right[i]){
            if(counter[C[r]] == 0) score++;
            counter[C[r]]++;
            r++;
        }
        while(r > right[i]){
            r--;
            counter[C[r]]--;
            if(counter[C[r]] == 0) score--;
        }
        ans[i] = score;
    }
    for(ll a : ans) cout << a << '\n';
}

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

typedef long long ll;
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
#define rep(i, n) for(int i = 0; i < n; i++)
#define fogg(i,a,b) for(int i = (a); i <= (b); i++)
#define ford(i,a,b) for(int i = (a); i >= (b); i--)
#define test int t; cin >> t; while(t--)
#define debug(x) cout << '>' << #x << ':' << x << "\n";
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair



int main() {
    int t;
    cin >> t;
    long long int ans=0;
    int count =0;
    int n=t;
    while(n!=0){
        n=n/10;
        count++;
    }
    for(int i=1;i<=count;i=i+2){
        if(i<count){
            ans+=9*int(pow(10,i-1));
        }
        else if(i==count){
            ans+=t-int(pow(10,i-1))+1;
        }
    }
    cout << ans;
    

return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

constexpr int MAX_N = 100010;
vector<int> G[MAX_N];

void dfs(int v, int d, vector<int> &dist, int p) {
    dist[v] = d;
    for (int i = 0; i < G[v].size(); i++) {
        int to = G[v][i];
        if (p != to) dfs(to, d + 1, dist, v);
    }
}

int main() {

    int N;
    cin >> N;

    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> dist_fenek(N), dist_snuke(N);
    dfs(0, 0, dist_fenek, -1);
    dfs(N - 1, 0, dist_snuke, -1);
    SHOW_VECTOR(dist_fenek);
    SHOW_VECTOR(dist_snuke);

    int fenec = 0, snuke = 0;
    for (int i = 0; i < N; i++) if (dist_fenek[i] <= dist_snuke[i]) fenec++; else snuke++;

    if (fenec > snuke) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;

    return 0;
}
















































Measured memory_bytes: 14336
/* 
 * Created by solzard on 2020-03-05.
 * C - Guess The Number
 */
#include <iostream>
#include <vector>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int GuessNumber(int n, int m, const std::vector<int> &s, const std::vector<int> &c) {
  int res = -1;
  for (int num = 999; num >= 0; --num) {
    std::string num_str = std::to_string(num);
    bool is_ok = true;
    if (num_str.size() != n) continue;
    rep(i, m) {
      if (num_str[s[i] - 1] != (char) ('0' + c[i])) {
        is_ok = false;
        break;
      }
    }
    if (is_ok) res = num;
  }
  return res;
}

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

  int n, m;
  std::vector<int> s(5, 0), c(5, 0);
  std::cin >> n >> m;
  rep(i, m) {
    std::cin >> s[i] >> c[i];
  }
  std::cout << GuessNumber(n, m, s, c) << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint a[200005];
llint lsum[200005], rsum[200005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	for(int i = 1; i <= n; i++) lsum[i] = lsum[i-1] ^ a[i];
	for(int i = n; i >= 1; i--) rsum[i] = rsum[i+1] ^ a[i];
	
	for(int i = 1; i <= n; i++) cout << (lsum[i-1]^rsum[i+1]) << " ";
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 8280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

double a,b,x;
int main(){
	cin >> a >> b >> x;
	double lb = 0, ub = acos(-1.)/2;
	double deg = atan2(b,a);
	rep(i,1919){
		double mid = (lb+ub)/2;
		if(mid <= deg){
			double gen = a * tan(mid);
			double sum = a*b-a*gen/2;
			sum *= a;
			if(sum >= x) lb = mid;
			else ub = mid;
		}
		else{
			double gen = b * tan(acos(-1.)/2-mid);
			double sum = b*gen/2;
			sum *= a;
			if(sum >= x) lb = mid;
			else ub = mid;
		}
	}
	printf("%.12f\n",lb*180./acos(-1.));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	long long int a,b,c,temp,ans;cin>>a>>b>>c;
  	if(a%2==0 || b%2==0 ||c%2==0){
    	ans=0;
    }else{
    	if(a<=b && c<=b){
        	ans=a*c;
        }else if(a<=c && b<=c){
        	ans=a*b;
        }else{
        	ans=c*b;
        }
    }
  		cout<<ans<<endl;
}

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

typedef long long ll;
typedef long double ld;
typedef double db;

typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<pii, int> piipi;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;
typedef pair<ll, pii> plpii;
typedef pair<db, db> pdd;
typedef pair<ld, ld> pldd;

typedef vector<int> vi;
typedef vector<pii> vii;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FOR2(i, a, b) for(int i=(a);i<=(b);++i)
#define ROF(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define ROF2(i, a, b) for(int i=(b);i>=(a);--i)
#define GO(i, x) for(auto &i : x)

#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define eb emplace_back
#define pf push_front
#define pb push_back
#define lb lower_bound
#define up upper_bound

template<typename T> inline bool min2(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool max2(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

const int mod = 1e9 + 7;
// const int mod = 998244353;
const int P1 = 999983, P2 = 999979;
const ld PI = acos((ld)-1);
const int dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const ll INF = 1e18;
const int N = 1e6;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll a[N];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll u = 0, v = 0;
    cin >> n;
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=2;i<n;i++) u ^= a[i];
    v = a[0]+a[1];
    if(u > v) cout << "-1\n";
    else if(u%2 != v%2) cout << "-1\n";
    else{
        ll w = (v-u)/2;
        ll ans1 = 0, ans2 = 0;
        for(int i=50;i>=0;i--){
            if((w>>i)&1) ans1+=(1ll<<i), ans2+=(1ll<<i);
        }
        for(int i=50;i>=0;i--){
            if(!((w>>i)&1)){
                if((u>>i)&1){
                    if(ans1+(1ll<<i) < a[0]) ans1+=(1ll<<i);
                    else ans2+=(1ll<<i);
                }
            }
        }
        if(ans1+ans2 != v) cout << "-1\n";
        else if(ans1 == 0) cout << "-1\n";
        else if(ans1 > a[0]) cout << "-1\n";
        else cout << a[0]-ans1 << "\n";
    }
}

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

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

	for (int i = 0; i < q; ++i) {
		int c, a, n;
		cin >> c >> a >> n;
		int cnt = min(c, min(a, n));
		c -= cnt; a -= cnt; n -= cnt;
		if (a >= 1) {
			if (c >= 2) {
				if (c >= a * 2) {
					cnt += a;
					c -= a * 2;
					a = 0;
				}
				else {
					cnt += c / 2;
					c = 0;
					a -= c / 2;
				}
			}
		}
		if (c >= 3) {
			cnt += c / 3;
		}

		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
N = int(input())
A = list(map(int,input().split()))
INF = float("inf")
ave = sum(A)/N
MIN = INF
#print(ave)
for i in range(N):
  if abs(A[i]-ave) < MIN:
    ans = i
    MIN = abs(A[i]-ave)
    #print(ans,i)
    
print(ans)
    

Measured memory_bytes: 61944
#include <iostream>
using namespace std;
 
int main(){
  int n,k,d,name,result=0;
  int array[100];
  cin>>n>>k;
  
  for(int i=1;i<=100;i++){array[i]=0;}
  
  for(int i=1;i<=100;i++){
    cin>>d;
    for(int i=1;i<=d;i++){
      cin>>name;
      array[name]=1;
    }
  }
  
  for(int i=1;i<=n;i++){
    if(array[i]==0){
      result++;
    }
  }
  cout<<result<<endl;
 
  return 0;
}

Measured memory_bytes: 3568
import Data.List
import Text.Printf

main = do
  _ <- getLine
  as <- map read . words <$> getLine::IO[Int]
  let [n, r] = solve as
  printf "%d %d\n" n r 


solve as =
  [n, r]
  where
    r = minimumBy (\x y -> compare (abs $ n'-x) (abs $ n'-y)) $ delete n as
    n = maximum as
    n' = div n 2
    


Measured memory_bytes: 36220
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		int ans = 0;
		if(A >= 6 && A <= 12) ans = B / 2;
		else if(A >= 13) ans = B;
		
		System.out.println(ans);
	}
}

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

int main(){
	int n,m;
	int A[101][101],B[101];
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>A[i][j];
		}//Aの行列代入
	}
		for(int i=0;i<m;i++){
			cin>>B[i];
		}
		
		for(int i=0;i<n;i++){
			int sum=0;
			for(int j=0;j<m;j++){
				sum+=A[i][j]*B[j];
			}
			cout<<sum<<endl;
		}
	
		
	return 0;
}


Measured memory_bytes: 3128
(let* ((n (abs (read)))
       (m (read))
       (l (read))
       (mn1 (mod n l))
       (mn1a (floor n l))
       (mn2 (- mn1 l))
       (mn2a (1+ (floor n l))))
  (if (if (= mn1 (min (abs mn1) (abs mn2)))
          (<= m mn1a)
          (<= m mn2a))
      (princ (- n (* m l)))
      (let* ((k (if (= mn1 (min (abs mn1) (abs mn2)))
                    (- m mn1a)
                    (- m mn2a))))
        (if (evenp k)
            (princ (abs (if (= mn1 (min (abs mn1) (abs mn2)))
                            mn1 mn2)))
            (princ (abs (if (= mn1 (min (abs mn1) (abs mn2)))
                            mn2 mn1)))))))

Measured memory_bytes: 24228
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy


if __name__ == "__main__":
    s = input()
    t = input()
    ans = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            ans+=1
    print(ans)

Measured memory_bytes: 68948
import java.util.Scanner;

public class Main {
	static byte[] asciiCodes;
	static int[] c = new int[26];//それぞれa-z の alphabetの数を格納
	static long Mod = 1_000_000_007;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Integer.parseInt(sc.next());
		String S = sc.next();
		sc.close();
        try {
            asciiCodes = S.getBytes("US-ASCII");
        } catch (Exception e) {
            e.printStackTrace();
            return;
        }
        for (int i = 0; i < asciiCodes.length; i++) {
        	c[asciiCodes[i]-97]++;
        }

		Main main = new Main();
		main.solve();
	}

	void solve() {
        long res = 1;
        for(int i=0;i<26;i++) {
        	res *= (c[i]+1);
        	while(res>Mod)res-=Mod;
        }
        res--;
        System.out.println(res);
	}
}

Measured memory_bytes: 24276
import sys
import itertools

with sys.stdin as f:
    s_input = f.read()

    s_args = s_input.splitlines()
    n = int(s_args[0])
    s = s_args[1:]

    a = len([nm for nm in s if nm.startswith("A")])
    c = len([nm for nm in s if nm.startswith("C")])
    h = len([nm for nm in s if nm.startswith("H")])
    m = len([nm for nm in s if nm.startswith("M")])
    r = len([nm for nm in s if nm.startswith("R")])
    
    #print([m, a, r, c, h])

    cmb = []
    if m > 0:
        cmb.append("m")
    if a > 0:
        cmb.append("a")
    if r > 0:
        cmb.append("r")
    if c > 0:
        cmb.append("c")
    if h > 0:
        cmb.append("h")

    res = 0
    pats = list(itertools.combinations(cmb, 3))
    for pat in pats:
        p_res = 1
        if 'm' in pat:
            p_res *= m
        if 'a' in pat:
            p_res *= a
        if 'r' in pat:
            p_res *= r
        if 'c' in pat:
            p_res *= c
        if 'h' in pat:
            p_res *= h
        res += p_res
        
    print(res)
            
sys.exit(0)


Measured memory_bytes: 12504
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s.at(i);
    ll res = 0;
    rep(i,n){
        rep(j,s.at(i).size()-1){
            if(s.at(i).at(j)=='A' && s.at(i).at(j+1)=='B') res++;
        }
    }
    // 1. Bで始まってAで終わる
    // 2. Bで始まってA以外で終わる
    // 3. B以外で始まってAで終わる
    // 2,3があれば1.の数が答え、なければ1.-1が答え
    ll p1=0,p2=0,p3=0;
    rep(i,n){
        if(s.at(i).at(0)=='B' && s.at(i).at(s.at(i).size()-1)=='A'){
            p1++;
        }else if(s.at(i).at(0)=='B' && s.at(i).at(s.at(i).size()-1)!='A'){
            p2++;
        }else if(s.at(i).at(0)!='B' && s.at(i).at(s.at(i).size()-1)=='A'){
            p3++;
        }
    }
    if(p1>0 && p2==0 && p3==0){
        res += p1-1;
    }else{
        res += p1 + min(p2,p3);
    }
    cout << res << endl;
}

Measured memory_bytes: 3724
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    A, B, C = [int(x) for x in input().split()]
    ans = B + min(A + B, C)
    if C > A + B:
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
string s;
int a=0,b=0;
signed main()
{
	cin>>s;
	rep(i,s.size()){
		if(i%2==0){
			if(s[i]=='1'){
				a++;
			}
		}else{
			if(s[i]=='0'){
				a++;
			}
		}
	}
	rep(i,s.size()){
		if(i%2==0){
			if(s[i]=='0'){
				b++;
			}
		}else{
			if(s[i]=='1'){
				b++;
			}
		}
	}
	cout<<min(a,b);	
}

Measured memory_bytes: 512
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
using namespace std;
#define REP(i,n) for(int i=0;i < n; i++)
#define RREP(i,n) for(int i=n-1;i >=0; i--)
#define p(a) (a) * (a)
#define p2(a,b) p((a) - (b)) 
#define MAX 100002
int main() {
	long long n, a, b,s=0,p,c;
	cin >> n >> a >> b;
	REP(i, n) {
		if (!i) {
			cin >> p;
			continue;
		}
		cin >> c;
		if ((c - p) * a < b) {
			s += (c - p) * a;
		}
		else {
			s += b;
		}
		p = c;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
xpy_max = -1001001001
xpy_min =  1001001001
xmy_max = -1001001001
xmy_min =  1001001001

for i in range(n):
    x, y = map(int, input().split())
    xpy_max = max(xpy_max, x+y)
    xpy_min = min(xpy_min, x+y)
    xmy_max = max(xmy_max, x-y)
    xmy_min = min(xmy_min, x-y)
ans = max(xpy_max - xpy_min, xmy_max - xmy_min)
print(ans)


Measured memory_bytes: 9200
n, k = map(int, input().split())
r, s, p = map(int, input().split())
T = list(input())
P = {'s':r, 'p':s, 'r':p}

mx = r*T.count('s')+s*T.count('p')+p*T.count('r')
if len(T)<k:
    print(mx)
else:
    for i in range(n-k):
        if T[i]==T[i+k]:
            mx -= P[T[i]]
            T[i+k] = '_'
print(mx)

Measured memory_bytes: 10008
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e9+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n;
string s, ans;

int main(){
	cin >> n;
	REP(k, n){
		cin >> s >> ans;
		reverse(ALL(s));
		REP(i,s.size()){
			if (s[i] == 'J'){
				ans = ans[ans.size() - 1] + ans.substr(0, ans.size() - 1);
			}
			else if (s[i] == 'C'){
				ans = ans.substr(1, ans.size() - 1) + ans[0];
			}
			else if (s[i] == 'E'){
				int num = ans.size() / 2;
				if (ans.size() % 2 == 1){
					ans = ans.substr(num + 1) + ans[num] + ans.substr(0, num);
				}
				else{
					ans = ans.substr(num) + ans.substr(0, num);
				}
			}
			else if (s[i] == 'A'){
				reverse(ALL(ans));
			}
			else if (s[i] == 'P'){
				REP(j, ans.size()){
					if (ans[j] >= '1'&&ans[j] <= '9'){
						ans[j] = (char)(ans[j] - 1);
					}
					else if (ans[j] == '0'){
						ans[j] = '9';
					}
				}
			}
			else{
				REP(j, ans.size()){
					if (ans[j] >= '0'&&ans[j] <= '8'){
						ans[j] = (char)(ans[j] + 1);
					}
					else if (ans[j] == '9'){
						ans[j] = '0';
					}
				}
			}
		}
		cout << ans << endl;
	}
}

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

using namespace std;

int findGCD(int I, int J, int L);
int main(){
    int K;
    long long sum = 0;

    cin>>K;

    for(int i = 1; i <= K; i++){
        for(int j = 1; j <= K; j++){
            for(int l = 1; l <= K; l++){
                sum = sum + findGCD(i, j, l);
            }
        }
    }
    cout<<sum<<"\n";

    return 0;
}

int findGCD(int I, int J, int L){
    int temp = __gcd(I, J);
    // cout<<__gcd(temp, L)<<"\n";
    return __gcd(temp, L);
}


Measured memory_bytes: 3592
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

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

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

vector < pll > vec;

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> n)
    {
		vec.clear();
		for(ll i = 0; i < n; i++)
		{
			slld(input);

			vec.push_back({input,2});
		}

		sort(vec.rbegin(),vec.rend());

		vec[0].second = 1;

		ll sum = 0;

		for(ll i = 1, j = 0; i < n; i++)
		{
			sum += vec[j].first;

			vec[j].second--;

			if(vec[j].second == 0) j++;
		}

		cout << sum << endl;
    }


}





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


int main() {
  	int n, a[200005], mn[200005];
 	cin >> n;
  	for(int i = 1; i <= n; ++i) cin >> a[i];
  	mn[0] = 1000000007;
  	for(int i = 1; i <= n; ++i) mn[i] = min(mn[i-1], a[i]);
  	int res = 0;
  	for(int i = 1; i <= n; ++i) {
    	if(a[i] <= mn[i]) ++res;
    }
  cout << res;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(void)
{
    int N;
    int K;
    int h[100000];
    int i;
    int ans=0;
    
    scanf("%d",&N);
    scanf("%d",&K);
    
    if(N<=100000)
    {
        for(i=0;i<N;i++)
        {
            scanf("%d",&h[i]);
        }
    }
    
    for(i=0;i<N;i++)
    {
        if(h[i]>=K)
        {
            ans++;
        }
    }
    printf("%d",ans);
    
}


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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define INF 2123456789
#define IINF 9123456789123456789

void use_cio() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}
// template <typename... Args>
// void dbg(Args... args) {
//     ((cout << args << " "), ...);
//     cout << endl;
// }
//--------------------------------------------------//
int n, m;
vector<pii> adj[30];

int main() {
    use_cio();
    int L;
    cin >> L;
    int tmp = 1;
    while (tmp <= L) tmp *= 2, n++;
    int last = n - 1, prv = n - 2;
    while (L > 1) {
        adj[prv].push_back({last, 0});
        adj[prv].push_back({last, L / 2});
        m += 2;
        if (L % 2)
            adj[0].push_back({last, L - 1}), m++;
        L >>= 1;
        last--, prv--;
    }
    cout << n << " " << m << "\n";
    rep(i, n) {
        for (auto x : adj[i]) {
            cout << i + 1 << " " << x.first + 1 << " " << x.second << "\n";
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>
#include <functional>

typedef long long ll;
using namespace std;

int h, w, k;


vector <vector<int>> m;

int re(int cnt, string bit){
    if(cnt == h + w){
        vector <vector<int>> cp_m = m;


        int ch = 0;
        for(int i = 0; i < h; i++){
            if(bit[i] == '1'){
                for(int j = 0; j < w; j++){
                    cp_m[i][j] = 0;
                }
            }
        }

        for(int i = h; i < h + w; i++){
            if(bit[i] == '1'){
                for(int j = 0; j < h; j++){
                    cp_m[j][i - h] = 0;
                }
            }
        }


        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(cp_m[i][j]){
                    ch++;
                }
            }
        }
        if(ch == k){
            return 1;
        }
        return 0;
    }
    return re(cnt + 1, bit + "1") + re(cnt + 1, bit + "0");
}

int main(){
    cin >> h >> w >> k;
    for(int i = 0; i < h; i++){
        vector<int> v;
        m.push_back(v);
        string x;
        cin >> x;
        for(int j = 0; j < x.length(); j++){
             if(x[j] == '.'){
                 m[i].push_back(0);
            } else {
                 m[i].push_back(1);
            }
        }
    }

    string bit = "";

    int ans = re(0, bit);
    cout << ans << endl;
}


Measured memory_bytes: 3584
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]int, n)
	m := map[int]int{}
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
		m[aa[i]]++
	}
	sort.Ints(aa)
	eras := make([]int, 1000001)
	ans := 0
	for i := 0; i < n; i++ {
		if eras[aa[i]] == 0 && m[aa[i]] == 1 {
			ans++
		}
		for j := aa[i]; j < 1000001; j += aa[i] {
			eras[j] = 1
		}
		if eras[1] == 1 {
			break
		}
	}
	fmt.Fprintln(writer, ans)
}
func gcd(m, n int) int {
	if n == 0 {
		return m
	}
	return gcd(n, m%n)
}


Measured memory_bytes: 23332
n = int(input())
d_array = list(map(int, input().split()))
if d_array[0] != 0:
    print(0)
else:
    count = [0 for _ in range(n)]
    count[0] = 1
    for d in d_array[1:]:
        count[d] += 1
    i = 1
    node = 1
    ans = 1
    while node < n and i < n:
        if count[i] == 0:
            ans = 0
            break
        ans *= count[i - 1] ** count[i]
        ans %= 998244353
        node += count[i]
        i += 1
    print(ans)

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

int main(){
	int N, K; cin>>N>>K;
	vector<int> A(N); rep(i, N) cin>>A[i];
	int ng = 0, ok = 1e9; // (ng,ok] = (l,r]
	while(ok - ng > 1){
		int m = (ok + ng) / 2;
		int c = 0;
		rep(i, N) c += (A[i] - 1) / m;
		if(c <= K) ok = m; else ng = m;
	}
	cout<< ok <<endl;
}


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

int main()
{
  int n;
  cin>>n;
  vector<int>a(n);
  vector<int>b(n);
  for(int i=0;i<n;i++)cin>>a[i];
  int p=-1;
  for(int i=0;i<n;i+=2)
  {
    b[++p]=a[n-i-1];
  }
  int t=1;
  if(n%2==0)t=0;
  for(int i=t;i<n;i+=2)
  {
	b[++p]=a[i];
  }
  for(auto x:b)
  {
    cout<<x<<' ';
  }
  return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
//i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;


struct fast_combination {
    fast_combination(i64 n, i64 mod_) :fac(n+1, 0), finv(n+1, 0), inv(n+1, 0), mod_(mod_) {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (i64 i=2; i<=n; ++i) {
            fac[i] = fac[i-1] * i % mod_;
            inv[i] = mod_ - inv[mod_%i] * (mod_/i) % mod_;
            finv[i] = finv[i-1] * inv[i] % mod_;
        }
    }

    i64 operator()(i64 n, i64 k) {
        if (n > fac.size()-1) return -1;
        if (n < k || n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n-k] % mod_) % mod_;
    }


    std::vector<i64> fac, finv, inv;
    int mod_;
};

template<typename IntType>
IntType all_pattern(IntType a, IntType b, IntType mod_) {
  IntType res = 1;
  for (a %= mod_; b; a = a * a % mod_, b >>= 1)
    if (b & 1) res = res * a % mod_;
  return res;
}

int main(int argc, char **argv) {
    i64 k;
    cin >> k;
    string s;
    cin >> s;
    i64 si=s.size();

    fast_combination cmb(si+k, mod);

    i64 ans{0};
    for (int i=0; i<=k; ++i) {
        i64 left = si+i;
        i64 right = k-i;
        i64 a = all_pattern<i64>(25, i, mod);
        a *= cmb(left-1, si-1);
        a %= mod;
        a *= all_pattern<i64>(26, right, mod);
        a %= mod;
        ans += a;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 51196
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-6;
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
const char nl = '\n';

template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> void ckmin(T& a, T b) { a = min(a, b); }
template <class T> void ckmax(T& a, T b) { a = max(a, b); }

// (Integer/Long).bitCount(x)
int pct(int x) { return __builtin_popcount(x); }
int pctll(ll x) { return __builtin_popcountll(x); }

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); }
}

// Binary Exponentiation
ll pow(ll b, ll e, ll m = 0LL, ll ans = 1LL) { while (e) { if (e & 1LL) { ans *= b; if (m) ans %= m; } b *= b, e >>= 1LL; if (m) b %= m; } return ans; }



void solve(int tcn) {
	int x;
	cin >> x;
	cout << !x << nl;
}

int main() {
    setIO();

    int t = 1; //cin >> t;
	for (int i = 1; i <= t; ++i) {
		//cout << "Case #" << i << ": ";
		solve(i);
	}
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[5],i;
    for(i=0; i<5; ++i)
    cin>>a[i];
    for(i=0; i<5; ++i)
    {
        if(a[i]==0)
            break;
    }
    cout<<i+1;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define mkp make_pair
#define fi first
#define se second
int n,k;
typedef long long ll;
typedef pair<ll,ll> pll; 
priority_queue <pll> q;
vector <pll> res;
map <ll,int> mp;
ll ans=0,num=0;
int main(){
	cin>>n>>k;
	for (int i=1;i<=n;i++){
		ll t,d;cin>>t>>d;
		q.push(mkp(d,t));
	}
	for (int i=1;i<=k;i++){
		pll aw=q.top();
		q.pop();
		mp[aw.se]++;
		num+=aw.fi;
		res.push_back(aw);
	}
	ll sz=mp.size();
	ans=num+sz*sz;
	reverse (res.begin(),res.end());
	for (int i=0;i<k;i++){
		if (mp[res[i].se]==1) continue;
		while (!q.empty()){
			pll aw=q.top();
			q.pop();
			if (mp[aw.se]==0){
            	num=num-res[i].fi+aw.fi;
            	sz++;
            	ans=max(ans,num+sz*sz);
 				mp[res[i].se]--;mp[aw.se]++;
 				res[i]=aw;
 				break;
            }
		}
	}
	cout<<ans;
}


Measured memory_bytes: 7280
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
  int i,j,n,a,b;
  string s;
  cin >> n;
  cin >> a >> b;
  if(n*a<b){
    cout << n*a << endl;
  }else{
    cout << b << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long x, a, b;
    scan(x, a, b);
    long z = b - a;
    if (z <= 0)
    {
        writeln("delicious");
        return;
    }

    bool c = z <= x;
    writeln(c ? "safe" : "dangerous");
}


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

typedef pair<long long, long long> p;

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

  string s1="";
  string s2="";

  for(int i = 0; i < a; i++){
    s1+=to_string(b);
  }
  for(int i = 0; i < b; i++){
    s2+=to_string(a);
  }

  string ans;
  if(s1 < s2){
    ans = s1;
  }else{
    ans = s2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,m = inpl()
g = [[False for j in range(n)] for i in range(n)]
for i in range(m):
    a,b = inpl()
    a -= 1
    b -= 1
    g[a][b] = True
    g[b][a] = True
# print(g)
res = 0
for flag in itertools.permutations(range(1,n)):
    # print(flag)
    for i in range(n-1):
        if i == 0:
            if not g[0][flag[0]]:
                break
            continue
        if not g[flag[i]][flag[i-1]]:
            break
    else:
        res += 1
print(res)

Measured memory_bytes: 65516
import sys
from collections import deque


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())
    V = list(map(int, input().split()))
    ans = 0

    for i in range(min(N + 1, K+1)):  # 左から i 個取る　　
        for j in range(min(N + 1 - i, K - i+1)):  # 右からi個取る 計算量10^3
            res = K - i - j  # 残り行動回数
            agg = V[:i] + V[N  - j:]
            agg.sort(reverse=True)
            while res > 0 and agg:
                if agg[-1] < 0:
                    agg.pop()
                    res -= 1
                else:
                    break
            ans = max(sum(agg), ans)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 73812
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mod 1000000007
#define INF 1e9+100
#define pii pair<int,int>
#define ppi pair<pii,int>
#define ff first
#define ss second
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
#define urs(r...)          typename decay<decltype(r)>::type
#define fo(i,n)                for(urs(n) i=0;i<n;i++)
#define re(i,n)               for(urs(n) i=1;i<=n;i++)
#define pb push_back
#define gap ' '
main()
{
	int i,j,n,m;
	int t;
	cin>>t;
	int ans=t/500;
	int sum=0;
	sum+=ans*1000;
	ans=t-ans*500;
	sum+=(ans/5)*5;
	cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

typedef struct{int h,p,q;} yokosen;

bool comp(const yokosen a, const yokosen b) {
    return a.h > b.h;
}

int main(void) {
    while(true) {
        int n,m,a;
        scanf("%d%d%d",&n,&m,&a);
        if(!n) break;

        vector<yokosen> yokosens;

        for(int i=0; i<m; i++) {
            int h,p,q;
            scanf("%d%d%d",&h,&p,&q);

            yokosens.push_back({h,p,q});
        }
        sort(yokosens.begin(), yokosens.end(), comp);

        int last = a;

        for(vector<yokosen>::iterator it=yokosens.begin(); it != yokosens.end(); it++)
            if(it->p == last)
                last = it->q;
            else if(it->q == last)
                last = it->p;

        printf("%d\n", last);
    }
    return 0;
}

Measured memory_bytes: 2668
#include <bits/stdc++.h>
#define int long long int
#define max1 10000001
using namespace std;
int a[max1];
void pre(){
for(int i=0;i<max1;i++){
    a[i]=1;
}
for(int i=2;i<max1;i++){
    for(int j=i;j<max1;j+=i){
        a[j]++;
    }
}
}
signed main(){
pre();
int n;
cin>>n;
int ans=0;
for(int i=1;i<=n;i++){
    ans+=i*a[i];
}
cout<<ans;
}


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

int main() {
  	int H, W;
  	cin >> H >> W;
    for(int i=0; i<W+2; i++){
    	cout << "#" ;
    }
  	cout << endl;
    vector<string> A(H);
    for (int i=0; i<H; i++){
    	cin >> A[i];
    }
    for (int i=0; i<H; i++){
  	cout << "#" << A[i] << "#" << endl;
    }
  	for(int i=0; i<W+2; i++){
    	cout << "#" ;
    }
  	cout << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

long long int n,d,k,sa,res=0;
long long int used[100005]={},x[11][11];
queue<long long int> qu[100005];

int main() {
    const long long int mod = 1000000007,INF=99999999999999;
	map<long long int, long long int>mp;
    string str[2005],tmp;
	cout << fixed << setprecision(10);
    cin>>n>>d;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=d;j++){
            cin>>x[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            sa=0;
            for(int p=1;p<=d;p++){
                sa+=(x[i][p]-x[j][p])*(x[i][p]-x[j][p]);
            }
            
            for(int i=1;i*i<=sa;i++){
                if(i*i==sa){
                    res++;
                }
            }
        }
    }
    cout<<res;
} 


Measured memory_bytes: 67968