akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

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

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " : " << p.second << "}";
	return os;
}

template<typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	string S;
	cin >> S;
	int erase = 0;
	for (int i = S.length() - 1; i >= 0; i--) {
		if (S[i] == 'B') erase++;
		else {
			if (erase > 0) {
				S.erase(S.begin() + i);
				erase--;
			}
		}
	}

	for (auto s : S)
		if (s != 'B')
			cout << s;
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
S = list(input())
B = list('abcdefghijklmnopqrstuvwxyz')
D = {}
tmp = 0
for i in range(len(B)):
    D[B[i]] = 0
for i in S:
    D[i] += 1
for i in B:
    if D[i] == 0:
        print(i)
        break
else:
    print('None')


Measured memory_bytes: 3956
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <type_traits>
#include <limits>
#include <tuple>

template <class Tp>
class lines {
  // based on Li Chao tree
  // std::map<Tp, size_t> enc;
  std::vector<Tp> dec;
  std::vector<std::pair<Tp, Tp>> c;
  size_t m = 1;
  Tp inf = std::numeric_limits<Tp>::max() / 8;

private:
  void init_resize(size_t n) {
    while (m < n+n) m <<= 1;
    c.assign(m, {0, inf});
  }

  void inspect() const {
    for (size_t i = 1; i < m; ++i) {
      std::string s = (c[i].first < inf? std::to_string(c[i].first) : "inf");
      std::string t = (c[i].second < inf? std::to_string(c[i].second) : "inf");
      fprintf(stderr, "(%s, %s)%c", s.c_str(), t.c_str(), (i&(i+1))? ' ':'\n');
    }
  }

public:
  template <class ForwardIt>
  lines(ForwardIt first, ForwardIt last): dec(first, last) {
    static_assert(std::is_same<typename ForwardIt::value_type, Tp>::value, "Type mismatch");
    std::sort(dec.begin(), dec.end());
    size_t n = dec.size();
    init_resize(n);
    // while (dec.size() < m/2) dec.push_back(dec.back()+1);
    dec.resize(m/2, dec.back()+1);
    // for (size_t i = 0; i < m/2; ++i) enc.emplace(dec[i], i);
  }

  void append(Tp a, Tp b) {
    size_t l = 0;
    size_t j = 1;
    size_t h = 1;
    size_t w = m/2;
    while (w > 0 && l+w-1 < dec.size()) {
      Tp xl = dec[l];
      Tp xm = dec[l+w/2];
      Tp xr = dec[l+w-1];

      Tp a0, b0;
      std::tie(a0, b0) = c[j];

      Tp yl0 = a0*xl + b0;
      Tp yr0 = a0*xr + b0;

      Tp yl = a*xl + b;
      Tp yr = a*xr + b;

      if (yl0 <= yl && yr0 <= yr) break;
      if (yl0 >= yl && yr0 >= yr) {
        c[j] = {a, b};
        break;
      }

      h <<= 1;
      w >>= 1;
      Tp ym0 = a0*xm + b0;
      Tp ym = a*xm + b;

      if (ym0 >= ym) {
        c[j] = {a, b};
        a = a0;
        b = b0;
        j <<= 1;
        if (yr0 < yr) {
          j |= 1;
          l += w;
        }
      } else {
        j <<= 1;
        if (yr0 >= yr) {
          j |= 1;
          l += w;
        }
      }
    }
  }

  Tp min_at(size_t i, Tp x) const {
    i += m/2;
    Tp y = inf;
    while (i > 0) {
      Tp a, b;
      std::tie(a, b) = c[i];
      y = std::min(y, a*x+b);
      i >>= 1;
    }
    return y;
  }
};

int main() {
  size_t N;
  intmax_t C;
  scanf("%zu %jd", &N, &C);

  std::vector<intmax_t> h(N);
  for (auto& hi: h) scanf("%jd", &hi);

  lines<intmax_t> cht(h.begin(), h.end());

  std::vector<intmax_t> dp(N);
  for (size_t i = 0; i+1 < N; ++i) {
    cht.append(-2*h[i], h[i]*h[i]+dp[i]);
    dp[i+1] = cht.min_at(i+1, h[i+1]) + h[i+1]*h[i+1] + C;
  }

  printf("%jd\n", dp[N-1]);
}


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

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
    	for (int k = j + 1; k < n; k++) {
    		if (a[k] < a[i] + a[j]) ans++;
    		else break;
    	}
    }
	}
	cout << ans << '\n';
}

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

typedef long long ll;

int main(void) {

    ll N, M; cin >> N >> M;
    ll cnt;
    if (M <= 2*N) {
        cnt = M/2;
    } else {
        cnt = N;
        M -= 2*N;
        cnt += M/4;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>


using namespace std;

typedef long long ll;

#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vld vector<ld>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define vvld vector<vector<ld>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M = 1000000007;
const ll MM = 998244353;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define trace(...)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

template<typename T, typename F>
void chmax( T &a, F b) {
  if (b > a)a = b;
}

template<typename T, typename F>
void chmin( T &a, F b) {
  if (b < a)a = b;
}



ll powM(ll a, ll b, ll m)
{
  if (a <= 0)return 0;
  a %= m;
  ll ans = 1LL;
  while (b)
  {
    if (b & 1)ans = ans * a % m;
    a = a * a % m;
    b >>= 1;
  }

  return ans;
}



ll poww(ll a, ll b)
{

  ll ans = 1;
  while (b)
  {
    if (b & 1)ans = ans * a;
    a = a * a;
    b >>= 1;
  }

  return ans;

}


string tostring(ll x) {
  stringstream sss;
  sss << x;
  string ans = sss.str();
  return ans;
}



const ll N = 1e6 + 5;





int main() {

  IOS;

#ifndef ONLINE_JUDGE

  freopen("input1.txt", "r", stdin);
  freopen("output1.txt", "w", stdout);

#endif

  ll n; cin >> n;

  vector<string>s(n);

  ll ans = 0;

  FOR(i, n)cin >> s[i];


  vl arr(3);

  FOR(i, n) {
    FOR(j, sz(s[i]) - 1) {
      if (s[i][j] == 'A' && s[i][j + 1] == 'B')ans++;
    }
    if (s[i][0] == 'B' && s[i][sz(s[i]) - 1] == 'A')arr[2]++;
    else if (s[i][0] == 'B')arr[0]++;
    else if (s[i][sz(s[i]) - 1] == 'A')arr[1]++;
  }


  if (arr[2]) {
    ans += arr[2] - 1;
    if (arr[1]) {
      ans++;
      arr[1]--;
    } if (arr[0]) {
      ans++;
      arr[0]--;
    }
  }

  ans += min(arr[0], arr[1]);

  cout << ans;


  return 0;
}

Measured memory_bytes: 3772
#include<stdio.h>
int change(char s){
  if(s=='A')return 0;
  if(s=='B')return 1;
  if(s=='C')return 2;
  return -1;
}
main(){
  int cup[3]={1,0,0};
  char x,y;
  int tmp;
  while(~scanf("%c,%c ",&x,&y)){
    tmp=cup[change(x)];
    cup[change(x)]=cup[change(y)];
    cup[change(y)]=tmp;
  }
  if(cup[0])printf("A\n");
  if(cup[1])printf("B\n");
  if(cup[2])printf("C\n");
  return 0;
}

Measured memory_bytes: 528
import itertools
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]

A = []
for i in range(1, M + 1):
    A.append(i)
H = list(itertools.combinations_with_replacement(A, N))

C = 0
while len(H) > 0:
    CC = 0
    h = H.pop()
    for i in range(Q):
        a = abcd[i][0] - 1
        b = abcd[i][1] - 1
        c = abcd[i][2]
        d = abcd[i][3]
        if h[b] - h[a] == c:
            CC += d
    C = max(C, CC)
print(C)

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  double r, p = 6.283185307179586232/2; cin >> r;
  cout << r * 2 * p << endl;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  if (a >= k) printf("%lld\n", k);
  else if (a+b >= k && a < k) printf("%lld\n", a);
  else printf("%lld\n", a-(k-(a+b)));
}

Measured memory_bytes: 3760
//abc160_a.cpp
//Sat Mar 28 20:59:27 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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

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

	if (s[2]==s[3] && s[4]==s[5]){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)


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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;

int H[110], h[110];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> h[i];
	int ans = 0;
	bool loop = true;
	while (loop) {
		loop = false;
		for (int i = 0; i < N; i++) {
			if (H[i] < h[i]) {
				if (!loop) ans++;
				loop = true;
				H[i]++;
				if (H[i + 1] >= h[i + 1]) break;
			}
		}
	}
	cout << ans << endl;
}

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

int main() {
    int n;
    cin >> n;
    int nm = 0,temp = n;
    while(temp > 0){
        nm += temp%10;
        temp /=10;
    }
    if(n % nm == 0)cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;
using ll = long long;
using tlll = tuple<ll, ll, ll>;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<tlll> d(n);
	for(int i = 0; i < n; ++i){
		ll a, b;
		cin >> a >> b;
		d.emplace_back(a + b, a, b);
	}
	sort(d.begin(), d.end(), greater<tlll>());
	ll answer = 0;
	for(int i = 0; i < n; ++i){
		if(i % 2 == 0){
			answer += get<1>(d[i]);
		}else{
			answer -= get<2>(d[i]);
		}
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 6784
import sys
input = sys.stdin.readline
import math
def print_ans(S):
    """Test Case
    >>> print_ans("sardine")
    xxxxxxx
    >>> print_ans("xxxx")
    xxxx
    >>> print_ans("gone")
    xxxx
    """
    print("x" * len(S))


if __name__ == '__main__':
    S = input().rstrip()
    print_ans(S)




Measured memory_bytes: 2940
/*Name:- Prince Soni
College:- Jalpaiguri Government Engineering College*/

/*.........Range of different integers and macro used by stl c++...................................................

Data Type                              Range                      Macro for min value           Macro for max value
char                                -128 to +127                        CHAR_MIN                      CHAR_MAX
short char                          -128 to +127                       SCHAR_MIN                     SCHAR_MAX
unsigned char                         0  to 255                             0                        UCHAR_MAX

short int                         -32768 to +32767                      SHRT_MIN                      SHRT_MAX
unsigned short int                    0  to  65535                          0                        USHRT_MAX 
int                          -2147483648 to +2147483647                  INT_MIN                       INT_MAX
unsigned int                          0  to  4294967295                     0                         UINT_MAX
long int            -9223372036854775808 to +9223372036854775807        LONG_MIN                      LONG_MAX
unsigned long int                     0  to  18446744073709551615           0                        ULONG_MAX 
long long int       -9223372036854775808 to +9223372036854775807       LLONG_MIN                     LLONG_MAX
unsigned long long int                0  to  18446744073709551615           0                       ULLONG_MAX

float                        1.17549e-38 to  3.40282e+38                 FLT_MIN                       FLT_MAX
float(negative)             -1.17549e-38 to -3.40282e+38                -FLT_MIN                      -FLT_MAX
double                      2.22507e-308 to  1.79769e+308                DBL_MIN                       DBL_MAX
double(negative)           -2.22507e-308 to -1.79769e+308               -DBL_MIN                      -DBL_MAX


......................................................................*/

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

#define ll long long int
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define fr(i,n) for(ll i=0;i<n;i++)
#define fr1(i,n) for(ll i=1;i<=n;i++)
#define MAX 100000

int main() 
{ 
    fio;
    ll n;
    cin>>n;
    ll h[n+1];
    fr1(i,n)
    cin>>h[i];
    ll dp[MAX+1];
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    dp[3]=min((abs(h[1]-h[2])+abs(h[2]-h[3])),abs(h[1]-h[3]));
    for(ll i=4;i<=n;i++)
    {
        dp[i]=min((dp[i-1]+abs(h[i]-h[i-1])),(dp[i-2]+abs(h[i]-h[i-2])));
    }
    cout<<dp[n];
} 

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

int main() {
    int n, x, t, cnt = 1;
    cin >> n >> x >> t;

    int tmp = x;
    for (int i = 0; i < n; i++)
    {
        if (n <= x) break;
        x += tmp;
        cnt++;
    }
    cout << cnt * t << endl;
    return 0;
}

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

const int MAXN = 105;

int n, a[MAXN], b[MAXN];
bool mark[MAXN];

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	
	for(int i = 0; i < n; i++){
		bool found = false;
		for(int j = n - 1; j >= 0; j--){
			if(mark[j])continue;
			
			int c = 1;
			for(int k = 0; k < j; k++)
				c += mark[k];
			
			if(c == a[j]){
				b[i] = a[j];
				mark[j] = true;
				found = true;
				break;
			}
		}
		
		if(!found){
			printf("-1\n");
			return 0;
		}
	}
	
	for(int i = 0; i < n; i++)
		printf("%d\n", b[i]);
	
    return 0;
}


Measured memory_bytes: 256
n,m = gets.split.map(&:to_i)
cnt = [0] * (n+1)
flgs = [false] * (n+1)
ac = 0
m.times do 
  t,s = gets.split
  t = t.to_i
  if s == "AC"
    ac += 1 if flgs[t] == false
    flgs[t] = true
  elsif s == "WA"
    cnt[t] += 1 if flgs[t] == false
  end
end

wa = 0
(1..n).each do |i|
  if flgs[i]
    wa += cnt[i]
  end
end
puts "#{ac} #{wa}"

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

int     main() {
        int H, W;
        cin >> H >> W;
        vector<vector<int>> T(H+2, vector<int>(W+2, 1));
        vector<vector<int>> V(H+2, vector<int>(W+2, 0));
        char C;
        for (int i=1; i<=H; i++)
                for (int j=1; j<=W; j++) {
                        cin >>C;
                        if ( C=='.' ) T.at(i).at(j) = 0;
                }
        for (int i=1; i<=H; i++) {
                int j=1;
                int ss=0;
                while (j<=W+1) {
                        if (T.at(i).at(j) ==0) ss++;
                        else {
                                if (ss>0) {
                                        for (int ii=1; ii<=ss; ii++) V.at(i).at(j-ii)+=ss;
                                }
                                ss=0;
                        }
                        j++;
                }
        }
        for (int j=1; j<=W; j++) {
                int i=1;
                int ss=0;
                while (i<=H+1) {
                        if (T.at(i).at(j) ==0) ss++;
                        else {
                                if (ss>0) {
                                        for (int ii=1; ii<=ss; ii++) V.at(i-ii).at(j)+=ss;
                                }
                                ss=0;
                        }
                        i++;
                }
        }
        int S=0;
        for (int i=1; i<=H; i++) {
                for (int j=1; j<=W; j++) {
                        S=max(S, V.at(i).at(j));
                }
        }
        cout <<S-1 << endl;
        return 0;
}

Measured memory_bytes: 33664
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,count=0;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  
  for(int i=0;i<n;i++)
  {
    if(a[i]>=k)
    {
      count++;
    }
  }
  cout<<count<<endl;
  
} 

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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if((A==B&&B!=C)||(A==C&&B!=C)||(B==C&&B!=A)) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <string>
#include<cstdio>
#include<vector>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;
typedef long long ll;

int main()
{
	string moji;
	int n; cin >> n;
	vector<int>a(10000);
	REP(i, 1000) { a[i] = 1; }
	REP(i, n) {
		char gomi;
		cin >> gomi; moji += gomi;
		if (gomi == '(') {
			a[i] = 1;
		}
		else {
			a[i] = 0;
		}
	}
	int sii = moji.size();
	while (1) {
		int c = 0;
		REP(i, n - 1) {

			if (a[i] == 1 && a[i + 1] == 0) {
				a.erase(a.begin() + i, a.begin() + i + 2);
				sii -= 2;
				c++;
				break;
			}
		}
		if (c == 0) {
			REP(i, sii) {
				int aa = a[i];
				if (aa) {
					moji = moji + ")";
				}
				else {
					moji = "(" + moji;
				}
			}
			break;
		}
	}
	cout << moji << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;

int GCD(int x, int y) {
	return x ? GCD(y % x, x) : y;
}
int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int ans = a[0];
	rep(i,n) {
		ans = GCD(ans, a[i]);
	}
	cout << ans << endl;
}

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

int N;

int mod(int n){
  int sum =0;
  while(n>0){
    sum += (n %10);
    n /= 10;
  }
  return sum;
}

int main(){
  cin >> N;
  int h = mod(N);
  if ( N % h == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ll ans=0,n;
    cin>>n;
    vec A(n),B(n);
    rep(i,n) cin>>A[i];
    rep(i,n) cin>>B[i];
    rep(i,29){
        ll z=0;
        vec C,D;
        ll a=pow(2,i);
        rep(j,n) C.push_back(A[j]%(2*a));
        rep(j,n) D.push_back(B[j]%(2*a));
        sort(all(D));
        rep(j,n){
            z+=upper_bound(all(D),2*a-1-C[j])-lower_bound(all(D),a-C[j]);
            z+=upper_bound(all(D),4*a-2-C[j])-lower_bound(all(D),3*a-C[j]);
        }
        if(z%2) ans+=a;
    }
    cout<<ans<<"\n";
}

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

ll dp[101010];

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

    vector<ll> h(n);
    rep(i, n) cin >> h[i];

    fill(dp, dp+n, 1e10);
    dp[0] = 0;
    for (int i=1; i<n; ++i) {
        for (int j=1;j<=k; ++j) {
            if (i-j >= 0) dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
        }
    }

    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1792
import glob
import math


# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\168\\C'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

        A, B, H, M = map(int, self.input_data().split())

        d_a = 90 - (360 / 12 * H + 30 / 60 * M)
        d_b = 90 - 360 / 60 * M

        c_a = [A * math.cos(math.radians(d_a)), A * math.sin(math.radians(d_a))]
        c_b = [B * math.cos(math.radians(d_b)), B * math.sin(math.radians(d_b))]

        print(str(math.sqrt((c_a[0] - c_b[0]) ** 2 + (c_a[1] - c_b[1]) ** 2)))






solver = Solver(REL_PATH)
solver.exec_resolve()


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

vector<int> l;

int main() {
    int n;
    cin >> n;
    l.resize(n);
    rep(i, n) {
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    long sum = 0;
    for (int i = 0; i < n - 2; i++) {
        for (int j = i + 1; j < n - 1; j++) {
            vector<int>::iterator begin = l.begin() + j + 1;
            vector<int>::iterator end = l.end();
            int left = l[j] - l[i];
            int right = l[i] + l[j];
            // left < a[i] < right を満たすa[i]の個数は、
            // right未満のa[i]の個数 - left以下のa[i]の個数に等しい
            sum += lower_bound(begin, end, right) - upper_bound(begin, end, left);
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

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


int main()
{
    int N;
    cin >> N;
    int t[N + 1],x[N + 1],y[N + 1];
    t[0] = 0, x[0] = 0,y[0] = 0;
    for(int i = 1; i < N + 1; i++) cin >> t[i] >> x[i] >> y[i];
    for(int i = 0; i < N; i++)
    {
        if(abs(x[i] - x[i + 1]) + abs(y[i] - y[i + 1]) > t[i + 1] - t[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i = 0; i < N; i++)
    {
        if( ( (t[i + 1] - t[i]) - abs(x[i] - x[i + 1]) + abs(y[i] - y[i + 1]) ) % 2 != 0 )
        {
            cout << "No" << endl;
            return(0);
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define mx 100009

ll ar[mx+10];
ll br[mx+10];
ll n,w;
ll dp[101][mx];

ll ks(ll ind,ll w){
    if(dp[ind][w]!=-1) return dp[ind][w];
    if(ind>=n||w<=0) return 0;
    if(w-ar[ind]>=0){
        return dp[ind][w]=max(br[ind]+ks(ind+1,w-ar[ind]),ks(ind+1,w));
    }
    else return dp[ind][w]=ks(ind+1,w);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin>>n>>w;
    for(ll i=0;i<n;i++){
        cin>>ar[i]>>br[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<ks(0,w)<<endl;
    return 0;
}


Measured memory_bytes: 80128
#!/usr/bin/env python3

def main():
    N = int(input())
    S = input()
    max_score = 0
    for i in range(N):
        left = "".join(set(S[:i]))
        right = "".join(set(S[i:]))
        score = 0
        for i in range(len(left)):
            if left[i] in right:
                score += 1
        max_score = max(max_score,score)
    print(max_score)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <cmath>
using namespace std;

#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647

int main() {
	int N, Y;
	cin >> N >> Y;

	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= N; ++j) {
			for (int k = 0; k <= N; ++k) {
				if (N < i + j + k)break;
				int bill1 = i * 1000, bill2 = j * 5000, bill3 = k * 10000;
				if (N == i + j + k && bill1 + bill2 + bill3 == Y) {
					cout << k << " " << j << " " << i << endl;
					return 0;
				}
			}
		}
	}

	cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}

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

using namespace std;

int main(){
  
  int n, k;
  cin >> n >> k;
  
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];
  
  sort(a, a + n);
  
  
  int mi = 1000000005;
  
  for(int i = k-1; i < n; i++){
      mi = min(mi, a[i] - a[i-k+1]);
   }
  
  cout << mi;
  
  
  return 0; 
}


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

int main() {
 int N,K,D,p;
  cin >> N>>K;
  D=0;
  
  for (int i=0 ; i<N;i++){
    cin >> p;
    if (K-p <=0){
      D +=(p-K);
    }
    
    else if(p>K-p){
      D += (K-p);
    }
    else {
      D += p;
    }
  }
  cout << D*2 <<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

void solve()
{
	int x,y;
	cin>>x>>y;
	int l=2*x,r=4*x;
	if((y%2==0)){
		if((l<=y)&&(y<=r)){
			cout<<"Yes";
		}
		else cout<<"No";
	}
	else cout<<"No";
}

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


Measured memory_bytes: 3652
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
typedef long long ll;
typedef double flot;
using namespace std;
#define rep(i,a,b) for(long long int i=a;i<b;i++)
int main()
{
    ll n,k;
    cin>>n>>k;
    if(k>=n)
    cout<<"unsafe";
    else
    cout<<"safe";
}


Measured memory_bytes: 3596
S = input()
while(len(S) >= 5):
  if(S[-5:] == "dream" or S[-5:] == "erase"):
    S = S[:-5]
  elif(S[-6:] == "eraser"):
    S = S[:-6]
  elif(S[-7:] == "dreamer"):
    S = S[:-7]
  else:
    break
if(len(S) == 0):
  print("YES")
else:
  print("NO")

Measured memory_bytes: 74780
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);

  int H;
  while (cin >> H && H){

    int board[H][5];
    REP(i, H){
      REP(j, 5) cin >> board[i][j];
    }


    int  score  = 0;
    bool update = true;

    
    while (update){
      update = false;
      int next_board[H][5];
      memcpy(next_board, board, sizeof(board));
      
      // REP(i, H){
      //   REP(j, 5) cout << board[i][j] << " " ;
      //   cout << endl;
      // }
      // cout << endl;

      REP(i, H) REP(r, 6) REP(l, r) if (r - l >= 3 && board[i][l] >= 0){
        bool same = true;
        int value = board[i][l];
        REP2(k, l, r) if (board[i][k] != value) same = false;
        
        REP2(k, l, r) if (same){
          next_board[i][k] = -1;
        }
      }
      
      REP(i, H) REP(j, 5) if (board[i][j] != next_board[i][j]){
        update = true;
      }

      if (update){
        REP(i, H) REP(j, 5){
          if (board[i][j] >= 0 && next_board[i][j] == -1){
            score += board[i][j];
          }
          board[i][j] = next_board[i][j];
        }
        
        bool has_drop = true;
        while (has_drop){
          has_drop = false;
          
          REP(i, H - 1) REP(j, 5) if (board[i + 1][j] == -1 && board[i][j] >= 0){
            has_drop = true;
            swap(board[i + 1][j], board[i][j]);
          }
        }
      }
    }
    cout << score << endl;
    
    
  }
  
  return 0;
}

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

int main() {
    int X, Y;
    cin >> X >> Y;

    int ans = 0;
    if(X == 1){
        ans += 300000;
    }
    else if(X == 2){
        ans += 200000;
    }
    else if(X == 3){
        ans += 100000;
    }

    if(Y == 1){
        ans += 300000;
    }
    else if(Y == 2){
        ans += 200000;
    }
    else if(Y == 3){
        ans += 100000;
    }

    if(X == 1 && Y == 1){
        ans += 400000;
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
s=input()
ind = 1
length=1
res=1
while ind < len(s):
  if length == 1 and s[ind] == s[ind-1]:
    length = 2
    ind += 2
    res += 1
  else:
    length = 1
    ind += 1
    res += 1
if ind > len(s):
  res -= 1
print(res)

Measured memory_bytes: 3624
n,x=map(int,input().split())
a=list(map(int, input().split()))
a.sort()
k,i=0,0
ans=0
while i<n:
	k+=a[i]
	ans+=1
	if k>x:
		ans-=1
		break
	i+=1
if k<x:
	ans-=1
print(ans)


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

// const double PI = acos(-1.0); 

void solve();

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}

int main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout); 
    // #endif
    
    fastio(); 

    int t; 
    // cin >> t;

    // while (t--) 
    solve(); 

    return 0;
}

void solve()
{
    char a, c;
    int b;
    cin >> a;
    b = a;
    c = b < 96? 'A': 'a';
    cout << c << "\n";
    return;
}

Measured memory_bytes: 3644
import java.util.*;

public class Main {
	
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		long count = b / x - a / x;
		if (a % x == 0) {
			count++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 25172
function prime(max){
   var arr=[];
   for(var i=0;i<=max;i++)arr[i]=i;
   arr[0]=false;
   arr[1]=false;
   var sqrt=Math.floor(Math.sqrt(max));
   for(var i=2;i<=sqrt;i++){
      if(arr[i]==false)continue;
         for(var j=i+i;j<=max;j+=i){
            arr[j]=false;
         }
   }
   var result=[];
   for(var i=0;i<=max;i++){
      if(arr[i]!==false)result.push(arr[i]);
   }
   return result;
}
var p=prime(50000);
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var n=Arr.shift()-0;
   if(n==0)break;
   var cnt=0;
   var k=p.length-1;
   for(var i=0;i<p.length;i++){
      while(p[i]+p[k]>n)k--;
      if(k<i)break;
      if(p[i]+p[k]==n)cnt++;
   }
   console.log(cnt);
}

Measured memory_bytes: 11488
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=1;i<n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
  int a;
  cin>>a;
  vector<int> b(a),c(a),d(100000,1),e(100000,0),f(100000,0);
  rep(i,a)
    cin>>b[i]>>c[i];
  rep1(i,100000){
  for(int j=2;j*j<=i;j++){
  if(i%j==0)
    d[i-1]=0;
  }
  }
  d[0]=0;
  rep1(i,100000){
    if(i%2==1&&(d[(i+1)/2-1]&&d[i-1]))
    e[i-1]=1;
    }
  rep2(i,100000){
  f[i]=f[i-1]+e[i-1];
  }
  
  rep(i,a)
    cout<<f[c[i]]-f[b[i]-1]<<endl;
}

Measured memory_bytes: 4608
n,k=input().split()
l=input().split()
n=int(n)
k=int(k)
l=[int(s) for s in l]
l.sort(reverse=True)

L=[]
for i in l:
    if k>0 :
        k-=1
    else:
        L.append(i)

S=sum(L)
print(S)

Measured memory_bytes: 26020
#include "bits/stdc++.h"
using namespace std;
long long const Zero = 0;
long long const MAX = 9;
int deg(long long M) {
	long long tmp = M;
	int ans = 0;
	while (tmp != 0) {
		ans++;
		tmp /= 10;
	}
	return ans;
}
int main() {
	long long N;
	cin >> N;
	long long ans = 0;
	for (long long i = 1; i <= N; i++) {
		if (deg(i) % 2 != 0) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
A = input()
B = input()
C = input()

count = 0
for a,b,c in zip(A,B,C):
    if a == b == c:
        continue
    if a != b:
        if a == c:
            count += 1
        else:
            if b == c:
                count += 1
            else:
                count += 2
    else:
        count += 1
print(count)

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

using namespace std;

int N;
char A[501][501];
int ok[501];

int main()
{
    scanf("%d", &N);
    int cc=0;
    for(int i=0; i<N; i++)
        for(int j=0; j<N; j++)
            scanf(" %c", A[i]+j), cc+=A[i][j]=='#';
    if(cc==0)
        return 0*printf("-1\n");
    for(int i=0; i<N; i++)
        ok[i]=1;
    for(int i=0; i<N; i++)
        for(int j=0; j<N; j++) if(A[i][j]=='#')
            ok[j]=0;
    int c=N;
    for(int j=0; j<N; j++)
    {
        int f=0;
        for(int i=0; i<N; i++)
            f+=A[i][j]=='#';
        if(f==N)
            c--;
    }
    int ans=0x3f3f3f3f;
    for(int i=0; i<N; i++)
    {
        int cnt=N;
        for(int j=0; j<N; j++)
            cnt-=A[i][j]=='#';
        ans=min(ans, cnt+c+ok[i]);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 512
console.log((args=>{
  let S = args.trim();
  const T = 'keyence', L = S.length;
  for ( let i = 0; i < L; i++ ) {
    const s = S.slice(0,i) + S.slice(i+L-7);
    if ( s === T ) return 'YES'
  }
  return 'NO';
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 29536
n = gets.to_i
w = gets.split.map(&:to_i)
w_sum = w.inject(:+)
prefix_sum = 0
ans = 100 * 100 + 1

n.times do |i|
  prefix_sum += w[i]
  diff = ((w_sum - prefix_sum) - prefix_sum).abs
  ans = diff if ans > diff
end

puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
  int A, B;
  cin >> A >> B;

  bool b = true;
  if (A > 8 || B > 8) b = false;

  if (b == true) cout << "Yay!" << endl;
  else cout << ":(" << endl;
}

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

#define fi first
#define se second
#define forn(i,n) for(int i=0; i< (int)n; ++i)
#define for1(i,n) for(int i=1; i<= (int)n; ++i)
#define fore(i,l,r) for(int i=(int)l; i<= (int)r; ++i)
#define ford(i,n) for(int i=(int)(n) - 1; i>= 0; --i)
#define fored(i,l,r) for(int i=(int)r; i>= (int)l; --i)
#define pb push_back
#define el '\n'
#define d(x) cout<< #x<< " " << x<<el
#define ri(n) scanf("%d",&n)

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<char,int> pci;
typedef tuple<int, int, int> tiii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const ll INF = LONG_LONG_MAX;
const int MAXN = 21;
const int mod = 1e9+ 7;

int can[MAXN][MAXN];
ll dp[int(1<<MAXN)];
int allmask;

int n;

ll go(int mask){
    int idx = __builtin_popcount(mask);
    if(idx == n) return (mask == allmask);
    ll &r = dp[mask];
    if(r!=-1) return r;
    r= 0;
    for(int i=0; i<n; ++i){ // i es mujeres, idx es hombres
        if(!((1<<i)&mask) && can[idx][i]){
            r+= go(mask|(1<<i));
            r%=mod;
        }
    }
    return r;
}

int main(){
    ri(n);
    memset(dp, -1, sizeof dp);
    forn(i,n){
        forn(j,n){
            ri(can[i][j]);
        }
    }
    allmask = (1<<n)-1;
    printf("%lld\n",go(0));

}


Measured memory_bytes: 16640
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <math.h>

#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))

using namespace std;

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    const double PI=acos((double)-1);
    const double eps=1e-14;
    vector<pair<double, pair<int,int> > > z(n);
    int i,j;
    for(i=0; i<n; i++) {
        int x,y;
        scanf("%d%d", &x, &y);
        double t=0;
        if(x!=0 || y!=0) {
            t=atan2((double)y,(double)x);
            if(t<-PI+eps) t+=2*PI;
        }
        z[i]=make_pair(t, make_pair(x,y));
    }
    sort(z.begin(), z.end());

    vector<double> sx(n+1,0), sy(n+1,0);
    for(i=0; i<n; i++) {
        sx[i+1]=sx[i]+z[i].second.first;
        sy[i+1]=sy[i]+z[i].second.second;
    }

    vector<double> args;
    for(i=0; i<n; i++) {
        double tmp=z[i].first;
        args.push_back(tmp);
        args.push_back(tmp>eps? tmp-PI: tmp+PI);
    }
    
    double ans=0;
    for(i=0; i<(int)args.size(); i++) {
        j=lower_bound(z.begin(),z.end(),make_pair(args[i]-eps, make_pair(0,0)))-z.begin();
        int k=lower_bound(z.begin(),z.end(),make_pair(args[i]+PI-eps, make_pair(0,0)))-z.begin();
        double sumx=sx[k]-sx[j];
        double sumy=sy[k]-sy[j];
        double ans0=sumx*sumx+sumy*sumy;
        ans=MAX(ans,ans0);

        sumx=sx[n]-sumx;
        sumy=sy[n]-sumy;
        ans0=sumx*sumx+sumy*sumy;
        ans=MAX(ans,ans0);
    }
    printf("%.16lf\n", sqrt(ans));

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using ll = long long int;

int main(){
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C ;
    vector<ll> p(A);
    vector<ll> q(B); 
    vector<ll> r(C);
    for(ll i=0; i<A; i++){
        cin >> p[i];
    }
    for(ll i=0; i<B; i++){
        cin >> q[i];
    }
    for(ll i=0; i<C; i++){
        cin >> r[i];
    }
    sort(p.begin(), p.end(), std::greater<ll>());
    sort(q.begin(), q.end(), std::greater<ll>());
    sort(r.begin(), r.end(), std::greater<ll>());
    vector<ll> g(0);
    for(int i=0; i<X; i++){
        g.push_back(p[i]);
    }
    for(int i=0; i<Y; i++){
        g.push_back(q[i]);
    }
    sort(g.begin(), g.end());
    ll c = 0;
    for(int i=0; i<X+Y; i++){
        if(g[i] < r[c]){
            g[i] = r[c];
            c++;
        }
    }
    ll ans = 0;
    for(int i=0; i<X+Y; i++){
        ans += g[i];
    }
    cout << ans;
}

Measured memory_bytes: 4724
N,K=map(int,input().split())
S=input()
seqs = [] #(start, end, 0or1): [start, end)
now_num = S[0]
start = 0
for i in range(1, N):
    if S[i] != now_num:
        seqs.append((start, i, int(now_num)))
        now_num = S[i]
        start = i
        if i == N-1:
            seqs.append((start, N, int(now_num)))
            break
    if i == N-1:
        seqs.append((start, N, int(now_num)))
        break

first = S[0]
zero_ranges = None
if first == "0":
    zero_ranges = [i for i in range(0, len(seqs), 2)]
else:
    zero_ranges = [i for i in range(1, len(seqs), 2)]
n_zero = len(zero_ranges)
if n_zero <= K:
    print(N)
    exit()

cum = [0]*(len(seqs)+1)
cum[0] = 0
for i in range(1, len(seqs)+1):
    s, e, n = seqs[i-1]
    cum[i] = cum[i-1] + e-s
length = len(seqs)
ans = 0
for i in range(int(first), len(seqs), 2):
    j = i + 2*K - 2
    if j+1 > length:
        continue
    tmp = 0
    if j+2 <= length and i-1 >= 0:
        tmp = cum[j+2] - cum[i-1]
    elif j+2 <= length and i-1 < 0:
        tmp = cum[j+2]
    elif j+2 > length and i-1 >= 0:
        tmp = cum[j+1] - cum[i-1]
    else:
        tmp = cum[j+1]
    ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 89380
n = int(input())
ac,wa,tle,re = 0,0,0,0
for i in range(n):
    s = input()
    if s=='AC':
        ac+=1
    elif s=='WA':
        wa+=1
    elif s=='TLE':
        tle+=1
    else:
        re+=1
print('AC'+' x '+str(ac))
print('WA'+' x '+str(wa))
print('TLE'+' x '+str(tle))
print('RE'+' x '+str(re))


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n;
	cin>>n;
	deque<int>ans;
	for(int i=1,tmp;i<=n;++i){
		cin>>tmp;
		if(i&1)ans.emplace_front(tmp);
		else ans.emplace_back(tmp);
	}
	if(n&1)for(auto i=ans.begin();i!=ans.end();++i){
		cout<<*i;
		if(i+1!=ans.end())cout<<" "s;
		else cout<<"\n"s;
	}else for(auto i=ans.end()-1;i>=ans.begin();--i){
		cout<<*i;
		if(i!=ans.begin())cout<<" "s;
		else cout<<"\n"s;
	}
}

Measured memory_bytes: 3072
function max(a, b:int64):int64;
begin
    if a>b then
        max:=a
    else
        max:=b;
end;
var dp: array[-1..100, -100000..100000] of int64;
    N, W, i, j: longint;
    ww, v: array[1..100000] of longint;
begin
    readln(N, W);
    for i:=1 to N do
        readln(ww[i], v[i]);
    
    for i:=1 to N do
    begin
        for j:=1 to W do
        begin
            if j-ww[i]<0 then
                dp[i,j]:=dp[i-1,j]
            else
                dp[i,j]:=max(dp[i-1,j], dp[i-1,j-ww[i]]+v[i]);
        end;
    end;
    writeln(dp[N, W]);
end.

Measured memory_bytes: 157824
from collections import deque

w, h = map(int, input().split())
mp = [input() for _ in range(h)]

springs = []
tile_cnt = 0
for y in range(h):
  for x in range(w):
    if mp[y][x] == "*":
      springs.append((x, y))
    if mp[y][x] == "g":
      gx, gy = x, y
    if mp[y][x] == "s":
      sx, sy = x, y
      tile_cnt += 1
    if mp[y][x] == ".":
      tile_cnt += 1

vec = ((1, 0), (0, -1), (-1, 0), (0, 1))
INF = 10 ** 10

g_dist = [[INF] * w for _ in range(h)]
que = deque()
que.append((0, gx, gy))
g_dist[gy][gx] = 0
while que:
  score, x, y = que.popleft()
  for dx, dy in vec:
    nx, ny = x + dx, y + dy
    if mp[ny][nx] in (".", "s"):
      if g_dist[ny][nx] == INF:
        g_dist[ny][nx] = score + 1
        que.append((score + 1, nx, ny))

s_dist = [[INF] * w for _ in range(h)]
que = deque()
for x, y in springs:
  s_dist[y][x] = 0
  que.append((0, x, y))
while que:
  score, x, y = que.popleft()
  for dx, dy in vec:
    nx, ny = x + dx, y + dy
    if mp[ny][nx] in (".", "s"):
      if s_dist[ny][nx] == INF:
        s_dist[ny][nx] = score + 1
        que.append((score + 1, nx, ny))

sorted_tiles = sorted([(g_dist[y][x] - s_dist[y][x] if g_dist[y][x] != INF else INF, x, y) for y in range(h) for x in range(w) if mp[y][x] in (".", "s")])

acc_g = 0
acc_s = 0
acc_t = 0
acc_g_dic = {}
acc_s_dic = {}
acc_t_dic = {}
keys = set()
for key, x, y in sorted_tiles:
  acc_g += g_dist[y][x]
  acc_s += s_dist[y][x]
  acc_t += 1
  acc_g_dic[key] = acc_g
  acc_s_dic[key] = acc_s
  acc_t_dic[key] = acc_t
  keys.add(key)
keys = sorted(list(keys))

length = len(keys)
for i in range(length - 1):
  key = keys[i]
  next_key = keys[i + 1]
  E = (acc_g_dic[key] + acc_s - acc_s_dic[key]) / acc_t_dic[key]
  if key <= E < next_key:
    print(min(g_dist[sy][sx], s_dist[sy][sx] + E))
    break
else:
  print(g_dist[sy][sx])


Measured memory_bytes: 46164
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i,m,n) for(ll i=m ; i<n ; i++)
#define forr(i,m,n) for(ll i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N =1e5+5;
using namespace std;
int main()
{
    IO;
    int n,mx=0; cin>>n;
    map<string,int>mp;
    rep(i,0,n){
    string s; cin>>s;
    mp[s]++;
    }
    for(auto i:mp){
        mx=max(mx,i.second);
    }

    for(auto i:mp){
        if(i.second==mx)
            cout<<i.first<<endl;

    }





}


Measured memory_bytes: 23808