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

#define int long long

//#define X first
#define Y second
#define eb emplace_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define EFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP rep
using vint=vector<int>;
typedef long long ll;
typedef ll LL;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> inline bool MX(T&l, const T&r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T&l, const T&r){return l>r?l=r,1:0;}

int N;
int M;
char cell[1145][1145];
bool used[114514];
vint es[114514];

//#define int long long

const long long INF=(1ll<<50);
struct graph{
  typedef long long flow_type;
  struct edge{
    int src,dst;
    flow_type capacity,flow;
    size_t rev;
  };
  int n;
  vector<vector<edge>> adj;
  graph(int n) : n(n),adj(n){}
  void add_edge(int src,int dst,flow_type capacity){
    adj[src].push_back({src,dst,capacity,0,adj[dst].size()});
    adj[dst].push_back({dst,src,0,0,adj[src].size()-1});
  }
  flow_type max_flow(int s,int t){
    vector<int> level(n),iter(n);
    function<int(void)> levelize = [&](){
      level.assign(n,-1); level[s]=0;
      queue<int> Q;Q.push(s);
      while(!Q.empty()){
        int u=Q.front();Q.pop();
        if(u==t) break;
        for(auto &e: adj[u]){
          if(e.capacity > e.flow && level[e.dst] <0){
            Q.push(e.dst);
            level[e.dst] = level[u]+1;
          }
        }
      }
      return level[t];
    };
    function<flow_type(int,flow_type)> augment = [&](int u,flow_type cur){
      if(u==t) return cur;
      for(int &i=iter[u];i<adj[u].size();++i){
        edge &e = adj[u][i],&r=adj[e.dst][e.rev];
        if(e.capacity>e.flow && level[u]<level[e.dst]){
          flow_type f=augment(e.dst,min(cur,e.capacity -e.flow));
          if(f>0){
            e.flow+=f;
            r.flow-=f;
            return f;
          }
        }
      }
      return flow_type(0);
    };
    for(int u=0;u<n;++u)
      for(auto &e:adj[u]) e.flow=0;

    flow_type flow=0;
    while(levelize()>=0){
      fill(all(iter),0);
      for(flow_type f;(f=augment(s,INF))>0;)
        flow+= f;
    }
    return flow;
  }
};

void dfs(int v) {
  used[v] = true;
  for (int u : es[v]) {
    if (used[u]) continue;
    dfs(u);
  }
}

signed  main(){
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  cin >> N >> M;
  graph G(N+N+2);
  rep(i, M) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    es[x].eb(y+N);
    es[y+N].eb(x);
    G.add_edge(x, y+N, 1);
  }

  rep(i, N) {
    G.add_edge(N+N, i, 1);
    G.add_edge(i+N, N+N+1, 1);
  }

  int num = 0;
  rep(i, N+N) {
    if (used[i]) continue;
    if (es[i].empty()) continue;
    num++;
    dfs(i);
  }

  cout << M-G.max_flow(N+N, N+N+1) << " " << M-num << endl;
} 



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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  int min = a[0], max = a[0];
  for(int i = 0; i < n; i++){
    if(a[i] < min){
      min = a[i];
    }
    if(a[i] > max){
      max = a[i];
    }
  }
  cout << max - min << endl;
  return 0;
}

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

int main() {
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;
    S = '#' + S + '#';
    
    bool flag = true;
    
    for (int i = A; i < C+1; i++){
        if (S.at(i) == S.at(i+1) && S.at(i) == '#'){
            flag = false;
        }
    }
    
    for (int i = B; i < D+1; i++){
        if (S.at(i) == S.at(i+1) && S.at(i) == '#'){
            flag = false;
        }
    }
    
    if (D<C){
        bool flag2 = false;
        for (int i = B-1; i<D; i++){
            if(S.at(i)==S.at(i+1) && S.at(i+1)==S.at(i+2) && S.at(i)=='.'){
                flag2 = true;
            }
        }
        
        if(flag2 == false){
            flag = false;
        }
    }
    
    if (flag == true){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
  }


Measured memory_bytes: 772
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>

const int INF = 1001001000;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

int main(){
  int n;
  map<int , int> a;
  int ans = 0;
  int tmp;
  int max = 0;

  cin >> n;

  for( int i = 0; i < n; ++i){
    cin >> tmp;
    a[tmp] += 1;
    if( max < tmp){
      max = tmp;
    }
  }

  int c,d;
  for( auto itr = a.begin(); itr != a.end(); ++itr){
    c = itr->first;
    d = itr->second;
    if(!( d == 0 || d == c)){
      if( c < d){
        ans += d - c;
      }else{
        ans += d;
      }
    }
  }
  cout << ans << endl;



}


Measured memory_bytes: 4736
// ------------------------------------
// Date:2018/ 4/ 7
// Problem:/ / / b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(A, B, K);
  vector< int > num;
  int cnt = 0;
  FOR(i, A, B + 1) {
    cnt++;
    if (cnt <= K) cout << i << endl;
    else if (0 <= (B - A + 1 - cnt) && (B - A + 2- cnt) <= K) cout << i << endl;
  }
   
  return 0;
}



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

using namespace std;

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

	int sum = 0;
	for(int i = 0; i < s.size(); ++i)
	{
		if(s[i] == 'o')
		{
			++sum;
		}
	}

	if(sum + 15 - s.size() >= 8)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
'use strict'

function main(s) {
  	// 入力用のデータにするための処理
  	// 改行ごとに要素を区切って、そのあとに頭の行以外を残す
	// そして念のために数値化
  	let orders = s.split('\n').slice(1,-1).map(n => Number(n));
  	
  	// 出力用のオブジェクト（配列にしないのは数字ごとにラベリングしたいから）
  	let list ={}
  	// 要素が有る限り、回したいのでfor of
    for(let num of orders){
    	if(list[num]){
        	delete list[num] 
        }else {
    		list[num] = true;
    	}
    }
  	// オブジェクトは単にlengthをつけるだけでは数取れないのでこの記法
  	// なお、keysと複数形なのは注意
  	console.log(Object.keys(list).length);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 67012
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<string.h>
#include<vector>
#include<queue>



using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const int INF=1001001001;
int map[302];
struct check{
	int i,j,k;
};




int main(){
	while(1){
		int a,b,c,N;
		vector<check> mic;
		scanf("%d %d %d",&a,&b,&c);
		if(a==0&&b==0&&c==0)break;
		rep(i,a+b+c)map[i]=2;
		scanf("%d",&N);
		rep(a,N){
			int i,j,k,r;
			scanf("%d %d %d %d",&i,&j,&k,&r);
			i--;j--;k--;
			if(r==1){map[i]=1;map[j]=1;map[k]=1;}
			else{
				check c;
				c.i=i;c.j=j;c.k=k;
				mic.push_back(c);
			}
		}
		rep(i,mic.size()){
			if( map[mic[i].i]==1&&map[mic[i].j]==1)map[mic[i].k]=0;
			if( map[mic[i].i]==1&&map[mic[i].k]==1)map[mic[i].j]=0;
			if( map[mic[i].k]==1&&map[mic[i].j]==1)map[mic[i].i]=0;
		}
		rep(i,a+b+c)printf("%d\n",map[i]);
	}
}

Measured memory_bytes: 1072
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a < b) System.out.println("a < b");
		else if (a == b) System.out.println("a == b");
		else if (a > b) System.out.println("a > b");
	}
}

Measured memory_bytes: 26260
a, b, c = sorted(list(map(int, input().split())))
ac = c - a
bc = c - b

res = 0
if ac % 2 == 0 and bc % 2 == 0:
    res = ac // 2 + bc // 2
elif ac % 2 == 1 and bc % 2 == 1:
    res = 1 + ac // 2 + bc // 2
else:
    res = 2 + ac // 2 + bc // 2

print(res)


Measured memory_bytes: 9152
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
using namespace std;

//#define FILE_INPUT
//#define DEBUG_MODE

void DebugPrint(vector<long long int> &a, int n)
{
#ifdef DEBUG_MODE
	for (int i = 0; i < min(20, n); ++i) {
		cout << a[i] << ",";
	}
	cout << endl;
#endif
}

int main()
{
#ifdef FILE_INPUT
	ifstream in("test3.txt");
	cin.rdbuf(in.rdbuf());
#endif	/* FILE_INPUT */  

	static const long long int MOD = 1000000007;
	int n, k;
	cin >> n >> k;

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

	vector<vector<long long int>> dp(n + 1, vector<long long int>(k + 1, 0));

	vector<long long int> acc(k + 1);

	dp[0][0] = 1;
	DebugPrint(dp[0], k + 1);
	for (int loop = 1; loop <= n; ++loop) {
		long long int sum = 0;
		for (int i = 0; i <= k; ++i) {
			sum += dp[loop - 1][i];
			acc[i] = sum;
		}
		for (int i = 0; i <= k; ++i) {
			if (i - a[loop - 1] - 1 < 0) {
				dp[loop][i] = acc[i] % MOD;
			}
			else {
				dp[loop][i] = (acc[i] - acc[i - a[loop - 1] - 1]) % MOD;
			}
		}
		DebugPrint(dp[loop], k + 1);
	}

	cout << dp[n][k] << endl;

	return 0;
}


Measured memory_bytes: 80256
n=int(input())
h=[int(x) for x in input().split()]
buf=[0 for i in range(n)]

ans=0

flag=False

for i in range(max(h)):
    for j in range(n):
        if h[j] >= i+1:
            flag=True
        if flag and h[j] <= i:
            ans+=1
            flag=False
    if flag:
        ans+=1
        flag=False

print(ans)

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	ll N; cin >> N;

	ll mod = 1e9+7;

	//T: 0 A: 1, G: 2, C: 3
	ll dp[200][4][4][4][4]; memset(dp, 0, sizeof(dp));

	dp[0][0][0][0][0] = 1;

	for (int pos = 0;pos < N;pos++){
		for (int i = 0;i < 4;i++){
			for (int j = 0;j < 4;j++){
				for (int k = 0;k < 4;k++){
					for (int l = 0;l < 4;l++){
						dp[pos][l][i][j][k] %= mod;
						if(i == 1 && j == 2 && k == 3) continue;
						if(i == 1 && j == 3 && k == 2) continue;
						if(i == 2 && j == 1 && k == 3) continue;
						if(l == 1 && j == 2 && k == 3) continue;
						if(l == 1 && i == 2 && k == 3) continue;
						dp[pos+1][i][j][k][0] += dp[pos][l][i][j][k];
						dp[pos+1][i][j][k][1] += dp[pos][l][i][j][k];
						dp[pos+1][i][j][k][2] += dp[pos][l][i][j][k];
				 		dp[pos+1][i][j][k][3] += dp[pos][l][i][j][k];
					}
				}
			}
		}
	}

	ll ans = 0;

	for (int i = 0;i < 4;i++){
		for (int j = 0;j < 4;j++){
			for (int k = 0;k < 4;k++){
				for (int l = 0;l < 4;l++){
					if(i == 1 && j == 2 && k == 3) continue;
					if(i == 1 && j == 3 && k == 2) continue;
					if(i == 2 && j == 1 && k == 3) continue;	
					if(l == 1 && j == 2 && k == 3) continue;
					if(l == 1 && i == 2 && k == 3) continue;
					ans += dp[N][l][i][j][k];
					ans %= mod;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  int temp = N / 1000;
  int ans;
  if(N % 1000 == 0) {
    ans = 1000 * (temp) - N;
  } else {
    ans = 1000 * (temp + 1) - N;
  }
  cout << ans << endl;
  
  return 0;
}

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

int main()
{
  int a,b;
  while(cin >> a >> b){
    int GCD,LCM;
    int temp;
    if(a<b){
      temp = a;
      a = b;
      b = temp;
    }
    for(int i=1; i<=b; i++){
      if( b%i==0 && a%(b/i)==0 ){
	GCD = b/i;
	break;
      }
    }
    for(int i=1; i<=b; i++){
      if( (a*i)%b == 0 ){
	LCM = a*i;
	break;
      }
    }
    cout << GCD << " " << LCM << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<string.h>
int main(void){
  int n;
  char s[100];
  scanf("%d",&n);
  scanf("%s",&s);
  if (n%2!=0){
    printf("No");
    return 0;
  }
  int i,j;
  for(i=0,j=n/2;i<n/2,j<n;i++,j++){
    if(s[i]!=s[j]){
      printf("No");
      return 0;
    }
  }
  printf("Yes");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <fstream>
#include <set>
#include <stack>
#include <queue>
#include <list>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
// // // // // // // // // // // // // // // // // // //
int64 q, n;

void solve(){

    return;
}


int main(){
    string s1;
    string s2;
    cin >> s1 >> s2;
    if (s2.substr(0, s2.length() - 1) == s1 && s2.size() == s1.size() + 1){
        ctn("Yes");
    }
    else{
        ctn("No");
    }
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long
#define ld long double
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define REP(i,a,b) for(ll i = a; i < b; i++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define bins(v, x) binary_search(v.begin(), v.end(), x)
#define pi 2*acos(0.0)
const int INF = 1e7;
const int mod = 1e9 + 7;
 
ll modExp(ll base, ll exp, ll mod) {
   ll res = 1;
   while (exp > 0) {
    	if (exp % 2 == 1) {
        	res= (res * base) % mod;
		}
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}
 
ll nCr(ll n, ll k) { 
   ll C[n + 1][k + 1]; 
   
   REP(i,0,n+1){ 
      REP(j,0,min(i,k)+1) {
         if(j==0 || j==i) {
            C[i][j] = 1;  
         } else {
            C[i][j] = C[i-1][j-1] + C[i-1][j]; 
         }
      } 
   }
   return C[n][k]; 
}

bool compare(pair<int, int>&i, pair<int, int>&j) {
    return (i.S > j.S || (i.S == j.S && i.F > j.F));
}

int main() {
   //freopen("input.txt","r",stdin);
   //freopen("output.txt","w",stdout);

   
   int n;
   cin >> n;
   ld max = pow(10, 18);
   ll a[n], prod = 1;
   REP(i,0,n) {
      cin >> a[i];
   }

   sort(a, a+n);
   for(int i = 0; i < n; i++) {
      if(a[i] > max/prod) {
         p1(-1);
         return 0;
      }
      prod *= a[i];
   }
   p1(prod);
}

Measured memory_bytes: 4372
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
template<typename T>vector<T> make_v(size_t a){ return vector<T>(a); }
template<typename T,typename... Ts>auto make_v(size_t a, Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T &t, const V &v){ t = v; }
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, a[101010];
LL sum;
int cnt;
int minl = HINF<int>();
int main(){
    cin >> n;
    REP(i, n){
        cin >> a[i];
        sum += abs(a[i]);
        minl = min(minl, abs(a[i]));
        if(a[i] < 0)cnt++;
    }
    if(cnt%2)sum -=minl*2LL;
    cout << sum << endl;
}

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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
int a[50],b[50],c[50],d[50];
int n,m,q;
ll ans = 0;
ll calc(vector<int> su){
    ll cnt=0;
    rep(i,0,q){
        if(su[b[i]-1] - su[a[i]-1] == c[i])cnt += d[i];
    }
    return cnt;
}

void dfs(vector<int> su){
    if(su.size()<n){
        int tmp;
        if(su.size()==0) tmp = 1;
        else tmp = su[su.size()-1];
        rep(i,tmp,m+1){
            su.push_back(i);
            dfs(su);
            su.pop_back();
        }
    }else{
        ans = max(ans,calc(su));
    }

}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cin >> n >> m >> q;
    rep(i,0,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    vector<int> su;
    dfs(su);
    cout << ans << endl;
    
}

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

int main(){

    int q;
    cin >> q;

    vector<int> vec;
    for(int i = 0; i < q; ++i){
        int com, num;;
        cin >> com;
        if(com == 0){
            cin >> num;
            vec.push_back(num);
        }
        else if(com == 1){
            cin >> num;
            cout << vec[num] << endl;
        }
        else if(com == 2){
            vec.pop_back();
        }
    }

    return 0;
}


Measured memory_bytes: 3932
#include <iostream>
#include <stdio.h>
#include <string>

int main()
{
    std::string x;
    int p=0;
    int num=0;
    while(true){
    std::cin >> x;
        if(x=="0")break;
        for(int i = 0; i < (int)x.size(); ++i){
            int ch = x[i]-'0';
            p=p+ch;
        }
        std::cout << p << std::endl;
        p=0;
    }
    return 0;
}

Measured memory_bytes: 3184
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    p=[int(input()) for _ in range(N)]
    p.sort()
    print(sum(p[:N-1])+p[N-1]//2)

if __name__ == '__main__':
    main()


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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, x) for (int i = 1, _##i = (x); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)

#define L(x) ((x)*2)
#define R(x) ((x)*2+1)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;
typedef pair<ll, ll> pll;

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    os << pai.first << ' ' << pai.second;
	return os;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    rep(i, sz(v)) cout << v[i] << ' ';
    return os;
}

template<typename T, typename V>
istream &operator>>(istream &is, pair<T, V> &pai) {
	is >> pai.first >> pai.second;
	return is;
}

int N, M;
int par[100001];
int num[100001];
pii bridge[100000];
vector<ll> res;

int find(int x) {return par[x]==0?x:(par[x]=find(par[x])); }

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

    cin >> N >> M;
    repp(i, N) num[i] = 1;
    rep(i, M) cin >> bridge[M-1-i];

    ll cnt = (ll)N*(N-1)/2;
    rep(i, M) {
        res.pb(cnt);
        int a = find(bridge[i].fi), b = find(bridge[i].se);
        if (a != b) {
            cnt -= num[a]*num[b];
            num[a] += num[b];
            par[b] = a;
        }
    }

    reverse(res.begin(), res.end());
    rep(i, sz(res)) cout << res[i] << '\n';
}   




Measured memory_bytes: 3828
#include <stdio.h>
#include <math.h>
#include <stdbool.h>
#define N 10000

bool isprime(int n){
  int i;

  if(n == 2) return true;

  if(n < 2 || n%2 == 0) return false;

  i = 3;
  while(i <= sqrt(n)){
    if(n%i == 0) return false;
    i = i+2;
  }

  return true;
}

int main(){
  int num[N];
  int i,n,p=0;

  scanf("%d",&n);

  for(i = 0; i < n; i++) scanf("%d",&num[i]);

  for(i = 0; i < n; i++){
    if(isprime(num[i]) == true) p++;
    else continue;
  }

  printf("%d\n",p);

  return 0;
}

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

using namespace std;



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

int main(){
    int a;
    cin >> a;
int p = a;
while(!is_prime(p))p++;
cout << p <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLL = vector<PLL>;
using VPLD = vector<PLD>;

int main() {
  
    LL n;
    cin >> n;
    set<LL> s;
    VLL v(n,0);
    LL amax = 0;
    map<string, LL> mp;
    REP(i,n) {
        cin >> v[i];
        mp[to_string(v[i])]++;
        s.insert(v[i]);
        amax = max(amax, v[i]);
    }
    sort(v.begin(), v.end());
    vector<LL> dp(amax+1, 0);

    for (auto i : s) {
        for (LL j=2; i*j<=amax; j++) {
            dp[i*j] += 1;
        }
    }

    LL ans = 0;
    for (auto i : s) {
        //cout << i << ":";
        if (dp[i]==0&&mp[to_string(i)]==1) ans++;//cout << dp[i] << endl;
        //else cout << dp[i] << endl;
    }

    cout << ans << endl;

    return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

vector< string > reply;
vector< vector< int > > tree;

void rec(int v, int d) {
	for_(i,0,d) cout << ".";
	cout << reply[v] << endl;
	
	int m = tree[v].size();
	for_(i,0,m) rec(tree[v][i], d + 1);
}

int main() {
	int n;
	cin >> n;
	
	reply.assign(n, string());
	tree.assign(n, vector< int >());
	
	for_(i,0,n) {
		int k;
		cin >> k >> reply[i];
		
		--k;
		if (k >= 0) tree[k].push_back(i);
	}
	
	rec(0, 0);
}

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

using namespace std;

struct UFNode
{
	UFNode *parent;
	int rank;
	UFNode() :parent(nullptr), rank(0) {}
	UFNode &Find() {
		if (parent == nullptr)
			return *this;
		return *(parent = &parent->Find());
	}
	int Union(UFNode &n) {
		auto &r = Find(), &nr = n.Find();
		if (&r == &nr) return 0;
		if (r.rank < nr.rank) r.parent = &nr;
		else nr.parent = &r, r.rank += r.rank == nr.rank;
		return -1;
	}
} u[111111];
int p[111111];

int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		scanf("%d", p + i);
	for (int i = 0; i < m; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		u[x].Union(u[y]);
	}
	int r = 0;
	for (int i = 1; i <= n; i++)
		if (&u[i].Find() == &u[p[i]].Find())
			r++;
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 2432
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
int t[5];
int main(){
	for(int i=0;i<6;i++){
		int p;scanf("%d",&p);p--;t[p]++;
	}
	std::sort(t,t+4);
	if(t[0]==1&&t[1]==1&&t[2]==2&&t[3]==2)printf("YES\n");else printf("NO\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> g[300005];
bitset<300005> vis;
int tin[300005], low[300005], timer;
set<pair<int, int>> wtf;
void dfs(int u, int p = -1) {
  vis[u] = 1;
  tin[u] = low[u] = timer++;
  for (int v : g[u]) {
    if (v == p)
      continue;
    if (vis[v]) {
      low[u] = min(low[u], tin[v]);
    } else {
      dfs(v, u);
      low[u] = min(low[u], low[v]);
      if (low[v] > tin[u]) {
        wtf.insert({min(u, v), max(u, v)});
      }
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 0; i < n; i++)
    if (!vis[i])
      dfs(i);
  for (pair<int, int> i : wtf) {
    cout << i.first << ' ' << i.second << endl;
  }
}


Measured memory_bytes: 11940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cY cout << "Yes" << endl;
#define cN cout << "No" << endl;
using namespace std;
using ll = long long;

int main() {
  string s;
  cin >> s;
  rep(i,s.size()) cout << "x";
  cout << endl;
}


Measured memory_bytes: 256
/*
      HET PAGHADAR
      DA-IICT
      @HET262
*/
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long double ld;
typedef long long ll;
 
typedef vector<ll> vec;
#define INF LLONG_MAX
 
#define P pair<ll,ll>
#define int long long int
 
#define ff first
#define ss second
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
 
#define N 3005
#define MOD 1000000007

ll nn;
ld a[N];
ld dp[N][N][2];
bool visit[N][N][2];

ld solve(ll h,ll t,ll curr)
{
      
      if(h==1 && t==0 && curr==0)
            return a[1];
      if(t==1 && h==0 && curr==1)
            return 1-a[1];
            
      ld &ans=dp[h][t][curr];
      if(visit[h][t][curr])
            return ans;
            
      visit[h][t][curr]=true;
            
      ll tt=h+t;
      
      if(curr==0)
      {
            ld t1=a[tt];
            if(h==0)
                  ans=0.0;
            else
            {
                  ans+=(t1*solve(h-1,t,0));
                  ans+=(t1*solve(h-1,t,1));
            }
      }
      else
      {
            ld t1=1-a[tt];
            if(t==0)
                  ans=0.0;
            else
            {
                  ans+=(t1*solve(h,t-1,1));
                  ans+=(t1*solve(h,t-1,0));
            }
      }
      
      return ans;
}


signed main()
{
      FAST;
      
      cin>>nn;
      
      for(int i=1;i<=nn;i++)
      {
            cin>>a[i];
      }
      
      ld ans=0;
      memset(dp,0,sizeof(dp));
      memset(visit,false,sizeof(visit));
      
      for(int i=(nn/2)+1;i<=nn;i++)
      {
            ans+=solve(i,nn-i,0);
            ans+=solve(i,nn-i,1);
      }
      
      cout<<setprecision(15)<<ans<<"\n";
}

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

#define ll long long
#define pb push_back
#define F first
#define S second

ll inf =1e16+10;
const int N=1e5+5, L = 7;
int n, k , x , y , m;

int mem[N];
vector<int>g[N];
int dp(int node)
{
    int &ret = mem[node];
    int leng = 0;

    if (g[node].size() == 0)
        return ret = 0;
    if (ret != -1)
        return ret;
        for (auto v : g[node])
            leng = max(leng , 1 + dp(v));
        return ret = leng;
}

int main()
{
#ifdef Mohammad
    freopen("input.in","r",stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >>m;
    for (int i =1;i<=m;i++)
    {
        cin >> x >> y ;
        g[x].pb(y);
    }

    memset(mem, -1, sizeof mem);
    int ans = 0;
    for (int i =1;i<=n;i++)
        if (mem[i] == -1)
            ans = max(ans , dp(i));
    cout<<ans;
}


Measured memory_bytes: 8192
#include <cstdio>
#include <vector>
using namespace std;

bool match(int x, const vector<vector<int> > &xg, vector<bool> &visited, vector<int> &p)
{
	if(x < 0)
		return true;
	if(visited[x])
		return false;
	visited[x] = true;

	for(int i = 0; i < xg[x].size(); ++i) {
		int y = xg[x][i];
		if(match(p[y], xg, visited, p)) {
			p[y] = x;
			return true;
		}
	}
	return false;
}

int max_matching(const vector<vector<int> > &xg, const int ys)
{
	vector<int> p(ys, -1);
	vector<bool> visited(xg.size());
	int count = 0;
	for(int x = 0; x < xg.size(); ++x) {
		fill(visited.begin(), visited.end(), false);
		if(match(x, xg, visited, p))
			count += 1;
	}
	return count;
}

int main()
{
	while(true) {

		int n, m;
		vector<pair<int, pair<int, int> > > troop;
		vector<pair<int, int> > base;

		scanf("%d%d", &n, &m);
		if(n == 0)
			break;
		troop.resize(n); base.resize(m);
		for(int i = 0; i < n; ++i) {
			int t1, t2, t3;
			scanf("%d%d%d", &t1, &t2, &t3);
			troop[i] = make_pair(t3, make_pair(t1, t2));
		}
		for(int i = 0; i < m; ++i) {
			int t1, t2;
			scanf("%d%d", &t1, &t2);
			base[i] = make_pair(t1, t2);
		}

		double lb = 0, ub = 1e6;

		for(int step = 0; step < 100; ++step) {

			double mid = (lb + ub) / 2;

			vector<vector<int> > xg(n);

			for(int i = 0; i < n; ++i) {
				for(int j = 0; j < m; ++j) {

					int dx = troop[i].second.first - base[j].first;
					int dy = troop[i].second.second - base[j].second;
					int speed = troop[i].first;
					int d2 = dx*dx + dy*dy;

					if(d2 <= speed*speed*mid*mid)
						xg[i].push_back(j);
				}
			}

			if(max_matching(xg, m) == m)
				ub = mid;
			else
				lb = mid;
		}

		double ans = lb;

		printf("%.8lf\n", ans);
	}

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for(auto& i:mp)

int main() {
  string s;
  cin >> s;
  if (s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main(int argc, char *argv[])
{
    long long s, a[(int)1e6];
    int i, j;

    scanf("%lld", &s);

    a[0] = s;

    for (i = 1; i < (int)1e6; i++) {
        if (a[i - 1] % 2) {
            a[i] = 3 * a[i - 1]+ 1;
        } else {
            a[i] = a[i - 1] / 2;
        }
    }

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

    return 0;
}


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

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            string w = Console.ReadLine();
            int n = 0;

            for (int i=0; i<3; i++)
            {
                if (w[i] == '1') n++;
            }

            Console.WriteLine(n);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
typedef long long int ll;
 
//typedef tree<pp, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
 
 
const ll N = 400005;
 ll mod = 1000000007;
const long long int inf = INT64_MAX;
#define pp pair<ll,ll>

typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++) 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   
 
const ld pi = 3.14159265359;

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

 
void fastIO(void);
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);

ll a[N],b[N][26];
int main()
{
	string s;
	cin>>s;
	ll cnt = 0;
	rep(i,3){
		if(s[i]=='A') cnt++;
	}
	if(cnt==0 || cnt==3){
		cout<<"No\n";

	}
	else cout<<"Yes\n";

	
}


	


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}

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


using namespace std;

int main(){
    int N;
    int flag = 0;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
        if(A.at(i) % 2 == 0){
            if(A.at(i) % 3 != 0 && A.at(i) % 5 != 0) flag = 1;
        }
    }

    if(flag == 0) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 998244353
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n;
	string st;
	cin>>n>>st;
	int dif = 0;
	int mi = 0;
	for(int i=0;i<n;i++){
		if( st[i] == '(' ) dif ++;
		else dif --;
		if( dif < mi ) mi = dif;
	}
	for(int i=0;i<-mi;i++){
		cout<<"(";
		dif++;
	}
	cout<<st;
	for(int i=0;i<dif;i++){
		cout<<")";
	}
	cout<<endl;
	return 0;
}

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

using namespace std;

#define LIMIT 100
typedef int64_t ll;
typedef pair<ll, ll> ii;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n; cin >> n;
  bool d[100];
  memset(d, 0, sizeof(d[0])*100);

  int z;
  for (int i = 0; i < n; ++i) {
    cin >> z;
    d[z-1] = true;
  }
  z = 0;
  for (int i = 0; i < 100; ++i) {
    z += d[i];
  }
  std::cout << z << std::endl;

  return 0;
}



Measured memory_bytes: 256
using System;
using System.Text.RegularExpressions;
public class Snakes{
    public static void Main(){
        int n=int.Parse(Console.ReadLine());
        for(int i=0;i<n;i++){
            Regex ra=new Regex(@"^>'(=+)#(=+)~$");
            Regex rb=new Regex(@"^>\^((Q=)+)~~$");
            string line=Console.ReadLine();
            MatchCollection ma=ra.Matches(line);
            MatchCollection mb=rb.Matches(line);
            if(ma.Count>0)
                Console.WriteLine(ma[0].Groups[1].Value.Length==ma[0].Groups[2].Value.Length?"A":"NA");
            else if(mb.Count>0)
                Console.WriteLine("B");
            else
                Console.WriteLine("NA");
        }
    }
}

Measured memory_bytes: 11512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int a[n], b[n];
    int ng = 1;
    rep(i,n){
        a[i] = s[i] - '0';
        b[i] = t[i] - '0';
        if(b[i]) ng = 0;
    }
    if(ng){
        rep(i,n){
            if(a[i]){
                cout << -1 << endl;
                return 0;
            }
        }
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1001001001001001001;

    int left[n], right[n];
    rep(i,n){
        left[i] = 0, right[i] = 0;
        int now = i;
        while(b[now] == 0){
            left[i]++;
            now = (now+n-1) % n;
        }
        now = i;
        while(b[now] == 0){
            right[i]++;
            now = (now+1) % n;
        }
    }

    // 右にk回シフトがゴール
    rep(k,n){
        int f[n] = {};
        rep(i,n){
            if(a[i] != b[(i+k)%n]) f[i] = 1;
        }
        ll tmp = 0;
        vector<P> v;
        rep(i,n){
            if(f[i] == 0) continue;
            tmp++;
            if(right[i] <= k) continue;
            v.push_back(P(left[i], right[i]-k));
        }
        if(v.size() == 0){
            ans = min(ans, tmp + k);
            continue;
        }
        sort(v.begin(), v.end(), greater<P>());
        int mi = 1001001001;
        int ma = 0;
        rep(i,v.size()){
            mi = min(mi, v[i].first + ma);
            ma = max(ma, v[i].second);
        }
        mi = min(mi, ma);
        ans = min(ans, tmp + mi*2 + k);
    }

    // 左にk回シフトがゴール
    rep(k,n){
        int f[n] = {};
        rep(i,n){
            if(a[i] != b[(i+n-k)%n]) f[i] = 1;
        }
        ll tmp = 0;
        vector<P> v;
        rep(i,n){
            if(f[i] == 0) continue;
            tmp++;
            if(left[i] <= k) continue;
            v.push_back(P(left[i]-k, right[i]));
        }
        if(v.size() == 0){
            ans = min(ans, tmp + k);
            continue;
        }
        sort(v.begin(), v.end(), greater<P>());
        int mi = 1001001001;
        int ma = 0;
        rep(i,v.size()){
            mi = min(mi, v[i].first + ma);
            ma = max(ma, v[i].second);
        }
        mi = min(mi, ma);
        
        ans = min(ans, tmp + mi*2 + k);
    }

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




Measured memory_bytes: 3676
#include <stdio.h>
void fibonacci(int);
int F[45];
int main(){
  int n;
  scanf("%d",&n);
  fibonacci(n);
  printf("%d\n",F[n]);
  return 0;
}
void fibonacci(int n){
  int i;  
  F[0]=1;
  F[1]=1;
  for(i=2;i<=n;i++){
    F[i]=F[i-2]+F[i-1];
  }
}

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

int isprime(int x){
  int i;
  double root;
  root = sqrt((double)x);
  if(x == 2)return 1;
  if(x < 2 || x%2 == 0)return 0;

  i = 3;
  while(i <= (int)root){
    if(x%i == 0)return 0;
    i = i + 2;
  }
  return 1;
}

int main(){
  int n,A[10000],i,result = 0;
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",&A[i]);
    result += isprime(A[i]);
  }
  printf("%d\n",result);
  return 0;
}



Measured memory_bytes: 2112
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.split( "\n" );
  var s = data[0]+data[0];
  var p = data[1];
 
 if( -1 == s.indexOf( p ) ) {
   console.log( "No" );
 } else {
   console.log( "Yes" );
 }
});

Measured memory_bytes: 7644
#include<bits/stdc++.h>
using namespace std;
#define N 410
#define LL long long
char a[N][N];
int n,m,vis[N][N];
int dir[4][2]={{1,0},{0,-1},{-1,0},{0,1}};
LL ans;
struct node
{
    int x,y;
};
bool check(int x,int y)
{
    if(x<0||x>=n)
        return false;
    if(y<0||y>=m)
        return false;
    return true;
}
void bfs(int x,int y)
{
    LL s1,s2;
    int i,j,k;
    queue<node> q;
    node s,e;
    s.x=x;
    s.y=y;
    q.push(s);
    vis[x][y]=1;
    s1=0;
    s2=0;
    while(!q.empty())
    {
        s=q.front();
        q.pop();
        if(a[s.x][s.y]=='.')
            s1++;
        else
            s2++;
        for(i=0;i<4;i++)
        {
            e.x=s.x+dir[i][0];
            e.y=s.y+dir[i][1];
            if(!check(e.x,e.y)||vis[e.x][e.y]||a[s.x][s.y]==a[e.x][e.y])
                continue;
            vis[e.x][e.y]=1;
            q.push(e);
        }
    }
    ans=ans+s1*s2;
}
int main()
{
    int i,j,k;
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++)
        scanf("%s",a[i]);
    memset(vis,0,sizeof(vis));
    ans=0;
    for(i=0;i<n;i++)
    for(j=0;j<m;j++)
    if(vis[i][j]==0)
        bfs(i,j);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
#include<unordered_map>
using namespace std;
int main(){
    int A, B;
    cin >> A >> B;
    int ans = 0;
    for(int i = A;i <= B;i++){
        int s1 = i / 10000;
        int s2 = i / 1000 % 10;
        int s4 = i / 10 % 10;
        int s5 = i % 10;
        if(s1 == s5 && s2 == s4)ans++;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map> 
using namespace std; 
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI1 3.14159265358979311599796346854418516159057617187500

typedef long long int ll;  
ll MOD = 1e9 + 7;

ll power(ll a , ll n)
{
    unsigned long long int result=1,x=a;
    while(n>0)
    {
        if(n % 2 ==1)
            result = (result * x)%MOD;
        x = (x * x)%MOD;
        n=n/2;
    }
    return result;
}

ll GCD(ll a , ll b)
{
    if(b==0)
        return a;
    else
        return GCD(b,a%b);
}

bool find(int a,int b, int c, int rem)
{
    if(rem==0)
    {
        if(a < b && b < c)
            return 1;
        else
            return 0;
    }

    bool f1 = find(2*a,b,c,rem-1);
    bool f2 = find(a,2*b,c,rem-1);
    bool f3 = find(a,b,2*c,rem-1);

    return f1||f2||f3;
}

int main()
{
    FIO;
    int t;
    t=1;
    //cin >> t;
    while(t--)
    {
        int a,b,c;
        cin >> a >> b >> c;
        int k;
        cin >> k;


        bool ans = find(a,b,c,k);

        if(ans)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }   
    return 0;
}


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

int main() {
  string s;
  int count;
  cin>>s;
  if(s.at(0)=='1') count++;
  if(s.at(1)=='1') count++;
  if(s.at(2)=='1') count++;
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include<cstdio>
#include<stdio.h>
using namespace std;

int main() {
	int r, c, sum[100]={};
	int number;
	int A[100][100];

	int total[100] = {};
	int toatalsum =0;

	cin >> r >> c;

	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			cin >> number;
			A[i][j] = number;
			sum[i] += number;
		}
	}
	
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			cout<< A[i][j] <<" ";
		}
		cout << sum[i] << endl;
	}

	for (int i = 0; i < c; i++) {
		for (int j = 0; j < r; j++) {
			total[i] += A[j][i];
		}
	}

	for (int i = 0; i < c; i++) {
		cout  << total[i] <<" ";
		toatalsum += total[i];
	}

	cout << toatalsum << endl;;
	

	return 0;
}




Measured memory_bytes: 3136
#include <bits/stdc++.h>
 using namespace std;
int main() {
    // insert code here...
    string a,b,c;
    int x,y;
    cin >> a >>b ;
    cin >> x >>y ;
    cin >> c;
    
    if(a==c){
        
        x=x-1;
        cout << x << " " << y << endl;
    }
    else{
        
        y=y-1;
        cout << x << " " << y << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int c,d=0,e=0,f=0,g=1,h=0;
    int ans=0;
    cin >>a>>b>>c;
    for(int n=1;n<=a;n++){
	d=n;
	int sum=0;
	while(d) sum+=d%10,d/=10;
	if(sum>=b&&sum<=c) ans+=n;
    }
    cout <<ans<<'\n';
    return (0);
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll N, M; cin >> N >> M;

    vector<vector<string > > vec(N + 1919);

    for(ll i = 0; i < M; i++){
        ll p; string s; cin >> p >> s;
        vec[p-1].push_back(s);
    }

    ll wa = 0;
    ll ac = 0;
    for(ll i = 0; i < N; i++){
        bool f = false;
        ll tmp = 0;
        for(ll j = 0; j < vec[i].size(); j++){
            //cout << vec[i][j] << " ";

            if(vec[i][j] == "AC"){
                ac++;  
                f = true;
                break;
            }
            if(vec[i][j] == "WA"){
                tmp++;
            }
            
        }   
        if(f == true){
            wa += tmp;
        }     
    }


    cout << ac << " " << wa << endl;


}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

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

    int w;
    cin >> w;
    for(int i=0;i<S.size();i+=w){
        cout << S[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256