akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
const int N = 1e5 + 10;
ll n,m;
ll v[N];
int fact[N];
ll mul(ll a, ll b) {
    if(a < 0) a += MOD;
    if(b < 0) b += MOD;
    return ( (a % MOD) * (b % MOD) ) % MOD;
}
ll add(ll a, ll b) {
    if(a < 0) a += MOD;
    if(b < 0) b += MOD;
    return ( (a % MOD) + (b % MOD) ) % MOD;
}
ll subs(ll a, ll b) {
    return ((a % MOD) - (b % MOD) + MOD) % MOD;
}
ll bpow(ll a, ll b) {
    ll ret = 1;
    while(b) {
        if(b & 1) {
            ret = mul(a, ret);
        }
        a = mul(a, a);
        b >>= 1;
    }
    return ret;
}
ll inv(ll a) {
    return bpow(a, MOD - 2);
}
ll comb(ll a, ll b) {
    ll num = fact[a];
    ll den = mul(fact[a - b], fact[b]);
    ll i = inv(den);
    ll ret = mul(num, i);
    return ret;
}
void getf() {
    fact[0] = fact[1] = 1;
    for(ll i = 2; i < N; ++i) {
        fact[i] = mul(fact[i - 1], i);
    }
}
int main() {
    getf();
    cin>>n>>m;
    for(int i = 0; i < n; ++i) {
        cin>>v[i];
    }
    sort(v, v + n);
    vector<ll> q;
    ll tempn = n - 1;
    ll tempm = m - 1;
    while(tempn >= tempm) {
        ll c = comb(tempn, tempm);
        q.emplace_back(c);
        tempn--;
    }
    reverse(q.begin(), q.end());
    ll forw = 0, back = 0;
    for(int i = 0, k = (int) q.size() - 1; i < n; ++i, --k) {
        ll mt = mul(v[i], q[k]);
        forw = add(forw, mt);
        if(k == 0) break;
    }
    for(int i = n - 1, k = (int) q.size() - 1; i >= 0; --i, --k) {
        ll mt = mul(v[i], q[k]);
        back = add(back, mt);
        if(k == 0) break;
    }
    ll ans = subs(back, forw);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2044
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def readInt():
    return list(map(int,input().split()))

def main():
    x = int(input())
    a = 0
    bl = -1000
    br = 1000
    b = False
    while not b:
        z = a**5
        bl = -1000
        br = 1000
        while abs(bl-br)!=1:
            if z-((bl+br)//2)**5<x:
                br = (bl+br)//2
            elif z-((bl+br)//2)**5>x:
                bl = (bl+br)//2
            if z-((bl+br)//2)**5==x:
                b = (bl+br)//2
                break
        if not b:
            a += 1
    print(a,b)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 9224
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int n;
ll a[200000];

ll func ( ll b ) {
    ll ret = 0;
    rep(i, n) ret += abs(a[i] - (b+(i+1)));
    return ret;
}

ll solve ( ll l, ll r ) {
    while( r - l > 2 ) {
        ll m1 = l + (r - l)/3;
        ll m2 = l + (r - l)*2/3;
        
        ll v1 = func(m1), v2 = func(m2);
        if ( v1 > v2 ) l = m1;
        else r = m2;
    }

    ll ans = 0, val = 1ll << 60;
    reep(i, l, r+1) {
        ll tmp = func(i);
        if ( val > tmp ) {
            ans = i;
            val = tmp;
        }
    }
    
    return ans;
}

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

    ll pos = solve(0, 1ll << 32), neg = solve(-10, 0);
    cout << min(func(pos), func(neg)) << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int a[100005][4];
int dp[100005][4];
int n;

int func(int ind, int flag)
{
	if (ind == n)
      return 0;

	if (dp[ind][flag] != -1)
      return dp[ind][flag];

	int maxi = 0;
	if (flag == 0)
    {
		maxi = max(maxi, a[ind][1] + func(ind + 1, 1));
		maxi = max(maxi, a[ind][2] + func(ind + 1, 2));
		maxi = max(maxi, a[ind][3] + func(ind + 1, 3));
	}
	else if (flag == 1)
    {
		maxi = max(maxi, a[ind][2] + func(ind + 1, 2));
		maxi = max(maxi, a[ind][3] + func(ind + 1, 3));
	}
	else if (flag == 2)
    {
		maxi = max(maxi, a[ind][1] + func(ind + 1, 1));
		maxi = max(maxi, a[ind][3] + func(ind + 1, 3));
	}
	else
    {
		maxi = max(maxi, a[ind][1] + func(ind + 1, 1));
		maxi = max(maxi, a[ind][2] + func(ind + 1, 2));
	}
	return dp[ind][flag] = maxi;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
    {
		for (int j = 1; j <= 3; j++)
        {
			cin >> a[i][j];
		}
	}
	memset(dp, -1, sizeof dp);
	cout << func(0, 0);
	return 0;
}

Measured memory_bytes: 14504
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

/*
h w
cij
 */

int h,w;

int main(){
  cin >>h>>w;
  char line[w];
  REP(i,h){
    REP(j,w){
      cin>>line[j];
      cout << line[j];
    }
    cout << endl;
    REP(j,w)
      cout << line[j];
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.split( " " ).map( Number );
  var x1 = data[0];
  var y1 = data[1];
  var x2 = data[2];
  var y2 = data[3];
  
  var d = Math.sqrt( (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2) );
  console.log( d );
});

Measured memory_bytes: 15928
#include<iostream>
#include<cstdio>
using namespace std;
long long n,k,ans,t;
int main()
{
	cin>>n>>k;
	for (long long i=k+1;i<=n;i++)
	{
		ans+=(n/i)*(i-k);
		t=n%i;
		if (t>=k) ans+=(t-k+1);
	}
	if (!k) ans-=n;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <sstream>
using namespace std;

#define INF (1<<29)

int toInt(string s){
  istringstream iss(s);
  int a;
  iss >> a;
  return a;
}

int main(){
  int n;
  string s;
  while(cin >> n >> s){
    if(n == 0 && s == "0") break;
    int ans = -1;
    vector<string> ans2;
    map<int, int> is_found;
    
    for(int i = 0 ; i < (1<<s.size()) ; i++){
      vector<string> tmp;
      int pos = 0;
      int point = 0;
      for(int j = 0 ; j < s.size() ; j++){
	if(j == s.size()-1){
	  string t = s.substr(pos, j-pos+1);
	  tmp.push_back(t);
	  pos = j+1;
	  point += toInt(t);
	}
	
	else if((1<<j) & i){
	  string t = s.substr(pos, j-pos+1);
	  tmp.push_back(t);
	  pos = j+1;
	  point += toInt(t);
	}
      }
      
      is_found[point]++;
      if(point <= n && n-point < n-ans){
	ans = point;
	ans2 = tmp;
      }
      /*
      cout << point << ' ';
      for(int b = 0 ; b < tmp.size() ; b++){
	cout << tmp[b] << ' ';
      }
      cout << endl;
      */
    }
    
    //cout << is_found[ans] << endl;
    bool f = true;
    if(is_found[ans] > 2) f = false;
    
    if(ans == -1) cout << "error" << endl;
    else if(!f){
      cout << "rejected" << endl;
    }
    else{
      cout << ans << ' ';
      for(int i = 0 ; i < ans2.size() ; i++){
	cout << ans2[i];
	if(i != ans2.size()-1) cout << ' ';
	else cout << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define all(v) v.begin(),v.end()
#define fi first
#define se second
const int inf = 1e9;
int mod = 1e9+7;

signed main(){
	int n, ans = 1;
	scanf("%lld", &n);
	rrep(i,n)ans = (ans*i)%mod;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int a, b;
  cin >> a >> b;

  // 解答
  cout << (a + b + 1) / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK: 16777216")

#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
//typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl


using ll = long long;
//#ifdef __int128
//using hll = __int128;
//#endif
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}


#ifdef _getchar_nolock
#else
#define _getchar_nolock getchar_unlocked
#endif

template <typename T>
void freadT(T &x) {
    x = 0;
    char ch = _getchar_nolock();
    ll sign = 1;

    while (!isdigit(ch)) {
        if (ch == '-')
            sign *= -1;
        ch = _getchar_nolock();
    }

    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = _getchar_nolock();
    }

    x *= sign;
}

int fparse(string s, int start_indx) {
    int x = 0;

    while (isdigit(s[start_indx])) {
        x = x * 10 + s[start_indx] - '0';
        ++start_indx;
    }

    return x;
}

//#define solvsh
//#define multi

#ifdef solvsh
#else


ll mod = 998244353;

ll add(ll a, ll b){
    return (a + b) % mod;
}
ll mult(ll a, ll b) {
    return (a * b) % mod;
}

const int MAXN = 3e5 + 120;

void solve() {

    string s;
    cin >> s;

    ll cnt = 0;

    for (auto e : s) {
        cnt += e-'9';
    }

    if (cnt % 9 == 0)
        cout << "Yes";
    else
        cout << "No";
}


#endif

clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}


void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
        solve();
        i++;
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifndef ONLINE_JUDGE

#else

#endif
#ifdef multi
    multisolve();
#else
    solve();
//    gen();
#endif
}


Measured memory_bytes: 3784
class UnionFind:
    def __init__(self, n):
        self.v = [-1 for _ in range(n)]

    def find(self, x):
        if self.v[x] < 0:
            return x
        else:
            self.v[x] = self.find(self.v[x])
            return self.v[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if -self.v[x] < -self.v[y]:
            x, y = y, x
        self.v[x] += self.v[y]
        self.v[y] = x

    def root(self, x):
        return self.v[x] < 0

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.v[self.find(x)]


n, m = map(int, input().split())

uf = UnionFind(n + m)
for i in range(n):
    _, *lngs = map(int, input().split())
    for lng in lngs:
        uf.unite(i, n + lng - 1)

can = all(uf.same(j, n - 1) for j in range(n - 1))
print('YES' if can else 'NO')


Measured memory_bytes: 9492
import sys
n = int(input())
ans, c, h, t = 0, 0, 0, 0

for x in sys.stdin.readlines():
    x = x.rstrip()
    ans += x.count("AB")
    if x[-1] == "A" and x[0] == "B":
        c += 1
    elif x[-1] == "A":
        t += 1
    elif x[0] == "B":
        h += 1
if t + h > 0:
    ans += min(t, h) + c
elif c > 0:
    ans += c-1
print(ans)

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vi;
typedef double db;

void file_put() {
    freopen("filename.in", "r", stdin);
    freopen("filename.out", "w", stdout);
}

const int N=1e5+5;
int n,q,in[N]; vi a,V[N],E[N]; ll x,v[N],cnt[N],dp[N],ret=0;

void dfs(int x) {
	rep(i,0,sz(V[x])) {
		ll y=V[x][i],w=E[x][i];
		dp[y]+=dp[x]*w;
		if (!--in[y]) dfs(y);
	}
}

int main() {
//	file_put();
	
	scanf("%d%d",&n,&q),a.pb(0),a.pb(n);
	rep(i,1,q+1) {
		scanf("%lld",&x);
		while (x<=a.back()) a.pop_back();
		a.push_back(x);
	}
	q=a.size()-1;
	rep(i,1,q+1) {
		x=a[i];
		for (int t=i; t; ) {
			t=upper_bound(a.begin(),a.begin()+t,x)-a.begin()-1;
			if (!t) { v[i]=x; break; }
			V[i].pb(t),E[i].pb(x/a[t]),in[t]++,x%=a[t];
			if (!x) break;
		}
	}
	dp[q]=1,dfs(q);
	rep(i,1,q+1) cnt[v[i]]+=dp[i];
	per(i,1,n) cnt[i]+=cnt[i+1];
	rep(i,1,n+1) printf("%lld\n",cnt[i]);
	
	return 0;
}



Measured memory_bytes: 33012
#include<stdio.h>
int main()
{
  int a,S,h,m,s;
  scanf("%d",&S);
  h=S/3600;
  m=(S%3600)/60;
  s=(S%3600)%60;
  printf("%d:%d:%d\n",h,m,s);
  return 0;
}

Measured memory_bytes: 592
s = input()
t = input()

dp = [[0] * len(t) for _ in range(len(s))]
for i in range(0, len(s)):
    for j in range(0, len(t)):
        if s[i] == t[j]:
            if i == 0 or j == 0:
                dp[i][j] = 1
            else:
                dp[i][j] = dp[i-1][j-1] + 1
        else:
            if i == 0:
                dp[i][j] = dp[i][j-1]
            elif j == 0:
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = max(dp[i-1][j], dp[i][j-1])


ans = " "
i = len(s) - 1
j = len(t) - 1
while i >= 0 and j >= 0:
    if s[i] == t[j]:
        ans = s[i] + ans
        i -= 1
        j -= 1
    elif i == 0:
        if dp[i][j] == 1:
            ans = s[i] + ans
        break
    elif j == 0:
        if dp[i][j] == 1:
            ans = t[j] + ans
        break
    else:
        if dp[i-1][j] == dp[i][j]:
            i -= 1
        elif dp[i][j-1] == dp[i][j]:
            j -= 1
        else:
            j -= 1
            i -= 1
print(ans)

Measured memory_bytes: 144224
#include <iostream>
using namespace std;
int n,i,j,num[100005],ans;
int main()
{
	ios::sync_with_stdio(0);
	cin>>n;
	for (i=1;i<=n;i++) cin>>num[i];
	i=1;
	while (i<=n)
	{
		for (j=i;j<=n;j++) if (num[j]!=j) break;
		if (j==i)
		{
			i++;
		}
		else
		{
			ans+=(j-i+1)/2;
			i=j;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

N, M = map(int, input().split())

#ゲートの数だけループ
maxL = 1
minR = 1000000
for m in range(M):
  l, r = map(int, input().split())
  maxL = max(maxL, l)
  minR = min(minR, r)
  
print(max(0, minR - (maxL - 1)))

Measured memory_bytes: 41452
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io

    int n, m;
    cin>>n>>m;

    vector<ll> a, b(m), c(m);
    priority_queue<P> pq;
    rep(i,n){
        ll x;
        cin>>x;
        pq.push(make_pair(x, 1));
    }
    rep(i,m){
        cin>>b[i]>>c[i];
        pq.push(make_pair(c[i], b[i]));
    }
    ll ans=0;
    rep(i,n){
        P p=pq.top();
        pq.pop();
        ans+=p.first;
        if(p.second>1){
            p.second--;
            pq.push(p);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7792
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX 100000
#define MAX_E 100000

int par[MAX], rank_[MAX];
int N;
void init(int N)
{
	for (int i = 0; i<N; i++)

	{
		par[i] = i;
		rank_[i] = 0;
	}
}

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

	}
	return par[x] = find(par[x]);

}

void unite(int x, int y)
{
	x = find(x);
	y = find(y);
	if (x == y)
	{
		return;
	}

	if (rank_[x] < rank_[y])
	{
		par[x] = y;
	}
	else
	{
		par[y] = x;
	}
	if (rank_[x] == rank_[y])
	{
		rank_[x]++;
	}
}


bool same(int x, int y)
{
	return find(x) == find(y);
}

struct edge
{
	int u, v, cost;
};
int E;
edge es[MAX_E];

bool comp(const edge& e1, const edge& e2)
{
	return e1.cost < e2.cost;
}

int Kruskal()
{
	int res = 0;
	sort(es, es + E, comp);
	for (int i = 0; i < E; i++)
	{
		if (same(es[i].u, es[i].v))
		{
			continue;
		}
		else
		{
			unite(es[i].u, es[i].v);
			res += es[i].cost;
		}
	}
	return res;
}

int main()
{

	cin >> N >> E;
	init(N);
	//vector<vector<edge>>v;
	for (int i = 0; i < E; i++)
	{
		cin >> es[i].u >> es[i].v >> es[i].cost;

	}
	cout << Kruskal() << endl;
	return 0;
}










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

int n,k;
int main() {
  cin >> n >> k;
  double ans = 0;

  for(int i = 1; i <= n; i++) {
    double tmp = 1 / (double)n;
    int t = i;
    while(k > t) {
      t *= 2;
      tmp = tmp / (double)2;
    }
    ans += tmp;
  }

  cout << setprecision(15) << ans << endl;
}
    
  


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    int n;
    cin>>n;
    vector<vector<int>> a(2,vector<int> (n));
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }

    int ans = 0;
    for(int i=0;i<n;i++){
        int tmp = 0;
        for(int j=0;j<=i;j++){
            tmp += a[0][j];
        }
        for(int j=i;j<n;j++){
            tmp += a[1][j];
        }
        ans = max(ans,tmp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
/*-----------------------------------------------,
|  __                                       __   |
| |  |--.-----.---.-.----.----.-----.-----.|  |_ |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _||
| |_____|_____|___._|____|____|_____|   __||____||
|                                   |__|         |
`-----------------------------------------------*/
#include<algorithm>
#include<array>
#include<bitset>
#include<cctype>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long ll; typedef long double ld ;using namespace std;
#define INF 1000000000000
#define MOD 10000007
#define ALL(name) (name).begin(),(name).end()
#define REP(counter, limit) for (long long counter = 0; counter < limit; counter++)
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){ios::sync_with_stdio(0);cin.tie(nullptr); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

  int n;
  cin>>n;
  int a[n];
  REP(i,n){
    cin>>a[i];
  }
  int cnt[8]={0};int x=0;
  REP(i,n){
    if(a[i]<400) cnt[0]=1;
    else if(a[i]<800) cnt[1]=1;
    else if(a[i]<1200) cnt[2]=1;
    else if(a[i]<1600) cnt[3]=1;
    else if(a[i]<2000) cnt[4]=1;
    else if(a[i]<2400) cnt[5]=1;
    else if(a[i]<2800) cnt[6]=1;
    else if(a[i]<3200) cnt[7]=1;
    else x++;
  }
  int ans=0;
  REP(i,8)	ans+=cnt[i];
  cout<<max(1,ans)<<" "<<ans+x<<endl; 
  return 0;

}


Measured memory_bytes: 256
N=int(input())
L=list(map(int,input().split()))

L.sort()
ans=0
for i in range(len(L)):
    for j in range(i+1,len(L)):
        for k in range(j+1,len(L)):
            if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
                continue   
            if L[i]+L[j] > L[k]:
                ans+=1
                #print(i,j,k)

print(ans)

Measured memory_bytes: 9192
#include "bits/stdc++.h"
using namespace std;
int n, m;
vector<int> p;
int main()
{
    cin >> n >> m;
    vector<vector<int>> graph(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    for (int& c : graph[0]) {
        for (int& p : graph[c]) {
            if (p == n - 1) {
                puts("POSSIBLE");
                return 0;
            }
        }
    }
    puts("IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 12016
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define ll long long
#define ff first
#define ss second

ll mod = 1000000007;

ll mulmod(ll a, ll b)
{
    if(b == 0)
        return 0;

    ll x = 0;
    if(b&1)
        x = a;
    ll y = mulmod(a, b/2);

    return ((y+y)%mod + x)%mod;
}

ll BigMod(ll B,ll P,ll M)
{
	ll R=1;
	while(P>0)
	{
		if(P%2==1)
		{
			R=(R*B)%M;
		}
		P/=2;
		B=(B*B)%M;
	}
	return R;
}

ll Extended_Euclidean(ll a,ll b,ll &x,ll &y)
{
    if(b==0)
    {
        x=1;y=0;
        return a;
    }

    ll d;

    d=Extended_Euclidean(b,a%b,y,x);
    y=y-(a/b)*x;

    return d;
}
ll Inverse_Modulo(ll a,ll m)
{
    ll x,y,d;

    d=Extended_Euclidean(a,m,x,y);

    if(d==1)    return (x+m)%m; //Solution Exists
    return -1;  //No Solution
}



ll func(ll r, ll c)
{
    ll i, ret = 0, x = 1;

    ll y = 1;
    for(i = r+c+2; i >= c+2; i--)
        y = (y*i)%mod;

    for(i = 2; i <= r+1; i++)
        x = (x*i)%mod;
//        y = (y*Inverse_Modulo(i, mod))%mod;

//    cout << r << " " << c << " " << y << " " << x << " " << Inverse_Modulo(x, mod) << endl;

    return mulmod(y, Inverse_Modulo(x, mod)) - 1;
}

//void nCr(ll n, ll r)
//{
//    if(r == 0)
//        return 1;
//    if(r == 1)
//        return n%mod;
//    return (nCr(n-1, r-1) + nCr(n-1, r))%mod;
//}


int main()
{
    ll r1, r2, c1, c2, i, ans = 0, x;
    cin >> r1 >> c1 >> r2 >> c2;

    ans = (ans + func(r2, c2))%mod;
    ans = (ans - func(r2, c1-1))%mod;
    ans = (ans - func(r1-1, c2))%mod;
    ans = (ans + func(r1-1, c1-1))%mod;
    ans = (ans + mod)%mod;

    cout << ans;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC54 A

a,b = map(int,input().split())

po = [2,3,4,5,6,7,8,9,10,11,12,13,1]

A = po.index(a)
B = po.index(b)
if A > B:
    print('Alice')
elif B > A:
    print('Bob')
else:
    print('Draw')


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

int main(){
  ll n, num4=0, num2=0, num1=0;
  cin >> n;
  for(int i=0;i<n;i++){
    ll x;
    cin >> x;
    if (x % 4 == 0){
      num4++;
    }else if (x % 2 == 0){
      num2++;
    }else{
      num1++;
    }
  }
  if (num1 - num4 > 1){
    cout << "No" << endl;
  }else if (num1 - num4 == 1){
    if (num2 % 2 == 0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
def solve(k, x):
    res = []
    for i in range(2*k-1):
        y = x-k+1+i
        if -1000000 <= y <= 1000000:
            res.append(y)
    return " ".join(map(str, res))

k, x = map(int, input().split())
print(solve(k, x))

Measured memory_bytes: 2940
N = gets.chomp.to_i
nums = gets.chomp.split(" ").map(&:to_i)

count = 0
0.upto(N-1) do |i|
    #N-1=4
    (N-1).downto(0) do |j|
        if nums[j] < nums[j-1] && j != 0
            nums[j], nums[j-1] = nums[j-1], nums[j]
            count += 1
        end
    end
end
output_str = ""
nums.each_with_index do |num,i|
    if i >=1
        output_str += " #{num}"
    else
        output_str = "#{num}"
    end
end
puts output_str
p count



Measured memory_bytes: 8908
/* ex 9_1
   Tarara */

#include <stdio.h>
#include <stdlib.h>
//スタックに格納するデータの最大数
#define SIZE 1000

//スタックの定義
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem){
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}

//データの取り出し
char pop(stack *stk){
    char latest;
    if(stk->count <= 0){
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        latest = *(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    }
}

int main(void)
{
    char input[SIZE];
    char *po = input;
    stack stk;
    initialize_stack(&stk);

    scanf("%s", input);
    for(; *po; po++)
    {
        if (*po == 'B')
        {
            if (stk.count > 0)
            {
                pop(&stk);
            }
        }
        else
        {
            push(&stk, *po);
        }
    }

    for (int i = 0; i < stk.count; i++)
    {
        printf("%c", stk.data[SIZE - 1 - i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1636
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>

using namespace std;

bool triangle(int a, int b, int c) {
    bool first = (a < (b + c));
    bool second = (b < (c + a));
    bool third = (c < (a + b));
    return first & second & third;
}

int main() {
    int n;
    vector<int> l;
    cin >> n;
    for (size_t i = 0; i < (size_t)n; ++i) {
        int tmp;
        cin >> tmp;
        l.push_back(tmp);
    }
    sort(l.begin(), l.end());
    int ret = 0;
    for (size_t i = 0; i < (size_t)(n-2); ++i) {
        for (size_t j = i + 1; j < (size_t)(n-1); ++j) {
            for (size_t k = j + 1; k < (size_t)(n); ++k) {
                if (!triangle(l[i], l[j], l[k])) {
                    break;
                }
                ret++;
            }
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for(ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
template<typename T> void print(const T &x){ cout << x << endl; }
template<typename T> void print(const vector<T> &x){ rep(i, SZ(x)){ cout << x[i] << " \n"[i+1==SZ(x)]; } cout << flush; }
template<typename T> void print(const vector<T> &x, ll s, ll n){ repr(i, s, n){ cout << x[i] << " \n"[i+1==n]; } cout << flush; }
template<typename T> void printv(const vector<T> &x){ rep(i, SZ(x)){ cout << x[i] << "\n"; } cout << flush; }
template<typename T> void printv(const vector<T> &x, ll s, ll n){ repr(i, s, n){ cout << x[i] << "\n"; } cout << flush; }
template<typename T> void print(const vector<vector<T>> &x){ rep(i, SZ(x)){ rep(j, SZ(x[i])){ cout << x[i][j] << " \n"[j+1==SZ(x[i])]; } } cout << flush; }
template<typename T> void print(const vector<vector<T>> &x, ll s1, ll n1, ll s2, ll n2){ repr(i, s1, n1){ repr(j, s2, n2){ cout << x[i][j] << " \n"[j+1==n2]; } } cout << flush; }
template<typename T, size_t S> void print(const T (&x)[S], ll s = 0, ll n = S){ repr(i, s, n){ cout << x[i] << " \n"[i+1==n]; } cout << flush; }
template<typename T, size_t S> void printv(const T (&x)[S], ll s = 0, ll n = S){ repr(i, s, n){ cout << x[i] << "\n"; } cout << flush; }
template<typename T, size_t S1, size_t S2> void print(const T (&x)[S1][S2], ll s1 = 0, ll n1 = S1, ll s2 = 0, ll n2 = S2){ repr(i, s1, n1){ repr(j, s2, n2){ cout << x[i][j] << " \n"[j+1==n2]; } } cout << flush; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    string s;
    cin >> s;
    rep(i, SZ(s)){
        s[i] = (s[i]-'A'+n)%26+'A';
    }
    cout << s << endl;
    return 0;
}

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  cout << 24 - M + 24 << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <cmath>
#include <iostream>
#include <string>
#include <time.h>
#include <stdio.h>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int top, S[1000];

void push(int x)
{
    S[++top] = x;
}

int pop()
{
    top--;
    return S[top + 1];
}

int main()
{
    int a, b;
    top = 0;
    char s[100];
    while (scanf("%s", s) != EOF)
    {
        if (s[0] == '+')
        {
            a = pop();
            b = pop();
            push(a + b);
        }
        else if (s[0] == '-')
        {
            a = pop();
            b = pop();
            push(b - a);
        }
        else if (s[0] == '*')
        {
            a = pop();
            b = pop();
            push(a * b);
        }
        else
        {
            push(atoi(s));
        }
    }

    cout << pop() << endl;
    return 0;
}



Measured memory_bytes: 3248
s = gets.chomp
c = {"a" => 0,"b" => 0,"c" => 0}
for i in 0..s.size-1
  c[s[i]] += 1
end
c = c.values
min = c.min
ans = true
c.each do |i|
  if i-min > 1
    ans = false
  end
end
if ans
  puts "YES"
else
  puts "NO"
end

Measured memory_bytes: 1916
using System;

namespace ITP1_8_B
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true)
            {
                string str = Console.ReadLine();
                int sum = 0;

                if (str == "0")
                    break;

                for (int i = 0; i < str.Length; i++ )
                {
                    sum += str[i] - '0';
                }

                Console.WriteLine("{0}", sum);
            }
        }
    }
}

Measured memory_bytes: 5616
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g PROGRAM -o OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>

#define ll unsigned long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;

typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;


inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

vector<string> split(char d,string s)
{
    stringstream ss(s);
    string t;
    vector<string> words;
    while(getline(ss,t,d))
    {
        words.pb(t);
    }

    return words;
}

int main(int argc, char *argv[])
{
    
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    ll t = modPow(10, n, MOD);
    ll u = ((2%MOD)*modPow(9, n, MOD))%MOD;
    ll v = modPow(8, n, MOD);

    ll ans = (t % MOD - u % MOD + v % MOD+MOD) % MOD;
    cout << ans;

    return 0;
}


Measured memory_bytes: 3664
import sys
import re
S = input()
if not ( 1 <= len(S) <= 10 ): sys.exit()
if not S.isupper: sys.exit()

result = 0
max = max(re.findall('[A|T|G|C]+', S),key=len) if re.findall('[A|T|G|C]+', S) else ''
if len(max) > 0:result = len(max)
print(result)

Measured memory_bytes: 9764
#include <stdio.h>

int main() {
	int n;
	scanf("%d", &n);
	char arr[n];
	scanf("%s", arr);
	if(n % 2 != 0) {
		printf("No\n");
	}
	else if (n % 2 == 0){
		int flag = 1;
		for(int i = 0; i < n / 2; i++) {
			if(arr[i] != arr[(n / 2) + i]) {
				flag = 0;
				break;
			}
		}
		if(flag == 0) {
			printf("No\n");
		}
		else {
			printf("Yes\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define MOD 1000000007
#define MP make_pair
#define EPS (1e-10)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#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() {
	string s; cin >> s;
	char c1 = *s.begin(), c2 = *s.rbegin();
	if (s.size() & 1)puts(c1 == c2 ? "Second" : "First");
	else puts(c1 == c2 ? "First" : "Second");
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

char f(char b) {
    if (b == 'A') {
        return 'T';
    }
    if (b == 'T') {
        return 'A';
    }
    if (b == 'C') {
        return 'G';
    }
    return 'C';
}

int main() {

    char b;
    cin >> b;

    char result = f(b);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool prime_number(ll x){
    for (ll i = 2; i*i <= x; i++)
    {
        if(x % i == 0) return false;
    }
        return true;
    
}
int main(){
    ll n, m; cin >> n;
    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        cin >> m;
        ans += prime_number(m);
    }
    cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  rep(i, n) {
    cin >> s[i] >> t[i];
  }
  string x;
  cin >> x;
  
  int ans = 0;
  bool sleeping = false;
  rep(i, n) {
    if (s[i] == x) {
      sleeping = true;
      continue;
    }
    if (sleeping) {
      ans += t[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
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;}

template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    //どれか一つ要素を決めて，その要素を含まない両端の区間のそれぞれの最大公約数を求める．
    //その二つの値の最大公約数が，最大公約数の最大値になる．(0,n-1番目の要素は例外処理が必要)
    int forgcd[n];forgcd[0]=a[0];
    for(int i=1;i<=n-1;i++)forgcd[i]=gcd(a[i],forgcd[i-1]);
    int backgcd[n];backgcd[n-1]=a[n-1];
    for(int i=n-2;i>=0;i--)backgcd[i]=gcd(a[i],backgcd[i+1]);
    int ans=0;
    rep(i,n){
        if(i!=0&&i!=n-1)chmax(ans,gcd(forgcd[i-1],backgcd[i+1]));
        else if(i==0)chmax(ans,backgcd[1]);
        else if(i==n-1)chmax(ans,forgcd[n-2]);
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 1408
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
using namespace std;

typedef complex<double> P;

#define x real()
#define y imag()

bool isIntersect(P p1,P p2,P p3,P p4){
	if((((p1.x - p2.x)*(p3.y - p1.y)+(p1.y - p2.y)*(p1.x - p3.x))*((p1.x - p2.x)*(p4.y - p1.y)+(p1.y - p2.y)*(p1.x - p4.x)))<0)
		return true;
	else
		return false;
}

int main(){
	
	double xa,ya,xb,yb,xc,yc,xd,yd;
	
	while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)){
		P a(xa,ya);
		P b(xb,yb);
		P c(xc,yc);
		P d(xd,yd);
		
		if(isIntersect(a,c,b,d)&&isIntersect(b,d,a,c))
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	

	
}

Measured memory_bytes: 1224
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        ans += x;
    }
    cout << ans/n << "\n";
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#define N1 50
using namespace std;
bool check[N1+1];
int main(){
  int N,K,m,b,R,p,q;
  vector<int> data[N1];
  cin >> N >> K;
  for(int i=0;i<K;i++){
    cin >> m;
    for(int j=0;j<m;j++){
      cin >> b;
      data[i].push_back(b);
    }
  }
  cin >> R;
  for(int i=0;i<R;i++){
    cin >> p >> q;
    for(int j=0;j<K;j++){
      int flag=0,flag1=0,len=data[j].size();
      for(int k=0;k<len;k++){
	if(p==data[j][k]) flag=1;
	if(q==data[j][k]) flag1=1;
      }
      if(flag&&flag1) check[p]=check[q]=true;
    }
  }
  int cnt=0;
  for(int  i=1;i<=N;i++){
    if(check[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1216
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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

ll a, b;

/*
ll oddsolve(ll a){ return (a+1)/2 %2; }
ll solve(ll a){
  if(a%2 == 1) return oddsolve(a);
  else return oddsolve(a+1)^(a+1);
}
*/

ll calc(ll val){
  ll ans = 0LL;
  
  if(val%4 == 0) ans = val;
  if(val%4 == 1) ans = 1;
  if(val%4 == 2) ans = val+1;
  if(val%4 == 3) ans = 0;

  return ans;
}

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

  cin >> a >> b;
  if(a == b) {
    cout << a << endl;
    return 0;
  }
  /*
  ll ans = solve(b);
  ans^=solve(a-1);
  cout << ans << endl;
  */

  ll ans = 0LL;
  /*
  REP(i, 600){
    ans ^= i;
    cerr << "i: " << i << " ans: "<<  ans << endl;    
  }
  */
  ans = calc(a-1);
  ans ^= calc(b);
  cout << ans << endl;

  
  
  return 0;
}


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

int main(){
    int N;
    cin>>N;
    vector<string> s(N);
    for(int i=0;i<N;i++) cin>>s[i];

    long long vari[5] = {};
    long long cnt[5] ={};
    for(int i=0;i<N;i++){
        if(s[i][0]=='M'){
            cnt[0]+=1;
        }
        if(s[i][0]=='A'){
            cnt[1]+=1;
        }
        if(s[i][0]=='R'){
            cnt[2]+=1;
        }
        if(s[i][0]=='C'){
            cnt[3]+=1;
        }
        if(s[i][0]=='H'){
            cnt[4]+=1;
        }
    }

    int R[10]= {0,0,0,0,0,0,1,1,1,2};
    int P[10]= {1,1,1,2,2,3,2,2,3,3};
    int Q[10]= {2,3,4,3,4,4,3,4,4,4};
    long long ans =0;

    for(int i=0;i<10;i++){
        ans +=cnt[R[i]]*cnt[P[i]]*cnt[Q[i]];
    }

    cout<<ans<<endl;
    return 0;

        return 0;


    
}

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

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

	nmod = N % 10;
	switch (nmod) {
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		printf("hon\n");
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		printf("pon\n");
		break;
	case 3:
		printf("bon\n");
	}
	
	fflush(stdout);
	return EXIT_SUCCESS;
}


Measured memory_bytes: 1648
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
using namespace std::chrono;
const int N = 1e5+4 , M=N,inf=(int)1e9;
const ll mod=1e9+7;
int fastAbs(int n) { return (n ^ (n >> 31)) - (n >> 31); }
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
map< pair<int,int> , int > mp;
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
void solve(){
   string s , t ;
   cin >> s >> t ;
   if(s==t){
        cout << "Yes";
        return ;
   }
   int n = s.size();
   int c = 0 ;
   while(c<=n+1){
        char temp = s[n-1];
        for( int i = n-1 ; i>0 ; i--){
                s[i] = s[i-1];
        }
        s[0] = temp ;
        if(s==t){
            cout << "Yes";
            return ;
        }
        c++;
   }
   cout << "No";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct node {
  int key;
  struct node *p , *r , *l;
} Node;

Node *root, *NIL;

Node * find(Node *u,int k) {
  while(u != NIL && k != u->key) {
    if( k < u->key) u = u->l;
    else u = u->r;
  }
  return u;
}
void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

  while( x != NIL) {
    y = x;
    if(z->key < x->key) {
      x = x->l;
    } else {
      x = x->r;
    }
  }
  z->p = y;
  if(y == NIL) {
    root = z;
  }
  else {
    if(z->key < y->key) {
     y->l = z;
   } else {
     y->r = z;
   }
  }
}

void inorder(Node *u) {
  if(u == NIL) return;
  inorder(u->l);
  printf(" %d", u->key);
  inorder(u->r);
}

void preorder(Node *u) {
  if(u == NIL) return;
  printf(" %d", u->key);
  preorder(u->l);
  preorder(u->r);
}

int main() {
  int n, i , x;
  char com[6];

  scanf("%d",&n);

  for(i = 0; i < n; i++) {
    scanf("%s\n", com);
    if(strcmp(com, "insert") == 0) {
      scanf("%d",&x);
      insert(x);
    } else if(strcmp(com, "print") == 0) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(strcmp(com,"find") == 0) {
      scanf("%d",&x);
      Node *t = find(root,x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    }
  }

  return 0;
}

Measured memory_bytes: 19368
n,m=map(int,input().split())
ax=set()
bx=set()
for i in range(m):
   a,b=map(int,input().split())
   if a==1:
      ax.add(b)
   if b==n:
      bx.add(a)
print("POSSIBLE" if len(ax&bx)!=0 else "IMPOSSIBLE")


Measured memory_bytes: 19024
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>

using int64 = long long;

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

    int N;
    std::cin >> N;

    long double ans = 0.0;
    for (int i = 0; i < N; i++) {
        long double x;
        std::string u;
        std::cin >> x >> u;

        if (u == "JPY") ans += x;
        else ans += x * 380000.0;
    }
    std::cout << std::fixed << std::setprecision(10) << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256