akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
using namespace std;
int n,a[100005],lft=2147483647,rht=-2147483647,middle,cnt[100005],tree[100005];
inline int min(int a,int b){
	if(a<b){
		return a;
	}
	return b;
}
inline int max(int a,int b){
	if(a>b){
		return a;
	}
	return b;
}
inline int lowbit(int x){
	return x&(-x);
}
inline void insert(int i,int x){
	while(i<=n){
		tree[i]+=x;
		i+=lowbit(i); 
	}
}
inline int getsum(int i){
	int ans=0;
	while(i>0){
		ans+=tree[i];
		i-=lowbit(i);
	}
	return ans;
}
inline bool check(int x){
	long long ans=0;
	int mn=n;
	for(register int i=1;i<=n;i++){
		cnt[i]=1;
		if(a[i]>=x){
			cnt[i]=-1;
		}
	}
	for(register int i=1;i<=n;i++){
		cnt[i]+=cnt[i-1];
		if(cnt[i]>0){
			ans++;
		}
		mn=min(mn,cnt[i]); 
	}
	for(register int i=1;i<=n;i++){
		tree[i]=0;
		cnt[i]+=1-mn;
	}
	for(register int i=1;i<=n;i++){
		ans+=getsum(cnt[i]-1);
		insert(cnt[i],1); 
	}
	if(ans<=1ll*n*(n+1)/4){
		return true;
	}
	return false;
}
int main(){
	scanf("%d",&n);
	for(register int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		lft=min(lft,a[i]);
		rht=max(rht,a[i]);
	}
	while(lft+1<rht){
		middle=(lft+rht)/2;
		switch(check(middle)){
			case true:lft=middle;break;
			case false:rht=middle-1;break;
		}
	}
	if(check(rht)==true){
		printf("%d\n",rht);
	}
	else{
		printf("%d\n",lft);
	}
	return 0;
} 

Measured memory_bytes: 4940
#include<cstdio>
#include<algorithm>
using namespace std;

int n[5];

int main(){
	while(scanf("%d,%d,%d,%d,%d",&n[0],&n[1],&n[2],&n[3],&n[4])!=EOF){
		sort(n,n+5);
		if((n[0]==n[1]&&n[1]==n[2]&&n[2]==n[3])||(n[1]==n[2]&&n[2]==n[3]&&n[3]==n[4])) printf("four card\n");
		else if((n[0]==n[1]&&n[1]==n[2]&&n[3]==n[4])||(n[0]==n[1]&&n[2]==n[3]&&n[3]==n[4])) printf("full house\n");
		else if((n[4]==n[3]+1&&n[3]==n[2]+1&&n[2]==n[1]+1&&n[1]==n[0]+1)||(n[0]==1&&n[1]==10&&n[2]==11&&n[3]==12&&n[4]==13)) printf("straight\n");
		else if((n[0]==n[1]&&n[1]==n[2])||(n[1]==n[2]&&n[2]==n[3])||(n[2]==n[3]&&n[3]==n[4])) printf("three card\n");
		else if((n[0]==n[1]&&n[2]==n[3])||(n[0]==n[1]&&n[3]==n[4])||(n[1]==n[2]&&n[3]==n[4])) printf("two pair\n");
		else if(n[0]==n[1]||n[1]==n[2]||n[2]==n[3]||n[3]==n[4]) printf("one pair\n");
		else printf("null\n");
	}
	return 0;
}

Measured memory_bytes: 2496
#include <iostream>

using namespace std;

int main()
{
   int n,a[20], b[20],c[20],sum=0;
   cin>>n;
   for(int i=0;i<n;i++)cin>>a[i];
   for(int i=0;i<n;i++)cin>>b[i];
   for(int i=0;i<n-1;i++)cin>>c[i];
   for(int i=0;i<n;i++)
   {
       sum+=b[a[i]-1];
       if(a[i]-1==a[i-1]&&i)
            sum+=c[a[i-1]-1];
   }

   cout<<sum;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
#define int long long
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;

int N,A,B,C;
int X[10];
int T[10];
int Min2=INF;

signed main(){
	cin>>N>>A>>B>>C;
	T[0]=A,T[1]=B,T[2]=C;
	sort(T,T+3);
	REP(i,N){
		cin>>X[i];
	}
	int f=1;
	REP(i,(int)pow(4,N)){
		int sum=0;
		int b=1;
		int s[10]={};
		int d[10]={};
		int dc[10]={};
		REP(j,N){
			if((i/b)%4==0){
				s[0]+=X[j];
				dc[0]++;
				if(dc[0]>=2){
					d[0]+=10;
				}
			}
			else if((i/b)%4==1){
				s[1]+=X[j];
				dc[1]++;
				if(dc[1]>=2){
					d[1]+=10;
				}
			}
			else if((i/b)%4==2){
				s[2]+=X[j];
				dc[2]++;
				if(dc[2]>=2){
					d[2]+=10;
				}
			}
			b*=4;
		}
		if(dc[0]==0||dc[1]==0||dc[2]==0){
			continue;
		}
		sort(s,s+3);
		sum+=abs(s[0]-T[0]);
		sum+=abs(s[1]-T[1]);
		sum+=abs(s[2]-T[2]);
		sum+=d[0]+d[1]+d[2];
		Min2=min(Min2,sum);
	}
	cout<<Min2<<endl;
	return 0;
}


Measured memory_bytes: 256
N, M, R = map(int, input().split())
R_LIST = list(map(int, input().split()))
ABC = []
for _ in range(M):
    a,b,c = map(int, input().split())
    ABC.append((a,b,c))
    
    
edges = ABC[:]


def warshall_floyd(d, n):
    # d: グラフ二次元リスト
    # n: 頂点数 (0始まり)
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

# グラフ無効グラフ化
graph = [[float("inf") for i in range(N+1)] for i in range(N+1)] 
for x,y,z in edges:
    graph[x][y] = z
    graph[y][x] = z
for i in range(N+1):
    graph[i][i] = 0 #自身のところに行くコストは０

#最短経路
shortest =  warshall_floyd(graph, N+1)
    
# 順列全探索
import sys
INT_MAX = sys.maxsize # 9223372036854775807
ans = INT_MAX

import queue

rest = set(R_LIST[:])

import copy  
def dfs(cost,pre,rest):
    if len(rest) == 0:
        return cost
    
    ret = INT_MAX
    for r in rest:
        if pre == None:
            next_cost = 0
        else:
            next_cost = cost + shortest[pre][r]
        next_rest = copy.copy(rest)
        next_rest.remove(r)
        
        tmp_ret = dfs(next_cost, r, next_rest)
        ret = min(ret, tmp_ret)
        
    return ret
        
    

print(dfs(0, None, rest))
            
      
        
        



Measured memory_bytes: 75092
import java.util.*;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Long c = sc.nextLong();
        Long k = sc.nextLong();
        List<Long> t = new ArrayList<>();
        IntStream.range(0, n).forEach(i -> t.add(sc.nextLong()));
        Collections.sort(t);
        Deque<Long> queue = new ArrayDeque<>(t);

        Long count = 0L;
        while (queue.size() != 0) {
            count++;
            Long target = queue.remove();
            Long rider = 1L;
            while (queue.size() != 0 && queue.element() <= target + k && rider < c) {
                rider++;
                queue.remove();
            }
        }
        System.out.println(count);

    }

}


Measured memory_bytes: 56068
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,i,k,j;
    cin>>n>>k;
    int a[n];
    for(i=0;i<n;++i)
        cin>>a[i];
    int dp[n];
    dp[0] = 0;
    for(i=1;i<n;++i)
    {
        dp[i] = INT_MAX;
        for(j=i-1;j>=max(0,i-k);--j)
            dp[i] = min(dp[i],dp[j]+abs(a[i]-a[j]));
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
    public static int max(int a, int b){return (a > b ? a : b);}
    public static int min(int a, int b){return (a < b ? a : b);}
    public static int gcd(int a, int b){return (b > 0 ? gcd(b, a % b) : a);}
    public static int lcm(int a, int b){return a / gcd(a, b) * b;}
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int[][] A = new int[3][3] ;
        int[][] B = new int[3][3];
        for(int y = 0; y < 3; y++){
            for(int x = 0; x < 3; x++){
                A[y][x] = sc.nextInt();
            }
        }
        int N = sc.nextInt();
        for(int i = 0; i < N; i++){
            int b = sc.nextInt();
            for(int y = 0; y < 3; y++){
               for(int x = 0; x < 3; x++){
                    if(A[y][x] == b)B[y][x] = 1;
                }
            }
        }
        String ans = "No";
        if(B[0][0] + B[1][1] + B[2][2] == 3)ans = "Yes";
        if(B[2][0] + B[1][1] + B[0][2] == 3)ans = "Yes";
        for(int i = 0; i < 3; i++){
            if(B[i][0] + B[i][1] + B[i][2] == 3)ans = "Yes";
            if(B[0][i] + B[1][i] + B[2][i] == 3)ans = "Yes";
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  map<string, long long> m;
  for (int i = 0; i < N; ++i) {
    string tmp;
    cin >> tmp;
    sort(tmp.begin(), tmp.end());
    if (m.find(tmp) == m.end())
      m[tmp] = 0;
    ++m[tmp];
  }

  long long ret = 0;
  for (map<string, long long>::iterator i = m.begin(); i != m.end(); ++i) {
    if (i->second == 1)
      continue;
    ret += i->second * (i->second - 1) / 2;
  }

  cout << ret << endl;

  return 0;
}

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

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

   if (n == 0) {
       cout << x << endl;
       return 0;
   }
   vector<int> p(n);
   rep(i, n) {
       cin >> p[i];
   }

   sort(p.rbegin(), p.rend());

   int ans = 0, min = 102, j = 0;
   for (int i=101; i>=0; i--) {
       if (p[j] == i) {
           if (j < n-1) j++;
           continue; 
       }
       if (min >= abs(x-i)) {
           min = abs(x-i);
           ans = i;
       }
   }

   cout << ans << endl;
}

Measured memory_bytes: 3600
n,m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
s = sum(a)
t = s/(4*m)
ans = "Yes"
for num,i in enumerate(a):
  if num == m:
    break
  elif i<t:
    ans = "No"
    break
print(ans)

Measured memory_bytes: 3060
A = [3, 5, 7]
B = [3, 5, 7]
for i in range(9):
    C = []
    for b in B:
        C.append(10*b+3)
        C.append(10*b+5)
        C.append(10*b+7)
    A += C
    B = C
n = int(input())
c = 0
for a in A:
    if a > n:
        break
    if set(list(str(a))) == {'3', '5', '7'}:
        c += 1
print(c)


Measured memory_bytes: 7796
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll dp[3000][3002];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N;
    string S;
    cin >> N >> S;
    dp[0][1] = 1;
    dp[0][N+1] = -1;
    for(int i = 0; i < N-1; i++){
        for(int j = 1; j <= N; j++){
            dp[i][j] += dp[i][j-1];
            dp[i][j] %= MOD;
        }
        if(S[i] == '>'){
            for(int j = 1; j <= N-i; j++){
                dp[i+1][1] += dp[i][j];
                dp[i+1][1] %= MOD;
                dp[i+1][j] -= dp[i][j];
                dp[i+1][j] += MOD;
                dp[i+1][j] %= MOD;
            }
        }else{
            for(int j = 1; j <= N-i; j++){
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
                dp[i+1][N-i] -= dp[i][j];
                dp[i+1][N-i] += MOD;
                dp[i+1][N-i] %= MOD;
            }
        }
    }
    // for(int i = 0; i < N; i++){
    //     for(int j = 1; j <= N-i; j++){
    //         cout << dp[i][j] << ' ';
    //     }
    //     cout << endl;
    // }
    cout << dp[N-1][1] << endl;
}

Measured memory_bytes: 70656
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			byte[] hand = new byte[5];
			hand[0] = sc.nextByte();
			if(hand[0] == 0) break;
			for(int i=1;i<5;i++) hand[i] = sc.nextByte();
			boolean rps[] = new boolean[3];
			for(int i=0;i<5;i++) rps[ hand[i] -1 ] = true;
			if( (rps[0]&rps[1]&rps[2]) || (rps[0]&!rps[1]&!rps[2]) || 
				 (!rps[0]&rps[1]&!rps[2]) || (!rps[0]&!rps[1]&rps[2]) ) {
				for(int i=0;i<5;i++) {
					System.out.println(3);
				}
			}
			else if( rps[0]&rps[1] ) {
				for(int i=0;i<5;i++)
					System.out.println( ( (hand[i]==1)? 1:2 ) );
			}
			else if( rps[1]&rps[2] ) {
				for(int i=0;i<5;i++)
					System.out.println( ( (hand[i]==2)? 1:2 ) );
				}
			else {
				for(int i=0;i<5;i++)
					System.out.println( ( (hand[i]==3)? 1:2 ) );
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

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

int main() {
    int n;
    cin >> n;
    int keep[100005] = {0};
    
    long long sum(0);    

    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        sum += (long long)x;
        keep[x]++;
    }
    int q; cin >> q;
    while (q--) {
        int b,c;
        cin >> b >> c;
        sum -= (b * keep[b]);
        sum += (c * keep[b]);
        keep[c] += keep[b];
        keep[b] = 0;
        cout << sum << "\n";
    }
    return 0;
}

Measured memory_bytes: 3556
from collections import Counter


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


N = int(input())
A = inpl()

oe = [0, 0]
for k, v in Counter(A).items():
    oe[v % 2] += 1

if oe[0] % 2 == 0:
    print(sum(oe))
else:
    print(sum(oe) - 1)


Measured memory_bytes: 18656
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main (){
  int a,b,d,k;
  cin >> a >> b >> k;
  d = min(a,b);
  vector <int> Num;
  for (int i = 1; i <= d; i++){
    if(a % i == 0 && b % i == 0){
      Num.push_back(i);
    }
  }
  cout << Num[Num.size() - k ] << endl;
  return 0;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;

ll f(ll a){
    if(a <= 0) return 0;

    if(a%4 == 3) return 0;
    if(a%4 == 0) return a;
    if(a%4 == 1) return a^(a-1);
    if(a%4 == 2) return a^(a-1)^(a-2);

    return -1;
}

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

    ll a, b; cin >> a >> b;

    cout << (f(a-1)^f(b)) << endl;

    return 0;
}

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

int main() {
	int n; cin >> n;
	int64_t L; cin >> L;
	int64_t l[n], r[n];
	for(int i = 0; i < n; ++i) {
		cin >> l[i] >> r[i];
	}
	{ // x
		// {l, r}
		pair<int64_t, int64_t> p[n];
		for(int i = 0; i < n; ++i) {
			p[i] = {l[i], r[i]};
		}
		sort(p, p + n);
		int64_t rr = 0;
		int64_t maxi = 0;
		int ans = 0;
		for(int i = 0; i < n; ++i) {
			int64_t l, r;
			tie(l, r) = p[i];
			if(l <= rr) {
				maxi = max(maxi, r);
			} else {
				rr = maxi;
				maxi = r;
				++ans;
			}
		}
		if(rr < L) {
			++ans;
		}
		cout << ans << " ";
	}
	{ // y
		map<int64_t, int> mp;
		for(int i = 0; i < n; ++i) {
			mp[l[i]]++;
			mp[r[i]]++;	
		}
		int idx = 0;
		for(auto &e : mp) {
			e.second = idx;
			idx++;
		}
		int imos[3 * n] = {};
		for(int i = 0; i < n; ++i) {
			imos[mp[l[i]]]++;
			imos[mp[r[i]] + 1]--;
		}
		for(int i = 1; i < 3 * n; ++i) {
			imos[i] += imos[i - 1];
		}
		int ans = n;
		for(int i = 0; i < 3 * n; ++i) {
			if(imos[i] > 0) {
				ans = min(ans, imos[i]);
			}
		}
		cout << n - ans + 1 << '\n';
	}
	return 0;
}


Measured memory_bytes: 33208
#include <bits/stdc++.h>
using namespace std;
 
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 if(d==22){
    cout << "Christmas Eve Eve Eve" <<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr << #x << ":" << (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;

	VAR(int, x, y);
	string ans = (abs(x - y) <= 1 ? "Brown" : "Alice");
	OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>

using namespace std;

int main(void) {
	int h, w;
	cin >> h >> w;
	vector<string>c(h);
	for (int i = 0; i < h; i++)cin >> c[i];
	for (int i = 0; i < h; i++) {
		cout << c[i];
		cout << endl;
		cout << c[i];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import itertools
import heapq
import functools
import operator

n = int(input())
a = list(map(int, input().split()))

desc_lengths = list(
  itertools.chain(
    *(
      [length, length] if count >= 4 else [length] if count >= 2 else []
      for (length, count)
      in [
        (length, sum(1 for _ in iter))
        for (length, iter)
        in itertools.groupby(sorted(a))
      ]
    )
  )
)
print(functools.reduce(operator.mul, heapq.nlargest(2, desc_lengths)) if len(desc_lengths) >= 2 else 0)


Measured memory_bytes: 22604
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    int N; cin>>N;
    vector<int> L(N);
    for (int i = 0; i < N; ++i) cin>>L[i];
    int ans = 0;
    sort(L.begin(), L.end());
    for (int i = 0; i < N-2; ++i) {
        for (int j = i+1; j < N-1; ++j) {
            int len = L[i]+L[j];
            for (int k = j+1; k < N; ++k) {
                if(L[k]<len) {
                    ans++;
                }else break;
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[4][13] = {};
    int x, y;
    char c[] = "SHCD";
    char b;
    rep(i, n){
        cin >> b >> y;
            rep(j, 4) if(b == c[j]) x = j;
            a[x][y - 1] = 1;
    }
    rep(i, 4){
        rep(j, 13){
            if(a[i][j] == 0) cout << c[i] << " " << j + 1 << endl;
        }
    }
}





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

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_op(i, a, n) for (int i = a; i < n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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

const int MOD = 1000000007;

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

bool is_prime(int x)
{
    if (x <= 1)
    {
        return false;
    }
    for (int i = 2; i * i <= x; i++)
    {
        if (x % i == 0)
        {
            return false;
        }
    }
    return true;
}

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

    vector<int> v;
    rep(i, n) v.push_back(i + 1);

    int idx = 0;
    int a = -1;
    int b = -1;

    do
    {
        bool ok = true;

        rep(i, n)
        {
            if (v[i] != p[i])
            {
                ok = false;
            }
        }
        if (ok)
        {
            a = idx;
        }

        ok = true;

        rep(i, n)
        {
            if (v[i] != q[i])
            {
                ok = false;
            }
        }
        if (ok)
        {
            b = idx;
        }
        idx++;
    } while (next_permutation(v.begin(), v.end()));
    cout << abs(a - b) << endl;
}


Measured memory_bytes: 256
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1)}([function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";var n=r(2);r(3)(n.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(4),i=r(5);t.exports=function(t){var e=new n(t);i(e)}},function(t,e,r){"use strict";var n=r(0);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new n(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";var n=r(0);t.exports=function(t){for(var e=t.in(),r=new Array(e),i=new Array(e),s=0;s<e;s++)r[s]=t.in(),i[s]=t.in();for(var o=0,u=0,a=new n,c=0;c<e;c++){var f=new Array(e).fill(0);f[c]=1,a.enq({d:0,dist:0,now:c,used:f})}for(;a.size>0;){var d=a.deq();if(d.d!=e-1){for(var l=0;l<e;l++)if(1!=d.used[l]){var p=d.used.concat();p[l]=1;var v=(r[d.now]-r[l])*(r[d.now]-r[l]),h=(i[d.now]-i[l])*(i[d.now]-i[l]),y=Math.sqrt(v+h),b=d.dist+y;a.enq({d:d.d+1,dist:b,now:l,used:p})}}else o+=d.dist,u++}var w=o/u;console.log(w)}}]);

Measured memory_bytes: 51532
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main(){
    let h: usize = read();
    let w: usize = read();
    let map:Vec<Vec<char>> = (0..h).map(|_| read::<String>().chars().collect()).collect();
    let mut line = 0;
    let mut start = 0;

    let mut trace: Vec<Vec<bool>> = vec![vec![true;w];h];

    for (i,l) in map.iter().enumerate(){
        for (j,c) in l.iter().enumerate(){
            if c == &'#' {
                trace[i][j] = false;
            }
        }
    }
 
    //println!("{:?}",trace);
    
    loop{
        for (i,c) in map[line][start..w].iter().enumerate(){
            //println!("line:{} start:{} i:{}",line,start,i);
            if c == &'.'{
                line += 1;
                if i != 0 {
                    start += i - 1;
                }
                break;
            }
            if start + i + 1 == w {
                trace[line][start+i] = true;
                line += 1;
                if i != 0 {
                    start += i;
                }
                break;
            }
            trace[line][start+i] = true;
        }
        if line == h {
            break;
        }
    }

    let mut ans = true;
    for i in trace.iter(){
        for j in i.iter(){
            if *j == false {
                ans = false;
            }
        }
    }

    println!("{}", if ans { "Possible" } else { "Impossible" });
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	sort(b.begin(),b.end());
	reverse(b.begin(),b.end());
	sort(a.begin(),a.end());
	if(b>a) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % mod;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}
long long power(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

const ll INF = 1LL << 60;

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

ll nCkmod(ll n, ll k) {
    ll denomi = 1;
    for (int i = n; i > n - k; i--) {
        denomi *= i;
        denomi %= mod;
    }
    ll numera = 1;
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}
vector<vector<ll>> graph;
vector<ll> as;
map<P, ll> number;
ll n;
ll memo[3001][3001];
ll func(ll first, ll length) {
    if (length == 0) {
        return 0;
    }
    if (memo[first][length] != INF) {
        return memo[first][length];
    }
    ll a, b;
    a = func(first, length - 1);
    b = func(first + 1, length - 1);
    memo[first][length] = max(-a + as[length - 1 + first], -b + as[first]);
    return memo[first][length];
}
int main() {
    string s;
    ll n;
    cin >> n;
    Fill(memo, INF);
    as.resize(n);
    REP(i, n) { cin >> as[i]; }
    cout << func(0, n) << endl;
}

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

a = 0
w = 0
t = 0
r = 0

for _ in range(n):
    s = input()
    if s == 'AC':
        a += 1
    elif s == 'WA':
        w += 1
    elif s == 'TLE':
        t += 1
    elif s == 'RE':
        r += 1

print('AC x ' + str(a))
print('WA x ' + str(w))
print('TLE x ' + str(t))
print('RE x ' + str(r))


Measured memory_bytes: 9204
#include "bits/stdc++.h"
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
int main(void) {
	int N, res = 0;
	cin >> N;
	vector<int> A(N);
	vector<int> L(N + 1, 0);
	vector<int> R(N + 1, 0);
	for (int i = 0; i < N; i++) { cin >> A[i]; }
	for (int i = 0; i < N; i++) { L[i + 1] = gcd(L[i], A[i]); }
	for (int i = N - 1; i >= 0; i--) { R[i] = gcd(R[i + 1], A[i]); }
	for (int i = 0; i < N; i++) { chmax(res, gcd(L[i], R[i + 1])); }
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c;
  bool ok = false; 
  cin >> a >> b >> c;
  for(int i=1;i<b;i++){
    if(a*i%b==c)ok =true;
  }
  if(ok)cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
//問題 E で AC したコード
#include <bits/stdc++.h>
using namespace std;

int main() {

 int H, N;
 cin >> H >> N;

 vector<int> A(N);
 vector<int> B(N);
 for (int i = 0; i < N; i++) {
   cin >> A[i] >> B[i];
 }

 // i 番目までの魔法からダメージの総和が j になるように選んだときの魔法消費量の総和の最小値
 vector<vector<int>> dp(N + 1, vector<int>(H + 1, 100000000));

 dp[0][0] = 0;

 for (int i = 0; i < N; i++) {
   for (int j = 0; j <= H; j++) {
     if (j <= A[i]) {
       dp[i+1][j] = min(dp[i][j], B[i]);
     } else {
       dp[i+1][j] = min(dp[i][j], dp[i+1][j - A[i]] + B[i]);
     }
   }
 }

 cout << dp[N][H] << endl;

}

Measured memory_bytes: 39424
#include <queue>
#include <cstdio>

using namespace std;

int main()
{
	int dp[18][18],n,a,b,kozix,koziy;
	bool map[18][18];

	while(scanf("%d %d",&a,&b) && a || b){
		for(int i = 0; i <= a+1; i++){
			for(int j = 0; j <= b+1; j++){
				dp[i][j] = 0;
				map[i][j] = true;
			}
		}
		for(int i = 0; i <= a+1; i++){
			map[i][0] = false;
			map[i][b+1] = false;
		}
		for(int i = 0; i <= b+1; i++){
			map[0][i] = false;
			map[a+1][i] = false;
		}
		
		scanf("%d",&n);
		for(int i = 0; i < n; i++){
			scanf("%d %d",&kozix,&koziy);
			map[kozix][koziy] = false;
		}
		
		dp[1][1] = 1;
		for(int y = 1; y <= b; y++){
			for(int x = 1; x <= a; x++){
				if(map[x][y]){
					dp[x][y] += dp[x-1][y];
					dp[x][y] += dp[x][y-1];
				}
			}
		}
		
		printf("%d\n",dp[a][b]);
	}
	

	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define f first
#define s second
using namespace std;
int a[100001];
int n, k;
int main(){
   cin >> n >> k;
   for(int i = 1; i <= n; i++)cin >> a[i];
   int cnt = 0;
   for(int i = 1; i <= n; i++){
    	int j;
    	for(j = i; j <= min(n, i+k-1) ; j++){
    	 	
    	}
    	cnt++;
    	if(j == n+1)break;
    	i = j-2;
   }
   cout << cnt << endl;
   return 0;
}                  


Measured memory_bytes: 3948
unittest
{
	assert( [ "41 2", "5 6" ].parse.expand.solve == 30 );
	assert( [ "10 2", "5 6" ].parse.expand.solve == -1 );
	assert( [ "11 2", "5 6" ].parse.expand.solve == 0 );
	assert( [ "314 15", "9 26 5 35 8 9 79 3 23 8 46 2 6 43 3" ].parse.expand.solve == 9 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( nm[ 0 ], as );
}

auto solve( long n, long[] as )
{
	auto t = as.sum;
	return ( t <= n ) ? n - t : -1;
}


Measured memory_bytes: 3120
#include<iostream>
#include<stdio.h>
using namespace std;
int main() {
	int i, j, l;
	int aa, ab,ac,ad,ae,af,ag;
	double ba, bb, bc;
	char ca, cb, cc;
////////////////////////////////////////////////////////
	int max;
	cin >> ag;
	for (i = 0; i < ag; i++) {
		cin >> aa;
		cin >> ab;
		cin >> ac;
		if (aa < ab) {
			max = aa;
			aa = ab;
			ab = max;
		}
		if (aa < ac) {
			max = aa;
			aa = ac;
			ac = max;
		}
		if (ab * ab + ac * ac == aa * aa) {
			cout << "YES\n";
		}
		else {
			cout << "NO\n";
		}

	}


}



Measured memory_bytes: 3088
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
H = list(map(lambda x: T - 0.006 * x, H))
tmp = 10**100
ans = 0
for i in range(N):
    if abs(H[i] - A) < tmp:
        tmp = abs(H[i] - A)
        ans = i
print(ans + 1)


Measured memory_bytes: 3060
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

Q,H,S,D=get_i
N=gets.to_i
h=[Q*2,H].min
s=[S,h*2].min
d=[D,s*2].min
puts N/2*d+N%2*s

Measured memory_bytes: 14320
def Base_10_to_n(X, n):
    X_dumy = X
    out = []
    while X_dumy > 0:
        X_dumy-=1
        out.append(X_dumy % n)
        X_dumy = int(X_dumy / n)
    return out

n = int(input())
d = {y: x for x, y in zip("abcdefghijklmnopqrstuvwxyz", range(26))}

res = []
array = Base_10_to_n(n, 26)

print("".join([d[x] for x in array[::-1]]))

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
int main()  
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int n, m, x, y;
    cin >> n >> m;
    int a[n];
    for (int &i: a) cin >> i;
    std::vector<int> g[n + 1];
    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        g[x - 1].push_back(y - 1);
        g[y - 1].push_back(x - 1);
    }
    std::map<int, int> mp;
    int res = 0;
    for (int i = 0; i < n; i++) {
        if (!mp[i]) {
            mp[i] = 1;
            bool flag = 1;
            for (int &j: g[i]) {
                if (a[j] >= a[i]) {
                    flag = 0;
                    break;
                }
                else {
                    mp[j] = 1;
                }
            }
            if (flag) res++;
        }
    }
    cout << res << "\n";
	// your code goes here
	return 0;
}

Measured memory_bytes: 13860
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, m, cost[105][105], pre[105], d[105], INF = 10000;
bool used[105];

void dijkstra(int s) {
	fill(d, d+n, INF);
	fill(used, used+n, false);
	fill(pre, pre+n, -1);
	d[s] = 0;
	
	while (true) {
		int v = -1;
		FOR(u, n) {
			if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
		}
		if (v == -1) break;
		used[v] = true;
		FOR(u, n) {
			if (d[u] > d[v] + cost[v][u]) {
				d[u] = d[v] + cost[v][u];
				pre[u] = v;
			}
		}
	}
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	MEM(cost, INF);
	map<pair<int, int>, int> mp;
	FOR(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		cost[a-1][b-1] = c;
		cost[b-1][a-1] = c;
		mp[make_pair(min(a-1, b-1), max(a-1, b-1))]++;
	}
	map<pair<int, int>, int> mp2;
	FOR(i, n) {
		dijkstra(i);
		FOR(j, n) {
			// cout <<  j << ": " << d[j] << " ";
			if (i == j) continue;
			int t = j;
			for ( ; t != -1; t = pre[t]) {
				if (pre[t] == -1) continue;
				mp2[make_pair(min(t, pre[t]), max(t, pre[t]))]++;
				// cout << i << " " << j << " " << t << " " << pre[t] << endl;
			}
		}
		// cout << endl;
	}
	// for (auto itr = mp2.begin(); itr != mp2.end(); itr++) cout << itr->first.first << " " << itr->first.second << endl;
	// cout << mp.size() << endl;
	cout << mp.size()-mp2.size() << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int main() {
  string S;
  cin >> S;
  if (S.at(S.size() - 1) == 's') {S += "es";}
  else {S += "s";}
  cout << S << endl;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt(); 
        int n = sc.nextInt();
        if(x >= n) {
            System.out.println(10);
        } else {
            System.out.println(0);
        }
    }
}

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

class Program {
    static void Main() {
        Scanner cin = new Scanner();
        int N = cin.Int();
        var v = cin.ArrayInt(N);

        var odd = new Dictionary<int, int>();
        var even = new Dictionary<int, int>();
        for (int i = 0; i < N; i++) {
            if(i % 2 == 0) {
                if (even.ContainsKey(v[i])) even[v[i]]++;
                else even[v[i]] = 1;
            }
            else {
                if (odd.ContainsKey(v[i])) odd[v[i]]++;
                else odd[v[i]] = 1;
            }
        }

        odd = odd.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);
        even = even.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);

        if(odd.Keys.ElementAt(0) != even.Keys.ElementAt(0)) {
            Console.WriteLine(N - odd.Values.ElementAt(0) - even.Values.ElementAt(0));
        }
        else {
            int odd_second = 0, even_second = 0;
            if (odd.Keys.Count > 1) odd_second = odd.Values.ElementAt(1);
            if (even.Keys.Count > 1) even_second = even.Values.ElementAt(1);
            Console.WriteLine(Math.Min(N - odd.Values.ElementAt(0) - even_second, N - odd_second - even.Values.ElementAt(0)));
        }
        
        Console.ReadLine();
    }
}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 30048
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
	
		Long [] m = new Long[n];

		for (int i = 0 ; i < n ; i++) {
			m[i] = Long.parseLong(sc.next());
		}
		
        Arrays.sort(m, Collections.reverseOrder());

		Long ans = 0l;
		
		if(n <= k) {
	
		}else {
			for (int i = k ; i < n ; i++) {
				ans += m[i]; 
			}
			
		}
		
		
		System.out.println(ans);
	}
	
	
	

}

Measured memory_bytes: 68168
s = list(input())
ans = 0
for i in range(1,len(s)):
  if i % 2 != 0:
    s.pop()
    continue
  else:
    s.pop()
    s1 = s[0:(len(s)//2)]
    s2 = s[(len(s)// 2) :]
    if s1 == s2:
      ans = len(s)
      break
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int n, m;
	cin >> n >> m;
	cout << n*(n-1)/2 + m*(m-1)/2 << endl; 
 	return 0;
 }

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#define ll long long
using namespace std;
string S;
int main(){
     cin >> S;
     vector<char> T;
     int counter = 0;
     int result = 0;
     T.resize(S.size());
     T[0] = S[0];
     for(int i = 1; i < S.size(); i++){
          if(counter%2 == 0 && S[0] == '0'){
               T[i] = '1';
          }else if(counter%2 == 1 && S[0] == '0'){
               T[i] = '0';
          }else if(counter%2 == 0 && S[0] == '1'){
               T[i] = '0';
          }else if(counter%2 == 1 && S[0] == '1'){
               T[i] = '1';
          }
          if(T[i] != S[i]){
               result++;
          }
          counter++;
     }
     cout << result << endl;
     return 0;
}

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

using namespace std;

string s;
int K;
long long int ans;

long long int Comb(long long int n,long long int m)
{
	if(m>n)
	    return 0;
	if(m==n || m==0)
	    return 1;
	if(m==1)
	    return n;
	if(m==2)
	    return n*(n-1)/2;
}

int main()
{
	cin>>s;
	scanf("%d",&K);
	if(K==1)
	{
		for(int i=1;i<=9;i++)
		{
			for(int j=1;j<s.size();j++)
			    ans++;
			if(i<=s[0]-'0')
			    ans++;
		}
	}
	if(K==2)
	{
		for(int i=1;i<=9;i++)
		{
			for(int j=1;j<=9;j++)
			{
				for(int k=2;k<s.size();k++)
					ans=ans+Comb(k-1,1);
				if(i<s[0]-'0')
					ans=ans+Comb(s.size()-1,1);
				else
				{
					if(i==s[0]-'0')
					{
						int loc=s.size();
						for(int k=1;k<s.size();k++)
						{
							if(s[k]!='0')
							{
								loc=k;
								break;
							}
						}
						if(loc<s.size())
						{
							ans=ans+s.size()-loc-1;	
						    if(j<=s[loc]-'0')
						        ans++;
						}		      
					}
				}
			}
		}
	}
	if(K==3)
	{
		for(int i=1;i<=9;i++)
		{
			for(int j=1;j<=9;j++)
			{
				for(int k=1;k<=9;k++)
				{
					for(int l=3;l<s.size();l++)
					    ans=ans+Comb(l-1,2);
					if(i<s[0]-'0')
					    ans=ans+Comb(s.size()-1,2);
					else
					{
						if(i==s[0]-'0')
						{
							int loc=s.size()-1;
							for(int l=1;l<s.size()-1;l++)
							{
								if(s[l]!='0')
								{
									loc=l;
									break;
								}
							}
							if(loc<s.size()-1)
							{
								if(j<s[loc]-'0')
								{
									ans=ans+Comb(s.size()-loc-1,1);
							        if(loc<s.size()-2)
							            ans=ans+Comb(s.size()-loc-1,2);
								}
								else
								{
									if(j==s[loc]-'0')
									{
										if(loc<s.size()-2)
							                ans=ans+Comb(s.size()-loc-1,2);
										int loc1=s.size();
								    	for(int l=loc+1;l<s.size();l++)
									    {
									    	if(s[l]!='0')
										    {
											    loc1=l;
						    					break;
							    			}
								    	}
									    if(loc1<s.size())
									    {
										    ans=ans+(long long)(s.size()-1-loc1);
										    if(k<=s[loc1]-'0')
										        ans++;
									    }
									}
									if(j>s[loc]-'0' && loc<s.size()-1)
								        ans=ans+Comb(s.size()-1-loc,2);
								}
							}
						}
					}
				}
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=sorted(limii())

s = [0]
for i in range(0, n):
    s.append(s[i] + arr[i])

#arr 1 3 4
#s [0, 1, 4, 8]

ans=0

for i in range(n):
    if s[i]*2>=arr[i]:
        ans+=1
    else:
        ans=0
print(ans+1)


Measured memory_bytes: 88940
#include<stdio.h>

int main(void) {
	int i, n, a, b, c, d;
	while (scanf("%d", &n) != EOF) {
		i = 0;
		for (a = 0; a<10; a++)
			for (b = 0; b<10; b++)
				for (c = 0; c<10; c++)
					for (d = 0; d<10; d++)
						if (a + b + c + d == n)i++;
		printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 596
import scala.io.StdIn.readLine

object Main extends App {
  val w = readLine

  var ans = 0
  while (true) {
    val line = readLine
    if (line == "END_OF_TEXT") {
      println(ans); sys.exit
    }
    val words = line.toLowerCase.split(" ")
    ans += words.count(e => e == w)
  }
}


Measured memory_bytes: 43928
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const int mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

int n, m;
vector<int> graph[1005];
int matrix[1005][1005];

vector<int> search(int st){
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    dist[st] = 0;
    queue<int> que;
    que.push(st);
    while(!que.empty()){
        int u = que.front();
        que.pop();
        for(int v : graph[u]){
            if(dist[v] != INF)  continue;
            dist[v] = dist[u] + 1;
            pre[v] = u;
            que.push(v);
        }
    }

    P best = P(INF, -1);
    for(int i = 0; i < n; ++i){
        if(i == st) continue;
        if(matrix[i][st]){
            if(dist[i] < best.first){
                best = P(dist[i], i);
            }
        }
    }

    int v = best.second;
    if(v == -1) return vector<int>(n+1, -1);
    vector<int> res;
    while(v != -1){
        res.push_back(v + 1);
        v = pre[v];
    }
    reverse(res.begin(), res.end());
    return res;
}

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

    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        --a, --b;
        graph[a].push_back(b);
        matrix[a][b] = 1;
    }
    
    vector<int> res(n+1, -1);
    for(int i = 0; i < n; ++i){
        vector<int> now = search(i);
        if(now.size() < res.size()) res = now;
    }

    int sz = res.size();
    if(sz == n + 1){
        cout << -1 << "\n";
        return 0;
    }
    cout << sz << "\n";
    for(int i = 0; i < sz; ++i) cout << res[i] << "\n";
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

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

    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    if (e-a <= k) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
    return 0;
}

Measured memory_bytes: 256