akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

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

int where(char c){
  if(c=='1' or c=='4' or c=='7') return 0;
  if(c=='2' or c=='8') return 1;
  if(c=='3' or c=='6' or c=='9') return 2;
}

void chmin(int &l, int r){if(l>r)l=r;}

int main(){

  while(true){
    string s; cin>> s;
    char c=s[0];
    if(c=='#') break;

    const int inf=1e5;
    int dp[3][3][2];
    rep(i, 3)rep(j, 3)rep(k, 2) dp[i][j][k]=inf;
    for(int j=where(s[0]); j<3; j++) dp[where(s[0])][j][0]=0;
    for(int j=0; j<=where(s[0]); j++) dp[j][where(s[0])][1]=0;
    for(int i=1; i<(int)(s.size()); i++){
      int cur=where(s[i]);
      int nex[3][3][2];
      rep(_i, 3)rep(_j, 3)rep(_k, 2) nex[_i][_j][_k]=inf;
      rep(l, 3)rep(r, 3){
        if(l<=cur) chmin(nex[l][cur][1], min(dp[l][r][0], dp[l][r][1]+1));
        if(cur<=r) chmin(nex[cur][r][0], min(dp[l][r][0]+1, dp[l][r][1]));
      }
      rep(_i, 3)rep(_j, 3)rep(_k, 2) dp[_i][_j][_k]=nex[_i][_j][_k];      
    }
    int mn=inf;
    rep(i, 3)rep(j, 3)rep(k, 2) chmin(mn, dp[i][j][k]);
    cout<< mn<< endl;
  }

  return 0;
}


Measured memory_bytes: 3268
T = str(input())
cdd =["dream","dreamer","erase","eraser"]

while len(T)>0:
    if T[-5:]=="dream":
        T= T[:-5]
    elif T[-7:]=="dreamer":
        T= T[:-7]
    elif T[-5:]== "erase":
        T= T[:-5]
    elif T[-6:]== "eraser":
        T= T[:-6]
    else: break
if len(T)==0:
    ans ="YES"
else:
    ans= "NO"
print(ans)

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

int main() {
    int N;
    cin>>N;
    vector<pair<int, int>> A(N);
    REP(i, 0, N){
        cin>> A[i].first;
        A[i].second = i+1;
    }
    sort(A.begin(), A.end());
    REP(i, 0, N) cout << A[i].second << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
#include<math.h>
int main(){
	int a[5];
	for(int i=1;i<=3;i++){
		scanf("%d",&a[i]);
	}
	for(int i=1;i<3;i++){
		int l=i;
		for(int j=i;j<=3;j++){
			if(a[l]>a[j])l=j;
		}
		int t=a[i];
		a[i]=a[l];
		a[l]=t;
	}
	printf("%.0f",fabs(a[3]-a[1]));
	
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<map>

using namespace std;

const int N = 100005;

int n, m, a[N];
map<int, int> c;
long long ans;

int main(){
	scanf("%d%d", &n, &m);
	c[0]++;
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		(a[i] += a[i-1]) %= m;
		ans += (c[a[i]]++);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3584
#include <iostream>

using namespace std;

int A[1000000], n;

int binarySearch(int key)
{
	int start = 0, end = n;
	while (start  < end) {
		int mid = (end - start) / 2 + start;
		if(A[mid] == key) return 1;
		else if(A[mid] < key) start = mid + 1;
		else end = mid;
	}
	return 0;
}

int main()
{
	int q, k, sum = 0;
	cin >> n;
	for(int i = 0;i < n; i++) {
		cin >> A[i];
	}

	cin >> q;
	for(int i = 0; i < q; i++) {
		cin >> k;
		if(binarySearch(k)) sum++;
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 3496
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n);(i)>=0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
 
int main(){
 lint N,K;
 cin>>N>>K;
 lint D[10];
 rep(i,K){
   cin>>D[i];
 }
 
 while(1){
   bool f=true;
   string s;
   s=to_string(N);
  rep(i,s.size()){
    rep(j,K){
      lint l;
      l=(s[i]-'0');
      if(l==D[j]){
      f=false;
      break;
      }
    }
    if(!f)break;
  }
  if(f){
    cout<<N<<endl;
    return 0;
  }
  N++;
 }
}

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

// --- DEBUG begin --- cut here ---
template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

template <class Head>
void dbgLog(Head&& head) {
  cerr << head << endl;
}

template <class Head, class... Tail>
void dbgLog(Head&& head, Tail&&... tail)
{
  cerr << head << " ";
  dbgLog(forward<Tail>(tail)...);
}

#if DEBUG
  #define DLOG(...)        dbgLog(__VA_ARGS__)
  #define DFMT(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DFMT(...)
  #define DCALL(func, ...)
#endif

// operator<< definitions for some classes

template <typename T1, typename T2>
ostream& operator<< (ostream& os, const pair<T1,T2>& p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}

template <typename T>
ostream& operator<< (ostream& os, const vector<T>& v) {
  os << '[';
  for (auto it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  os << ']';

  return os;
}

template <typename T, typename T2, typename T3>
ostream& operator<< (ostream& os, const priority_queue<T, T2, T3>& orig) {
  priority_queue<T, T2, T3> pq(orig);
  bool first = true;
  os << '[';
  while (!pq.empty()) {
    T x = pq.top(); pq.pop();
    if (!first) os << ", ";
    os << x;
    first = false;
  }
  return os << ']';
}
// --- DEBUG end --- cut here ---

ll pwr(ll b, ll r) {
  ll ans = 1;
  for (ll i = 0; i < r; i++) ans *= b;
  return ans;
}

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<vector<ll>> nbr(N);
  map<pair<ll, ll>, ll> ename;
  for (ll i = 0; i < N-1; i++) {
    ll a, b; cin >> a >> b; a--; b--;
    nbr.at(a).push_back(b);
    nbr.at(b).push_back(a);
    ename[make_pair(a, b)] = i;
    ename[make_pair(b, a)] = i;
  }
  vector<ll> parent(N);
  auto storeParent = [&](const auto& recF, ll i, ll p) -> void {
    parent.at(i) = p;
    for (ll c : nbr.at(i)) {
      if (c == p) continue;
      recF(recF, c, i);
    }
  };
  storeParent(storeParent, 0, -1);

  auto parentSeq = [&](ll n) -> ll {
    ll ret = 0;
    for ( ; n > 0; n = parent.at(n)) {
      ret |= (1LL << ename[make_pair(n, parent.at(n))]);
    }
    return ret;
  };
  
  ll M; cin >> M;
  vector<ll> conn(M);
  for (ll j = 0; j < M; j++) {
    ll u, v; cin >> u >> v; u--; v--;
    conn.at(j) = parentSeq(u) ^ parentSeq(v);
  }
  ll cnt = 0;
  for (ll x = 1; x < (1L << M); x++) {
    // vector<bool> vec(N-1);
    ll sunion = 0;
    for (ll i = 0; i < M; i++) {
      if (!(x & (1L << i))) continue;
      sunion |= conn.at(i);
    }
    ll c = __builtin_popcountll(sunion);
    DLOG("x, c", x, c);
    ll thisCnt = pwr(2, N-1 - c);
    if (__builtin_popcountll(x) % 2 == 1) cnt += thisCnt;
    else                                  cnt -= thisCnt;
  }
  cout << pwr(2, N-1) - cnt << endl;

  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define INF 1000000001
using namespace std;
typedef long long int ll;

int main()
{
	int n;
	scanf("%d", &n);
	int f[100];
	for(int i=0; i<n; i++){
		f[i]=0;
		for(int j=0; j<10; j++){
			int a;
			scanf("%d", &a);
			f[i]+=(a*(1<<j));
		}
	}
	int p[100][11];
	for(int i=0; i<n; i++){
		for(int j=0; j<=10; j++){
			scanf("%d", &p[i][j]);
		}
	}
	int ans=-INF;
	for(int i=1; i<1024; i++){
		int ans1=0;
		for(int j=0; j<n; j++){
			int x=(i&f[j]);
			int c=0;
			while(x>0){
				c+=(x%2);
				x/=2;
			}
			ans1+=p[j][c];
		}
		if(ans<ans1) ans=ans1;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[0])

ans = bought = 0
for a, b in AB:
    m = min(M - bought, b)
    bought += m
    ans += a * m
print(ans)


Measured memory_bytes: 23640
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I;
		var a=new string[n][];
		for(int i = 0;i<n;i++) {
			a[i]=sc.Sa2;
			a[i][2]=(i+1).ToString();
		}
		Array.Sort(a,Ca);
		for(int i = 0;i<n;i++) {
			Console.WriteLine("{0}",a[i][2]);
		}
	}
	static int Ca(string[] a,string[] b){
		if(a[0].CompareTo(b[0])==1){return 1;}
		else if(a[0].CompareTo(b[0])==-1){return -1;}
		else if(int.Parse(a[1])>int.Parse(b[1])){return -1;}
		else if(int.Parse(a[1])<int.Parse(b[1])){return 1;}
		else{return 0;}
	}
}

public class Sc{
	private string[] a;
	private int n=-1,m=0;
	public int I{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return int.Parse(a[n]);}}
	public long L{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return long.Parse(a[n]);}}
	public double D{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return double.Parse(a[n]);}}
	public string S{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return a[n];}}
	public string Sz{get{return Console.ReadLine();}}
	public int[] Ia{get{if(n!=-1&&n!=a.Length-1){m=n;n=-1;return Array.ConvertAll(a.Skip(m+1).ToArray(),int.Parse);}return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2(int b){return Array.ConvertAll((((b&1)!=0?"0 ":"")+Console.ReadLine()+((b&2)!=0?" 0":"")).Split(),int.Parse);}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public string[] Sa2{get{return (Console.ReadLine()+" 0").Split();}}
}


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

#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MAXN 10005
#define MAXM 100005
#define pi 3.14159265359

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef long long ll;
typedef priority_queue<int> pqi;
typedef priority_queue<pii, vpii, greater<pii> > dij;

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

	string N;

	cin >> N;
	for(auto x: N){
		if(x == '7'){
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";

	return 0;		
}



Measured memory_bytes: 3648
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int K,X;
    vector<int> ans;
    cin >> K >> X;
    REP(i,X-(K-1),X+K){
        ans.push_back(i);
    }
    REP(i,0,ans.size()-1){
        cout << ans[i]  << " ";
    }
    cout << ans[ans.size()-1] << endl;
}

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

const long long MOD = 1000000007;
const long long MAX = 2000000;

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

int main()
{
    long long N, K;
    cin >> N >> K;
    long long p[N];
    long long maxx = -1;
    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
        if(p[i]>maxx){
            maxx = p[i];
        }
    }
    long long ll[maxx + 1];
    for (int i = 0; i < maxx + 1;i++){
        ll[i] = i;
    }
    long long ll_ruiseki[maxx + 1];
    ll_ruiseki[0] = ll[0];
    for (int i = 1; i < maxx + 1;i++){
        ll_ruiseki[i] = ll_ruiseki[i - 1] + ll[i];
    }
    double ans[N];
    for (int i = 0; i < N;i++){
        ans[i] = (double)ll_ruiseki[p[i]] / (double)p[i];
    }
    /*for (int i = 0; i < N;i++){
        cout << ans[i] << endl;
    }*/
    double ans_ruiseki[N];
    ans_ruiseki[0] = ans[0];
    for (int i = 1; i < N;i++){
        ans_ruiseki[i] = ans_ruiseki[i - 1] + ans[i];
    }
    double ans_max = ans_ruiseki[K-1];
    for (int i = K ; i < N;i++){
        if(ans_ruiseki[i]-ans_ruiseki[i-K]>ans_max){
            ans_max=ans_ruiseki[i]-ans_ruiseki[i-K];
        }
    }
    
    cout << setprecision(10)<<ans_max << endl;
}


Measured memory_bytes: 4992
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from math import *
import random

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

N = int(input())
A = sorted(readln())
x,y = 0,0
for i in range(1,N):
    if(A[i] == A[i-1]):
        y = x
        x = A[i]
        A[i] = 0
print(x*y)


Measured memory_bytes: 16572
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int temp = (a + b + c) / 2;
		System.out.println((int)Math.sqrt(temp * (temp - a) * (temp - b) * (temp - c)));
	}
}


Measured memory_bytes: 26068
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
ll dx[4] = {1,0,0,-1};
ll dy[4] = {0,1,-1,0};

#define ARRAY_MAX 105

char mp[ARRAY_MAX][ARRAY_MAX];

int main(){

    int h,w;
    cin >> h >> w;
    vector<int> alpha(26,0);

    REP(i,h){
        REP(j,w){
            cin >> mp[i][j];
            alpha[mp[i][j]-'a']++;
        }
    }

    int one = 0;
    int two = 0;
    int four = 0;

    REP(i,26){
        if(alpha[i] == h*w){
            cout << "Yes" << endl;
            return 0;
        }
    }

    REP(i,26){
        //1個と4個のペアの数をカウント
        if(alpha[i] % 2 == 1){
            one++;
            alpha[i]--;
        }
        four += alpha[i]/4;
        alpha[i] %= 4;
    }


    REP(i,26){
        two += alpha[i]/2;
        alpha[i] %= 2;
    }
    //個数カウント終了


    int two_pair = 0;
    int four_pair = 0;
    int one_cnt = 0;

    if(h % 2 == 1 && w % 2 == 1){
        //奇奇
        //cout << "a" << endl;
        one_cnt = 1;
        four_pair = ((h-1)/2)*((w-1)/2);
        two_pair = (h*w - one_cnt - 4*four_pair)/2;
    }else if(h % 2 == 0 && w % 2 == 0){
        //偶偶
        //cout << "b" << endl;
        one_cnt = 0;
        four_pair = h*w/4;
        two_pair = 0;
    }else if(h % 2 == 1 && w % 2 == 0){
        //cout << "c" << endl;
        //奇偶
        one_cnt = 0;
        four_pair = ((h-1)/2)*(w/2);
        two_pair = (h*w - 4*four_pair)/2;
    }else{
        //cout << "d" << endl;
        //偶奇
        one_cnt = 0;
        four_pair = (h/2)*((w-1)/2);
        two_pair = (h*w - 4*four_pair)/2;
    }

    //cout << one << " " << two << " " << four << endl;
    //cout << one_cnt << " " << two_pair << " " << four_pair << endl;

    if(four > four_pair){
        two += (four - four_pair)*2;
        four = four_pair;
    }


    if(one == one_cnt && two == two_pair && four == four_pair){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>

#include <iostream>

#include <vector>
#include <algorithm>

int main(){
  int N,M;
  std::cin >> N >> M;
  int k[N];
  int s[N][N];
  for(int i=0;i<M;i++){
    std::cin >> k[i];
    for(int j=0;j<k[i];j++) std::cin >> s[i][j];
  }
  int p[N];
  for(int i=0;i<M;i++) std::cin >> p[i];

  int ret = 0;
  for(int i=0;i<(1<<N);i++){
    bool on = true;
    for(int j=0;j<M;j++){
      int num = 0;
      /*
      printf("k=%d\ns=",k[j]);
      for(int l=0;l<k[j];l++) printf(" %d",s[j][l]);
      printf("\n");
      */
      for(int l=0;l<k[j];l++){
	//printf("%d %d %d\n",i,s[j][l]-1,(i>>(s[j][l]-1))&0x1);
	if((i>>(s[j][l]-1))&0x001){
	  num++;
	}
      }
      //printf("%d %x %d %d\n",j,i,num,p[j]);
      if(num%2 != p[j]){
	on = false;
      }
    }
    if(on){
      ret++;
      //printf("ok\n");
    }
    //printf("\n");
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <float.h>
#include <stdlib.h>
#include <functional>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define in cin >>
#define out cout <<
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define all(v) v.begin(),v.end()
typedef long long ll;
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
ll modpow(ll a,ll n,ll mod){
    ll res=1;
    while(n>0){
        if(n&1)res=a*res%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}
void comb(vector<vector <long long int> > &v){
  for(int i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(int k = 1;k <v.size();k++){
    for(int j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}


int main(){
    int n;
    cin >> n;
  vector<string> vec(n);
  rep(i,n){
      cin >> vec[i];
  }
  sort(vec);
  vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
  cout << vec.size();
}


Measured memory_bytes: 9588
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let s = input_line_str().to_charvec();
    println!(
        "{}",
        1 + s.iter().rposition(|&x| x == 'Z').unwrap() - s.iter().position(|&x| x == 'A').unwrap()
    );
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ll inf = 1LL<<56;
const int mxN = 305;
ll dp[mxN][mxN], H[mxN];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int N, K;
	cin>>N>>K;
	for(int i = 1; i <= N; i++){
		cin>>H[i];
	}
	for(int n = 0; n <= N; n++){
		for(int k = 0; k <= N; k++){
			dp[n][k] = inf;
		}
	}
	dp[0][0] = H[0] = 0;
	for(int n = 1; n <= N; n++){
		for(int k = 1; k <= n; k++){
			for(int m = 0; m < n; m++){
				dp[n][k] = min(dp[n][k], dp[m][k - 1] + max(0LL, H[n] - H[m]));
			}
		}
	}
	ll ans = inf;
	for(int n = 0; n <= N; n++){
		for(int k = N - K; k <= N; k++){
			ans = min(ans, dp[n][k]);
		}
	}
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

const int MAX_Q = 100000;

bool isprime(int n) {

    if (n == 2) return true;
    if (n == 3) return true;

    int sn = sqrt(n);

    for (int i = 2; i <= sn; ++i) {
        if (n % i == 0) return false;
    }

    return true;
}

int main() {

    bool p[MAX_Q + 1] = {false};
    for (int i = 2; i <= MAX_Q; ++i) {
        p[i] = isprime(i);
    }

    int c[MAX_Q + 2] = {0};
    for (int i = 3; i <= MAX_Q; i += 2) {
        if (p[i] && p[(i + 1) / 2]) {
            c[i]++;
        }
    }

    for (int i = 3; i <= MAX_Q; i++) {
        c[i] += c[i - 1];
    }

    int Q;
    scanf("%d", &Q);

    for (int i = 0; i < Q; ++i) {
        int l, r;
        scanf("%d %d", &l, &r);

        printf("%d\n", c[r] - c[l - 1]);
    }

    return 0;
}


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

using namespace std;

#define ll long long 
#define pi 3.14159265358979323
#define mod 1000000007

void solve(){
    int n;
    cin>>n;
    ll sum = 0;
    for(int i = 1;i<=n;i++){
        if(i % 3 != 0 && i % 5 != 0){
            sum += i;
        }
    }
    cout<<sum;
}

int main() {
    int t = 1;
    while(t--)
        solve();
    return 0;
}



Measured memory_bytes: 3580
#!python3

import sys
sys.setrecursionlimit(200000)


# input
N = int(input())
l = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]


def solve(s, m):
    if len(s) == N:
        print(s)
    else:
        for i in range(m + 1):
            solve(s + l[i], max(i + 1, m))


def main():
    solve("a", 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 4412
import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


N, K = na()
a_array = na()

win = [0] * (K+1)

for i in range(a_array[0]):
    win[i] = 1

for i in range(a_array[0], K+1):
    for a in a_array:
        if i-a >= 0 and win[i-a] == 1:
            win[i] = -1
            break
    else:
        win[i] = 1

# print(win)

print("First" if win[-1] == -1 else "Second")


Measured memory_bytes: 68800
// AOJ 0146
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<limits>
#include<vector>
#define rep(i,a) for( int i = 0; i != (a); ++i )
#define repi(i,a,b) for( int i = (a); i != (b); ++i )

const int MAX_V = 15;
const double INF = std::numeric_limits<double>::max()/4.0;

int n;
int ord[MAX_V], d[MAX_V], w[MAX_V];
double dp[MAX_V][1<<MAX_V];
double ans = INF;
int ansOrd[MAX_V];

void rec( int v, double t, int ws, int S, std::vector<int> &ords )
{
	if( t > dp[v][S] )
		return;

	if( S == (1<<n)-1 && ans > t )
	{
		ans = t;

		rep( i, n )
			ansOrd[i] = ords[i];
		
		return;
	}

	rep( u, n )
	{
		if( !(S>>u&1) )
		{
			double vel = 2000.0/(70.0+ws), tim = t+abs(d[u]-d[v])/vel;
			ords.push_back( ord[u] );
			if( dp[u][S|1<<u] > tim )
			{
				dp[u][S|1<<u] = tim;
				rec( u, tim, ws+w[u]*20, S|1<<u, ords );
			}
			ords.pop_back();
		}
	}

	return;
}

int main()
{
	scanf( "%d", &n );
	rep( i, n )
		scanf( "%d%d%d", ord+i, d+i, w+i );

	std::fill( (double*)dp, (double*)(size_t(dp)+sizeof(dp)), INF );

	rep( i, n )
	{
		std::vector<int> vec( 1, ord[i] );
		rec( i, 0, w[i]*20, 1<<i, vec );
	}
	
	rep( i, n )
		printf( "%d%c", ansOrd[i], i==n-1?'\n':' ' );

	return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, v, m, x, y, p, q, k, W;
string s, t, s0, s1, s2;
vll a;
vll b;

// <------------- Implement Functions Here ----------> //
ll chk(ll M) {
	for(ll i=M;i>=0;i--) {
		ll j = M-i;
		if(i <= n && j <= m) {
			if(a[i] + b[j] <= k) return 1;
		}
	}
	return 0;
}


ll bs() {
	ll l = 0, r = n + m;
	while (l < r) {
		ll M = (l + r + 1) / 2;
		if (chk(M)) {
			l = M;
		}
		else {
			r = M - 1;
		}
	}
	return l;
}


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> m >> k;

	for (ll i = 0; i < n; i++) cin >> x, a.pb(x);
	for (ll i = 0; i < m; i++) cin >> x, b.pb(x);


	for (ll i = 1; i < n; i++) a[i] += a[i - 1];
	for (ll i = 1; i < m; i++) b[i] += b[i - 1];
	a.insert(a.begin(),0);
	b.insert(b.begin(),0);

	cout << bs();
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 8020
#include "bits/stdc++.h"
#include <chrono> 
 
using namespace std;
using namespace std::chrono; 
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
#define gcd(a,b) __gcd(a,b)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vc vector<char>
#define pb(n) push_back(n)
#define pp pop_back()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define type(a) typeid(a).name();
#define print(arr) cout << "[" ;for(unsigned int i=0;i<(unsigned int) arr.size();i++){ (i==arr.size()-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define Arr(arr,l) cout << "[" ;for(unsigned int i=0;i<(unsigned int) l;i++){ (i==l-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define console(arr) cout << "["<<endl; for(ll i=0;i<(ll)arr.size();++i){cout << " [";for(ll j=0;j<(ll)arr[i].size();++j){(j==(int)arr[i].size()-1)?cout << arr[i][j]:cout << arr[i][j] << ",";}cout << "]"<<endl;} cout << "]"<<endl
#define starting() auto start = high_resolution_clock::now()
#define ending() auto stop = high_resolution_clock::now();auto duration = duration_cast<microseconds>(stop - start);cout << endl << endl << "Execution Time : "<<duration.count()/1000 << " ms" << endl
 
template <typename T1,typename T2>
void mapped(map<T1,T2>m){for(auto ite=m.begin();ite!=m.end();++ite){cout << "'" << ite->first << "'"<<" : "<<ite->second <<endl;}}
 
template <typename T1 , typename T2>
void mappedArr(map<T1,vector<T2>>m){for(auto ity=m.begin();ity!=m.end();++ity){cout << "'"<< ity->first <<"'"<<" : "<<"[";
for(int i=0;i<(int)ity->second.size();++i){(i==(int)ity->second.size()-1)?cout << ity->second[i]:cout << ity->second[i] << ",";}cout << "]"<<endl;}}
 
string int_to_string(int x){ stringstream ss; ss << x; string ni = ss.str(); return ni;}
int char_to_int(char c){ int n = (int)c - 48; return n; }
int string_to_int(string x){ int n; stringstream s(x); s >> n; return n; }
 
template <typename T1,typename T2>
void ArrPair(vector<pair<T1,T2>>vp){for(int i=0;i<(int)vp.size();++i){
cout << "(" << vp[i].first << "," << vp[i].second << ")"<<endl ;}}
 
const int MOD = 1e9 + 7;
const ll INF = 1e18L + 5;
 
int main(){
  string s;
  cin >> s;
  string k = "";
  for (int i = 0; i < (int)s.size(); ++i) {
	  if(s[i] == '0'){
		  k += "0";
	  }else if(s[i] == '1'){
		  k += "1";
	  }else{
		  if((int)k.size() != 0){
		    k.pop_back();
	     }
	  }
  }
  cout << k;
}














Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
    char s[1201];
    for(int i=0; i< 1201; i++){
        scanf("%c", &s[i]);
        if(s[i]=='\n'){
            s[i]='\0';
            break;
        }
    }
    int n = strlen(s);
    for(int i=0; i<n ; i++){
        if(s[i]<='z' && s[i]>='a') s[i]-= 32;
        else if(s[i]<='Z' && s[i]>='A') s[i]+= 32;
    }
    puts(s);
}



Measured memory_bytes: 2128
N = int(input())
X = [int(i) for i in input().split()]

ans = float("inf")
for P in range(1, 100+1):
  power_sum = 0
  for i in range(N):
    power_sum += (X[i]-P)**2
  if power_sum < ans:
    ans = power_sum

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#define MOD 1000000007

using namespace std;

pair<int,int> v[100005];
///  val,poz

long long f[100005],invf[100005];

long long exp(long long x,int p){
    if(x==1 || x==0)
        return x;
    if(p==0)
        return 1;
    long long y=exp(x,p/2);
    if(p%2)
        return (((y*y)%MOD)*x)%MOD;
    return (y*y)%MOD;
}

void getf(int n){
    f[0]=1;
    for(int i=1;i<=n;i++)
        f[i]=(f[i-1]*i)%MOD;
}

void getif(int n){
    for(int i=0;i<=n;i++)
        invf[i]=exp(f[i],MOD-2)%MOD;
}

long long c(int n,int k){
    if(k>n)
        return 0;
    if(k==n)
        return 1;
    if(k==0)
        return 1;
    return (((f[n]*invf[k])%MOD)*invf[n-k])%MOD;
}

long long n,k,i;
long long sum,a,b;
int main()
{
    cin>>n>>k;
    for(i=1;i<=n;i++){
        cin>>v[i].first;
        v[i].second=i;
    }
    getf(n+1);
    getif(n+1);
    sort(v+1,v+n+1);
    for(i=1;i<=n;i++){
        ///cum contribuie ca minim
        a=v[i].first * c(n-i,k-1);
        a%=MOD;
        ///cum contribuie ca maxim
        b=v[i].first * c(i-1,k-1);
        b%=MOD;
        ///modificat suma
        sum=(((sum-a)%MOD)+b)%MOD;
    }
    cout<<sum<<'\n';
    return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int d;
	cin >> d;

	string ans = "Christmas";
	if (d == 24) {
		ans += " Eve";
	} else if (d == 23) {
		ans += " Eve Eve";
	} else if (d == 22) {
		ans += " Eve Eve Eve";
	}

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


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

using namespace std;

int main()
{
    string s;
    int n;

    cin >> s;

    n = stoi(s);

    for (int i = n; i <= 999; i++) {
        s = to_string(i);

        if (s[0] == s[1] && s[1] == s[2]) {
            cout << i << endl;
            return (0);
        }
    }

    return (0);
}





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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int T, X; cin >> T >> X;
	cout << (double)T / X << endl;

	return 0;
}


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

ll sum(ll n){
    ll s = 0;
while(n){
    s += n % 10;
    n /= 10;
}
return s;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k;
    cin >> k;

    ll start = 1, add = 1;
    for(int i = 1; i <= k; i++){
            cout<<start<<endl;
    while((start + 2*add) * sum(start + add) < (start + add) * sum(start + 2 * add))
        add *= 10;
    start += add;
    }
    return 0;

}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int x = in.nextInt();
            int y = in.nextInt();
            int ans = Math.min(n, k) * x;
            ans += Math.max(0, n - k) * y;
            out.println(ans);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
            this.bufPointer = 0;
            this.bufLength = 0;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int nextInt() {
            int n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

    }
}



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

typedef long long int ll;
typedef pair<ll, ll> pii;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define sz(a) ll(a.size())
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front 
#define MAXN 100010
#define N 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define debug(x) cout << '>' << #x << ':' << x << " ";
#define nl '\n'
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define int long long int

set<int> adj[2*MAXN];
vector<bool> vis;
int sz = 0;
void dfs(int s){
    sz++;
    vis[s] = true;
    for(auto v: adj[s]){
        if(vis[v] == false){
            dfs(v);
        }
    }
}

main()
{
    IO;
	int T = 1;
    // cin >> T;
    fo(c, 1, T){
        // cout<<"Case #"<<c<<": ";
        int n, m;
        cin >> n >> m;
        vis.clear();
        vis.resize(n+1, false);
        for(int i = 1; i <n+1; i++){
            adj[i].clear();
        }
        for(int i = 0; i < m; i++){
            int u, v;
            cin >> u >> v;
            adj[u].insert(v);
            adj[v].insert(u);
        }
        int ans = 0;
        for(int i = 1; i <= n; i++){
            if(vis[i] == false){
                sz = 0;
                dfs(i);
                ans = max(ans, sz);
            }
        }
        cout << ans<< nl;
    }
    return 0;
}

Measured memory_bytes: 38044
#include <stdio.h>
#include <string.h>
int main(){
  char s[201];
  scanf("%s",s);
  int n=strlen(s);
  int m=n;
  for(int i=0;i<n/2;i++){
    m-=2;
    if(!(strncmp(s,&s[m/2],m/2-1))){
      printf("%d",m);
      return 0;
    }
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
const ll fact_table = 5000000;
double Pi = 3.1415926535897932384626;
 
//vector<ll> G[550010];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
//ll mod = 998244353;
ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
 */
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k;
ll ans;
ll x[500005], y[500005], z[500005];
char s[400004];

int main(){
    cin >> n;
    bool ok = false;
    for(int i=1;i<=n;i++){
        ll price = i * 1.08;
        if(price == n){
            ok = true;
            p(i);
            return 0;
        }
    }
    p(":(");
    
    return 0;
    
}


















Measured memory_bytes: 13824
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb push_back
#define endl "\n"
#define X first
#define Y second
#define pii pair<int,int>
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout)

const int maxn=1e5+5;
const int mod=1e9+7;
const int inf=1e9;
const int del=728729;

ll poww(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));}
ll n;
int main(){
	migmig;
  	ll ted = 0;
  	ll i = 2;
  	cin >> n;
	if (n % 2 == 1) {
		cout<<0;return 0;
	}
  	while (n >= i * 5) {
    i *= 5;
    ted += n / i;
	}
	cout<< ted;
	
	return 0;
}



Measured memory_bytes: 256
A, B, C, D = map(int, input().split())

def f(a, b):
    if a == 0:
        return b
    if b == 0:
        return a        
    if a > b:
        return f(a%b, b)
    else:
        return f(a, b%a)

def g(a, b):
    return a * b // f(a,b)

def h(x, a, b):
    return x - (x // a) - (x // b) + (x // g(a,b))

print(h(B, C, D) - h(A-1, C, D))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int opt = 0;
    while(a >= b){
        b*=2;
        opt++;
    }
    while(b >= c){
        c*=2;
        opt++;
    }
    if(opt <= k)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
inline void read(int &x){
    char c = getchar();
    int p = 1;
    x = 0;
    while(!isdigit(c)){
        if(c == '-')p = -1;
        c = getchar();
    }
    while(isdigit(c)){
        x = (x << 1) + (x << 3) + (c ^ '0');
        c = getchar();
    }
    x *= p;
}
inline bool cmp(int a, int b){
    return a > b;
}
int a[100050], n, k;
vector<int>vec1, vec2;
int main(){
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    read(n), read(k);
    int ans = INT_MAX;
    for(register int i = 1; i <= n; ++i){
        read(a[i]);
        if(a[i] <= 0)vec1.push_back(a[i]);
        else vec2.push_back(a[i]);
    }
    sort(vec1.begin(), vec1.end(), cmp);
    for(register int i = 0, sz = vec1.size(); i < sz; ++i){
        int tmp1 = i + 1;
        int tmp2 = k - tmp1;
        if(tmp2 <= 0)ans = min(ans, abs(vec1[i]));
        else if(tmp2 <= vec2.size())ans = min(ans, abs(vec1[i]) * 2 + vec2[tmp2 -1]);
    }
    for(register int i = 0, sz = vec2.size(); i < sz; ++i){
        int tmp1 = i + 1;
        int tmp2 = k - tmp1;
        if(tmp2 <= 0)ans = min(ans, vec2[i]);
        else if(tmp2 <= vec1.size())ans = min(ans, vec2[i] * 2 + abs(vec1[tmp2 - 1]));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1404
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		//int k = sc.nextInt();

		long count=0;

		/*if(n==m) {
			System.out.println(n*2);
		}else {
			System.out.println(Math.max(n, m)+Math.max(n, m)-1);
		}*/

		System.out.println((n*3+m)/2);
	}
}




Measured memory_bytes: 23892
#include <iostream>
#include <algorithm>
#include <vector>
#include "string"
#include <iterator>
#include <list>

using namespace std;

typedef long long ll;

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

    int N, M;
    cin >> N >> M;

    vector<int> L(M);
    vector<int> R(M);

    for (int i = 0; i < M; i++) {
        cin >> L[i] >> R[i];
    }

    auto min = *std::min_element(R.begin(), R.end());
    auto max = *std::max_element(L.begin(), L.end());

    if (max > min) {
        cout << 0 << endl;
        return 0;
    }

    cout << min - max + 1 << endl;

    return 0;
}



Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<string>

using namespace std;

int main() {	
	string in;
	char input[1201] = { 0 };
	int m = 0, n = 0, ascii = 0, inputlen = 0;
	getline(cin, in);
	while (in[m] != '\0') {
		input[m] = in[m];
		m++;
	}
	inputlen = strlen(input);
	for (int i = 0; i < inputlen; i++) {
		ascii = input[i];
		if (65 <= ascii&&ascii <= 90) {
			ascii += 32;
			input[i] = ascii;
		}
		else if (97 <= ascii&&ascii <= 122) {
			ascii -= 32;
			input[i] = ascii;
		}
	}
	while (input[n] != '\0') {
		printf("%c", input[n]);
		n++;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1168