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

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

  if ((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int a,b,c,d,e,f;cin >>a>>b>>c>>d>>e>>f;
  double threshold = (double)(100*e)/(double)(100 + e);
  double max_concent = 0.0;
  int max_w = 0;
  int max_s = 0;
  for(int i=0;i<= 30/b;++i){
    for(int j=0;j<= 30/a;++j){
      if(i==0 && j==0) continue;
      int val_w = 100*b*i + 100*a*j;
      int thre_s = (b*i + a*j)*e;
      for(int k=0;k<= thre_s/d;++k){
        for(int l=0;l<= thre_s/c;++l){
          int val_s = d*k + c*l;
          double tmp_concent = (double)(100*val_s)/(double)(val_w + val_s);
          if(val_s + val_w <= f &&  tmp_concent <= threshold){
            if(tmp_concent >= max_concent){
              max_concent = tmp_concent;
              max_s = val_s;
              max_w = val_w;
            }
          }
        }
      }
    }
  }
  cout << max_w + max_s << " " << max_s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int x;
	cin >> x;

	cout << (x ^ 1);

	return 0;
}

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

//#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
typedef vector<int>vint;
typedef pair<int,int>pint;

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

int W,H;
int fld[100][100];
bool used[100][100];

void dfs(int y,int x){
    if(fld[y][x]||used[y][x])return;
    used[y][x]=true;
    rep(i,6){
        int ny=y+dy[i],nx=x+dx[y&1][i];
        if(ny<0||ny>=H||nx<0||nx>=W||fld[ny][nx]||used[ny][nx])continue;
        dfs(ny,nx);
    }
}

signed main(){
    cin>>W>>H;
    rep(i,H)rep(j,W)cin>>fld[i][j];

    rep(i,H){
        dfs(i,0);dfs(i,W-1);
    }
    rep(j,W){
        dfs(0,j);dfs(H-1,j);
    }

    int ans=0;
    rep(i,H)rep(j,W)if(fld[i][j])rep(k,6){
        int ny=i+dy[k],nx=j+dx[i&1][k];
        if(ny<0||ny>=H||nx<0||nx>=W||used[ny][nx])ans++;
    }

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

Measured memory_bytes: 1508
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

ll dp[(1<<20)];

ll mod_pow(ll x,ll n){
  ll res=1;
  while(n>0){
    if(n&1) res=res*x%MOD;
    x=x*x%MOD;
    n>>=1;
  }
  return res;
}

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N) cin>>A[i];

  rep(i,N) dp[A[i]]++;

  for(int k=0;k<20;k++){
    for(int s=0;s<(1<<20);s++){
      if(s&(1<<k));
      else dp[s]+=dp[s^(1<<k)];
    }
  }

  ll ans=0;
  for(int i=1;i<(1<<20);i++){
    int n=0;
    for(int j=0;j<20;j++){
      if(i&(1<<j)) n++;
    }
    if(n%2) ans+=(mod_pow(2,dp[i])-1);
    else ans-=(mod_pow(2,dp[i])-1);
    ans=(ans+MOD)%MOD;
  }

  ll result=mod_pow(2,N)-1-ans;
  result=(result+MOD)%MOD;
  cout<<result<<endl;

  return 0;
}



Measured memory_bytes: 11564
MOD=10**9+7
import sys
N,K=map(int,input().split())
alist=list(map(int,input().split()))

num_neg=0
num_pos=0
num_zero=0
aalist=[]
for a in alist:
  if a>0:
    num_pos+=1
  elif a<0:
    num_neg+=1
  else:
    num_zero+=1
  aalist.append((abs(a),a))
aalist.sort(reverse=True)
    
if N==K:
  answer=1
  for a in alist:
    answer*=a
    answer%=MOD
  print(answer)
  sys.exit(0)
  
pos_possible=True
if num_neg==N and K%2==1:
  pos_possible=False
    
if not pos_possible:
  aalist.sort()
  answer=1
  for i in range(K):
    aa,a=aalist[i]
    answer*=a
    answer%=MOD
  print(answer)
  sys.exit(0)
    
aalist.sort(reverse=True)
#print(aalist)
answer=1
sgn=1
pos_absmin=0
neg_absmin=0
for i in range(K):
  aa,a=aalist[i]
  answer*=a
  answer%=MOD
  if a>0:
    pos_absmin=a  
  elif a<0:
    neg_absmin=a
    sgn*=-1
  else:
    sgn=0

if sgn==0:
  print(0)    
elif sgn>0:
  print(answer)
else:
  pos_absmax=0
  neg_absmax=0
  for i in reversed(range(K,N)):
    aa,a=aalist[i]
    if a>0:
      pos_absmax=a
    else:
      neg_absmax=a
      
  #print(pos_absmin,neg_absmin,pos_absmax,neg_absmax)
  if pos_absmin==0:
    answer*=pos_absmax
    answer*=pow(neg_absmin%MOD,MOD-2,MOD)
    answer%=MOD
  elif neg_absmin==0:
    answer*=neg_absmax%MOD
    answer*=pow(pos_absmin,MOD-2,MOD)
    answer%=MOD
  elif pos_absmin*pos_absmax<neg_absmin*neg_absmax:
    answer*=neg_absmax%MOD
    answer*=pow(pos_absmin,MOD-2,MOD)
    answer%=MOD
  else:
    answer*=pos_absmax
    answer*=pow(neg_absmin%MOD,MOD-2,MOD)
    answer%=MOD
  
  print(answer)

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

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 11111111111111111
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

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

#define MAX 10000

bool x_sort(const pll& p1, const pll& p2) {
  if (p1.first != p2.first) {
	return p1.first < p2.first;
  }
  else {
	return p1.second < p2.second;
  }
}

bool y_rsort(const pll& p1, const pll& p2) {
  if (p1.first != p2.first) {
	return p1.second > p2.second;
  }
  else {
	return p1.first > p2.first;
  }
}



int main(void) {
  bool c[110];
  vector<pll> red, blue;

  cin >> n;
  FOR(i, 0, n) {
	cin >> m;
	cin >> k;
	red.push_back(make_pair(m, k));
	c[i] = false;
  }

  FOR(i, 0, n) {
	cin >> m;
	cin >> k;
	blue.push_back(make_pair(m, k));
  }

  sort(ALL(red), y_rsort);
  sort(ALL(blue), x_sort);

  FOR(i, 0, n) {
	FOR(j, 0, n) {
	  if (blue[i].first > red[j].first && blue[i].second > red[j].second && !c[j] ) {
		c[j] = true;
	    ans++;
		break;
	  }
	}
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int color( int a )
{
	a = a % 3 ;
	if( a == 0 )
	{
		a = 3 ;
	}
	return a ;
}
int main()
{
	int n ;
	int k ;
	int yoko ,tate ;
	int i ;
	scanf( "%d", &n ) ;
	scanf( "%d", &k ) ;
	for( i = 0 ; i < k ; i++ )
	{
		scanf( "%d %d", &yoko , &tate ) ;
		if( yoko > tate )
		{
			if( yoko > n - tate )
			{
				yoko = ( n - yoko ) + 1 ;
				printf( "%d\n", color( yoko ) ) ;
			}
			else
			{
				printf( "%d\n", color( tate ) ) ;
			}
		}
		else
		{
			if( tate > n - yoko )
			{
				tate = ( n - tate ) + 1 ;
				printf( "%d\n", color( tate ) ) ;
			}
			else
			{
				printf( "%d\n", color( yoko ) ) ;
			}
		}
	}
	return 0 ;
}

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

using namespace std;
#define LL long long
#define N 10005
LL frogDist(LL *arr, LL n)
{
    LL dp[n];
    dp[0]=0 ; 
    for(LL i=1; i<n; i++) dp[i] = LONG_LONG_MAX;
    for(LL i=0; i<n-1; i++)
    {
        dp[i+1]= min(dp[i+1], dp[i]+ abs(arr[i]-arr[i+1]));
        
        if(i!=n-2) dp[i+2]= dp[i]+ abs(arr[i]-arr[i+2]);
        
        
        
    }
    
    
    return dp[n-1];




}

int main()
{
    ios_base::sync_with_stdio();
    cin.tie(0);
    cout.tie(0);
    //cout<<"N="<<N<<endl;
    int t;
    t=1;
    while(t--)
    {
        LL n;
        cin>>n;
        LL arr[n];
        for(LL i=0; i<n; i++) cin>>arr[i];
        int val= frogDist(arr, n);
        cout<<val<<endl;

    }

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int,int>;

const int mx = 3005;

ll dp[mx][mx][2];
int n, a[mx];

ll fun(int i, int j, int t){
    if(i > j) return 0;
    ll &ans = dp[i][j][t];
    if(~ans) return ans; ans=0;

    ans = a[i] - fun(i+1, j, !t);
    ans = max(ans, a[j] - fun(i, j-1, !t));
    return ans;
}

void solve(){
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> a[i];
    memset(dp, -1, sizeof dp);
    cout << fun(0, n-1, 0) << "\n";
}

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

    int tc = 1;
    while(tc--) solve();
    return 0;
}



Measured memory_bytes: 144976
#include<stdio.h>

int main(void){
  int n,t;
  scanf("%d", &n);
  if(n % 1000 == 0){
    printf("0");
  }
  else {
    t = n / 1000;
    n = 1000 * (t+1) - n;
    printf("%d", n);
  }
  
  return 0;
}

Measured memory_bytes: 1732
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	int x, y, z;
	cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << " " << y << " " << z << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?-1:*p1++)
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
char buf[1<<23],*p1=buf,*p2=buf;
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=2e5;
typedef int fuko[yuzu|10];
fuko a,ans,b;
int main() {
int i,n=read();
for (i=1;i<=n;++i) a[i]=b[i]=read();
sort(a+1,a+n+1);
for (i=1;i<=n;++i) {
  int p=lower_bound(a+1,a+n+1,b[i])-a;
  write(a[p<=n/2?n/2+1:n/2]),pl;
  }
}

Measured memory_bytes: 5504
import math
N = int(input())
cnt2 = 0
for n in range(1,N+1,2):
    cnt = 0
    for i in range(1,n+1,2):
        if n % i == 0:
            cnt += 1
    if cnt == 8:
        cnt2 += 1
 
print(cnt2)

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

int main() {
  	string s,t;
  	cin >> s >> t;
  
	sort(s.begin(),s.end());
  	sort(t.begin(),t.end(), greater<int>());
   
     if(s<t){
         cout << "Yes" << endl;
     }else{
         cout << "No" << endl;

     }
   
}

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

using namespace std;

double dp[3001];

int main(){

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

    int n; cin >> n;

    dp[0] = 1;

    for(int i = 1; i <= n; ++i){ // coin
        
        double p; cin >> p;
        
        // go through every possible # of coin flips
        
        for(int j = i; j > 0; --j){
            
            // dp[j] = case 1 + case 2
            // case 1: tails, you suck
            // case 2: heads
            
            dp[j] -= p * (dp[j] - dp[j - 1]);
            
        }
        
        dp[0] -= p * dp[0];
        
    }

    double tot = 0;

    for(int i = n; i + i > n; --i)
        tot += dp[i];

    cout << setprecision(10) << fixed << tot << "\n";

    return 0;
}

Measured memory_bytes: 256
def sumcnt(a, b, val):
  am=(a-1)//val
  bm=b//val
  return bm-am

a,b,c,d=map(int,input().split())
p=c
q=d
while p%q>=1:
  bk=p%q
  p=q
  q=bk
mc=c//q
md=d//q
m=mc*md*q
summ=sumcnt(a,b,m)
sumc=sumcnt(a,b,c)
sumd=sumcnt(a,b,d)
print((b-a+1)-(sumc+sumd-summ))

Measured memory_bytes: 3064
import itertools


def check(x: int) -> bool:
    s = str(x)
    prev = ord(s[0])
    for c in s[1:]:
        if ord(c) != prev+1:
            return False
        prev = ord(c)
    return True


def main() -> None:
    n = int(input())
    v = list(map(int, input().split(' ')))
    max_ = -1
    for c in itertools.combinations(sorted(v), 2):
        p = c[0] * c[1]
        if check(p):
            max_ = max(max_, p)

    print(max_)


if __name__ == '__main__':
    main()


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

int main() {

  int N, X; //入力
  int fn = 0;
  cin >> N;
  X = N;

  for (int i = 0; i < 9; i++) {
      fn += N%10;
      N /= 10;
  }

  if (X%fn == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}


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


int main(int argc, char** argv) {
	int a, b, c;
	cin>>a;
	cin>>b;
	c = ((b-a)*(1+b-a))/2;
	printf("%d\n",c-b);
	return 0;
}

Measured memory_bytes: 256
while True:
    n=input()
    if n=="0":
        break
    x=list(n)
    a=0
    b=0
    for i in range(len(x)-1):
        if x[i]=="A" and x[i+1]=="A":
            a+=1
        elif x[i]=="B" and x[i+1]=="A":
            a+=1
        elif x[i]=="B" and x[i+1]=="B":
            b+=1
        else:
            b+=1
    if a>=10 and b<10:
        a+=1
    elif b>=10 and a<10:
        b+=1
    elif a>=10 and b>=10:
        if x[len(x)-1]=="A":
            a+=1
        else:
            b+=1
    print(a,b)


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

#define int long long

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

string N;

signed main() {
    cin >> N;
    int ans = 0;
    int sum = 0;
    for (int i = 0; i < N.length(); i++) {
        ans += N[i] - '0';
    }
    for (int i = 0; i < N.length(); i++) {
        if (N[i] == '0') {
            continue;
        }
        sum += N[i] - '0';
        int cur = sum + (N.length() - i - 1) * 9 - 1;
        ans = max(cur, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
	    int n=sc.nextInt();
	    int t=sc.nextInt();
	    int price[]=new int[n];
	    for(int i=0;i<n;i++){
	    	price[i]=sc.nextInt();
	    }
	    int min[]=new int[n];
	    int max[]=new int[n];
	    min[0]=price[0];
	    max[n-1]=price[n-1];
	      for(int i=1;i<n;i++){
	    	if(price[i]>min[i-1])min[i]=min[i-1];
	    	else min[i]=price[i];
	    	int j=n-i-1;
	    	if(price[j]<max[j+1])max[j]=max[j+1];
	    	else max[j]=price[j];
	    }
	      int ans=0;
	      int mc=-1;
	      for(int i=0;i<n;i++){
	    	  if(price[i]-min[i]>mc){
	    		  ans=1;mc=price[i]-min[i];
	    	  }
	    	  else if(price[i]-min[i]==mc)ans++;
	      }
	      System.out.println(ans);
	}
	
}

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

int main() {
    string S;
    cin >> S;
    int N = S.length();
    if (N < 7) {
        cout << "NO" << endl;
        return 0;
    }
    if (N >= 7 && (S.substr(0, 7) == "keyence" || S.substr(N - 7, 7) == "keyence")) {
        cout << "YES" << endl;
        return 0;
    }

    if (S.substr(0, 1) + S.substr(N - 6) == "keyence") {
        cout << "YES" << endl;
        return 0;
    }
    if (S.substr(0, 2) + S.substr(N - 5) == "keyence") {
        cout << "YES" << endl;
        return 0;
    }
    if (S.substr(0, 3) + S.substr(N - 4) == "keyence") {
        cout << "YES" << endl;
        return 0;
    }
    if (S.substr(0, 4) + S.substr(N - 3) == "keyence") {
        cout << "YES" << endl;
        return 0;
    }
    if (S.substr(0, 5) + S.substr(N - 2) == "keyence") {
        cout << "YES" << endl;
        return 0;
    }
    if (S.substr(0, 6) + S.substr(N - 1) == "keyence") {
        cout << "YES" << endl;
        return 0;
    }

    cout << "NO" << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"io"
	"os"
)

var (
	reader io.Reader = os.Stdin
	writer io.Writer = os.Stdout
)

func main() {
	run()
}

func run() {
	var N, Y int
	fmt.Fscan(reader, &N, &Y)

	for i := N; i >= 0; i-- {
		for j := N - i; j >= 0; j-- {
			total := 10000*i + 5000*j + 1000*(N-i-j)

			// if total <= Y {
			if total == Y {
				fmt.Fprintln(writer, i, j, (N - i - j))
				// } else {
				// 	fmt.Fprintln(writer, -1, -1, -1)
				return
			}

			// }
		}
	}

	fmt.Fprintln(writer, -1, -1, -1)

}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
ll gcd(ll a,ll b){
	return a%b==0?b:gcd(b,a%b);
}
int main(void)
{
	ll n,x;
	scanf("%lld%lld",&n,&x);
	printf("%lld\n",3*(n-gcd(n,x)));
	return 0;
}

Measured memory_bytes: 128
#if defined(LOCAL)
// #define RANDOM_TEST
#define PROBLEM_NAME "b"
const double _max_double_error = 1e-9;
#include "testutils.h"
#endif
#include <bits/stdc++.h>

using namespace std;

using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<int>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)

#if defined(LOCAL)
bool local = true;
#define L(x...) debug(x)
#else
bool local = false;
#define L(x, ...) (x)
#endif
struct VoidStream { void operator&(std::ostream&) { } };
#define LOG !(local) ? (void) 0 : VoidStream() & cerr

struct Graph {
  vvl adj;
  vvl up;
  vl depth;
  vl subtree_size;

  Graph(l n) {
    adj.resize(n);
    depth.resize(n);
    subtree_size.resize(n);
    l k = 0;
    while ((1 << k) <= n) k++;
    up.resize(k, vl(n, -1));
  }

  void build_up(l a) {
    F(i, 1, up.size()) {
      l t = up[i - 1][up[i - 1][a]];
      if (t == -1) break;
      up[i][a] = t;
    }
  }

  l walk(l a, l d) {
    l k = 0;
    while (d > 0) {
      if (d % 2) a = up[k][a];
      d /= 2;
      k++;
    }
    return a;
  }

  l lca(l a, l b) {
    a = walk(a, depth[a] - depth[b]);
    b = walk(b, depth[b] - depth[a]);
    if (a == b) return a;
    B(i, 0, up.size()) {
      if (up[i][a] != up[i][b]) {
        a = up[i][a];
        b = up[i][b];
      }
    }
    return up[0][a];
  }

  void dfs(l root) {
    subtree_size[root]++;
    for (auto a : adj[root]) {
      if (up[0][root] == a) continue;
      up[0][a] = root;
      depth[a] = depth[root] + 1;
      build_up(a);
      dfs(a);
      subtree_size[root] += subtree_size[a];
    }
  }
};

void solve(istream& cin, ostream& cout) {
  l N;
  cin >> N;
  Graph g(N);
  F(i, 0, N - 1) {
    l a, b; cin >> a >> b; a--; b--;
    g.adj[a].emplace_back(b);
    g.adj[b].emplace_back(a);
  }
  // TODO: add standard walk to template
  g.dfs(0);
  l d = (g.depth[N - 1] - 1) / 2;
  l p = g.walk(N - 1, d);
  if (g.subtree_size[p] * 2 >= N) {
    cout << "Snuke" << lf;
  } else {
    cout << "Fennec" << lf;
  }
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 24432
def examB():
    A = SI(); N = len(A)
    d = defaultdict(int)
    for s in A:
        d[s] +=1
#    print(d)
    ans = N*(N-1)//2 +1
    for i in d.values():
        ans -= i*(i-1)//2
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examB()


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

int main(){

	long int  i,j;
	int 	x,y,a,b,c;
	long int N,K,prev_N;
	long sum=0;
	scanf("%ld%ld",&N,&K);
	N=N%K;
	if(K==1){
		printf("0\n");
		return 0;
	}
	prev_N=N+1;
	for(;prev_N>N;){
		prev_N=N;
		
		N=labs(N-K);
	}
	printf("%ld\n",prev_N);
 return 0;
 }

Measured memory_bytes: 128
import sys

# Union Find
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def unite(x, y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        if par[x] > par[y]:
            x, y = y, x
        par[x] += par[y]
        par[y] = x
        return True


if __name__ == "__main__":
    input = sys.stdin.readline
    n, m = map(int, input().split())
    par = [-1] * n
    s = set()
    for _ in range(m):
        a, b = map(int, input().split())
        if a > b:
            a, b = b, a
        s.add((a, b))

    for x, y in s:
        unite(x - 1, y - 1)

    print(-min(par))

Measured memory_bytes: 47136
#include <iostream>

using namespace std;

long long  all[51];
long long  pn[51];
long long  ans = 0;

long long calc(long long  x, int  n) {
  //cout << n << " " << x << "\n";
  if (x == all[n]) {
    ans += pn[n];
    return 0;
  }
  if (x == (all[n - 1] + 2 )) {
    ans += pn[n - 1] + 1;
    return 0;
  }
  if (x == 1) {
    return 0;
  }
  if (x > (all[n - 1]) + 2 ) {
    ans += pn[n - 1] + 1;
    calc(x - (all[n - 1] + 2) , n - 1);
  } else {
    calc(x - 1, n - 1);
  }


}

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

  all[0] = 1;
  pn[0] = 1;
  int n;
  long long  x;
  cin >> n;
  cin >>  x ;


  for (int i = 1; i <= n; i++) {
    all[i] = 2 * all[i - 1] + 3;
    pn[i] = 2 * pn[i - 1] + 1;
  }
  /*
    for(int i = 0; i <= n; i++) {
      cout << all[i] << "\n";
    }
    for(int i = 0; i <= n; i++) {
      cout << pn[i] << "\n";

    }
    */
  calc(x, n);

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i = a; i >= b; i--)
#define all(container) container.begin(), container.end()
using namespace std;
typedef pair<int, int> P;
const int INF = 1e9;

int main() {
  double t, x, ans;
  cin >> t >> x;

  ans = t / x;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll N,M,X;
    cin>>N>>M>>X;
    vl C(N);
    vvl A(N,vl(M));
    rep(i,N){
        cin>>C[i];
        rep(j,M){
            cin>>A.at(i).at(j);
        }
    }
    ll Ans=INF;
    for(ll bit=0;bit<(1<<N);++bit){
                    ll cost=0;
            vl vec(M,0);
        rep(i,N){

            if(bit&(1<<i)){
                cost+=C[i];
                rep(j,M){
                    vec[j]+=A[i][j];
                }
            }
        }
            rep(j,M){
                if(vec[j]<X){
                    break;
                }
                if(j==M-1){
                    chmin(Ans,cost);
                }
            }
        }
    
    if(Ans!=INF){
    cout<<Ans<<endl;
    }else{
        cout<<-1<<endl;
    }

}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

vector<int> d, color;
vector<vector<int>> A;

void bfs() {
    queue<int> q;
    q.push(0);
    d[0] = 0;
    color[0] = 1;
    while (!q.empty()) {
        int i = q.front(); q.pop();
        for (auto j : A[i]) {
            if (color[j] == 0) {
                q.push(j);
                d[j] = d[i] + 1;
                color[j] = 1;
            }
        }
    }
}

int main() {
    int n;
    cin >> n;
    A = vector<vector<int>>(n, vector<int>(0));
    d = vector<int>(n, -1);
    color = vector<int>(n, 0);
    rep(i, n) {
        int u, k;
        cin >> u >> k;
        rep(j, k) {
            int tmp;
            cin >> tmp;
            A[i].push_back(--tmp);
        }
    }
    bfs();
    rep(i, n) {
        printf("%d %d\n", i + 1, d[i]);
    }
    return 0;
}


Measured memory_bytes: 3260
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll m, n;
    cin >> n >> m;
    if (n == m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
As = list(map(int, input().split()))
cnt = 0
for i in range(N):
    minj = i
    for j in range(i,N):
        if As[j] < As[minj]:
            minj = j
    if minj != i:
        tmp = As[i]
        As[i] = As[minj]
        As[minj] = tmp
        cnt += 1
    
print(" ".join([str(a) for a in As]))
print(cnt)


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

int main(){
  int a, b, t, x, ans;
  cin >> a >> b >> t;
  x = (t + 0.5) / a;
  ans = x * b;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  
  int diff;
  char L;
  char S;
  
  while( scanf("%c", &S) != EOF){
    
    diff = 'a' - 'A';
    
    if( S == ' ' || S =='.'||S == '!'|| S =='?'|| S == '\n') diff=0;
    
    L = S - diff;
    
    printf("%c", L);
    
  }
  
  
  //printf("\n");


  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

int H, W;
int MAP[2010][2010];

int TATE[2010][2010];
int YOKO[2010][2010];
int main(void){
    cin >> H >> W;
    char c;
    REP(i, H) REP(j, W){
        cin >> c;
        if (c=='.') MAP[i][j] = 0;
        else MAP[i][j] = 1;
    }
    REP(w,W){
        int start = 0;
        int end = 0;
        while(end < H){
            int count = -1;
            while(MAP[end][w] != 1 and end < H){
                count++;
                end++;
            }
            for (int i=start;i<end;i++) TATE[i][w] = count;
            start = ++end;
        }
    }
    REP(h,H){
        int start = 0;
        int end = 0;
        while(end < W){
            int count = -1;
            while(MAP[h][end] != 1 and end < W){
                count++;
                end++;
            }
            for (int i=start;i<end;i++) YOKO[h][i] = count;
            start = ++end;
        }
    }

    int res = 0;
    REP(h,H) REP(w,W) res = max(res, TATE[h][w]+YOKO[h][w]+1);
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 47616
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

using namespace std;

int main()
{
    IOS;
    int n,k;
    cin>>n>>k;
    ld ans=0;
    for(int i=1;i<=n;i++)
    {
        int j=i,cnt=0;
        while(j<k)
        {
            j*=2;
            cnt++;
        }
        ans+=pow(0.5,cnt);
    }
    ans/=n;
    cout<<fixed<<setprecision(15)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;
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 D;
	int[] c;
	int[][] s;
	int[] last;

	Main(BufferedReader in) throws IOException {
		D = Integer.parseInt(in.readLine());
		String[] tokens = in.readLine().split(" ");
		c = new int[tokens.length];
		for (int i = 0; i < tokens.length; ++i) {
			c[i] = Integer.parseInt(tokens[i]);
		}
		s = new int[D][c.length];
		for (int i = 0; i < D; ++i) {
			tokens = in.readLine().split(" ");
			for (int j = 0; j < tokens.length; ++j) {
				s[i][j] = Integer.parseInt(tokens[j]);
			}
		}
		last = new int[c.length];
		Arrays.fill(last, 0);
	}

	int sub(int day, int contest) {
		int result = s[day][contest];
		int minus = 0;
		for (int i = 0; i < c.length; ++i) {
			if (i != contest) {
				minus += (day - last[i]) * c[i];
			}
		}
		return result - minus;
	}

	int sub(int day) {
		// 最も得られる満足度が高いものを選ぶ
		int result = -1;
		int max = Integer.MIN_VALUE;
		for (int contest = 0; contest < c.length; ++contest) {
			int effort = sub(day, contest);
			if (max < effort) {
				result = contest;
				max = effort;
			}
		}

		return result;
	}

	void calc() {
		// まずは最大のSを選ぶことにする
		for (int i = 0; i < D; ++i) {
			int r = sub(i);
			if (r >= 0) {
				System.out.println((r + 1));
				last[r] = i;
			} else {
				System.out.println("1");
				last[0] = i;
			}

		}
	}

	void showResult() {
	}
}

Measured memory_bytes: 35976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

typedef string::const_iterator State;
string s;
void init(){
    s.clear();
}
bool sig[15];
bool expr(State &begin);
bool fact(State &begin){
    if(*begin=='('){
        begin++;
        bool a,b;
        a=expr(begin);
        string ope;ope+=*begin;
        begin++;
        if(ope[0]=='-')begin++;
        b=expr(begin);
        begin++;
        if(ope[0]=='+'){
            return a|b;
        }else if(ope[0]=='*'){
            return a&b;
        }else{
            if(a==false)return true;
            return b;
        }
    }else{
        bool res;
        if('a'<=*begin&&*begin<='k'){
            res=sig[*begin-'a'];
            begin++;
            return res;
        }else{
            if(*begin=='T')res=true;
            else res=false;
            begin++;
            return res;
        }
    }
}
bool expr(State &begin){
    if(*begin=='-'){
        begin++;
        bool res=expr(begin);
        return !res;
    }else{
        return fact(begin);
    }
}


int main(){fastio
    while(1){
        cin>>s;
        if(s[0]=='#')break;
        string x,y;
        bool whi=true;
        rep(i,0,s.size()-1){
            if(s[i]=='='){
                whi=false;
            }else{
                if(whi)x+=s[i];
                else y+=s[i];
            }
        }
        bool flag=true;
        rep(i,0,(1<<11)-1){
            rep(j,0,10){
                sig[j]=(i>>j)&1;
            }
            State bex=x.begin(),bey=y.begin();
            bool bx=expr(bex),by=expr(bey);
            if(bx^by){
                flag=false;
                break;
            }
        }
        if(flag)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
        init();
    }
    
    return 0;
}


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

class D
{
	static void Main()
	{
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

		var M = 1000000007;
		for (int i = 1; i <= a[1]; i++)
			Console.WriteLine(i > a[0] - a[1] + 1 ? 0 : (long)ModNcr(a[0] - a[1] + 1, i, M) * ModNcr(a[1] - 1, i - 1, M) % M);
	}

	static int ModPow(int b, int i, int mod)
	{
		for (var r = 1; ; b = (int)((long)b * b % mod))
		{
			if (i % 2 > 0) r = (int)((long)r * b % mod);
			if ((i /= 2) < 1) return r;
		}
	}
	static int ModInv(int x, int p) => ModPow(x, p - 2, p);
	static int ModFactorial(int n, int mod) => n == 0 ? 1 : (int)Enumerable.Range(1, n).Select(x => (long)x).Aggregate((x, y) => x * y % mod);
	static int ModNpr(int n, int r, int mod) => r == 0 ? 1 : (int)Enumerable.Range(n - r + 1, r).Select(x => (long)x).Aggregate((x, y) => x * y % mod);
	static int ModNcr(int n, int r, int p) => n - r < r ? ModNcr(n, n - r, p) : (int)((long)ModNpr(n, r, p) * ModInv(ModFactorial(r, p), p) % p);
}


Measured memory_bytes: 13396
n=int(raw_input())
p=map(int,raw_input().split())
a=[(i+1)*n for i in range(n)]
b=[0]*n
for i in range(n):
    b[p[i]-1]=n*n+i+1-a[p[i]-1]
print ' '.join(map(str,a))
print ' '.join(map(str,b))


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

int main(){
    int N, H;
    cin >> N >> H;
    vector<int> a(N);
    vector<int> b(N);
    int max_a = 0;
    for (int i = 0; i < N; i++){
	cin >> a[i] >> b[i];
	max_a = max(max_a, a[i]);
    }

    int res = 0;
    int sum_b = 0;
    for (int  i = 0; i < N; i++){
	if (max_a < b[i]){
	    res++;
	    sum_b += b[i];
	}
    }

    if (sum_b >= H){
	sort(b.begin(), b.end(), greater<int>());
	res = 0;
	int sum = 0;
	for (int i = 0; i < N; i++){
	    sum += b[i];
	    res++;
	    if (sum >= H){
		cout << res << endl;
		return 0;
	    }
	}
    }

    H -= sum_b;
    res += (H+max_a-1)/max_a;

    cout << res << endl;

    return 0;
}


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

vector <int> deq;
vector <vector <vector <int>>> dp, aux;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	deq.resize(n);
	dp.resize(n);
	aux.resize(n);
	// ux.resize(n);
	for (int i = 0; i < n; i++){
		cin >> deq[i];
		dp[i].resize(n);
		aux[i].resize(n);
		// ux[i].resize(n);
		for (int j = 0; j < n; j++){
			dp[i][j].resize(k + 1);
			aux[i][j].resize(k + 1);
			// ux[i][j].resize(k + 1);
		}
	}
	for (int l = n - 1; l >= 0; l--){
		for (int r = l; r < n; r++){
			dp[l][r][0] = 0;
			aux[l][r][0] = 0;
			// ux[l][r][0] = 0;
			for (int i = 1; i <= k; i++){
				if (l == r){
					dp[l][r][i] = max(0, deq[l]);
					aux[l][r][i] = max(0, deq[l]);
					// ux[l][r][i] = max(0, deq[l]);
				}
				else{
					aux[l][r][i] = max(aux[l + 1][r][i - 1] + deq[l], 0);
					// ux[l][r][i] = max(ux[l][r - 1][i - 1] + deq[l], 0);
					if (i > 1){
						aux[l][r][i] = max(aux[l][r][i], aux[l + 1][r][i - 2]);
						// ux[l][r][i] = max(ux[l][r][i], aux[l][r - 1][i - 2]);
					}
					dp[l][r][i] = max(max(dp[l][r][i - 1], deq[r] + dp[l][r - 1][i - 1]), aux[l][r - 1][i]);
					if (i > 1){
						dp[l][r][i] = max(dp[l][r][i], dp[l][r - 1][i - 2]);
					}
				}
				// cout << l << ' ' << r << ' ' << i << ' ' << dp[l][r][i] << '\n';
			}

		}
	}
	cout << dp[0][n - 1][k];
}

Measured memory_bytes: 2432
a, b, c, d = list(map(int, input().split()))
while True:
    c = c - b
    if c < 1:
        kati = 0
        break
    a = a -d
    if a < 1:
        kati = 1
        break
if kati == 0:
    print("Yes")
if kati == 1:
    print("No")

Measured memory_bytes: 9120
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int n; cin>>n;
    vector<int>ans;
    map<int,vector<int>>Mp;
    vector<int>v(n);
    rep(i,n)cin>>v[i];
    rep(i,n){
        Mp[v[i]].push_back(i+1);
    }
    rep(i,Mp[2].size())ans.push_back(Mp[2][i]);
    if(Mp[-2].size()%2&&Mp[-1].size()>0){
        rep(i,Mp[-2].size())ans.push_back(Mp[-2][i]);
        ans.push_back(Mp[-1].front());
    }else if(Mp[-2].size()%2&&Mp[-1].size()==0)
        rep(i,Mp[-2].size()-1)ans.push_back(Mp[-2][i]);
    else if(Mp[-2].size()%2==0LL)
        rep(i,Mp[-2].size())ans.push_back(Mp[-2][i]);
    sort(all(ans));
    if(ans.size()==0)cout<<0<<endl;
    else{
        cout<<ans.size()<<endl;
        rep(i,ans.size())cout<<ans[i]<<endl;
    }
}



Measured memory_bytes: 3168
// Marcin Knapik
#include<bits/stdc++.h>

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< pair<int, int> , null_type,less<pair<int, int>>, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ull>(a, b)(rng)
#define losuj_real(a, b) uniform_real_distribution<long double>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef unsigned long long      ull;
typedef pair<ll, ll>            pll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vector<ii>>      vvii;
typedef vector< ll >            vll;
typedef vector< pll >           vpll;
 
#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second
 
template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}
 
template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> inline T russian(T a, T b, T mod) {ll res = 0; while(b){if(b&1) res = (res + a)%mod; a = (a+a)%mod; b>>=1;}return res;}
template <class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<typename T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }
  
const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll N = 1e6+7;
const ll T = 1<<20;
const ll BIG_INF = 1e18 + 7;

ll n, m, k, q;
	
vi tab;
pll dp[3005][3005];

pll policz(int pocz, int kon){
	if(dp[pocz][kon].f != BIG_INF)
		return dp[pocz][kon];
	if(pocz == kon)
		return dp[pocz][kon] = {tab[pocz], 0};
	pll a = {tab[pocz] + policz(pocz+1, kon).s, policz(pocz+1, kon).f};
	pll b = {tab[kon] + policz(pocz, kon-1).s, policz(pocz, kon-1).f};
	
	return dp[pocz][kon] = (a.f - a.s > b.f - b.s ? a : b); 
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    FOR(i, 3005)
    	FOR(j, 3005)
    		dp[i][j] = {BIG_INF, BIG_INF};

    cin >> n;
    tab.resize(n);
    cin >> tab;

    cout << policz(0, n-1).f - policz(0, n-1).s << '\n';
}

Measured memory_bytes: 141824
// B - Cakes and Donuts
// https://beta.atcoder.jp/contests/abc105/tasks/abc105_b

import scala.io.StdIn.readLine

object Main extends App {

  val n = readLine.toInt

  val sums = for {
    i <- (0 to n by 4)
    j <- (0 to n by 7)
  } yield (i + j)

  val isOk = sums.exists(_ == n)

  isOk match {
    case true  => println("Yes")
    case false => println("No")
  }

}

Measured memory_bytes: 25420
#include <iostream>
#include <string>

using namespace std;

int main(){
    string a;
    string b;
    string c;
    cin >> a >> b >> c;
    a[0] = a[0] + 'A'-'a';
    b[0] = b[0] + 'A'-'a';
    c[0] = c[0] + 'A'-'a';
    cout << a[0] << b[0] << c[0] << endl;
}


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

int calc( int N, int M, int X[], int C[], int A[], int infCost )
{
    if ( N == 1 ) {
        int flag = true;
        for ( int j = 0; j < M; j++ ) {
            if ( X[j] > 0 ) {
                flag = false;
            }
        }
        if ( flag ) {
            return 0;
        }
        for ( int j=0; j<M; j++ ) {
            if ( X[j] - A[0*M+j] > 0 ) {
                return infCost;
            }
        }
        return C[0];
    } else {
        int flag = true;
        for ( int j=0; j<M; j++ ) {
            if ( X[j] > 0 ) {
                flag = false;
            }
        }
        if ( flag ) {
            return 0;
        }

        int X_buy[12];
        for ( int j=0; j<M; j++ ) {
            X_buy[j] = X[j] - A[(N-1)*M + j];
        }

        int cost_buy = C[N-1] + calc( N-1, M, X_buy, C, A, infCost );
        int cost_nobuy = calc( N-1, M, X    , C, A, infCost );
        int cost = std::min( cost_buy, cost_nobuy );
        return cost;
    }
}

int main()
{
    int N,M;
    int X;
    int X_buf[12];
    int C[12];
    int A[12*12];

    // input
    scanf( "%d %d %d", &N, &M, &X );
    for ( int i=0; i<N; i++ ) {
        scanf(" %d", C+i );
        for ( int j=0; j<M; j++ ) {
            scanf(" %d", &A[i*M+j] );
        }
    }

    // process
    int maxCost = 0;
    for ( int i=0; i<N; i++ ) {
        maxCost += C[i];
    }
    for ( int j=0; j<N; j++ ) {
        X_buf[j] = X;
    }

    int cost = calc( N, M, X_buf, C, A, maxCost + 1 );

    // output
    if ( cost > maxCost ) {
        printf("%d\n", -1 );
    } else {
        printf("%d\n", cost );
    }

    return 0;
}


Measured memory_bytes: 1732
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stdio.h>
#include<deque>
#include<map>
#include<queue>
#include<cmath>

typedef long long ll;

#define debug(x) cout << #x << "=" << x << endl;
#define debug_arr(a, n) for(ll i = 0; i < n; i++)cout << a[i] << " "
#define inf 100000000000
#define loop(i,n) for(ll i = 0; i < n; i++)
#define graph vector<vector<ll>>
#define P pair<ll,ll>

using namespace std;

int main(){
    ll n,min,max,minIndex,maxIndex,a,b,result = 0;
    cin >>n;

    vector<ll> l(n);
    loop(i,n) cin >>l[i];

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

    loop(i,n-1){
        for(ll j = i+1; j<=n-1; j++){
            a = l[i];
            b = l[j];

            min = b - a + 1;
            max = a + b - 1;
            if(min > max)continue;
            if(min > l[n-1] || max < l[0])continue;

            ll noIndex,okIndex,mid;

            noIndex = -1;okIndex = n;
            while(noIndex + 1 < okIndex){
                mid = (noIndex + okIndex) / 2;
                if(min <= l[mid]){
                    okIndex = mid;
                }else{
                    noIndex = mid;
                }
            }
            minIndex = noIndex;

            noIndex = n;okIndex = -1;
            while(okIndex + 1 < noIndex){
                mid = (noIndex + okIndex) /2;
                if(l[mid] <= max){
                    okIndex = mid;
                }else{
                    noIndex = mid;
                }
            }
            maxIndex = noIndex;

            // debug(max);
            // debug(min);
            // debug(maxIndex);
            // debug(minIndex);

            if(maxIndex < minIndex) continue;

            result += maxIndex - minIndex - 1;
            if(minIndex < i && i < maxIndex) result--;
            if(minIndex < j && j < maxIndex) result--;
        }
    }
    cout << result / 3 << endl;
}

Measured memory_bytes: 256
let (n, k) = readInts().mapToTuple()
let ps = readInts()
print(ps.sorted()[..<k].reduce(0, +))


// MARK: -----------------------------------------------------------------------


func readInt() -> Int {
    Int(readLine()!)!
}

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

extension Collection {
    func mapToTuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }
}

struct DP<Argument: Hashable, Element> {
    var dictionary = [Argument: Element]()
    
    var expression: (Argument, (Argument) -> Element) -> Element
    
    init(expression: @escaping (_ argument: Argument, _ note: (Argument) -> Element) -> Element) {
        self.expression = expression
    }
    
    subscript(_ argument: Argument) -> Element {
        mutating get {
            if let note = dictionary[argument] {
                return note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                return result
            }
        }
    }
}


Measured memory_bytes: 8416
n = int(input())
nums = list(map(int,input().split()))
limit = 10**18
res = 1
i = 0
if 0 in nums:
    print(0)
    exit()
while i<n:
    res *= nums[i]
    i += 1
    if res > limit:
        res = -1
        break
print(res)

Measured memory_bytes: 21580