akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
const double INF = 1e10;
//const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
typedef tuple<int, int, int> Q;

int main() {
    int d, g;
    cin >> d >> g;

    vector<Q> questions(d);//i, 問題数, ボーナス

    rep(i, d) {
        int p, c;
        cin >> p >> c;
        Q q(i + 1, p, c);
        questions[i] = q;
    }

    map<int, int> ok_i;

    for (int pattern = 0; pattern < (1 << d); pattern++) {
        // 最大値

        int max_points = [&] {
            int ans = 0;
            for (int i = 0; i < d; i++) {
                auto q = questions[i];
                int baisu = get<0>(q) * 100;
                int mondaisu = get<1>(q);
                int bonus = get<2>(q);
                int a = (pattern >> i) & 1;
                if (a == 1) {
                    ans += baisu * mondaisu + bonus;
                } else {
                    ans += baisu * (mondaisu - 1);
                }
            }
            return ans;
        }();

//        cout << bitset<8>(pattern) << ' ' << max_points << endl;

        if (max_points >= g) {
            ok_i[pattern] = max_points;
        }

    }

    int ans = INF;
    for (auto m : ok_i) {
        int pattern = m.first;
        int point = m.second;
        int question_count = 0;

        vector<int> herasite_iiyatsu; // 減らしていい奴、得点が低い順

        for (int j = 0; j < d; j++) {
            int a = (pattern >> j) & 1;
            if (a == 0) {
                herasite_iiyatsu.push_back(j);
                int mondaisu = get<1>(questions[j]);
                question_count += mondaisu - 1;
            } else {
                int mondaisu = get<1>(questions[j]);
                question_count += mondaisu;
            }
        }

        int now = [&] {
            int now = point;
            int qc = question_count;

            for (int herasuyatsu : herasite_iiyatsu) {
                int mondaisu = get<1>(questions[herasuyatsu]) ;
                int tokuten = (herasuyatsu + 1) * 100;
                for (int nokori = 0; nokori < mondaisu - 1; nokori++) {
                    if ((now - tokuten) < g) {
                        return qc;
                    } else {
                        now -= tokuten;
                        qc--;
                    }
                }
            }
            return qc;

        }();
        ans = min(ans, now);
    }
    cout << ans << endl;
}


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

int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    while(k--)
    {
        if(b<=a)
        {
            b*=2;
            continue;
        }
        else if(c<=b)
        {
            c*=2;
            continue;
        }
    }
    if(a<b&&b<c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


//stack<char> stk;
//set<ll> sll;
//set<pair<ll,ll>> spll;
//map<string,ll> mp;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<ll> deq;
//vector<ll> vll;
ll num[ten5],pp[ten52],mm[ten52];
//priority_queue<ll> pq;          //decreasing

int main(void)
{
    ll m,n,i,j,k=0,pre,money=1000;
    cin>>n;
    cin>>pre;
    for(i=1;i<n;i++)
    {
        cin>>m;
        if(m>pre)
        {
            k+=money/pre;
            money%=pre;
        }
        else if(m<pre)
        {
            money+=k*pre;
            k=0;
        }
        pre=m;
    }
    money+=k*pre;
    cout<<money;
    return 0;
}





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

int main() {
  string s;
  cin>>s;
  int ans=0;
  for (int i = 0; i < s.size(); i++) {
    if(s.at(i)=='0'){
      ans++;
    }
  }
 
  int sna=s.size()-ans;
     int b=min(sna,ans);
 
  
    cout<<2*b<<endl;
  
}




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

int a[60];

int main() {
	int N; cin >> N;
	int maxNum = 0, point = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (abs(a[i]) > maxNum) {
			maxNum = abs(a[i]);
			point = i;
		}
	}
	cout << N * 2 - 1 << endl;
	for (int i = 0; i < N; i++) {
		cout << point + 1 << " " << i + 1 << endl;
	}
	if (a[point] >= 0) {
		for (int i = 0; i < N - 1; i++) {
			cout << i + 1 << " " << i + 2 << endl;
		}
	}
	else {
		for (int i = N - 1; i > 0; i--) {
			cout << i + 1 << " " << i << endl;
		}
	}

	return 0;
}

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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) <<"\n"


int main() {
	int h, w;
	cin >> h >> w;

	int Ch, Cw;
	cin >> Ch >> Cw;

	int Dh, Dw;
	cin >> Dh >> Dw;

	vvc s(h + 2, vc(w + 2, '#'));
	repp(i, h) repp(j, w) cin >> s[i][j];

	queue<pii> q, qq;
	q.push(mp(Ch, Cw));

	vvb f(h + 2, vb(w + 2, false));
	f[Ch][Cw] = 0;

	int cnt = 0;

	while (1) {
		while (!q.empty()) {
			auto t = q.front(); q.pop();
			bool ff = false;

			rep(i, 4) {
				int ty = t.fi + DY[i];
				int tx = t.se + DX[i];

				if (f[ty][tx]) continue;

				if (s[ty][tx] == '.') {
					if (ty == Dh && tx == Dw) {
						prt(cnt);
						return 0;
					}

					q.push(mp(ty, tx));
					f[ty][tx] = true;
				} else {
					ff = true;
				}
			}

			if (ff > 0) qq.push(mp(t.fi, t.se));
		}

		if (qq.empty()) {
			prt(-1);
			return 0;
		}

		while (!qq.empty()) {
			auto t = qq.front(); qq.pop();

			repp(i, t.fi - 2, t.fi + 2) {
				if (i < 1 || i > h) continue;
				repp(j, t.se - 2, t.se + 2) {
					if (j < 1 || j > w) continue;

					if (s[i][j] == '.' && !f[i][j]) {
						if (i == Dh && j == Dw) {
							prt(cnt + 1);
							return 0;
						}

						q.push(mp(i, j));
						f[i][j] = true;
					}
				}
			}
		}

		cnt++;
	}

	return 0;
}

Measured memory_bytes: 4852
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    string s;
    cin >> s;
    int cnt0 = count(s.begin(), s.end(), s[0]);
    int cnt1 = count(s.begin(), s.end(), s[1]);
    int cnt2 = count(s.begin(), s.end(), s[2]);
    if (cnt0 == 1 && cnt1 == 1 && cnt2 == 1) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
}


Measured memory_bytes: 256
def abc108_c():
  n, k = map(int, input().split())
  d, m = divmod(n, k)
  # n以下のkの倍数の個数、の3乗
  ans = d ** 3
  # %kがk/2になる数の個数、の3乗
  if k % 2 == 0:
    x = d
    if k // 2 <= m: x += 1
    ans += x ** 3
  print(ans)

abc108_c()

Measured memory_bytes: 3060
<?php
// Your code here!
fscanf(STDIN,"%d %d", $n,$l);
for($i=0; $i<$n; $i++){
    $line[$i] = trim(fgets(STDIN));
}
sort($line);

$ans = "";
foreach($line as $val){
    $ans .= $val;
}
echo $ans;


Measured memory_bytes: 4856
N, A = gets.chomp.split.map(&:to_i)
x = gets.chomp.split.map(&:to_i)

x = x.map{ |e| e - A }

h = Hash.new(0)
h[0] = 1

hh = h.dup

N.times do |i|
  # その時点でありえる全hに対して、足す
  h.each do |k,v|
    # hでeachしている最中に中身を増やすのはよくないので dupにする
    # その数値になる通りになる
    hh[x[i]+k] += v
  end
  h = hh.dup
end
p h[0] - 1


Measured memory_bytes: 3452
import bisect,collections,copy,heapq,itertools,math,string
import sys
def I():
    # 1 line 1 int
    return int(sys.stdin.readline().rstrip())
def LI():
    # 1 line n ints
    return list(map(int,sys.stdin.readline().rstrip().split()))
def S():
    # 1 line 1 string
    return sys.stdin.readline().rstrip()
def LS():
    # 1 line n strings
    return list(sys.stdin.readline().rstrip().split())

N, A, B = LI()

x = A*N
y = B

if x <= y:
    print(x)
else:
    print(y)



Measured memory_bytes: 10052
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF (ll)(1e17+5)
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
      ll x,y,a,b,c,i;
      cin>>x>>y>>a>>b>>c;
      vector <ll> va(a),vb(b),vc(c);
      for(i=0;i<a;i++)
       cin>>va[i]; 
      for(i=0;i<b;i++)
       cin>>vb[i];
      for(i=0;i<c;i++)
       cin>>vc[i];
      sort(va.rbegin(),va.rend());
      sort(vb.rbegin(),vb.rend());
      sort(vc.rbegin(),vc.rend());
      ll p=x-1,q=y-1;
      for(i=0;i<min(x+y,vc.size());i++)
      {
          if(p>=0&&q>=0&&vc[i]>va[p]&&vc[i]>vb[q])
          {
              if(va[p]<vb[q])
              {
                  va[p]=vc[i];
                  p--;
              }
              else
              {
                  vb[q]=vc[i];
                  q--;
              }
          }
          else if(p>=0&&vc[i]>va[p]&&p>=0)
          {
              va[p]=vc[i];
              p--;
          }
          else if(q>=0&&vc[i]>vb[q])
          {
              vb[q]=vc[i];
              q--;
          }
      }
      ll ans=0;
      for(i=0;i<x;i++)
       ans+=va[i];
      for(i=0;i<y;i++)
       ans+=vb[i];
      cout<<ans<<"\n";  
   }
}

Measured memory_bytes: 2560
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



int N;
string s;
char d[4][2];
vector<string> v = {"S", "W"};

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

  d[0][0] = 'S';
  d[0][1] = 'W';
  d[1][0] = 'W';
  d[1][1] = 'S';
  d[2][0] = 'W';
  d[2][1] = 'S';
  d[3][0] = 'S';
  d[3][1] = 'W';

  map<string, int> mp;
  mp["SS"] = 0;
  mp["SW"] = 1;
  mp["WS"] = 2;
  mp["WW"] = 3;
  mp["o"] = 0;
  mp["x"] = 1;

  for (auto i: v) {
    for (auto j: v) {
      string ans = i + j;

      Rep(i, N-2) {
        string tmp = ans.substr(i, 2);
        string tmp2 = s.substr(i+1, 1);
        char next = d[mp[tmp]][mp[tmp2]];
        ans += next;
      }

      string tmp = ans.substr(N-2, 2);
      string tmp2 = s.substr(N-1, 1);
      char next = d[mp[tmp]][mp[tmp2]];

      //cout << ans << "\n";
      //cout << next << "\n";
      //cout << ans[0] << "\n";
      
      if (next == ans[0]) {
        string tmp = ans.substr(N-1, 1) + ans.substr(0, 1);
        string tmp2 = s.substr(0, 1);
        char next = d[mp[tmp]][mp[tmp2]];

        if (next == ans[1]) {
          cout << ans << "\n";
          return 0;
        }
      }
    } 
  }
  
  cout << -1 << "\n";

}

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

int main(){
  int n;
  cin>>n;
  int ac=0,wa=0,tle=0,re=0;
  rep(i,n){
    string s;
    cin>>s;
    if(s=="AC") ac++;
    if(s=="WA") wa++;
    if(s=="TLE") tle++;
    if(s=="RE") re++;
  }
  cout<<"AC"<<" "<<"x"<<" "<<ac<<endl;
  cout<<"WA"<<" "<<"x"<<" "<<wa<<endl;
  cout<<"TLE"<<" "<<"x"<<" "<<tle<<endl;
  cout<<"RE"<<" "<<"x"<<" "<<re<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int  n;cin>>n;
  vector<vector<int>>f(n,vector<int>(11));
  auto p=f;
  rep(i,n)
  {
    rep(j,10)
    {
      cin>>f[i][j];
    }
  }
  rep(i,n)rep(j,11)cin>>p[i][j];
  int res=-1e9;
  repi(i,1,1<<10)
  {
    int tres=0;
    bitset<10>ti=i;
  //  cout<<ti<<endl;
    rep(j,n)
    {
      int cnt=0;
      rep(k,10)
      {
        if(f[j][k]&&ti[k])cnt++;
      }
      tres+=p[j][cnt];
    }
    chmax(res,tres);
    //cout<<res<<endl;
  }
  cout<<res<<endl;








  return 0;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  string s;
  cin >> s;

  if (s == "Sunny")
  {
    cout << "Cloudy" << endl;
  }
  else if (s == "Cloudy")
  {
    cout << "Rainy" << endl;
  }
  else
  {
    cout << "Sunny" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int char_upll(const void *a, const void *b) { return *(char *)a < *(char *)b ? -1 : *(char *)a > *(char *)b ? 1 : 0; }
int char_downll(const void *a, const void *b) { return *(char *)a < *(char *)b ? 1 : *(char *)a > *(char *)b ? -1 : 0; }
void char_sortup(char *a, int n) { qsort(a, n, sizeof(char), char_upll); }
void char_sortdown(char *a, int n) { qsort(a, n, sizeof(char), char_downll); }
char s[110], t[110];
int main()
{
  scanf("%s%s", s, t);
  char_sortup(s, strlen(s));
  char_sortdown(t, strlen(t));
  puts(strcmp(s, t) < 0 ? "Yes" : "No");
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int fx = 0;
  int x = N;
  while (x) {
     fx += x % 10;
     x /= 10;
    }
 
    if (N % fx == 0){
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
      }    
}


Measured memory_bytes: 256
import sys

#+++++
		
def main():
	n = int(input())
	s = input()
	count=0
	for i in range(1000):
		ss=str(i)
		if i < 10:
			ss = '00'+ss
		elif i < 100:
			ss='0'+ss
			
		if ss[0] in s:
			iia = s.index(ss[0])
		else:
			continue
		#pa(ii)
		if ss[1] in s[iia+1:]:
			iib = s[iia+1:].index(ss[1])+iia+1
		else:
			continue
		#pa(ii)
		if ss[2] in s[iib + 1:]:
			iic = s[iib+1:].index(ss[2])+iib+1
		else:
			continue
			
		#pa((ss,i))
		#pa((iia,iib,iic,s[iia],s[iib],s[iic]))
		count+=1
			
	print(count)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3188
def readinput():
    n,q=map(int,input().split())
    s=input()
    lr=[]
    for _ in range(q):
        l,r=map(int,input().split())
        lr.append((l,r))
    return n,q,s,lr

def main(n,q,s,lr):
    count=[0]*n
    i=0
    nac=0
    while(i+1<n):
        count[i]=nac
        if s[i:i+2]=='AC':
            nac+=1
        i+=1
    count[i]=nac
    ans=[]
    for l,r in lr:
        ans.append(count[r-1]-count[l-1])
    return ans

if __name__=='__main__':
    n,q,s,lr=readinput()
    ans=main(n,q,s,lr)
    for a in ans:
        print(a)


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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll mi_ans = 2, ma_ans = 2;
    for (int i = n - 1; i >= 0; --i) {
        ll mi = ((mi_ans + a[i] - 1) / a[i]) * a[i];
        ll ma = (ma_ans / a[i]) * a[i] + a[i] - 1;

        if (mi > ma_ans || ma < mi_ans) {
            cout << -1 << endl;
            return 0;
        }
        mi_ans = mi;
        ma_ans = ma;
    }
    cout << mi_ans << " " << ma_ans << endl;

    return 0;
}

Measured memory_bytes: 4052
#include<stdio.h>
i,S[9999],T[9999];main(){char b[99];for(;fgets(b,99,stdin),*b-10;S[i]++)sscanf(b,"%d,%*d",&i);for(;~scanf("%d,%*d",&i);)S[i]&&T[i]++;for(i=0;i<9999;i++)T[i]&&printf("%d %d\n",i,S[i]+T[i]);exit(0);}

Measured memory_bytes: 0
import sys
n = int(input())
P = [0] * n
for i in range(n):
    P[i] = list(map(int, input().split()))
P = sorted(P, key=lambda x: x[2], reverse=True)

max_h = P[0][2]

for hh in range(max_h+200, max_h-1, -1):
    for cx in range(101):
        for cy in range(101):
            for x, y, h in P:
                th = max(hh-abs(cx-x)-abs(cy-y),0)
                if h == th:
                    continue
                else:
                    break
            else:
                print('%d %d %d' % (cx, cy, hh))
                sys.exit(0)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;
long long modinv(long long a, long long m=MOD) {long long b = m, u = 1, v = 0;while (b) {    long long t = a / b;    a -= t * b; swap(a, b);    u -= t * v; swap(u, v);}u %= m; if (u < 0) u += m;return u;}
//MODの割り算の際にa/＝b;をa *= modinv(b,MOD);とする。
int gcd(int a, int b){if (a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}
 
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int dx = a-c;
    int dy = b-d;

    cout << c + dy << " "<< d - dx << " " << a + dy  << " " << b - dx  << endl;
    return 0;
}

Measured memory_bytes: 3632
import numpy as np
n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        res = 0
        a = np.array(x[i])
        b = np.array(x[j])
        dist = np.linalg.norm(b - a)
        if dist % 1 == 0:
            cnt += 1
print(cnt)


Measured memory_bytes: 12428
x = int(input())
if x >= 400 and x<=599:
    print(8)
elif x >= 600 and x<=799:
    print(7)
elif x >= 800 and x<=999:
    print(6)
elif x >= 1000 and x<=1199:
    print(5)
elif x >= 1200 and x<=1399:
    print(4)
elif x >= 1400 and x<=1599:
    print(3)
elif x >= 1600 and x<=1799:
    print(2)
elif x >= 1800 and x<=1999:
    print(1)

Measured memory_bytes: 9192
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//



int main() {
	lint r, d, x;
	cin >> r >> d >> x;
	for (int i=0; i<10; ++i) {
		x = r * x - d;
		cout << x << endl;
	}
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int h,w,n;
    cin >> h >> w >> n;

    int x = max(h, w);

    int ans = (n -1) / x + 1;

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(void){
    int n, ch;
    vector<tuple<int, int, int>> v;
    cin >> n >> ch;
    
    for (int i = 0; i < n; i++) {
        int s, t, c;
        cin >> s >> t >> c;
        v.emplace_back(s, t, c);
    }
    
    sort(v.begin(), v.end());
    
    for (int i = 1; i <= ch; i++) {
        int last[35] = {}, last_ch[35] = {};
        bool ok = true;
        for (int j = 0; j < n; j++) {
            bool in = false;
            for (int p = 0; p < i; p++) {
                if (last_ch[p] == get<2>(v[j])) {
                    if (last[p] <= get<0>(v[j])) {
                        last[p] = get<1>(v[j]);
                        in = true;
                        break;
                    }
                }
                else {
                    if (last[p] < get<0>(v[j])) {
                        last[p] = get<1>(v[j]);
                        last_ch[p] = get<2>(v[j]);
                        in = true;
                        break;
                    }
                }
            }
            if (!in) {
                ok = false;
                break;
            }
            
        }
        if (ok) {
            cout << i << endl;
            return 0;
        }
        
    }
    
    
}

Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

int g[212345][2];
ll x = 0;
int maxSize = 0;
ll l;

ll gr[112345];

void dfs(int p, int r)
{
    for (int i = 0; i < 2; i++)
    {
        if (g[p][i] == -1)
        {
            ll t = (1LL << 60);
            while ((l - r) % t)
                t /= 2;

            x ^= t;
        }
        else
            dfs(g[p][i], r + 1);
    }
}

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

    int n;

    const string Al = "Alice";
    const string Bb = "Bob";

    cin >> n >> l;

    memset(g, -1, sizeof(g));

    int gsize = 1;

    REP(i, n)
    {
        string s;
        cin >> s;

        maxSize = max(maxSize, (int)s.size());

        int pos = 0;

        REP(j, s.size())
        {
            if (g[pos][s[j] - '0'] == -1)
            {
                g[pos][s[j] - '0'] = gsize;
                gsize++;
            }

            pos = g[pos][s[j] - '0'];
        }
    }

    dfs(0, 0);

    cout << (x ? Al : Bb) << endl;

    return 0;
}

Measured memory_bytes: 6764
#include <stdio.h>

int main()
{
    int  persons[4][3][10];
    int b, f, r, v;

    int i, j, k;

    for (i = 0; i < 4; i++) {
        for (j = 0; j < 3; j++) {
            for (k = 0; k < 10; k++) {
                persons[i][j][k] = 0;
            }
        }
    }

    int n;
    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        scanf("%d %d %d %d", &b, &f, &r, &v);
        persons[b - 1][f - 1][r - 1] += v;
    }

    for (i = 0; i < 4; i++) {
        for (j = 0; j < 3; j++) {
            for (k = 0; k < 10; k++) {
                  printf(" %d", persons[i][j][k]);
                  if (k == 9)
                    printf("\n");

            }
        }
        if (i == 3) {
            break;
        } else {
            printf("####################\n");
        }
    }

    return 0;
}



Measured memory_bytes: 2112
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int n, m;
int a[100005];
int sum[100005];
int ans;
int pos;
int main() {
    cin >> n >> m;
    rep(i, n - 1) cin >> a[i];

    rep(i, n) sum[i + 1] = sum[i] + a[i];
    rep(i, m) {
        int k;
        cin >> k;
        if (k > 0) {
            ans += sum[pos + k] - sum[pos];
        } else {
            ans -= sum[pos + k] - sum[pos];
        }
        ans %= 100000;
        pos += k;
    }

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

Measured memory_bytes: 3836
int_a, int_b = map(int, input().split())

int_a = int_a if int_a != 1 else 20
int_b = int_b if int_b != 1 else 20

if int_a > int_b:
    print("Alice")
elif int_a < int_b:
    print("Bob")
else:
    print("Draw")



Measured memory_bytes: 2940
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	S, T := getString(), getString()
	A, B := getInt(), getInt()
	U := getString()

	if U == S {
		A--
	} else if U == T {
		B--
	}
	out(A, B)
}


Measured memory_bytes: 640
/*
	A - RGB Cards
*/
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;

double EPS = 1e-10;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define int(x) int x; cin >> x;
#define lint(x) long long x; cin >> x;
#define vint(v,n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vlint(v,n) vector<lint> v(n); REP(i,n) cin >> v[i];
#define double(x) double x; cin >> x[i];
#define vdouble(v,n) vector<double> v(n); REP(i,n) cin >> v[i];
#define string(x) string x; cin >> x;

int main()
{
	int(r);
	int(g);
	int(b);

	if ((r * 100 + g * 10 + b) % 4)
		cout << "NO" << endl;
	else
		cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<iomanip>
#include<sstream>
#include<cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
typedef long long int ll;
typedef long double ld;
const ll INF = 1LL << 60;
const int inf = (1 << 30);
const int MOD = 1000000007;
int n, k, ans = 0, h, w, sum = 0,a,b,c,d;
int main() {
	cin >> n; set<string> s; string t;
	rep(i, n) {
		cin >> t;
		s.insert(t);
	}
	cout << s.size() << endl;
}

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

using namespace std;

typedef long long ll;
const int MAX = 100005;
const int MOD = 1000000007;

#define F first
#define S second

void solve()
{
	
	return;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	vector<vector<ll>> bin(3,vector<ll>(3)),visit(3,vector<ll>(3,0));
	map<ll,pair<ll,ll>> mp;
	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>bin[i][j];
			mp[bin[i][j]]={i,j};
		}
	}	
	ll n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		ll x;
		cin>>x;
		if(mp.count(x))
		{
			pair<ll,ll> pr=mp[x];
			visit[pr.F][pr.S]=1;
		}
	}
	ll ans=0;
	for(int i=0;i<3;i++)
	{
		ll flag=1;
		for(int j=0;j<3;j++)
		{
			if(visit[i][j]==0)
				flag=0;
		}
		if(flag==1)
			ans=1;
	}
	for(int j=0;j<3;j++)
	{
		ll flag=1;
		for(int i=0;i<3;i++)
		{
			if(visit[i][j]==0)
				flag=0;
		}
		if(flag==1)
			ans=1;
	}
	ll flag=1;
	for(int i=0;i<3;i++)
	{
		if(visit[i][i]==0)
			flag=0;
	}
	if(flag==1)
			ans=1;
	flag=1;
	for(int i=0;i<3;i++)
	{
		if(visit[i][2-i]==0)
			flag=0;
	}
	if(flag==1)
			ans=1;
	if(ans==1)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	D, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	G, _ := strconv.Atoi(sc.Text())

	problems := make([][]int, D)
	for i := 0; i < D; i++ {
		sc.Scan()
		p, _ := strconv.Atoi(sc.Text())

		sc.Scan()
		c, _ := strconv.Atoi(sc.Text())

		problems[i] = []int{p, c}
	}

	minCount := math.MaxInt64
	for i := 0; i < 2<<uint(D); i++ {
		count := 0
		score := 0
		maxZeroIndex := -1
		for j := 0; j < D; j++ {
			if i>>uint(j)&1 == 1 {
				problem := problems[j]
				count += problem[0]
				score += problem[1] + problem[0]*(j+1)*100
			} else {
				maxZeroIndex = j
			}
		}

		if score >= G {
			if count < minCount {
				minCount = count
			}
		} else if maxZeroIndex != -1 {
			restCount := (G - score) / ((maxZeroIndex + 1) * 100)
			if (G-score)%((maxZeroIndex+1)*100) != 0 {
				restCount++
			}
			if restCount <= problems[maxZeroIndex][0] {
				count += restCount
				if count < minCount {
					minCount = count
				}
			}
		}
	}
	fmt.Println(minCount)
}

func min(s ...int) int {
	minContent := s[0]
	for _, el := range s {
		if el < minContent {
			minContent = el
		}
	}
	return minContent
}


Measured memory_bytes: 640
from math import ceil
def kaibun(moji):
    N = len(moji)
    n = 0
    for i in range(int((N+1)//2)):
        if moji[i] == moji[N-i-1]:
            n += 1
    if n == int((N+1)//2) :
        return 1
    else:
        return 0

S = input()
N = len(S)
mae = S[:ceil((N-1)/2)]
ato = S[-ceil((N-1)/2):]
if kaibun(S) == 0:
    print("No")
elif kaibun(mae) == 1 and kaibun(ato) == 1:
    print("Yes")
else :
    print("No")


Measured memory_bytes: 3064
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
pair<int,int>solve(vector<int>h){
	if(!h.size())return make_pair(0,1);
	int low=*min_element(h.begin(),h.end());
	vector<int>split;
	for(int i=0;i<h.size();i++){
		h[i]-=low;if(!h[i])split.push_back(i);
	}
	pair<int,int>ret(modpow(2,split.size(),mod),2);
	split.insert(split.begin(),-1);split.push_back(h.size());
	for(int i=0;i+1<split.size();i++){
		vector<int>tmp(h.begin()+split[i]+1,h.begin()+split[i+1]);
		auto got=solve(tmp);
		ret.first=ret.first*(got.first+got.second)%mod;
		ret.second=ret.second*got.second%mod;
	}
	ret.first+=ret.second*(modpow(2,low-1,mod)-1)%mod;ret.first%=mod;
	ret.second=ret.second*modpow(2,low-1,mod)%mod;
	return ret;
}
vector<int>h;
signed main(){
	int n;cin>>n;h.resize(n);
	for(int i=0;i<h.size();i++)cin>>h[i];
	cout<<solve(h).first<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int a[100000][2], i, I, x, y, z;
	for(i = 0 ;  ; i++)
	{
		scanf("%d%d", &a[i][0], &a[i][1]);
		if(a[i][0] == 0 || a[i][1] == 0)
		{
			for(I = 0; I < i ; I++)
			{
				for(x = 0 ; x < a[I][0] ; x++)
				{
					if(x % 2 == 0)
					{
						for(y = 0 ; y < a[I][1] ; y++)
						{
							if(y % 2 == 0)
							{
								printf("#");
							}
							if(y % 2 == 1)
							{
								printf(".");
							}
						}
						printf("\n");
					}
					if(x % 2 == 1)
					{
						for(y = 0 ; y < a[I][1] ; y++)
						{
							if(y % 2 == 0)
							{
								printf(".");
							}
							if(y % 2 == 1)
							{
								printf("#");
							}
						}
						printf("\n");
					}
				}
				printf("\n");
			}
			exit(0);
		}
	}
	return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define inf 2e9
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define LL long long
using namespace std;
int n;
string s;
int main(){
	cin>>n;
	s="";
	if (n==0)
		s="0";
	while (n!=0){
		int r=n%-2;
		n/=-2;
		if (r==0)
			s='0'+s;
		else {	
			s='1'+s;
			if (r < 0)
			n++;
		}
	}
	cout<<s<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  int A[3][3];
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      cin>>A[i][j];

  int n;
  cin>>n;
  for(int t=0;t<n;t++){
    int b;
    cin>>b;
    for(int i=0;i<3;i++)
      for(int j=0;j<3;j++)
        if(A[i][j]==b) A[i][j]=0;
  }

  for(int i=0;i<3;i++){
    int sum=0;
    for(int j=0;j<3;j++)
      sum+=A[i][j];
    if(sum==0) drop("Yes");
  }

  for(int j=0;j<3;j++){
    int sum=0;
    for(int i=0;i<3;i++)
      sum+=A[i][j];
    if(sum==0) drop("Yes");
  }

  if(A[0][0]+A[1][1]+A[2][2]==0) drop("Yes");
  if(A[0][2]+A[1][1]+A[2][0]==0) drop("Yes");

  drop("No");
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int ox = 0, oy = 0, W, H, x, y, r;
    int up, und, rig, lef;

    scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);

    up = y + r;
    und = y - r;
    rig = x + r;
    lef = x - r;

    if(up <= H && und >= 0){
        if(rig <= W && lef >= 0) printf("Yes\n");
        else printf("No\n");

    }
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 2120
N,Q = list(map(int,input().split()))

G = [[] for i in range(N)]
for i in range(N-1):
    A,B = list(map(int,input().split()))
    G[A-1].append(B-1)
    G[B-1].append(A-1)

QL = [0]*N
for i in range(Q):
    P,X = list(map(int,input().split()))
    QL[P-1] += X

from collections import deque
values = [None]*N
que = deque([0])
values[0] = QL[0]
while que:
    v = que.popleft()
    d = values[v]
    for w in G[v]:
        if values[w] is not None:
            continue
        values[w] = d + QL[w]
        que.append(w)

print(" ".join(list(map(str,values))))

Measured memory_bytes: 123512
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };



int main() {
	int n, i;
	cin >> n;
	vi a(n);
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	int al = 0, b = 0;
	for (i = 0; i < n; i++) {
		if (i % 2) {
			b += a[i];
		}
		else {
			al += a[i];
		}
	}
	cout << al - b << endl;
}

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

using namespace std;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(max(( long long) a * c, ( long long)a * d), max(( long long)b * c, ( long long)b * d)) << endl;


	return 0;
}


Measured memory_bytes: 3672
// finish date: 2018/01/20
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(B, A * N) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	string S;
  	cin>>S;
  	bool alpha[26];
  	string ans;
  	rep(i,26) alpha[i]=false;
  	rep(i,S.size()){
		alpha[S[i]-'a']=true;
    }
  	
  	if(S.size()<26){
     	 rep(i,26){
			if(alpha[i]==false){
             	ans=S;
              	ans.push_back('a'+i);
              	break;
            }
         }
    }else if(S=="zyxwvutsrqponmlkjihgfedcba"){
     	ans="-1";
    }else{
     	string T=S;
      	next_permutation(S.begin(),S.end());
    	int j=0;
      	while(S[j]==T[j]){
         	ans.push_back(S[j]);
          	j++;
        }
      	ans.push_back(S[j]);
    }
  
  
  	cout<<ans<<endl;
}

Measured memory_bytes: 3632
from collections import deque
N,M=map(int,input().split())
A=[0]*M;B=[0]*M
C=[[] for i in range(N+1)]

for i in range(M):
  A[i],B[i]=sorted(list(map(int,input().split())))
  C[A[i]].append(B[i])
  C[B[i]].append(A[i])

d=[-1]*(N+1)
d[0]=0
d[1]=0

queue=deque([1])
while queue:
  now = queue.popleft()
  for i in C[now]:
    if d[i]!=-1:continue
    d[i]=now
    queue.append(i)

if d.count(0)>2:print('No');exit
print('Yes')
for i in range(2,N+1):
  print(d[i])

Measured memory_bytes: 37260
def main():
    a = input()
    array = list(map(int, input().split()))

    sum = 1

    new_array = sorted(array)
    for i in range(len(new_array)):
        sum *= new_array[i]
        if (sum > 10**18 or sum == 0):
            break

    if (sum > 10**18):
        sum = -1

    print(sum)

if __name__ == "__main__":
    main()

Measured memory_bytes: 21708
/**
 *    author:  Aurthur
 *    Created : 12.09.2020       
**/
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <vector>
#include <map>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i, a, n) for(int i = a; i < n; ++i)
#define per(i, a, n) for(int i = n-1; i >= a; --i)
#define mp make_pair
typedef long long ll;
using namespace std;
int main()
{
	ll a, b, c, d;
	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
	ll r = a*c;
	ll s = a*d;
	ll ans1 = max(r,s);
	ll t = b*c;
	ll u = b*d;
	ll ans2 = max(t, u);
	ll ans = max(ans1, ans2);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3824
#include<stdio.h>

int selectionSort(int A[],int N)
{
int i,minj,j,a,sw=0;
for(i=0;i<N-1;i++){
    minj = i;
        for(j=i;j<N;j++){
            if(A[j]<A[minj]){
                minj=j;
            }
        }
            a=A[i];
            A[i]=A[minj];
            A[minj]=a;
            if(i!=minj){
                sw++;
            }
    }
    return sw;
}
int main(void)
{
    int sw,A[100],i,N;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    sw = selectionSort(A,N);
    for(i=0;i<N;i++){
        if(i>0){
            printf(" ");
        }
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",sw);
    return 0;
}


Measured memory_bytes: 1964
H, W, K = map(int, input().split())
C = [list(input()) for _ in range(H)]

ans = 0
for x in range(2**W):
    for y in range(2**H):
        m = [[False for _ in range(W)] for _ in range(H)]

        for xi in range(W):
            if ((x >> xi) & 1):
                for i in range(H):
                    m[i][xi] = True

        for yi in range(H):
            if ((y >> yi) & 1):
                for i in range(W):
                    m[yi][i] = True
        
        count = 0
        for i in range(W):
            for j in range(H):
                if C[j][i] == "#" and not m[j][i]:
                    count += 1
        if count == K:
            ans += 1
print(ans)

Measured memory_bytes: 69212
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
struct edge{
    int to,ecost,scost;
};
typedef pair<int,int>P;
const int MAX_N=1e5;
int n;
vector<edge> G[MAX_N];
int ed[MAX_N];
int sd[MAX_N];

void endijkstra(int s){
    priority_queue<P,vector<P>,greater<P>> que;
    fill(ed,ed+n,INF);
    ed[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p=que.top();que.pop();
        int v= p.second;
        if(ed[v]<p.first)continue;
        REP(i,G[v].size()){
            edge e = G[v][i];
            if(ed[e.to] > ed[v]+ e.ecost){
                ed[e.to] = ed[v] + e.ecost;
                que.push(P(ed[e.to],e.to));
            }
        }
    }
}

void sndijkstra(int t){
    priority_queue<P,vector<P>,greater<P>> que;
    fill(sd,sd+n,INF);
    sd[t]=0;
    que.push(P(0,t));
    while(!que.empty()){
        P p=que.top();que.pop();
        int v= p.second;
        if(sd[v]<p.first)continue;
        REP(i,G[v].size()){
            edge e = G[v][i];
            if(sd[e.to] > sd[v]+ e.scost){
                sd[e.to] = sd[v] + e.scost;
                que.push(P(sd[e.to],e.to));
            }
        }
    }
}

signed main(){
    int m,s,t;cin>>n>>m>>s>>t;s--;t--;
    REP(i,m){
        int u,v,a,b;cin>>u>>v>>a>>b;u--;v--;
        G[v].pb({u,a,b});
        G[u].pb({v,a,b});
    }  
    endijkstra(s);
    sndijkstra(t);
    int a[n];
    int ans=INF;
    RREP(i,n){
        chmin(ans,ed[i]+sd[i]);
        a[i]=1e15-ans;
    }
    REP(i,n)cout<<a[i]<<endl;
}

Measured memory_bytes: 13128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		sc.close();
		int len = x.length();
		int nt = 0;
		int ns = 0;
		for(int i = 0; i<len; i++){
			if(x.charAt(i) == 'S'){
				ns++;
			}else{
				if(ns == 0){
					nt++;
				}else{
					ns--;
				}
			}
		}
		int ans = nt*2;
		System.out.println(ans);
	}

}

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

int main() {
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k-1] << endl;
}

Measured memory_bytes: 256