akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 1000000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n;cin>>n;
    V<ll>use;
    map<ll,ll>m;ll ans=0;
    for(ll i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0)ans+=i;
    }
    cout<<ans<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------




































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

int main() {
  int N; cin >> N;
  long A[N]; for (int i =0; i<N; i++) cin >> A[i];
  
  long ans =0;
  for (int i =1; i<N; i++) {
    if (A[i] - A[i-1] <0) {
      ans += A[i-1] - A[i];
      A[i] = A[i-1];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5152
X, Y, A, B, C = map(int, input().split())
*P, = map(int, input().split())
*Q, = map(int, input().split())
*R, = map(int, input().split())
P, Q = sorted(P, reverse=True), sorted(Q, reverse=True)
P, Q = P[:X], Q[:Y]
ans = sum(sorted(P + Q + R, reverse=True)[:X + Y])
print(ans)

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

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define PII pair<int, int>
#define mp make_pair
#define x first
#define y second

#define LL long long
#define Ldouble long double

using namespace std;

int n;

int query(int p){
  printf("%d\n", p);
  fflush(stdout);
  char str[10];
  scanf("\n%s", str);
  if(!strcmp(str, "Vacant")) exit(0);
  else if(!strcmp(str, "Male")) return 0;
  else return 1;
}

int main(){
  scanf("%d", &n);
  int Q = query(0);
  int l = 0, lc = Q, r = n, rc = Q;
  while(r - l > 1){
    int mid = (l + r) >> 1;
    int MQ = query(mid);
    if(((mid - l) % 2) ^ lc ^ MQ){
      r = mid; rc = MQ;
    }
    else{
      l = mid; lc = MQ;
    }
  }
  return 0;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
int main(void) 
{
	int n, q, *S, *T, i, j, count = 0;
	scanf("%d", &n);
	S = new int[n];
	for (i = 0; i < n; i++)
		scanf("%d", &S[i]);
	scanf("%d", &q);
	for (i = 0; i < q; i++)
	{
		scanf("%d", &j);
		if (*(lower_bound(S, S + n, j)) == j)
			count++;
	}
	cout << count << endl;
}


Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(ALL(a),greater<ll>());
    ll ans=a[0];
    n-=2;
    int idx=1;
    while(n>0){
        ans+=a[idx];
        n--;
        if(n==0) break;
        ans+=a[idx];
        n--;
        idx++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 4776
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

int main(){
  int n; cin >> n;
  int p[n], ma = 0, sum = 0;
  REP(i, n){
    cin >> p[i];
    ma = max(ma, p[i]);
    sum += p[i];
  }

  cout << sum - ma/2 << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
from collections import Counter
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

S = input().rstrip()
T = input().rstrip()

cs = Counter(S).most_common()
ct = Counter(T).most_common()

N = len(cs)

vs, cs = zip(*cs)
vt, ct = zip(*ct)

#print(vs, cs, vt, ct)

for i,j in zip(cs, ct):
	if cs != ct:
		print('No')
		sys.exit()
print('Yes')

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

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

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

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int main() {
  
  string s;
  cin >> s;
  
  for ( int i = 97; i < 123; i++){
    int hantei = 0;
    for ( int j = 0; j < s.size(); j++){
      if ( s[j] == i ){
        hantei = 1;
        break;
      }
    }
    if ( hantei == 0 ){
      cout << char(i) << endl;
      return 0;
    }
  }
  
  cout << "None" << endl;
  return 0;

}

Measured memory_bytes: 512
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int N;
	string A,B,C;
	cin>>N>>A>>B>>C;
	int aco=0,bco=0,cco=0,ans=0;
	REP(i,N){
		if(A[i]==B[i] && B[i]!=C[i])cco++;
		else if(A[i]!=B[i] && B[i]==C[i])aco++;
		else if(A[i]==C[i] && B[i]!=C[i])bco++;
		else if(A[i]==B[i] && B[i]==C[i])continue;
		else ans+=2;
	}
	//ans+=max(aco,max(bco,cco));
	ans+=aco+cco+bco;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define lli long long int
# define pb push_back
# define loop(i,a,b) for(int i=a;i<b;i++)
# define loopl(i,a,b) for(lli i=a;i<b;i++)
# define MAXN 1000
# define INF 1000000000
# define mod 1000000007

using namespace std;

void sumod(lli n)
{
	lli k=n,ans=0;
	while(k!=0)
	{
		ans+=k%10;
		k/=10;
	}
	if(n%ans==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
int main()
{
  lli n;
  cin>>n;
  sumod(n);
} 

Measured memory_bytes: 256
n , m , q = map(int, input().split())
table = [[0]*n for i in range(n)]

for i in range(m):
    l , r = map(int, input().split())
    l-=1
    r-=1
    table[r][l]+=1

for i in range(n):
    for j in range(1,n):
        table[i][j]=table[i][j]+table[i][j-1]

for i in range(n):
    for j in range(1,n):
        table[j][i]=table[j][i]+table[j-1][i]

for i in range(q):
    l , r = map(int, input().split())
    l-=1
    r-=1
    if l!=0:
        ans=table[r][r]-table[r][l-1]
    else:
        ans=table[r][r]
    print(ans)


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

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

using namespace std;

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

	int ans=10000;
	rep(t,n-1) ans=min(ans,abs(accumulate(w,w+t+1,0)-accumulate(w+t+1,w+n,0)));
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
int main(void)
{
	int A, B,C;
	std::cin >> A >> B;
	C = A + B;
	if (C > 23)
	{
		C = C - 24;
		std::cout << C;
	}
	else
	{
		std::cout << C;
	}


	return 0;
}
	

		
	

Measured memory_bytes: 256
s = input()
ans = "YES"
while s != "":
    if s[len(s) - 5:] == "dream" or s[len(s) - 5:] == "erase":
        s = s[:len(s) - 5]
    elif s[len(s) - 6:] == "eraser":
        s = s[:len(s) - 6]
    elif s[len(s) - 7:] == "dreamer":
        s = s[:len(s) - 7]
    else:
        ans = "NO"
        break
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

vector<int> ro(200005);
vector<int> rorank(200005);
vector<int> tr(200005);

void init(int n) {
  for(int i=1; i<=n; i++) {
    ro.at(i) = i;
    rorank.at(i) = 0;
  }
}

int find(int x) {
  if (ro.at(x) == x) {
    return x;
  } else {
    return ro.at(x) = find(ro.at(x));
  }
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x==y) return;
  if (rorank.at(x) < rorank.at(y)) {
    ro.at(x) = y;
  } else {
    ro.at(y) = x;
    if (rorank.at(x) == rorank.at(y)) {
      rorank.at(x)++;
    }
  }
}

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

  int n, k, l; cin >> n >> k >> l;

  init(n);
  rep(i, k) {
    int p, q; cin >> p >> q;
    unite(p, q);
  }
  for(int i=1; i<=n; i++) {
    find(i);
  }
  tr = ro;
  init(n);
  rep(i, l) {
    int r, s; cin >> r >> s;
    unite(r, s);
  }
  for(int i=1; i<=n; i++) {
    find(i);
  }

  map<P, int> mp;
  for(int i=1; i<=n; i++) {
    mp[P(tr.at(i), ro.at(i))]++;
  }

  for(int i=1; i<=n; i++) {
    cout << mp[P(tr.at(i), ro.at(i))] << ' ';
  }
  cout << endl;
}

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

#include <iostream>
#define rep(i,a,b) for(i=a;i<=b;i++)
#define pb push_back
#define sort_incr(v) sort(v.begin(),v.end());
#define sort_decr(v) {sort(v.begin(),v.end()); reverse(v.begin(),v.end());}
#define take_input(v,n) for(ll i=0,temp;i<n;i++){cin>>temp;v.pb(temp);}
#define fastio {ios_base::sync_with_stdio(false);    cin.tie(NULL);}
#define ALL(v) v.begin(),v.end()

typedef long long ll;
using namespace std; 

int main() 
{

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r", stdin);
    freopen("output.txt","w", stdout);
    #endif

    ll n,d;
    cin>>n>>d;
    ll ans=0;
    for(int i=0;i<n;i++)
    {
    	ll a,b;
    	cin>>a>>b;

    	double di=sqrt(a*a + b*b);
    	if(di<=d)
    		ans++;


    }

    cout<<ans;

	return 0;
} 























Measured memory_bytes: 3576
#include <stdio.h>
int main(){
  int n,q,i,j,k;
  int a[2000]={0};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&q);
    for(j=2000-q;j>0;j--){
      if(a[j]){
        a[j+q] = 1;
      }
    }
    a[q] = 1;
  }
  scanf("%d",&k);
  for(i = 0; i < k; i++){
    scanf("%d", &q);
    if(a[q]){
      printf("yes\n");
    }
    else printf("no\n");
  }
   
  return 0;
}

Measured memory_bytes: 1768
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    k = I()
    l = 0
    for c in s:
        if c != '1':
            break
        l += 1
    if l >= k:
        return 1
    return s[l]



print(main())


Measured memory_bytes: 5456
#include<bits/stdc++.h>
using namespace std;
#define F(i,L,R) for(int i=L;i<R;i++)
#define FE(i,L,R) for(int i=L;i<=R;i++)
#define RF(i,l,r) for(int i=r;i>l;i--)
#define RFE(i,l,r) for(int i=r;i>=l;i--)
#define getI(i) scanf("%d",&i)
#define getII(i,j) scanf("%d%d",&i,&j)
#define getIII(i,j,k) scanf("%d%d%d",&i,&j,&k)
#define VgetI(i) int (i);scanf("%d",&(i));
#define VgetII(i,j) int (i),(j);scanf("%d%d",&(i),&(j));
#define VgetIII(i,j,k) int (i),(j),(k);scanf("%d",&(i),&(j),&(k));
#define EoF(n) int(n);while(~getI(n))
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(n) (n>0?n:(-n))
#define INF 2147483647
#define nINF -2147483648
int pow(int a,int b){
	int res=1;
	while(b--) res*=a;
	return res;
}
int main(){
	int a,b;
	while(~getII(a,b)){
		int ans,dig=0;
		if(b<=9) dig++;
		else if(b<=99) dig+=2;
		else dig+=3;
		ans=a*pow(10,dig)+b;
		printf("%s\n",(int)sqrt(ans)*(int)sqrt(ans)==ans?"Yes":"No");
	}
}


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

int main(){
	int n;
	cin >> n;
	if ((n + 3) % 10 == 0)cout << "Yes" << endl;
	else if ((n + 30) % 100 < 10)cout << "Yes" << endl;
	else if ((n + 300) % 1000 < 100)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3632
// abc131_a
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string S;
  cin >> S;
  if(S[0] == S[1] || S[1] == S[2] || S[2] == S[3]){
   cout << "Bad" << endl;
  }else{
    cout << "Good" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	D := ReadInt()
	_ = ReadInts(26)
	ss := make([][]int, D)
	for i := 0; i < D; i++ {
		ss[i] = ReadInts(26)
	}

	answers := []int{}

	last := make([]int, 26)
	for d := 1; d <= D; d++ {
		maxT, maxScore := -1, -1
		for i := 0; i < 26; i++ {
			s := ss[d-1][i]
			if s > maxScore {
				maxT, maxScore = i, s
			}
		}
		last[maxT] = d
		answers = append(answers, maxT)
	}

	for _, v := range answers {
		fmt.Println(v + 1)
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 2084
#include <iostream>
using namespace std;
#define REPLACE(x,y)    if(x > y)rep(x,y)

void rep(int& x, int& y){
    int temp;
    temp = x;
    x = y;
    y = temp;
}

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    
    REPLACE(a,b);
    REPLACE(a,c);
    REPLACE(b,c);
        
    cout << a << " " << b << " " << c << endl;
    
    return 0;
}

Measured memory_bytes: 1164
n = int(input())

v = list(map(int, input().split()))
c = list(map(int, input().split()))

def dfs(s, i=n - 1):
    if i < 0:
        return s
    return max(dfs(s + v[i] - c[i], i - 1), dfs(s, i - 1))

print(dfs(0))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};





int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  ll k;
  cin >> n >> k;
  int a,f;
  vector<ll> A,F;
  REP(i,n){
    cin >> a;
    A.push_back(a);
  }
  REP(i,n){
    cin >> f;
    F.push_back(f);
  }
  SORT(A);
  SORT(F);
  REV(F);
  ll left = -1;
  ll right = 1e+18 + 1;
  while (right - left > 1) {
  ll mid = left + (right - left) / 2;
  ll cost = 0;
  REP(i,n){
    cost += max((A[i] * F[i] - mid + (F[i] - 1 )) / F[i],(ll) 0);
    //dump(i);dump(cost);
  }
  if (k>=cost) right = mid; 
  else left = mid;
  //cout << (k>=cost) << mid << endl;
}
  cout <<  right << endl;
}


Measured memory_bytes: 4976
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <utility>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> d(N);
    REP(i,N) cin>>d[i];
    sort(d.begin(),d.end());
    cout << d[N/2] - d[N/2-1] << endl;
    return 0;
}

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

int gcd(int x,int y){
 	if(x < y){
    	swap(x,y);
    }
  	if(y == 0){
     	return x; 
    }
  	return gcd(x%y,y);
}

int main(){
	
  	int n;
  	cin >> n;
  	int a[n];
  	for(int i=0; i<n; ++i){
    	cin >> a[i];
    }
  	
  	int left[n]={0};
  	int right[n]={0};
  	
  	for(int i=0; i<n-1; ++i){
   		left[i+1] = gcd(left[i],a[i]);
    }
  
  	for(int i=n-1; i >= 1; --i){
    	right[i-1] = gcd(right[i],a[i]); 
    }
  
  	int ans = 1;
  
  	for(int i=0; i<n; i++){
    	ans = max(ans, gcd(left[i],right[i])); 
    }
  
  	cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
using vc = vector<char>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  long n,k,s;
  cin >> n >> k >> s;
  vector<long> a(n,1e9);
  if(s == 1e9){
    rep(i,n-k) a.at(i) = 1;
  }else{
    rep(i,k) a.at(i) = s;
  }
  rep(i,n) cout << a.at(i) << " ";
  cout << endl;
}

Measured memory_bytes: 2048
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 150, task C, 2020/05/04
//ms,
/*
精進！！！！
順列全探索。二問目。
*/

int main(void){
  int N;

  cin>>N;
  vector<int> P(N);
  vector<int> Q(N);
  vector<int> O(N);
  int a,b;


  for(int i=0;i<N;i++) cin >>P.at(i);
  for(int i=0;i<N;i++) cin >>Q.at(i);
  for(int i=0;i<N;i++) O.at(i)=i+1;

/*
  for(int i=0;i<N;i++) cout <<P.at(i);
  cout<<endl;
  for(int i=0;i<N;i++) cout <<Q.at(i);
  cout<<endl;
  for(int i=0;i<N;i++) cout <<O.at(i);
  cout<<endl;
*/

  int counter=0;
  do{/*
    for(int i=0;i<N;i++) cout <<O.at(i);
    cout<<endl;*/
    //cout <<(O==P) <<endl;
    if(equal(O.begin(),O.end(),P.begin())) {
      a=counter;
      //cout <<a<<endl;
    }
    if(equal(O.begin(),O.end(),Q.begin())) {
      b=counter;
      //cout <<b <<endl;
    }
    counter++;
  }while(next_permutation(O.begin(),O.end()));

  cout <<abs(a-b) <<endl;
  return 0;
}
/*
*/


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = Integer.parseInt(in.nextLine());
            String S = in.nextLine();
            int x = 0;
            int max = 0;
            for (int i = 0; i < N; i++) {
                if (S.charAt(i) == 'I') {
                    x++;
                } else {
                    x--;
                }
                max = Math.max(max, x);
            }
            System.out.println(max);
        }
    }
}


Measured memory_bytes: 9684
from math import ceil

n,k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)

def check(m):
    used = 0
    for i in range(n):
        b = ceil(a[i]-m/f[i])
        if b < 0:
            b = 0
        if a[i]-b < 0:
            return False
        used += b
        if used > k:
            return False
    return True

left = -1
right = max(a)*max(f)
while right-left > 1:
    mid = (right+left)//2
    if check(mid):
        right = mid
    else:
        left = mid
print(right)



Measured memory_bytes: 120524
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>

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

int main(){
  int d;
  cin >> d;
  if(d==25)cout << "Christmas" << endl;
  else if(d==24)cout << "Christmas Eve" << endl;
  else if(d==23)cout << "Christmas Eve Eve" << endl;
  else cout << "Christmas Eve Eve Eve" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n[]=new int[3],s=1,i,j,t;
		for(i=0;i<3;i++) n[i]=stdIn.nextInt();
		for(i=0;i<2;i++) {
			for(j=2;j>i;j--) {
				if(n[j-1]>n[j]) {
					t=n[j-1];
					n[j-1]=n[j];
					n[j]=t;
				}
			}
		}
		for(i=0;i<2;i++) if(n[i]!=n[i+1]) s++;
		System.out.print(s);
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;
int N, K;
char str[10];
char aim;

signed main(void) {
cin >> N;
rep(i,N){
    cin >> str[i] ;
//    cout << str[i] << i ;
}
cin >> K;
aim = str[K-1];
//cout << aim <<endl;
rep(i,N){
    if(str[i]!=aim){
        str[i] = '*';
    }
}
rep(i,N){
    cout << str[i];
}


    return 0;
}


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

using namespace std;

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

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

	sort(a.begin(), a.end());
	long long cumul = 0;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		// printf("%d: %d %d\n", i, a[i], cumul);
		if (a[i] <= 2 * cumul) {
			ans++;
		} else {
			ans = 1;
		}
		cumul += a[i];
	}


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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int x, y;
	cin >> x >> y;
	int count = 0;
	for (int i = 0; i < x; i++) {
		string str;
		cin >> str;
		for (int j = 0; j < y; j++) {
			count += str[j] == '#';
		}
	}
	cout << (count==x+y-1 ? "Possible" : "Impossible");
	return 0;
}

Measured memory_bytes: 3600
using System;
using System.Linq;
using System.Diagnostics;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var stream = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToList();

            long result = long.MaxValue;
            var X = stream.Sum();
            long x = 0;
            for (int i = 0; i < N - 1; i++)
            {
                x += stream[i];
                var abs = Math.Abs(X - 2 * x);
                result = Math.Min(result, abs);
            }
            Console.Write(result.ToString());
        }
    }
}

Measured memory_bytes: 32964
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define pb push_back
#define alt(v) v.begin(),v.end()
#define ll long long
int main()
{
    ll n,x;
    string s;
    cin>>n>>s;
    vector<ll>r,g,b;
    for(ll i=0;i<n;i++)
    {
        if(s[i]=='R')
        r.pb(i+1);
        if(s[i]=='G')
        g.pb(i+1);
        if(s[i]=='B')
        b.pb(i+1);
    }
    ll n33=b.size();
    ll n22=g.size();
    ll n11=r.size();
    ll ans=0;
    for(auto it:r)
    {
        for(auto it1:g)
        {
            if(it1<it)
            continue;
            ll n3=n33;
            x=(it1-it);
            auto p=lower_bound(alt(b),it1);
            if(p!=b.end())
            {
                n3-=(p-b.begin());
                p=lower_bound(alt(b),it1+x);
                if(*p==it1+x)
                n3--;
                ans+=max(n3,0LL);
            }
        }
        for(auto it1:b)
        {
            ll n3=n22;
            if(it1<it)
            continue;
            x=(it1-it);
            auto p=lower_bound(alt(g),it1);
            if(p!=g.end())
            {
                n3-=(p-g.begin());
                p=lower_bound(alt(g),it1+x);
                if(*p==it1+x)
                n3--;
                ans+=max(n3,0LL);
            }
        }
    }
    for(auto it:g)
    {
        for(auto it1:r)
        {
            if(it1<it)
            continue;
            ll n3=n33;
            x=(it1-it);
            auto p=lower_bound(alt(b),it1);
            if(p!=b.end())
            {
                n3-=(p-b.begin());
                p=lower_bound(alt(b),it1+x);
                if(*p==it1+x)
                n3--;
                ans+=max(n3,0LL);
            }
        }
        for(auto it1:b)
        {
            ll n3=n11;
            if(it1<it)
            continue;
            x=(it1-it);
            auto p=lower_bound(alt(r),it1);
            if(p!=r.end())
            {
                n3-=(p-r.begin());
                p=lower_bound(alt(r),it1+x);
                if(*p==it1+x)
                n3--;
                ans+=max(n3,0LL);
            }
        }
    }
    for(auto it:b)
    {
        for(auto it1:r)
        {
            if(it1<it)
            continue;
            ll n3=n22;
            x=(it1-it);
            auto p=lower_bound(alt(g),it1);
            if(p!=g.end())
            {
                n3-=(p-g.begin());
                p=lower_bound(alt(g),it1+x);
                if(*p==it1+x)
                n3--;
                ans+=max(n3,0LL);
            }
        }
        for(auto it1:g)
        {
            ll n3=n11;
            if(it1<it)
            continue;
            x=(it1-it);
            auto p=lower_bound(alt(r),it1);
            if(p!=r.end())
            {
                n3-=(p-r.begin());
                p=lower_bound(alt(r),it1+x);
                if(*p==it1+x)
                n3--;
                ans+=max(n3,0LL);
            }
        }
    }
    cout<<ans;

    
    
    return 0;
}

Measured memory_bytes: 3688
class Treap
  def initialize
    @root = nil
  end

  def add(x)
    if @root
      @root = @root.add(x)
    else
      @root = Node.new(x)
    end
  end

  def query(x)
    if @root
      @root.query(x)
    else
      0
    end
  end

  class Node
    def initialize(x)
      @value = x
      @priority = rand(0)
      @left_child = @right_child = nil
      @count = 1
    end

    def add(x)
      @count += 1
      if x <= @value
        if @left_child
          @left_child = @left_child.add(x)
        else
          @left_child = Node.new(x)
        end
        if @left_child.priority > @priority
          return rotate_right
        else
          return self
        end
      else
        if @right_child
          @right_child = @right_child.add(x)
        else
          @right_child = Node.new(x)
        end
        if @right_child.priority > @priority
          return rotate_left
        else
          return self
        end
      end
    end

    def rotate_right
      v = @left_child
      @left_child = v.right_child
      v.right_child = self
      update
      v.update
      return v
    end

    def rotate_left
      v = @right_child
      @right_child = v.left_child
      v.left_child = self
      update
      v.update
      return v
    end

    def update
      @count = (@left_child ? @left_child.count : 0) + 1 + (@right_child ? @right_child.count : 0)
    end

    def query(x)
      if x <= @value
        if @left_child
          return @left_child.query(x)
        else
          return 0
        end
      else
        if @right_child
          return (@left_child ? @left_child.count : 0) + 1 + @right_child.query(x)
        else
          return @count
        end
      end
    end

    attr_accessor :priority, :left_child, :right_child, :count, :max
  end
end

n = gets.to_i
plus_tree = Treap.new
minus_tree = Treap.new
timeline = []
ranges = []
n.times do
  l, r = gets.split.map(&:to_i)
  ranges << [l, r]
  plus_tree.add(l)
  minus_tree.add(r)
  timeline << [l, +1]
  timeline << [r, -1]
end

policy1 = ranges.map {|l, r| plus_tree.query(r) - minus_tree.query(l + 1) }.max

timeline.sort!
policy2 = 0
k = 0
until timeline.empty?
  t = timeline[0][0]
  while !timeline.empty? && timeline[0][0] == t
    _, diff = timeline.shift
    k += diff
  end
  policy2 = k if k > policy2
end

puts "#{policy1} #{policy2}"


Measured memory_bytes: 87132
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll  long long
#define endl '\n'
#define pi 3.14159265
int32_t main()
{           
    IOS;   
    ll n;
    cin>>n;
    vector<string> v(n);
    for(ll i=0;i<n;i++)
        cin>>v[i];
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<v[i].length()-1;j++)
            ans+=((v[i][j]=='A')&&(v[i][j+1])=='B');
    }
    ll a=0;
    ll b=0;
    ll both=0;
    for(ll i=0;i<n;i++)
    {
        if(v[i][0]=='B')
            b++;
        if(v[i][v[i].length()-1]=='A')
            a++;
        if((v[i][0]=='B')&&(v[i][v[i].length()-1]=='A'))
            both++;
    }
    if(both>0)
    ans+=(both-1);
    a-=both;
    b-=both;
    if(a>0&&both>0)
    {
        ans++;
        a--;
    }
    if(b>0&&both>0)
    {
        ans++;
        b--;
    }
    ans+=min(a,b);
    cout<<ans;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>

using namespace std;

int sw[5000][5000];
int sb[5000][5000];
int dp[5000][5000];

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

  vector<bool> color(n * 2);
  vector<int> a(n * 2);
  vector<int> pw(n);
  vector<int> pb(n);
  for (int i = 0; i < n * 2; i++) {
    char c;
    cin >> c >> a[i];
    a[i]--;
    color[i] = c == 'B';
    if (color[i] == false) {
      pw[a[i]] = i;
    } else {
      pb[a[i]] = i;
    }
  }

  for (int i = 0; i < n * 2; i++) {
    for (int j = 0; j < n * 2; j++) {
      sw[i + 1][j] = sw[i][j];
      sb[i + 1][j] = sb[i][j];
      if (color[i] == false && a[i] >= j) {
        sw[i + 1][j]++;
      }
      if (color[i] == true && a[i] >= j) {
        sb[i + 1][j]++;
      }
    }
  }

  fill_n(*dp, 5000 * 5000, 1e9);
  dp[0][0] = 0;

  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      if (i + 1 <= n) {
        int k = pw[i];
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + sw[k][i] + sb[k][j]); 
      }
      if (j + 1 <= n) {
        int k = pb[j];
        dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + sw[k][i] + sb[k][j]);
      }
    }
  }
  cout << dp[n][n] << endl;
}

Measured memory_bytes: 256256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple
{
    //////////////////////////////
    void Solve() {
        //input
        var a = io.Long;
        var b = io.Long;
        //cal
        var isOdd = ((a * b) & 1) == 1;
        //ret
        Console.WriteLine(isOdd ? "Odd" : "Even");
    }
    //////////////////////////////
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() { Solve(); io.writeFlush(); }
}
class SimpleIO
{
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,T,A;
  cin >> N >> T >> A;
  
  vector<int> H(N);
  for(int i=0; i<N; i++){
    cin >> H.at(i);
  }
  
  double tem=0;
  double min=0;
  vector<vector<int>> ans(N, vector<int>(2));
  
  for(int i=0; i<N; i++){
    tem = (T * 1000 - H.at(i) * 6) - A * 1000;
    if(tem < 0){
      tem = -tem;
    }
    
    ans.at(i).at(0) = tem;
    ans.at(i).at(1) = i+1;
  }
  
  sort(ans.begin(),ans.end());
  cout << ans.at(0).at(1) << endl;
  
}

Measured memory_bytes: 3604
<?php
  fscanf(STDIN, "%d%d", $x, $y);
  $flag = false;
  for($i=0; $i<=100; $i++){
      for($j=0; $j<=100; $j++){
          if($i+$j == $x && ($i*2)+($j*4) == $y){
              $flag = true;
          }
      }
  }
  if($flag){
      echo "Yes";
  }else{
      echo "No";
  }

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i=0; i<N; i++) {
    cin >> d.at(i);
  }
  
  int count=0;
  for (int i=100; i>0; i--) {
    for (int j=0; j<N; j++) {
      if (d.at(j)==i) {
        count++;
        break;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#define __DEBUG__

using namespace std;
typedef long long ll;

int main(){
    ll N,K;
    ll ans = 0;
    cin>>N>>K;
    ll temp = (N/K);
    ans = temp*temp*temp;
    if(K%2==0){
        temp = (N+K/2)/K;
        ans += temp*temp*temp;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
N=int(input())
b=list(map(int,input().split()))
ans=[]
for k in range(N):
    for i in range(len(b)):
        if b[len(b)-1-i]==len(b)-i:
            x=b.pop(len(b)-1-i)
            ans.insert(0,x)
            break
if len(b)==0:
    for p in range(N):
        print(ans[p])
else:
    print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> S(h+2, vector<char>(w+2));
  for(int i=0;i<h+2;i++) {
    if(i == 0 || i == h+1) for(int j=0;j<w+2;j++) S[i][j] = '#';
    else {
      for(int j=0;j<w+2;j++) {
        if(j == 0 || j == w+1) S[i][j] = '#';
        else {
          cin >> S[i][j];
        }
      }
    }
  }

  map<pair<int, int>, int> usedd;

  vector<int> vec(0);
 
  for(int i=1;i<=h;i++) {
    for(int j=1;j<=w;j++) {
      if(S[i][j] == '#') continue;
      vector<vector<int>> root(h+2, vector<int>(w+2, 0));
 
      root[i][j] = 0;
      
      queue<pair<int, int>> que;
    
      map<pair<int, int>, int> used;
    
      que.push(make_pair(i, j));
    
      while(!que.empty()) {
        pair<int, int> p = que.front();que.pop();
        if(used[p]) continue;
        int a = root[p.first][p.second] + 1;
        if(S[p.first+1][p.second] == '.' && !used[make_pair(p.first+1, p.second)]) {
          root[p.first+1][p.second] = a;
          que.push(make_pair(p.first+1, p.second));
        }
        if(S[p.first-1][p.second] == '.' && !used[make_pair(p.first-1, p.second)]) {
          root[p.first-1][p.second] = a;
          que.push(make_pair(p.first-1, p.second));
        }
        if(S[p.first][p.second+1] == '.' && !used[make_pair(p.first, p.second+1)]) {
          root[p.first][p.second+1] = a;
          que.push(make_pair(p.first, p.second+1));
        }
        if(S[p.first][p.second-1] == '.' && !used[make_pair(p.first, p.second-1)]) {
          root[p.first][p.second-1] = a;
          que.push(make_pair(p.first, p.second-1));
        }
    
        used[p] = 1;
      }

      int max = 0;
      pair<int, int> co;

      for(int e = 1; e <= h; e++) {
        for(int f = 1; f <= w; f++) {
          if(root[e][f] > max) {
            max = root[e][f];
            co.first = e;
            co.second = f;
          }
        }
      }

      vec.push_back(max);
    }
  }

  cout << *max_element(vec.begin(), vec.end()) << endl;
 
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  vector<int> sum1(n);
  vector<int> sum2(n);
  partial_sum(a.begin(), a.end(), sum1.begin());
  partial_sum(b.rbegin(), b.rend(), sum2.begin());
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    ans = max(ans, sum1[i] + sum2[n - i - 1]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main()
{
    int R[MAX];
    int n;
    
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> R[i];
    }
    
    int maxProfit = -2000000000;
    int minValue = R[0];

    for(int i = 1; i < n; i++){
        maxProfit = max(maxProfit, R[i] - minValue);
        minValue = min(minValue, R[i]);
    }

    cout << maxProfit << endl;
    
    return 0;
}


Measured memory_bytes: 3868
import collections
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
hint = collections.Counter(A)
ans = 0
bb = hint.most_common()
if K >= len(bb):
    print(ans)
else:
    for i in range(-1, -(len(bb)-K)-1, -1):
        ans += bb[i][1]
    print(ans)

Measured memory_bytes: 39320
import sys
import math
n = int(sys.stdin.readline().rstrip())
for i in range(n):
    x1,y1,x2,y2,x3,y3 = map(float, sys.stdin.readline().rstrip().split(' '))
    p = ((y1-y3)*(y1**2-y2**2+x1**2-x2**2)-(y1-y2)*(y1**2-y3**2+x1**2-x3**2)) / (2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3))
    q = ((x1-x3)*(x1**2-x2**2+y1**2-y2**2)-(x1-x2)*(x1**2-x3**2+y1**2-y3**2)) / (2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3))
    r = math.sqrt((p-x1)**2 + (q-y1)**2)
    print("{:0.3f} {:0.3f} {:0.3f}".format(round(p,3),round(q,3),round(r,3)))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1e18

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

void solve_abc_a() {
	ll n, m;
	ll x, y;
	ll a, b, d;
	ll c;
	//char c;
	ll h, w;
	ll k;
	string s, t;
	//ll s, t;
	ll l_ans = 0;
	string s_ans = "NG";

	cin >> n >> k;
	
	l_ans = k;
	rep(i, n - 1) {
		l_ans *= k - 1;
	}

	cout << l_ans << "\n";

	return;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_a();

	return 0;
}


Measured memory_bytes: 3580
#include <stdio.h>
#include <math.h>

int main(void) {
	int i,n;
	double p,p1,p2,p3,pinf,x[100],y[100];

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lf",&x[i]);
	}
	for(i=0,p1=0,p2=0,p3=0,pinf=0;i<n;i++){
		scanf("%lf",&y[i]);
		p=fabs(x[i]-y[i]);
		p1+=p;
		p2+=pow(p,2);
		p3+=pow(p,3);
		if(p>pinf) {pinf=p;}
	}
	printf("%.6lf\n%.6lf\n%.6lf\n%.6lf\n",p1,sqrt(p2),cbrt(p3),pinf);
	return 0;
}

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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 100000

int main() {
	int N, K;

	cin >> N >> K;

	int ans = 1;
	for( int i = 0; i < N; i++ ) {
		if( i == 0 ) {
			ans *= K;
		}
		else {
			ans *= ( K - 1 );
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FS reader = new FS();
		int N = reader.nextInt();
		int[] a = new int[N];
		for(int i=0; i<N; i++) {
			a[i] = reader.nextInt()-1;
		}
		int counter = 0;
		for(int i=0; i<N; i++) {
			if (a[a[i]] == i) counter++;
		}
		System.out.println(counter/2);
		// write reader
	}

	public static void solver(int N, int[][] costs) {
	}

	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}

		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}

Measured memory_bytes: 10928
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll maxi=0,f=0,mini=INF,sum=0;
    string str,str2;
    ll h,w;
    ll n,x,m;
    ll a,b,d,c;
    multiset<int> s;
    cin>>a>>b>>c>>d;
    if(d%2){
        cout<<b-a;
    }else{
        cout<<a-b;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

struct edge{
    ll to,cost,ind;
};
ll INF=1e15;
vector<edge> g[110];
vector<ll> d(110);
vector<P> pre(110);
vector<bool> used(1010,false);
ll n,m;
 
void dijkstra(ll x){
    rep(i,len(d)){
        d[i]=INF;
    }
    rep(i,110){
      pre[i].first=-1;
      pre[i].second=-1;
    }
    priority_queue<P,vector<P>,greater<P> > que;
    d[x]=0;
    que.push(P(0,x));
    while(!que.empty()){
        P p=que.top();
        que.pop();
        ll v=p.second;
        if(d[v]<p.first){
            continue;
        }
        rep(i,len(g[v])){
            edge e=g[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                pre[e.to]=P(v,e.ind);
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

void get_path(ll t){
  for(;t!=-1;t=pre[t].first){
    //cout<<t<<' '<<pre[t].first<<' '<<pre[t].second<<endl;
    if(pre[t].second!=-1) used[pre[t].second]=true;
  }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m;
    rep(i,m){
      ll a,b,c;
      cin>>a>>b>>c;
      g[a].push_back({b,c,i+1});
      g[b].push_back({a,c,i+1});
    }
    FOR(i,1,n+1)FOR(j,i+1,n+1){
      //cout<<i<<' '<<j<<endl;
      dijkstra(i);
      get_path(j);
    }
    ll ans=0;
    FOR(i,1,m+1){
      if(!used[i]) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384