akhauriyash/Code-Regression huggingface dataset:
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int n;
	cin >> n;
	vector<int> a(n, 0);
	int pre = 0;
	REP(i, n - 1)
	{
		int b;
		cin >> b;

		if (i == 0)
		{
			a[0] = b;
		}
		else
		{
			a[i] = min(pre, b);
		}
		pre = b;
	}
	a[n - 1] = pre;
	int ans = accumulate(a.begin(), a.end(), 0);

	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


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

int main()
{
  ll x;
  cin >> x;
  ll dep = 100;
  ll ans = 0;
  while (x > dep)
  {
    dep += dep / 100;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
 
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define endl "\n"
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    
    
 int h,w;
 cin>>h>>w;
 int ci,cf,di,df;
 cin>>ci>>cf>>di>>df;
 ci--;cf--;di--;df--;
 vector<vector<char>>grid(h,vector<char>(w,'#'));
 //vector<vector<int>>vis(h,vector<int>(w,-1));

 for(int i=0;i<h;i++)
 {
     for(int j=0;j<w;j++)cin>>grid[i][j];
 }
 vector<vector<pair<int,int>>>adj(h*w,vector<pair<int,int>>());//first edge second 0 or 1;
 for(int i=0;i<h;i++)
 {
    for(int j=0;j<w;j++) 
    {   
        if(grid[i][j]=='.')
        for(int k=-2;k<=2;k++)
        {
            for(int l=-2;l<=2;l++)
            {
                if((k||l)&&(i+k<h)&&i+k>=0&&j+l>=0&&j+l<w&&(grid[i+k][j+l]=='.'))
                {
                    if(abs(k)+abs(l)==1)
                    {
                        adj[i*w+j].push_back(MP((i+k)*w+(j+l),0));
                    }else
                    {
                         adj[i*w+j].push_back(MP((i+k)*w+(j+l),1));
                    }
                    
                }
            }
        }
    }
 }
/*for(int i=0;i<h*w;i++)
{   cout<<i<<"->";
    for(auto u:adj[i])
    {
        cout<<u.first<<"("<<u.second<<") ";
    }
    cout<<endl;
}*/
//implementing the 0-1 BFS using queue not  set.
vector<int>d(h*w,10000000);
d[ci*w+cf]=0;
deque<int>q;
q.push_front(ci*w+cf);
while(!q.empty())
{   
    /*for(int u:d)
    {
        cout<<u<<' ';
    }
    cout<<endl;*/
    int v=q.front();
    q.pop_front();
    for(auto edge :adj[v])
    {
        int f=edge.first;
        int val=edge.second;
        if(d[v]+val<d[f])
        {
            d[f]=d[v]+val;
            if(!val)
            {
                q.push_front(f);
            }else
            {
                 q.push_back(f);
            }
        } 
    }
}
if(d[di*w+df]==10000000)
{
    cout<<-1;
}else
{
    cout<<d[di*w+df];
}

















return 0;   
}
/*0-1 BFS*/

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

int main(){
  int i,j,m1,m2;
  string s;
  cin>>s;
  for(i=0;i<s.size();i++){
    if(s[i]=='A'){
      m1=i;
      break;
    }
  }
  for(i=s.size()-1;i>=0;i--){
    if(s[i]=='Z'){
      m2=i;
      break;
    }
  }
  cout<<m2-m1+1;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 998244353;

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

	ll x;
	cin >> x;
	ll t = x / 500;
	ll s = x - 500 * t;
	s /= 5;
	cout << t * 1000 + s * 5;

	return 0; 
}


Measured memory_bytes: 256
N = int(input())

Bxxx = 0
xxxA = 0
BxxA = 0
AB = 0
for i in range(N):
    s = input()
    AB += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        BxxA += 1
    elif s[0] == 'B':
        Bxxx += 1
    elif s[-1] == 'A':
        xxxA += 1

if BxxA == 0:
    print(AB + min(Bxxx, xxxA))
elif Bxxx + xxxA == 0:
    print(AB + BxxA - 1)
else:
    print(AB + min(Bxxx, xxxA) + BxxA)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

int main() {
	makei(a);
	makei(b);
	if (a == 1)say(1);
	else if (a > b)say(a - 1);
	else say(a);
}

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

int main() {
    int D;
    cin >> D;
    vector<int> c;
    vector<int> s;
    vector<int> t;
    vector<int> contests_held;
    int S = 0;
    for (int j = 0; j < 26; j++) {
        int tempC = 0;
        cin >> tempC;
        c.push_back(tempC);
    }
    for (int d = 1; d <= D; d++) {
        for (int l = 0; l < 26; l++) {
            int tempS = 0;
            cin >> tempS;
            s.push_back(tempS);
        }
    }
    for (int e = 0; e < D; e++) {
        int tempT = 0;
        cin >> tempT;
        t.push_back(tempT);
        int u = 0;
        u = (e * 26 ) + t[e] - 1;
        S += s[u];
        for (int a = 1; a <= 26; a++) {
            int contest_count = 0;
            int tempContestDay = 0;
            for (int n = 0; n <= e; n++) {
                if (t[n] == a) {
                    contest_count += 1;
                    tempContestDay = n;
                }
            }
            if (contest_count == 0) {
                S = S - (c[a - 1] * (e + 1));
            } else {
                S = S - (c[a - 1] * (e - tempContestDay));
            }
        }
        cout << S << "\n";
    }
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

const int mod = 1e9 + 7;

int add(int a, int b)
{
    a += b;
    if (a >= mod)
        a -= mod;
    return a;
}

int sub(int a, int b)
{
    a -= b;
    if (a < 0)
        a += mod;
    return a;
}

int mul(int a, int b)
{
    return (LL)a * b % mod;
}

int binpow(int a, int n)
{
    int res = 1;
    while (n)
    {
        if (n & 1)
            res = mul(res, a);
        a = mul(a, a);
        n >>= 1;
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    LL ans = binpow(10, n);
    ans = sub(ans, binpow(9, n));
    ans = sub(ans, binpow(9, n));
    ans = add(ans, binpow(8, n));
    cout << ans;
    return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void sort(int A[], int n){
  int i,j,key;

  for( i = 2; i <= n; i++ ){
    key = A[i];
    j = i -1;

    while( (j >= 0) && (A[j] > key) ){
      A[j+1] = A[j];
      j--;
    }

    A[j+1] = key;

    trace(A, n);
  }
}

int main(){
  int n, i;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  sort(A, n);

  return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a, v, b, w, t; cin >> a >> v >> b >> w >> t;
	t *= (v - w);
    if (abs(a - b) <= t)
        cout << "YES" << '\n';
    else
        cout << "NO" << '\n';
    return 0;
}

Measured memory_bytes: 3520
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


int main() {
	init();
	
	int N; cin >> N;
	cout << 180 * (N - 2) << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<assert.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
int N,x,y,pos,tri0,tri1,tri2,pw3[13]={1},A[531441],salsa[531441],sw[200001];
char T[200001];
void OUT(int x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
char* replace(char* s,const char* before,const char* after)
{
  assert(s!=(char*)NULL);assert(before!=(char*)NULL);assert(after!=(char*)NULL);
  const size_t szb=strlen(before),sza=strlen(after);
  char* pt=s;
  if(szb==0)return s;
  for(;;)
  {
    pt=strstr(pt,before);if(pt==(char*)NULL)break;const char* remain=pt+szb;
    memmove(pt+sza,remain,strlen(remain)+1);
    memcpy(pt,after,sza);
    pt+=sza;
  }
  return s;
}
signed main(void)
{
  x=scanf("%d %s",&N,T+1);
  replace(T+1,"SS","");if(T[0]=='\n')return 0;
  rep(i,N)pw3[i+1]=3*pw3[i];
  tri0=pw3[N],tri1=pw3[N/2],tri2=pw3[N-N/2];
  rep(i,tri0)salsa[i]=salsa[i/3]*3+(3-i%3)%3;
  rep(i,tri1)
  {
    x=i,pos=0;
    rep(j,strlen(T+1))
    {
      if(T[j+1]=='S'){x=salsa[x];if(sw[pos]>0)pos--;else sw[++pos]=1;}
      if(T[j+1]=='R'){x++;if(x==tri1)sw[++pos]=-1,x=0;}
    }
    rep(j,tri2)
    {
      y=j;
      rep(k,pos){if(sw[k+1]>0)y=salsa[y];else if(sw[k+1]<0){if((++y)==tri2)y=0;}}
      A[i+j*tri1]=y*tri1+x;
    }
  }
  rep(i,tri0)printf("%d\t",A[i]);
}

Measured memory_bytes: 8200
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main() {

	char ch[4];
	int cnt;
	bool flg;

	cin >> ch;

	sort(ch,ch+4);

	for (int i = 0; i < 4; i++) {
		if (ch[i] == ch[i + 1]) {
			cnt++;
		}
	}

	if (cnt == 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int a, b; cin >> a >> b;
  if(a > 0) cout << "Positive\n";
  else if(a < 0 && b > 0) cout << "Zero\n";
  else {
    if(abs(b - a) % 2 == 0) cout << "Negative\n";
    else cout << "Positive\n";
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

int i,n,a,b,c;

scanf("%d",&n);

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

scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);

if(a*a+b*b==c*c || c*c+a*a==b*b || b*b+c*c==a*a) printf("YES\n");
else printf("NO\n");

}

return 0;

}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  string s,t;
  cin>>s>>t;
  map<char,char> mp,rev;
  string res="Yes";
  FOR(i,0,s.size()){
    if(mp.find(s[i])==mp.end()){
      mp[s[i]]=t[i];
      rev[t[i]]=s[i];
    }
    else if(mp[s[i]]!=t[i])res="No";
  }
  FOR(i,0,s.size()){
    if(rev[t[i]]!=s[i])res="No";
  }
  cout<<res<<endl;
}


Measured memory_bytes: 916
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static int n;
    static void Main()
    {
        n = int.Parse(Console.ReadLine());
        int[] p = new int[n];
        for (int i = 0; i < n; i++)
            p[i] = int.Parse(Console.ReadLine()) - 1;
        int[] ind = new int[n];
        for (int i = 0; i < n; i++)
            ind[p[i]] = i;
        bool[] d = new bool[n - 1];
        for (int i = 1; i < n; i++)
            d[i - 1] = ind[i] > ind[i - 1];
        List<int> l = new List<int>();
        int c = 1;
        for (int i = 0; i < n - 1; i++)
        {
            if (!d[i])
            {
                l.Add(c);
                c = 1;
            }
            else
                c++;
        }
        l.Add(c);
        Console.WriteLine(n - l.Max());
    }
}

Measured memory_bytes: 20700
#include<iostream>
#include<cstring>
#include<vector>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<utility>
#include<climits>
#include<set>
using namespace std;
#define ll long long


int main(){ 
	ios_base::sync_with_stdio(false);
	    cin.tie(0);
	    cout.tie(0);
	    
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);
	    freopen("output.txt","w",stdout);
	#endif

	string s,t;cin>>s>>t;
	int maxi=0;
	for(int i=0;i<=s.length()-t.length();i++)
	{

			int ans=0;
			int temp=i;
			int temp1=0;
			while(temp<s.length() and temp1<t.length())
			{
				if(s[temp]==t[temp1])
				{
					ans++;
				}
				
					temp++;
					temp1++;


			}
			maxi=max(maxi,ans);

	}
	cout<<t.length()-maxi;
    
}

Measured memory_bytes: 3612
from math import hypot

N = int(input())
pts = [tuple(map(int, input().split())) for _ in range(N)]

def getIntersectionLL(a1, b1, c1, a2, b2, c2):
    v = a1*b2 - a2*b1
    if v == 0:
        return (None, None)
    else:
        return ((b1*c2-b2*c1) / v, (-a1*c2+a2*c1) / v)
def getPerpendicularBisector(x1, y1, x2, y2):
    dx, dy = x2-x1, y2-y1
    xM, yM = (x1+x2)/2, (y1+y2)/2
    return (-dx, -dy, dx*xM+dy*yM)
def getCircumcenter(x1, y1, x2, y2, x3, y3):
    a12, b12, c12 = getPerpendicularBisector(x1, y1, x2, y2)
    a13, b13, c13 = getPerpendicularBisector(x1, y1, x3, y3)
    intLL = getIntersectionLL(a12, b12, c12, a13, b13, c13)
    return intLL

ans = float('inf')
for i in range(N):
    x1, y1 = pts[i]
    for j in range(i+1, N):
        x2, y2 = pts[j]
        xC, yC = (x1+x2)/2, (y1+y2)/2
        dist = max([hypot(x-xC, y-yC) for x, y in pts])
        ans = min(ans, dist)

for i in range(N):
    x1, y1 = pts[i]
    for j in range(i+1, N):
        x2, y2 = pts[j]
        for k in range(j+1, N):
            x3, y3 = pts[k]
            xC, yC = getCircumcenter(x1, y1, x2, y2, x3, y3)
            if xC is None: continue
            dist = max([hypot(x-xC, y-yC) for x, y in pts])
            ans = min(ans, dist)

print(ans)


Measured memory_bytes: 9332
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))

using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vf = vector<float>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using sl = stack<ll>;
using ql = queue<ll>;

const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};


void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

int binary_search(ll x, vl a){
    auto ite = lower_bound(ALL(a), x);
    if(ite != a.end() && *ite == x) {
        return ite - a.begin() ;
    } else {
        return -1;
    }

}

ll modpow(ll a, ll n, ll mod) {
    if(n == 0)
        return 1;
    if(n == 1)
        return a % mod;
    if(n % 2 == 1)
        return (a * modpow(a, n - 1, mod)) % mod;
    ll t = modpow(a, n / 2, mod);
    return (t * t) % mod;
}

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        REP(i, N) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    UnionFind tree(N);

    REP(i, M) {
        int  x, y;
        cin >> x >> y;
        tree.unite(x-1, y-1);
    }

    int cnt=0;
    REP(i, N){
        if(!tree.same(0,i)){
            tree.unite(0, i);
            cnt++;
        }
    }

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

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

int compaere_char(const void* left, const void* right){
  char *left_char = (char *)left;
  char *right_char = (char *)right;

  return strcmp(left_char, right_char);
}

int main(void)
{
  int n, l, i;
  char s[105][105];

  scanf("%d %d", &n, &l);
  for(i = 0; i < n; i++) scanf("%s", &s[i]);

  qsort(s, n, sizeof(s[0]), compaere_char);

  for(i = 0; i < n-1; i++)
    printf("%s", s[i]);
  printf("%s\n", s[n-1]);

  return 0;
}

Measured memory_bytes: 252
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 10005
 
#define PI   3.14159265358979323846264338327950
 
#define F first
#define S second
 
#define ll 	 long long int
 
#define mod  1000000007



int main()
{
	FAST;
	ll n;
	cin >> n;
	if(n % 2 ){
		n *= 2;
	}
	cout << n;
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
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;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        cout << "Possible\n";
    } else {
        cout << "Impossible\n";
    }
}

Measured memory_bytes: 3608
N = int(input())
P = input().split()
Q = input().split()
R = [0,0,0,0,0,0,0,0,0]
j = 0
count = 0
sum_P = 0

def kaijo(x):
    if x == 1 or x == 0:
        return 1
    else:
        return x * kaijo(x - 1)

for i in range(N):
    R[int(P[i])] += 1
    for j in range(int(P[i])):
        if R[j+1] == 0:
            count += 1
    sum_P += kaijo(N - i - 1) * count
    count = 0
    j = 0

R = [0,0,0,0,0,0,0,0,0]
j = 0
count = 0
sum_Q = 0

for i in range(N):
    R[int(Q[i])] += 1
    for j in range(int(Q[i])):
        if R[j+1] == 0:
            count += 1
    sum_Q += kaijo(N - i - 1) * count
    count = 0
    j = 0

print(abs(sum_P - sum_Q))


Measured memory_bytes: 3064
n,m=map(int,input().split())
h=list(map(int,input().split()))
p=[]
num=set(p)
a,b=[0]*m,[0]*m
for i in range(m):
    a[i],b[i]=map(int,input().split())
ans=n
for i in range(m):
    if h[a[i]-1]<h[b[i]-1] and (not a[i] in num):
        ans-=1
        num.add(a[i])
    elif h[a[i]-1]>h[b[i]-1] and (not b[i] in num):
        ans-=1
        num.add(b[i])
    elif h[a[i]-1]==h[b[i]-1]:
        if not b[i] in num:
            ans-=1
            num.add(b[i])
        if not a[i] in num:
            ans-=1
            num.add(a[i])
print(ans)


Measured memory_bytes: 23596
#include <bits/stdc++.h>
#define Maxn 207
using namespace std;
int n;
int a[Maxn];
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=2*n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+2*n+1);
    int ans=0;
    for (int i=1;i<=n;i++)
        ans+=min(a[2*i-1],a[2*i]);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC137_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var kx = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var k = kx[0];
            var x = kx[1];

            var ans = new List<int>();
            for (int i = x - k + 1; i < x + k; i++)
            {
                if (i >= -1000000 && i <= 1000000)
                {
                    ans.Add(i);
                }
            }

            Console.WriteLine(string.Join(" ", ans));
        }
    }
}


Measured memory_bytes: 13396
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, K;
  cin >> N >> K;
  map<ll, ll> m;
  rep(i, N){
    ll a, b;cin >> a >> b;
    m[a]+=b;
  }
  ll cnt= 0;
  for(auto im:m){
    cnt += im.second;
    if(cnt >=K){
      cout << im.first;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 4224
import heapq
n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = []
for i in range(n):
    heapq.heappush(b, a[i] * (-1))

while m > 0:
    bb = ((heapq.heappop(b) * (-1)) // 2) * (-1)
    heapq.heappush(b, bb)
    m -= 1

total = 0
for i in range(n):
    total += b[i] * -1

print(total)

Measured memory_bytes: 14180
from itertools import accumulate
from math import sqrt, ceil
from bisect import bisect_left

N = int(input())
n = list(accumulate(range(ceil(sqrt(2 * N)) + 1)))

r = bisect_left(n, N)

if n[r] == N:
    print('\n'.join(map(str, range(1, r + 1))))
    exit()

d = n[r] - N
for i in range(1, r + 1):
    if i != d:
        print(i)

Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#define INF 1e9
using namespace std;

class data{
public:
	int x,y,t;
	data(){}
	data(int xx,int yy,int tt){
		x=xx;
		y=yy;
		t=tt;
	}
};

int dx[6]={0,1,1,0,-1,-1};
int dy[2][6]={
	1,0,-1,-1,-1,0,
	1,1,0,-1,0,1
};
int sx,sy,gx,gy;
int n;
int lx,ly;
int fie[301][301];
int dp[301][301][6];

int bfs(){
	for(int i=0;i<=300;i++){
		for(int j=0;j<=300;j++){
			for(int k=0;k<6;k++){
				dp[i][j][k]=INF;
			}
		}
	}
	queue<data> que;
	que.push(data(sx+100,sy+100,0));
	dp[sx+100][sy+100][0]=0;
	while(que.size()){
		queue<data> que2;
		while(que.size()){
			data q=que.front();
			que.pop();
			if(q.x-100==gx && q.y-100==gy)return dp[q.x][q.y][q.t];
			que2.push(q);
			bool flag=true;
			while(flag){
				flag=false;
				int sdir=abs((q.x-100)*(q.y-100)*q.t)%6;
				int nx=q.x+dx[sdir],ny=q.y+dy[q.x%2][sdir];
				if(nx>=100-lx && nx<=lx+100 && ny>=100-ly && ny<=100+ly){
					if(fie[nx][ny]!=-1 && dp[nx][ny][(q.t+1)%6]==INF){
						flag=true;
						if(nx-100==gx && ny-100==gy)return dp[q.x][q.y][q.t];
						que2.push(data(nx,ny,(q.t+1)%6));
						dp[nx][ny][(q.t+1)%6]=dp[q.x][q.y][q.t];
					}
				}
				q.x=nx;
				q.y=ny;
				q.t=(q.t+1)%6;
			}
		}
		while(que2.size()){
			data q=que2.front();
			que2.pop();
			if(dp[q.x][q.y][(q.t+1)%6]==INF){
				dp[q.x][q.y][(q.t+1)%6]=dp[q.x][q.y][q.t]+1;
				que.push(data(q.x,q.y,(q.t+1)%6));
			}
			for(int i=0;i<6;i++){
				int nx=q.x+dx[i],ny=q.y+dy[q.x%2][i];
				if(nx>=100-lx && nx<=lx+100 && ny>=100-ly && ny<=100+ly){
					if(fie[nx][ny]!=-1 && dp[nx][ny][(q.t+1)%6]==INF){
						dp[nx][ny][(q.t+1)%6]=dp[q.x][q.y][q.t]+1;
						que.push(data(nx,ny,(q.t+1)%6));
					}
				}
			}
		}
	}
	return -1;
}

int main(void){
	scanf("%d%d%d%d",&sx,&sy,&gx,&gy);
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		fie[x+100][y+100]=-1;
	}
	scanf("%d%d",&lx,&ly);
	printf("%d\n",bfs());
	return 0;
}

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

int main() {
  int N;
  scanf("%d", &N);

  vector<int> L(N, 0);
  for (int i = 0; i < N; i++) {
    scanf("%d", &L.at(i));
  }

  sort(L.begin(), L.end());

  int ans = 0;
  for (int i = 0; i < N; i++) {
    int a = L.at(i);
    for (int j = i + 1; j < N; j++) {
      int b = L.at(j);
      for (int k = j + 1; k < N; k++) {
        int c = L.at(k);
        if (c < a + b) {
          ans++;
        } else {
          break;
        }
      }
    }
  }

  printf("%d", ans);
  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 rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;
int main(){
  int k;
  string s;
  cin >> k >> s;
  int n = s.size();
  if(n <= k) cout << s << endl;
  else cout << s.substr(0,k) << "..." << endl;
}

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int,int> p;

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

#define MAX_N 100010


int d[MAX_N*2];
int renum[MAX_N];

struct edge {int to, cost;};
vector<edge> G[MAX_N*2];
int V;

void dijkstra(int s){
    priority_queue<p,vector<p>, greater<p> > que;
    fill(d,d+V, INF);
    d[s]=0;
    que.push(p(0,s));
    while(!que.empty()){
        p pi = que.top(); que.pop();
        int v = pi.second;
        if(d[v] < pi.first) continue;
        REP(i,G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(p(d[e.to],e.to));
            }
        }
    }
}
int N,M;
int main(){
    ios::sync_with_stdio(false);
    cin >> N >> M;
    V = N+M;
    
    int ln_cur = N;
    REP(i,N) {
        int k;
        cin >> k;
        REP(j,k) {
            int ln;
            cin >> ln;
            if (renum[ln] < N) {
                renum[ln] = ln_cur;
                ln_cur++;
            }
            G[i].pb((edge){renum[ln],1});
            G[renum[ln]].pb((edge){(int)i,1});
        }
    }

    dijkstra(0);
    // たどり着けない奴がいたら即アウト
    int max_dis = 0;
    int max_dis_p = -1;
    REP(i,N) {
        if (d[i] == INF) {
            cout << "NO" << endl;
            return 0;
        }
        if (max_dis < d[i]) {
            max_dis = 1;
            max_dis_p = i;
        }
    }
    dijkstra(max_dis_p);
    max_dis = 0;
    max_dis_p = -1;
    REP(i,N) {
        if (d[i] == INF) {
            cout << "NO" << endl;
            return 0;
        }
        if (max_dis < d[i]) {
            max_dis = 1;
            max_dis_p = i;
        }
    }
    if (max_dis > 4) {
        cout << "NO" << endl;
        return 0;
    }
    else {
        cout << "YES" << endl;
    }
    
    return 0;
}

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

int P,Q,A,N;

int rec(int now,int p,int q,int n){
    if(P*q==Q*p) return 1;
    if(n==N) return 0;
    int res=0;
    for(int i=now;i*q<=A;i++){
        int np=p*i+q;
        int nq=i*q;
        if(P*nq<Q*np) continue;
        res+=rec(i,np,nq,n+1);
    }
    return res;
}

void solve(){
    cout<<rec(1,0,1,0)<<endl;
}

int main(){
  while(1){
      cin>>P>>Q>>A>>N;
      if(P==0) break;
      solve();
  }

  return 0;
}



Measured memory_bytes: 3004
N = int(input())
猫 = N % 10
if 猫 == 2 or 猫 == 4 or 猫 == 5 or 猫 == 7 or 猫 == 9:
  print("hon") 
elif 猫 == 0 or 猫 == 1 or 猫 == 6 or 猫 == 8:
  print("pon")
else:
  print("bon")

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

void maxHeapify(int*,int);
void buildMaxHeap(int*);

int H;

int main(){
  int *A;
  int i;
  
  //input
  scanf("%d",&H);
  A = malloc(sizeof(int)*(H+1));
  for(i = 1; i < H+1; i++) scanf("%d",&A[i]);

  //process
  buildMaxHeap(A);

  //output
  for(i = 1; i < H+1; i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  
  free(A);
  
  return 0;
}

void maxHeapify(int* A, int i){
  int l, r, largest, temp;
  l = i*2;
  r = i*2+1;
  
  if(l <= H && A[l] > A[i]) largest = l;

  else largest = i;
  
  if(r <= H && A[r] > A[largest]) largest = r;

  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(A, largest);
  }// 再帰的に呼び出し
}

void buildMaxHeap(int* A){
  int i;
  
  for(i = H/2; i >= 1; i--){
    maxHeapify(A, i);
  }
}


Measured memory_bytes: 3348
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int f[2][5][5][5][5];
bool bad(int a, int b, int c){
  if(a == 1 && b == 3 && c == 2) return true;
  return false;
}
bool valid(int a, int b, int c, int d){
  bool good = true;
  good &= !bad(a, b, c);
  good &= !bad(b, a, c);
  good &= !bad(a, c, b);
  good &= !bad(a, c, d);
  good &= !bad(b, c, d);
  good &= !bad(b, d, c);
  good &= !bad(c, b, d);
  good &= !bad(a, b, d);
  return good;
}
int doit(int N){
  // ACGT, AGC
  f[0][0][0][0][0] = 1;
  for(int i = 0; i < N; i++){
    int from = i&1, to = 1^from;
    memset(f[to], 0, sizeof(f[to]));
    for(int j = 0; j < 5; j++){
      for(int k = 0; k < 5; k++){
        for(int l = 0; l < 5; l++){
          for(int m = 0; m < 5; m++){
            for(int n = 1; n < 5; n++){
              if(valid(k, l, m, n)){
                f[to][k][l][m][n] += f[from][j][k][l][m];
                if(f[to][k][l][m][n] >= mod) f[to][k][l][m][n] -= mod;
              }
            }
          }
        }
      }
    }
  }
  int ans = 0;
  for(int i = 0; i < 5; i++) 
    for(int j = 0; j < 5; j++)
      for(int k = 0; k < 5; k++)
        for(int l = 0; l < 5; l++){
          ans += f[N&1][i][j][k][l];
          if(ans >= mod) ans -= mod;
        }
  return ans;
}
int main(){
  int n; cin >> n;
  cout << doit(n) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n, sum;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			for(int k = 1; k <= n; k++){
				sum += __gcd(i, __gcd(j, k));
			}
		}
	}
	cout<<sum;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S)
{
    bool type1 = (S[0] == S[1] && S[2] == S[3]);
    bool type2 = (S[0] == S[2] && S[1] == S[3]);
    bool type3 = (S[0] == S[3] && S[1] == S[2]);
    bool type0 = (S[0] == S[1] && S[1] == S[2] && S[2] == S[3]);

    cout << (((type1 || type2 || type3) && (!type0)) ? YES : NO) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
import numpy as np

n_person, n_food = map(int, input().split(' '))

array = [1] * n_food

for i in range(n_person):
    li = list(map(int, input().split(' ')))
    li_sub = np.zeros(n_food)
    for j in li[1:]:
        li_sub[j-1] = 1
    array = array * li_sub

print(int(np.sum(array)))

Measured memory_bytes: 21408
n=int(input())
a=[int(i) for i in input().split()]
arr=[]
for i in a:
    arr.append(abs(i))
neg=0
for i in a:
    if(i<0):
        neg+=1

if(neg%2==0):
    print(sum(arr))
else:
    print(sum(arr) - 2*min(arr))


Measured memory_bytes: 14412
#include<iostream>
#include<cstdio>
using namespace std;
int n,a[20];
char c;
void dfs(int x,int z,int mx)
{
     a[x]=z;
     int i;
     if(x==n)
     {
         for(i=1;i<=n;i++)
         {
             c='a'+a[i]-1;
             printf("%c",c);
         }
         printf("\n");
         return;
     }
     for(i=1;i<=mx+1;i++) 
     {
         if(i<=mx) dfs(x+1,i,mx);
         else dfs(x+1,i,mx+1);
     }
}
int main()
{
    cin>>n;
    dfs(0,0,0);
    //system("pause");
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
//get the biggest element.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

int main() {
  cin.tie(0);ios::sync_with_stdio(false);
  string s, head, tail, tmp;
  head = tail = "";
  int q, cnt = 0;
  cin >> s;
  cin >> q;
  rep (i, q) {
    int x; cin >> x;
    if (x == 1) {
      ++cnt;
      swap(head, tail);
    } else {
      int p; cin >> p;
      cin >> tmp;
      if (p == 1) {
        head += tmp;
      } else {
        tail += tmp;
      }
    }
  }
  if (cnt % 2 != 0) reverse(s.begin(), s.end());
  reverse(head.begin(), head.end());
  cout << head + s + tail << endl;
  return 0;
}


Measured memory_bytes: 4232
#include <stdio.h>
int main() {
	int X, a;
	int b = 0;
	scanf("%d", &X);
	int c[100000];
	for (int i = 0; i<X; i++) {
		scanf("%d", &c[i]);
	}
	for (int j = 0; b<=X; j = a) {
		a = c[j] - 1;
		b++;
		if (a == 1)
		break;
	}
	if (b <=X) {
		printf("%d", b);
	}
	else {
		printf("-1");
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    string s, tmp;
    cin >> s;
    tmp = s;
    reverse(tmp.begin(), tmp.end());
    int ans = 0, i = 0, j = 0, n = s.size();
    while (i < n && j < n)
    {
        if (s[i] == tmp[j])
        {
            i++;
            j++;
        }
        else if (s[i] == 'x')
        {
            i++;
            ans++;
        }
        else if (tmp[j] == 'x')
        {
            j++;
            ans++;
        }
        else
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << (ans + max(n - i + 1, n - j + 1)) / 2 << endl;
    return 0;
}

Measured memory_bytes: 512
"""MILOY"""
x=input()
p=len(x)
n=int(x)
s=0
c=int(x)
for i in range(p):
    
    rem=n%10
    n=n/10
    s=(s*10)+int(rem)
    n=int(n)
    
    
   
   
if (c==s):
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int a[25];
int b[25];
int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(a[i] - b[i] > 0){
            ans += a[i] - b[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
int main() {
  int n, m, x[100000], cnt[100000] = {};
  vector<vector<int> > v;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x[i]);
  }
  sort(x, x + n);
  for (int i = 0; i < n - 1; i++) {
    if (x[i] == x[i + 1]) {
      cnt[x[i] % m]++;
      i++;
    }
  }
  v.resize(m);
  for (int i = 0; i < n; i++) {
    v[x[i] % m].push_back(x[i]);
  }
  int ans = 0;
  for (int i = 0; i <= m / 2; i++) {
    if (i == 0 || m - i == i) {
      ans += v[i].size() / 2;
    } else {
      ans += min(v[i].size(), v[m - i].size());
      int a;
      if (v[i].size() > v[m - i].size()) {
        a = i;
      } else {
        a = m - i;
      }
      ans += min((int)((v[a].size() - v[m - a].size()) / 2), cnt[a]);
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 6528
n = int(input())
ab = []
for i in range(n):
    ab.append([int(item) for item in input().split()])
ab.sort(key=lambda x : x[1])

task_time = 0
for a, b in ab:
    task_time += a
    if task_time > b:
        print("No")
        exit()
print("Yes")

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

int main() {
  int A , B;
  cin >> A >> B;
  int count = 0;
  for (int i = A; i <= B; i++) {
    int s = i % 10;
    int t = i / 10 % 10;
    int u = i / 1000 % 10;
    int v = i / 10000 % 10;
    if (s == v && t == u) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

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

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


Measured memory_bytes: 3580
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
 
 
 
class Solve
{
    public Solve() { }
    public static int Main()
    {
        new Solve().calc();
        return 0;
    }
 
 
    Scanner cin;
 
    void calc()
    {
        cin = new Scanner();
        var S = cin.next();
        var flag = new bool[3];
        if(S.Length == 3){
            for (int i = 0; i < 3; i++){
                var str = S.Substring(i, 1);
                switch(str){
                    case "a":
                        flag[0] = true;
                        break;
                    case "b":
                        flag[1] = true;
                        break;
                    case "c":
                        flag[2] = true;
                        break;
                }
            }
        }
        int count = 0;
        for (int i = 0; i < 3; i++){
            if(flag[i] == true)
                count++;
            
        }
        if (count == 3)
        {
            Console.WriteLine("Yes"); 
        }else{
            Console.WriteLine("No");
        }


    }
}

public class Point {
    public int X, Y;
    public Point(int x, int y){
        X = x;
        Y = y;
    }
}
 
class Scanner
{
    string[] s;
    int i;
 
    char[] cs = new char[] { ' ' };
 
    public Scanner()
    {
        s = new string[0];
        i = 0;
    }
 
    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }
 
    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }
 
    public long nextLong()
    {
        return long.Parse(next());
    }
 
    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }
 
    public double nextDouble()
    {
        return double.Parse(next());
    }
 
 
    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<P> xy(4);
	rep(i, 2) cin >> xy[i].first >> xy[i].second;
	xy[2].first = xy[1].first + xy[0].second - xy[1].second;
	xy[2].second = xy[1].second + xy[1].first - xy[0].first;
	xy[3].first = xy[2].first + xy[0].first - xy[1].first;
	xy[3].second = xy[2].second + xy[0].second - xy[1].second;
	cout << xy[2].first << ' ' << xy[2].second << ' ' << xy[3].first << ' ' << xy[3].second << endl;
	return 0;
}

Measured memory_bytes: 256