akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
	"sort"
)

type ByRune []rune

func (r ByRune) Len() int           { return len(r) }
func (r ByRune) Swap(i, j int)      { r[i], r[j] = r[j], r[i] }
func (r ByRune) Less(i, j int) bool { return r[i] < r[j] }

func StringToRuneSlice(s string) []rune {
	r := make([]rune, 0, 10)
	for _, runeValue := range s {
		r = append(r, runeValue)
	}
	return r
}

func SortStringByCharacter(s string) string {
	var r ByRune = StringToRuneSlice(s)
	sort.Sort(r)
	return string(r)
}

func count(ss []string) int64 {
	var cnt int64
	cnt = 1
	var ans int64
	sort.Strings(ss)
	n := len(ss)
	// fmt.Println(ss)
	for i := 0; i < n-1; i++ {
		s1 := ss[i]
		s2 := ss[i+1]
		if s1 == s2 {
			cnt++
		} else {
			ans += (cnt * (cnt - 1)) / 2
			// fmt.Println(ss[i], cnt, ans)
			cnt = 1
		}
	}
	if cnt > 1 {
		// fmt.Println(ss[n-1], cnt)
		ans += (cnt * (cnt - 1)) / 2
	}
	return ans
}

func main() {
	var n int
	fmt.Scan(&n)
	ss := make([]string, n)

	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		s = SortStringByCharacter(s)
		ss[i] = s
	}
	fmt.Println(count(ss))
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1e5 + 34;
const int INF = -1;

vector <int> graf[SIZE];
int topsort[SIZE];
int dp[SIZE];
vector <int> v;
int n, m, a, b;

    void input(){
        cin >> n >> m;
        for(int i = 0; i < m; i++){
            cin >> a >> b;
            graf[a].push_back(b);
            topsort[b]++;
        }
        for(int i = 0; i < SIZE; i++)
            dp[i] = INF;
    }

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    input();
    
    for(int i = 1; i <= n; i++)
        if(topsort[i] == 0)
            v.push_back(i);
    
    for(auto it : v)
        dp[it] = 0;
        
    while(!v.empty()){
        int akt = v.back();
        v.pop_back();
            for(auto it : graf[akt]){
                topsort[it]--;
                dp[it] = max(dp[it], dp[akt] + 1);
                    if(topsort[it] == 0)
                        v.push_back(it);
            }
    }

    int wynik = -1;

    for(int i = 1; i <= n; i++)
        if(dp[i] > wynik)
            wynik = dp[i];

    cout << wynik;    
    return 0;
}

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

int main(){
  int x,y;
  cin>>x>>y;
  int sum=0;
  for(int i=1;i<=3;i++){
    if(x==i){
      sum+=(4-i)*100000;
        }
    }

    for(int i=1;i<=3;i++){
      if(y==i){
        sum+=(4-i)*100000;
          }
      } 


      if(x==1 && y==1){
        sum+=400000;
      } 

      cout<<sum<<endl;
  
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n,m,l,i,j,k;
	int a[100][100]={0,};
	int b[100][100]={0,};
	long long c[100][100];

	scanf("%d %d %d",&n,&m,&l);

	for(j=0;j<n;j++){
		for(i=0;i<m;i++){
			scanf("%d",&a[i][j]);
		}
	}
	for(j=0;j<m;j++){
		for(i=0;i<l;i++){
			scanf("%d",&b[i][j]);
		}
	}
	for(k=0;k<n;k++){
		for(j=0;j<m;j++){
			for(i=0;i<l;i++){
				c[i][k]+=a[j][k]*b[i][j];
			}
		}
	}
	
	for(j=0;j<n;j++){
		for(i=0;i<l;i++){
			if(i!=0) printf(" ");
			printf("%lld",c[i][j]);
		}
		printf("\n");
	}

	return 0;	
}	

Measured memory_bytes: 768
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;

const int maxs = 100000000;

int dictionary[maxs];
int n;
string str;

int main(void) {
    cin >> n;
    while (n --) {
        cin >> str;
        int ok = 0;
        if (str[0] == 'i') {
            ok = 1;
        }
        cin >> str;
        int temp = 0;
        for (int i = 0; i < str.length(); i ++) {
            temp = temp * 4;
            if (str[i] == 'A') {
                temp += 1;
            }
            else if (str[i] == 'C') {
                temp += 2;
            }
            else if (str[i] == 'G') {
                temp += 3;
            }
            else {
                temp += 4;
            }
        }
        if (ok) {
            dictionary[temp] = 1;
        }
        else {
            if (dictionary[temp]) cout << "yes" << endl;
            else cout << "no" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 8588
#include<bits/stdc++.h>
using namespace std;
long long h,w;
int main()
{
	cin>>h>>w;
	if (h==1||w==1)
	{
		cout<<1;
		return 0;
	}
	if ((h*w)%2==0) cout<<h*w/2;
	else cout<<(h*w+1)/2;
	return 0;
}

Measured memory_bytes: 256
/*input
13 1 4 3000
*/

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <math.h>
#include <iomanip>
#include <utility>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

ll MOD = 1000000007;
const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define inv(a)      powr((a), (MOD - 2))
#define all(c)      (c).begin(),(c).end()
#define rep(i,a,b)  for(ll i = (a); i < (b); i ++)
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template<typename T> void toInt(string s, T &a) { istringstream(s) >> a; }
ll gcd(ll a, ll b) { ll t; while(a) { t = a; a = b%a; b = t; } return b; }
ll sub(ll a, ll b) { a -= b; a = (a + MOD) % MOD; return a; }
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll add(ll a, ll b) { a += b; a %= MOD; return a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/*********************************START**********************************/
const int N = 100005;

int main()
{
  ifalse;
  int r, g, b, n;
  cin >> r >> g >> b >> n;

  int ans = 0;
  for(int i = 0; i <= n; i ++) {
    for(int j = 0; j <= n; j ++) {
      int d = i * r + j * g;
      int c = (n - d) / b;
      if(c >= 0 and d + c * b == n) {
        ans ++;
      }
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
S = str(input())
ans = 0
count = 0
out = ''
for i in range(len(S)):
  if S[i]=='A' or S[i]=='C' or S[i]=='G' or S[i]=='T':
    out += '1'
  else:
    out += '0'
out += '$'
for i in range(len(S)):
  if out[i]=='1':
    count += 1
    if out[i+1]!='1' and count>=ans:
      ans = count
      count = 0
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

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

	vector<int> count(n + 1, 1), red(n + 1);
	red[1] = 1;
	int x, y;
	for (int i = 0; i < m; ++i) {
		cin >> x >> y;
		if (red[x]) {
			red[y] = 1;
		}

		--count[x];
		++count[y];

		if (count[x] == 0) {
			red[x] = 0;
		}
	}

	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (red[i]) {
			++ans;
		}
	}

	cout << ans << "\n";

	return 0;

}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
int a;
	cin >> a;
	ce(a+a*a+a*a*a)
    return 0;
}



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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);
const long long MOD = 1000000007;

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll x, y;
    ll p[200010];
    vector<ll > v;
    string s, t;

    cin >> s >> t;

    ll ans = 0;
    REP(i, s.length()){
        if (s[i] != t[i]){
            ans++;
        }
    }

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

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

int main() {
  int p[8], a[] = {4, 1, 4, 1, 2, 1, 2, 1};
  vector<int> v{3, 5, 1, 7, 4, 6, 2, 0};
  while (cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7]) {
    int maxs = 0;
    int idx = 0;

    for (auto i : v) {
      int cnt = 0;
      for (int j = 0; j < 8; ++j) {
        cnt += min(p[j], a[(i + j) % 8]);
      }

      if (maxs < cnt) {
        idx = i;
        maxs = cnt;
      }
    }

    for (int i = 0; i < 8; ++i) {
      cout << a[(i + idx) % 8] << (i + 1 == 8 ? "\n" : " ");
    }
  }
}

Measured memory_bytes: 2960
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int N;
	int[] A;
	Set<Integer>[] sets;
	int[] filter;

	Main(BufferedReader in) throws IOException {
		N = Integer.parseInt(in.readLine());
		String[] tokens = in.readLine().split(" ");
		A = new int[N];
		for (int i = 0; i < N; ++i) {
			A[i] = Integer.parseInt(tokens[i]);
		}
		Arrays.sort(A);
		filter = new int[A[N - 1] + 1];
		Arrays.fill(filter, -1);
		filter[1] = 1;
		for (int step = 2; step <= A[N - 1]; ++step) {
			for (int i = step; i <= A[N - 1]; i += step) {
				if (filter[i] < 0) {
					filter[i] = step;
				}
			}
		}
		sets = new Set[N];
		for (int i = 0; i < N; ++i) {
			sets[i] = getYakusuu(A[i]);
		}
	}

	void show() {
		for (int i = 0; i < N; ++i) {
			System.out.print(i + ": ");
			for (Integer val : sets[i]) {
				System.out.print(val + " ");
			}
			System.out.println("");
		}
	}

	Set<Integer> getYakusuu(int val) {
		Set<Integer> result = new HashSet<>();
		if (val == 1) {
			return result;
		}
		while (filter[val] != val) {
			result.add(filter[val]);
			val = val / filter[val];
		}
		result.add(val);
		return result;
	}

	int gcd(int large, int small) {
		if (large < small) {
			return gcd(small, large);
		}
		if (large % small == 0) {
			return small;
		} else {
			return gcd(small, large % small);
		}
	}

	boolean isSetwise() {
		int gcd = gcd(A[0], A[1]);
		for (int i = 2; i < N; ++i) {
			gcd = gcd(gcd, A[i]);
		}
		if (gcd == 1) {
			return true;
		} else {
			return false;
		}
	}

	boolean isPairwise() {
		int count = 0;
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < N; ++i) {
			count += sets[i].size();
			list.addAll(sets[i]);
		}
		if ((long) count == list.stream().distinct().count()) {
			return true;
		} else {
			return false;
		}
	}

	void calc() {
		if (isSetwise()) {
			if (isPairwise()) {
				System.out.println("pairwise coprime");
			} else {
				System.out.println("setwise coprime");
			}
		} else {
			System.out.println("not coprime");
		}
	}

	void showResult() {
		// show();
	}
}

Measured memory_bytes: 424720
s = gets.split("").map(&:to_s)
if s[0] == s[2]
  if s[1] == "R"
    if s[0] == "R"
      puts 3
    else
      puts 1
    end
  else
    if s[0] == "R"
      puts 1
    else
      puts 0
    end
  end
else
  puts s.count("R")
end


Measured memory_bytes: 14396
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int a;
	int seki[20] = {1};
	int l;

	cin >> a;

	for (int i = 1; i <= a; i++) {
		for (int j = 0; j < 20; j++) {
			seki[j] *= i;
		}

		for (int j = 0; j < 20; j++) {
			if (seki[j] >= 10) {
				seki[j+1] += seki[j] / 10;
				seki[j] = seki[j] % 10;
			}
		}
	}

	for (int i = 19; i >= 0; i--) {
		if(seki[i] != 0) {
			l = i;
			break;
		}
	}

	for (int k = l; k >= 0; k--) {
		cout << seki[k];
	}

	cout << endl;

	return 0;
}

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

int main()
{
    int k, a, b;
    cin >> k >> a >> b;
    for(int i = a; i <= b; i++)
    {
        if(i%k==0) {cout << "OK" << endl;return 0;}
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3596
town = [0]*4
for i in range(3):
    a, b = map(int, input().split())
    town[a-1] += 1
    town[b-1] += 1

even = 0
for i in range(4):
    if town[i]%2 == 0:
        even += 1

if even == 2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9068
#include <stdio.h>

int n,m;
int k[30];
int a[30][30];

int main()
{
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&k[i]);
        for(int j=0;j<k[i];j++)
        scanf("%d",&a[i][j]);
    }

    int memo[31]={};
    for(int i=0;i<n;i++)
        for(int j=0;j<k[i];j++)
            memo[a[i][j]]++;
    int ans=0;
    for(int i=1;i<31;i++) 
        if(memo[i]==n) ans++;
    printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define rep(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define irep(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define rrep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

const int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    cout << "ABC" << n << endl;
    return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

int n, a, b;

int read() {
  if (scanf("%d%d%d", &n, &a, &b) < 3) {
    return false;
  }
  return true;
}

void solve() {
  if ((b - a - 1) & 1) {
    printf("Alice\n");
  } else {
    printf("Borys\n");
  }
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 768
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

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

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

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


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

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

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

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class CRally {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n;
        in >> n;
        vi X(n);
        in >> X;
        int sum = accumulate(all(X), 0), p = (int) round((double) sum / n), res = 0;
        trav(x, X) {
            int d = x - p;
            res += d * d;
        }
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    CRally solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<string> ss(n); cin >> ss;
    int ans = 0;
    for(int i = 0; i < n; i++){
        bool ok = true;
        for(int j = 0; j < n && ok; j++){
            int y = j, x = (i + j) % n;
            for(int k = 0; k < n && ok; k++){
                ok &= ss[(y + k) % n][x] == ss[y][(x + k) % n];
                // ok &= ss[(y + k) % n][(x - k + n) % n] == ss[(y - k + n) % n][(x + k) % n];
            }
        }
        ans += ok;
    }
    cout << ans * n << '\n';
}


Measured memory_bytes: 384
using System;
using System.Linq;

class E
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var z = Read();
		int h = z[0], w = z[1], m = z[2];
		var ps = new int[m].Select(_ => Read()).Select(v => (i: v[0], j: v[1])).ToArray();

		var tate = new int[h + 1];
		var yoko = new int[w + 1];

		foreach (var (i, j) in ps)
		{
			tate[i]++;
			yoko[j]++;
		}

		var Mi = tate.Max();
		var Mj = yoko.Max();
		var mis = Enumerable.Range(0, h + 1).Where(i => tate[i] == Mi).ToHashSet();
		var mjs = Enumerable.Range(0, w + 1).Where(j => yoko[j] == Mj).ToHashSet();

		var r = Mi + Mj;
		if (ps.Count(p => mis.Contains(p.i) && mjs.Contains(p.j)) == mis.Count * mjs.Count) r--;
		Console.WriteLine(r);
	}
}


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

int main() {
	string s;
	cin >> s;
	cout << (s[0] - '0') + 9 * (s.size() - 1) - (s.substr(1, s.size() - 1) != string(s.size() - 1, '9')) << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int N;
const LL MOD = 998244353;
LL mpow(LL a, LL x) {
	if (x == 0)return 1;
	LL h = mpow(a, x / 2);
	h *= h;
	h %= MOD;
	if (x % 2) {
		h *= a;
		h %= MOD;
	}
	return h;
}

int main() {
	cin >> N;
	map<int, int>mp;
	int big = 0;
	for (int i = 0; i < N; ++i) {
		int d;
		cin >> d;
		mp[d]++;
		if (i == 0 && d != 0) {
			cout << 0 << endl;
			return 0;
		}
		if (i != 0 && d == 0) {
			cout << 0 << endl;
			return 0;
		}
		big = max(big, d);
	}
	LL ans = 1;
	for (int x = 1; x <= big; ++x) {
		ans *= mpow(mp[x - 1], mp[x]);
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
import java.io.*;
import java.util.*;
import java.text.*;
public class Main {
    public static void main(String args[]) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
        DecimalFormat df = new DecimalFormat("0.000000000");
        double pi = 3.14159;
        int r = in.nextInt();
        out.println(df.format(pi*2*r));
        in.close();out.flush();out.close();
    }
}

Measured memory_bytes: 36084
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner s = new Scanner(System.in);
        
        int N = s.nextInt();
        int K = s.nextInt();
        String S = s.next();
        
        String a = S.substring(0, K - 1);
        String b = S.substring(K - 1, K);
        String c = S.substring(K, N);
        
        String res = a + b.toLowerCase() + c;
        
        System.out.println(res);


    }
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> cnt(n+1, 0);
  for(int i=1; i<=100; i++){
    for(int j=1; j<=100; j++){
      for(int k=1; k<=100; k++){
        int val = i*i+j*j+k*k+i*j+j*k+i*k;
        if(val <= n){
          cnt[val]++;
        }
      }
    }
  }
  for(int i=1; i<=n; i++){
    cout << cnt[i] << "\n";
  }
  return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k,n;
  cin >>k >>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    int b;
    cin >>b;
    a.at(i)=b;
  }
  sort(a.begin(),a.end());
  vector<int>b(n-1);
  for(int i=0;i<n-1;i++){
    b.at(i) =a.at(i+1)-a.at(i);
  }
  sort(b.begin(),b.end());
  int ans=0;
  for(int i=0;i<n-(k-1)-1;i++){
    ans +=b.at(i);
  }
  cout <<ans;
}

Measured memory_bytes: 1024
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
sum = 0

for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            sum += (k+1)*k//2 if j > i else k*(k-1)//2

print(sum % (10**9+7))


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

long long A, B, C;

int main() {
	scanf("%lld%lld%lld", &A, &B, &C);
	int ans = 0;
	while (1) {
		if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
			printf("%d\n", ans);
			return 0;
		}
		if (ans > 1000000) break;
		long long na = (B + C) / 2;
		long long nb = (A + C) / 2;
		long long nc = (A + B) / 2;
		A = na;
		B = nb;
		C = nc;
		ans++;
	}
	printf("-1\n");
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#include <random>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#include "./Lib/Timer.h"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================


signed main() {
	ll n;
	cin >> n;
	cout << n * n << endl;

}


Measured memory_bytes: 256
x = int(input())
if x == 1:
  print(1)
elif x==2:
  print(1)
else:
  candidates = []
  for i in range(x):
    for j in range(2,x):
      t = i**j
      if x>=t:
        candidates.append(t)
      else:
        break
  print(max(candidates))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

ll gcd(ll n,ll m){
    if(n%m==0) return m;
    else return gcd(m,n%m);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,B;
    cin >> A >> B;
    if(A>B) swap(A,B);
    for(ll i=B;;i+=B) if(i%A==0){
        cout << i << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

li dp[301][301][301];

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

    string s;
    cin >> s;
    
    li k;
    cin >> k;
    
    const li n = s.size();
    for (int len = 0; len <= n; ++len) {
        for (int l = 0; l <= n; ++l) {
            const int r = l + len;
            if (r > n) {
                continue;
            }
            for (int kk = 0; kk <= k; ++kk) {
                if (kk > 0) {
                    dp[l][r][kk] = max(dp[l][r][kk], dp[l][r][kk - 1]);
                }
                if (len > 0) {
                    dp[l][r][kk] = max(dp[l][r][kk], dp[l + 1][r][kk]);
                    dp[l][r][kk] = max(dp[l][r][kk], dp[l][r - 1][kk]);
                }
                if (len == 1) {
                    dp[l][r][kk] = max(dp[l][r][kk], 1LL);
                }
                if (len >= 2) {
                    if (kk > 0) {
                        dp[l][r][kk] = max(dp[l][r][kk], dp[l + 1][r - 1][kk - 1] + 2);
                    }
                    if (s[l] == s[r - 1]) {
                        dp[l][r][kk] = max(dp[l][r][kk], dp[l + 1][r - 1][kk] + 2);
                    }
                }
            }
        }
    }    
    
    cout << dp[0][n][k] << endl;
    return 0;
}

Measured memory_bytes: 213248
#include <stdio.h>
#include <math.h>
double byou(double v);
double kyori(double t);
int kaisu(double y);
int main(){
    double input,y,t;
    int kai;
    while(scanf("%lf",&input)!=EOF){
        t=byou(input);
        y=kyori(t);
        kai=kaisu(y);
        printf("%d\n",kai);
    }
    
    
    return 0;
}
double byou(double v){
    double result;
    result=v/9.8;
    return result;
}

double kyori(double t){
    double result;
    result=(t*t)*4.9;
    return result;
}
int kaisu(double y){
    int i;
    for(i=1;(i*5-5)<y;i++){
        if(i*5-5>y) break;
    }
    return i;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int N,X;cin>>N>>X;
  VECINT donuts(N);
  REP(i,N) cin>>donuts[i];
  X -= accumulate(ALL(donuts),0);
  sort(ALL(donuts));
  int ans = N;
  while (X>=donuts[0]) {
    X -= donuts[0];
    ans++;
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;
/*  gcd(a,b)
    入力：整数 a, b
    出力：aとbの最大公約数
    計算量：O(log(a)) (a>=bのとき)
*/
long long gcd(long long a, long long b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}
using D = double;
const D PI = std::acos(-1);
int main() {
    string s;
    cin >> s;
    string ans;
    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] == '1' || s[i] == '0') {
            ans.push_back(s[i]);
        } else {
            if (!ans.empty()) {
                ans.pop_back();
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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

const ll mod=1e9+7;

int main(){
    ll n;
    cin >> n;
    map<ll,ll> m;
    rep(i,n){
        ll a;
        cin >> a;
        m[a]++;
    }
    ll ans=0;
    for(auto x:m){
        if(x.se>=x.fi){
            ans+=(x.se-x.fi);
        }
        else{
            ans+=x.se;
        }
    }
    cout << ans << endl;
}

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

int main()
{
	string s;
	cin >> s;
	bool f = 0, ss = 0;
	int num1 = 0, num2 = 0;
	num1 = (s[0]-'0') * 10 + (s[1] - '0');
	num2 = (s[2] - '0') * 10 + (s[3] - '0');

	if (num1 >= 1 && num1 <= 12) {
		f = 1;
	}
	if (num2 >= 1 && num2 <= 12) {
		ss = 1;
	}

	if (f == 1 && ss == 1) {
		cout << "AMBIGUOUS" << endl;
	}
	else if (f == 0 && ss == 0) {
		cout << "NA" << endl;
	}
	else if(f == 1 && ss == 0){
		cout << "MMYY" << endl;
	}
	else {
		cout << "YYMM" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#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; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll t,n,i,j,k,c,f;
	cin>>n;
	ll ans=((power(10,n)-2*power(9,n)+power(8,n)+2*MOD))%MOD;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
vector<int> G[9];
int n;
int cnt=0;
void dfs(int now,vector<int> visit){
    visit[now] = true;
    bool end=true;
    rep(i,n){
        if(!visit[i]){
            end = false;
        }
    }
    if(end){
        cnt++;
        return ;
    }
    for(int i=0;i<G[now].size();i++){
        int child = G[now][i];
        if(!visit[child]){
            dfs(child,visit);
        }
    }
    
}
int main(){
    int m;
    cin>>n>>m;
    vector<int> visited(n,false);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    /*
    for(int i=0;i<n;i++){
        cout << "G[" <<i <<"]={";
        for(unsigned int j=0;j<G[i].size();j++){
            cout<<G[i][j]<<" ";
        }
        cout<<"}"<<endl;
    }
    */
    dfs(0,visited);
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/

// struct d{ll a,b;};
// bool operator<(const d &l, const d &r){
// 	if(l.a<r.a)return true;
// 	if(l.a==r.a && l.b>r.b)return true;
// 	return false;
// }
// d p[200010];

ll n,a[200010],b[200010];

int main(void){
	cin>>n;
	rep(i,n){
		cin>>a[i]>>b[i];
	}
	sort(a,a+n);
	sort(b,b+n);
	if(n%2==1){
		cout<<b[n/2]-a[n/2]+1<<endl;
	}else{
		cout<<(b[n/2]+b[n/2-1])-(a[n/2]+a[n/2-1])+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 6708
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll n,k;
ll a[2*MAX];
map<ll,ll>dp[2*MAX];
ll pre[2*MAX];

ll solve(ll i,ll j){
  ll idx = n-i+1;
  // cout<<i<<' '<<j<<'\n';
  if(!j)return 0;
  if(dp[i].count(j))return dp[i][j];
  ll ans = 0;
  if(i%2 == 0){
    ans = max(a[idx] + solve(i-2,j-1),solve(i-1,j));
  }
  else{
    if(j>i/2){
      ans = pre[i];
    } 
    else{
      ans = max({a[idx]+solve(i-2,j-1),solve(i-1,j),solve(i-2,j)});
    }
  }
  return dp[i][j] = ans;
}

int main(){FAST;
cin>>n;
for(ll i=1;i<=n;++i)cin>>a[i];
  pre[1] = a[n];
for(ll i=n-2;i>=1;i-=2){
  pre[n-i+1] = pre[n-i-1] + a[i];
}  
cout<<solve(n,n/2);
return 0;
}

/*
 WA? check edge cases, N=1,M=1 etc. Read code fully once and check all variables.
 Read the question again and see what you might have missed.
 Consider changing your solution or find more cases.
 */


Measured memory_bytes: 45780
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


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

  sort(ALL(a),greater<int>());
  ll A=0;
  ll B=0;
  bool c=1;
  rep(i,n-1){
    if(a[i]==a[i+1]&&c){
      A=a[i];
      i++;c=0;
    }
    else if(a[i]==a[i+1]&&!(c)){
      B=a[i];
      break;
    }
  }
  cout<<A*B<<endl;

  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
  int N,i,odd=0;
  long int A[100000];

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
    if(A[i]%2) odd++;
  }
  if(odd%2) printf("NO\n");
  else printf("YES\n");

  return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x;
  string s;
  x=0;
  cin >> n >> s;
  for(int i=0;i<n-2;i++){
    if(s.at(i)=='A'&&s.at(i+1)=='B'&&s.at(i+2)=='C'){
      x+=1;
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 256
a, b, c, d = gets.chomp.split(" ").map(&:to_i)
res_a = (a-1)/c + (a-1)/d - (a-1)/(c.lcm(d))
res_b = b/c + b/d - b/(c.lcm(d))
puts (b-res_b) - (a-1-res_a)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  int B;
  int C;
  int D;
  cin >> A >> B >> C >> D;
  if ((A + B) > (C + D)){
    cout << "Left" << endl;
  }
  else if ((A + B) == (C + D)){
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[10]:


N = int(input())
W = []
for _ in range(N):
    W.append(input())


# In[11]:


if len(set(W)) != N:
    print("No")
else:
    for i,word in enumerate(W):
        if i > 0:
            if W[i-1][-1] != word[0]:
                print("No")
                break
    else:
        print("Yes")


# In[ ]:






Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define F first
#define S second
#include<unordered_map>
using namespace std;
typedef long long ll;
const ll inf=(1ll<<61);
const ll mod=1e9+7;
const int MX=3e5+9;
int n;
string s,la;
unordered_map<string,int>d;
int main(){
    cin>>n;
    cout<<0<<endl;
    cout.flush();
    cin>>s;
    la=s;
    int last=0;
    if(s=="Vacant")return 0;
    if(s=="Male")d["Female"]=1;
    else d["Male"]=1;
    int l=1,r=n-1,mid;
    while(l<=r){
        mid=(l+r)/2;
        cout<<mid<<endl;
        cout.flush();
        cin>>s;
        if(s=="Vacant")return 0;
        if(mid%2==d[s]){
            l=mid+1;
        }
        else{
            r=mid-1;
        }
    }
}



Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
const int maxn=1000100;
int n,k,a[maxn],lv[maxn],rv[maxn],suml[maxn],sumr[maxn],nxt[maxn],pre[maxn],tot,flag[maxn];
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > Q;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",a+i),Q.push(make_pair(a[i],i));
	for(int i=1;i<=n;i++) nxt[i]=i+1,pre[i]=i-1,lv[i]=rv[i]=1;tot=n;nxt[n]=0;
	long long ans=0;
	while(Q.size())
	{
		int v=Q.top().second;Q.pop();
		if(flag[v]) continue;
		int l=v,r=v,cnt=1,lst=0;
		while(a[pre[l]]==a[v]) l=pre[l],cnt++;
		while(a[nxt[r]]==a[r]) r=nxt[r],cnt++;
		for(int i=l,j=1;;i=nxt[i],j++)
		{
			suml[j]=suml[j-1]+lv[i];sumr[j]=sumr[j-1]+rv[i];
			if(i<=n) lst=j;
			if(lst&&j>=k) ans+=1ll*suml[min(j-k+1,lst)]*rv[i];
			flag[i]=1;if(i==r) break;
		}
		if(cnt<k) {nxt[pre[l]]=pre[nxt[r]]=0;continue;}
		int stpos=tot+1;
		for(int i=1;i<=cnt/k;i++)
		{
			rv[++tot]=sumr[min(cnt,(i+1)*k-1)]-sumr[i*k-1];a[tot]=a[l]+1;
			lv[tot]=suml[cnt-(cnt/k-i+1)*k+1]-suml[max(0,cnt-(cnt/k-i+2)*k+1)];
		}
		nxt[pre[l]]=stpos;pre[stpos]=pre[l];
		pre[nxt[r]]=tot;nxt[tot]=nxt[r];
		for(int i=stpos;i<tot;i++) nxt[i]=i+1,pre[i+1]=i;
		Q.push(make_pair(a[stpos],stpos));
	}
	printf("%lld\n",ans+n);
}

Measured memory_bytes: 14088
#include <iostream>

using namespace std;


int main()
{
    int h, w;
    cin >> h >> w;
    for(int i = 0; i < w + 2; i++)
    {
        cout << "#";
    }
    cout << endl;

    for(int i = 0; i < h; i++ )
    {
        cout << "#";
        string s;
        cin >> s;
        cout << s;
        cout << "#" << endl;
    }
    for(int i = 0; i < w + 2; i++)
    {
        cout << "#";
    }
    cout << endl;
    
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
from fractions import gcd
g=0
for i in a:
    g=gcd(g,i)
if k>max(a):
    print("IMPOSSIBLE")
else:
    for i in a:
        if k%g==i%g:
            print("POSSIBLE")
            break
    else:
        print("IMPOSSIBLE")

Measured memory_bytes: 14224
#include<iostream>
#include<algorithm>
#include<climits>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
string s;
int main(){
  scan(s);
  char res[100010];
  rep(i,s.size()){
    if(i%2==0){
      res[i/2]=s[i];
    }
  }
  rep(i,(s.size()+1)/2){
    cout<<res[i];
  }
  cout<<"\n";
    
  
  return 0;
}


Measured memory_bytes: 540
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
// #define ll long long
typedef long long ll;
typedef pair<int, int> P;



int main(int argc, const char * argv[]) {

  int a, b, c;
  cin >> a >> b >> c;
  // vector<int> w(n);
  int diff = a-b;
  if (diff >= c){
    cout << 0 << endl;
  }else{
    cout << c-diff << endl;
  }


  return 0;
}

Measured memory_bytes: 888