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

int main(){
	int s[300];
	for(int i = 0; i < 300; i++) s[i] = 0;
	cin >> s[0];
	for(int i = 1; ; i++){
		s[i] = (s[i-1]%2 == 0) ? s[i-1]/2 : s[i-1]*3+1;
		for(int j = 0; j < i; j++){
			if(s[i] == s[j]){
				cout << i + 1 << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int ans=0;
  for(int i=0;i<3;i++){
    if(s.at(i)==t.at(i)){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
#define MAX 2000000

int gHeap[MAX + 1],gSize;

void maxHeapify(int i){
    int left,right,largest;
    left = 2 * i;
    right = 2 * i + 1;
    
    // 左の子、自分、右の子で値が最大のノードを選択
    if(left <= gSize && gHeap[left] > gHeap[i]){
        largest = left;
    }
    else{
        largest = i;
    }
    // 右の子と比較
    if(right <= gSize && gHeap[right] > gHeap[largest]) largest = right;
    
    if(largest != i){
        swap(gHeap[i],gHeap[largest]);
        maxHeapify(largest);
    }
}

int main(){
    cin >> gSize;
    
    for(int i = 1;i <= gSize;++i) cin >> gHeap[i];
    // buildMaxHeap
    for(int i = gSize / 2;i >= 1;--i)maxHeapify(i);
    
    for(int i = 1;i <= gSize;++i){
        cout << " " << gHeap[i];
    }
    cout << endl;
    
    return 0;
}



Measured memory_bytes: 4956
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scanner = new Scanner(System.in);
        int card = scanner.nextInt();
        int gate = scanner.nextInt();
        
        int l = 0,r = Integer.MAX_VALUE,tmpr = 0,tmpl = 0;
        for(int i=0;i < gate; i++){
            tmpl = scanner.nextInt();
            tmpr = scanner.nextInt();
            l = (l > tmpl ? l : tmpl);
            r = (r < tmpr ? r : tmpr);
        }
        
        int open  = r-l+1;
        open = open <= 0 ? 0 : open; 
        System.out.println(open);
    }
}


Measured memory_bytes: 62532
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int n,ans=0;
	cin>>n;
	string s;
	cin>>s;
	for(int i=1;i<n;i++){
		int cnt=0;
		for(char c='a';c<='z';c++){
			bool left=false,right=false;
			for(int j=0;j<i;j++)
				if(s[j]==c)
					left=true;
			for(int j=i;j<n;j++)
				if(s[j]==c)
					right=true;
			if(left&&right)
				cnt++;
		}
		if(ans<cnt)
			ans=cnt;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0L;i--)
#define prep(i,n) for(int64_t i=1;i <= (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  fspcnt = 0;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int64_t n,k;
  cin >> n >> k;
  vector<int64_t> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  
  int64_t b = 1 ;
  b = b << 58;
  int64_t res = 0;
  while(b > 0){
    //cout << "#";
    int64_t onecnt = 0;
    rep(i,n){
      if(a.at(i) & b){
        onecnt++;
      }
    }
    if(onecnt < n - onecnt && res + b <= k){
      res += b;
    }
    b = b >> 1;
  }
  int64_t res2 = 0;
  rep(i,n){
    res2 += res^a.at(i);
  }
  cout << res2 << endl;
    
}

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

using namespace std;

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

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

int main(){
  int n;cin>>n;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin>>h.at(i);
  }
  vector<int> dp(n);
  
  dp.at(0)=0;dp.at(1)=abs(h.at(1)-h.at(0));
  
  for(int i=2;i<n;i++){
    dp.at(i)=min(dp.at(i-1)+abs(h.at(i)-h.at(i-1)),dp.at(i-2)+abs(h.at(i)-h.at(i-2)));
  }
  cout<<dp.at(n-1);    
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define maxn 100010
#define ll long long
#define db double
#define vi vector<int>
#define pb push_back
#define mod 998244353
#define fi first
#define pi pair<int, int>
#define se second
#define mp make_pair
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
// head
int fa[maxn];
ll sz[maxn], ans[maxn];
int gfa(int a) {
	if (fa[a] == a) return a;
	return fa[a] = gfa(fa[a]);
}
int n, m;
vi eg[maxn];
int a[maxn], b[maxn];
int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		scanf("%d%d", &a[i], &b[i]), 
		a[i] -= b[i];
	for (int i = 1; i <= m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		eg[u].pb(v), eg[v].pb(u);
	}
	vector<pi> r(n);
	for (int i = 1; i <= n; i++)
		r[i - 1] = mp(a[i], i), 
		sz[i] = b[i];
	sort(r.begin(), r.end());
	for (int i = 0; i < n; i++) {
		int nid = r[i].se;
		fa[nid] = nid;
		ll nans = max(0, a[nid]);
		for (auto v : eg[nid]) {
			if (!fa[v]) continue;
			else {
				int nf = gfa(v);
				if (nf == nid) continue;
				fa[nf] = nid;
				nans = min(nans, max(ans[nf], a[nid] - sz[nf]));
				sz[nid] += sz[nf];
			}
		}
		ans[nid] = nans;
	}
	cout << ans[gfa(1)] + sz[gfa(1)] << endl;
	return 0;
}


Measured memory_bytes: 9468
using System;
using System.Collections.Generic;
using System.Linq;

namespace RacconVSMonster
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var attackInput = Console.ReadLine().Split(' ');
            int monsterHealth = int.Parse(input[0]);
            int attacksNumber = int.Parse(input[1]);

            List<int> specialAttacks = new List<int>();
            for(int i = 0; i < attacksNumber; i++)
            {
                specialAttacks.Add(int.Parse(attackInput[i]));
            }

            int attackPower = specialAttacks.Sum();

            if(attackPower >= monsterHealth)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 19296
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ans = 0;
    int tem = 0;
    int p = -1;
    for(int i = 0; i < n; i++) {
      int h = sc.nextInt();
      if(tem >= h) {
        p++;
        ans = Math.max(ans, p);
      } else { 
        p = 0;
      }
      tem = h;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 50268
import collections

N = int(input())
A = [int(input()) for _ in range(N)]

a = collections.Counter(A)
a = sorted(a.items(), key=lambda x: -x[0])

for i in A:
    if a[0][1] == 1 and i == a[0][0]:
        print(a[1][0])
    else:
        print(a[0][0])


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

void push(int x);
int pop();

int top, S[199];

int main(int argc, char *argv[]) {

  int x,y;
  char s[100];

  top = 0;

  while(scanf("%s", s) != EOF) {
    if(s[0] == '+') {
      x = pop();
      y = pop();
      push(x + y);
    }
    else if(s[0] == '-') {
      y = pop();
      x = pop();
      push(x - y);
    }
    else if(s[0] == '*') {
      x = pop();
      y = pop();
      push(x * y);
    }
    else push(atoi(s));
  }

  printf("%d\n", pop());
  
  return 0;
}

void push(int x) {
  S[++top] = x;
}

int pop() {
  top--;
  return S[top+1];
}



Measured memory_bytes: 2088
#include <stdio.h>

int main (void)

{

int n,i, num,min=1000001,max=-1000001;

long sum=0;

scanf("%d",&n);

for(i=0;i<n;i++)

{

scanf("%d",&num);

sum+=num;

if(min>num){

min=num;

}

if(max<num){

max=num;

}

}

printf("%d %d %ld\n",min,max,sum);

return 0;

}

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

int main(){
  int n;
  cin >> n;
  vector<int> lines(n);
  for (int i = 0; i < n; i++){
    cin >> lines.at(i);
  }
  sort(lines.begin(),lines.end());
  int sum = 0;
  for (int i = 0; i < n-1 ; i++){
    sum += lines.at(i);
  }
  if (sum > lines.at(n-1)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 384
s = input()
mods = [0]*2019
mods[0] = 1
accu = 0
for i, j in enumerate(reversed(s)):
    accu += int(j)*pow(10, i, 2019)
    accu %= 2019
    mods[accu] += 1
ans = 0
for i in mods:
    ans += i*(i-1)//2
print(ans)

Measured memory_bytes: 9140
#include <stdio.h>

long pp[100001];

long p(int w) {
  
   if (pp[w]>0) return pp[w];
   pp[w]=(p(w-1)+p(w-2))%1000000007;
   return pp[w];
}

int main(){
   int n,m,a[100000],i,j,w;
   long ans;
    
   scanf("%d %d",&n,&m);
   for (i=0;i<m;i++) scanf("%d",&a[i]);
   pp[1]=pp[2]=1;
   for (i=3;i<=n;i++) pp[i]=0;
   ans=1;j=0;
   for (i=0;i<m;i++) {
      w=a[i]-j;
      if (w==0) {
         ans=0;
         break;
      }
      ans=(ans*p(w))%1000000007;
      j=a[i]+1;
   }
   w=n-j+1;
   if (w>0) ans=(ans*p(w))%1000000007;
   else     ans=0;
   printf("%d\n",ans);
   return 0;
}


Measured memory_bytes: 4480
// https://atcoder.jp/contests/abc089/tasks/abc089_c

#include <bits/stdc++.h>
#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

ll N, m[5] = {0}, r = 0;
string S;

void add(int a, int b, int c)
{
  r += m[a] * m[b] * m[c];
}

int main()
{
  cin >> N;
  REP(i, N)
  {
    cin >> S;
    if (S[0] == 'M')
      m[0]++;
    else if (S[0] == 'A')
      m[1]++;
    else if (S[0] == 'R')
      m[2]++;
    else if (S[0] == 'C')
      m[3]++;
    else if (S[0] == 'H')
      m[4]++;
  }

  REP(i, 5)
  {
    FOR(j, i + 1, 5)
    {
      FOR(k, j + 1, 5)
      {
        add(i, j, k);
      }
    }
  }

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#define MAX 100
#define INFTY 200000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,a[MAX][MAX];

void dijkstra(){
	int minv,i,v,u;
	int d[MAX],color[MAX];

	for(i=0;i<n;i++){
		d[i] = INFTY;
		color[i] = WHITE;
	}

	d[0] = 0;
	color[0] = GRAY;
	while(1){
		minv = INFTY;
		u = -1;
		for(i = 0;i<n;i++){
			if(minv>d[i] && color[i] != BLACK){
				u = i;
				minv = d[i];
			}
		}
		if(u == -1)break;
		color[u] = BLACK;
		for(v = 0;v<n;v++){
			if(color[v] != BLACK && a[u][v] != INFTY){
				if(d[v]>d[u]+a[u][v]){
					d[v] = d[u] + a[u][v];
					color[v] = GRAY;
				}
			}
		}
	}
	for(i = 0;i<n;i++){
		printf("%d",i);
		printf(" ");
		d[i]= (d[i] == INFTY) ? -1 : d[i];
		 printf("%d\n",d[i]);
	}
}

int main(){
	int i,k,c,u,v,j;

	scanf("%d",&n);
	for(i = 0;i<n;i++){
		for(j = 0;j<n;j++){
			a[i][j] = INFTY;
		}
	}
	for(i=0;i<n;i++){
		scanf("%d %d",&u,&k);
		for(j = 0;j<k;j++){
			scanf("%d %d",&v,&c);
			a[u][v] = c;
		}
	}
	dijkstra();

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,m;
  while(cin >>n>>m,n|m){
    vector<int> h,t;
    int sum[2] = {0};
    for(int i=0,x; i<n; i++){
      cin >>x;
      sum[0]+=x;
      t.push_back(x);
    }
    for(int i=0,x; i<m; i++){
      cin >>x;
      sum[1]+=x;
      h.push_back(x);
    }
    int ans[2] = {101, 101}, dif = sum[0]-sum[1];
    for(int i=0; i<t.size(); i++){
      for(int j=0; j<h.size(); j++){
	if(2*(t[i]-h[j]) == dif){
	  if(ans[0]+ans[1] > h[j]+t[i]){ans[0] = t[i]; ans[1] = h[j];}
	}
      }
    }
    if(ans[0] == 101){cout <<"-1"<<endl;}
    else{cout <<ans[0]<<" "<<ans[1]<<endl;}
  }
  return 0;
}

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

using namespace std;
long long int n;
long long int A[100][2];
long long int dpdp[100][100000];
long long int dp(long long int,long long int);

long long int dp(long long int i,long long int w)
{long long int ans;
    if(i==n)
        return(0);

        if(dpdp[i][w]!=-1)
            return(dpdp[i][w]);

            ans=dp(i+1,w);

            if(w-A[i][0]>=0)
                ans=max(dp(i+1,w),A[i][1]+dp(i+1,w-A[i][0]));

    dpdp[i][w]=ans;

    return(ans);
}

int main()
{
memset(dpdp,-1,sizeof(dpdp));
    long long int w,i,j,ans;
    cin>>n>>w;
    for(i=0;i<n;i++)
    {
        for(j=0;j<2;j++)
        {
            cin>>A[i][j];
        }
    }

    ans=dp(0,w);
    cout<<ans;

    return(0);
}


Measured memory_bytes: 78336
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    A, B = map(int, input().split())
    for i in range(100):
        if A * i - (i - 1) >= B:
            print(i)
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long ll;

int main(){
    ll n,neck=1e16;
    vector<ll> a;
    cin>>n;

    a.resize(5);
    for(int i=0; i<5; i++){
        cin>>a[i];
    }
    for(int i=0; i<5; i++){
        if(a[i]<neck){
            neck=a[i];
        }
    }
    cout<<(n+neck-1)/neck+4<<endl;

    return 0;    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int k = sc.nextInt(), t = sc.nextInt();
		int[] a = new int[t];
		int max = 0;
		int sum = 0;
		for (int i = 0; i < t; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
			max = Math.max(max, a[i]);
		}
		System.out.println(Math.max(0, max - (sum - max) - 1));
	}
}

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

int main(){
  int Bfir=0,Wfir=0;
  string str;
  cin >> str ;
  for(int i=0;i<str.length();i++){
    if(i%2==0){
     if(str[i]=='0')Bfir++;
     else Wfir++;
    }else{
      if(str[i]=='0')Wfir++;
      else Bfir++;
    }
  }  
  cout << min(Bfir,Wfir) << endl;
  return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();
      int y = sc.nextInt();
      int z = sc.nextInt();
      int count = 0;
      x -= z;
      while(x >= 0){
      	x -= y+z;
        count++;
      }
      System.out.println(count-1);
    }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int a[200005],pos[200005],n;
ll ret;
int main()
{
	cin >> n;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		pos[a[i]] = i;
	}
	set<P>S;
	S.insert(mp(1,n));
	for(int i=1;i<=n;i++){
		set<P>::iterator it = S.upper_bound(mp(pos[i],INF));
		it--;
		int L = (*it).fi, R = (*it).sc; S.erase(it);
		
		ll x = R - L+ 1; x = x*(x+1)/2LL;
		ll y = 0;
		if(L < pos[i]){
			ll D = pos[i] - L;
			y += D*(D+1)/2LL;
			S.insert(mp(L,pos[i]-1));
		}
		if(R > pos[i]){
			ll D = R - pos[i];
			y += D*(D+1)/2LL;
			S.insert(mp(pos[i]+1,R));
		}
		ret += (x-y) * i;
	}
	cout << ret << endl;
}

Measured memory_bytes: 4096
#include <stdio.h>
int min(int a,int b){
    if(a<b){
        return a;
    }
    return b;
}
int main(){
    int L,R;
    scanf("%d %d",&L,&R);
    int i,j;
    int l;
    int k;
    int ans;
    ans=2019;
    l=min(L+2019,R);
    for(i=L;i<l;i++){
        for(j=i+1;j<=l;j++){
            k=((i%2019)*(j%2019))%2019;
            ans=min(ans,k);
        }
    }
    printf("%d",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#ifdef LOCAL
	#define debug(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define debug(...) 42
#endif

#define sf scanf
#define pf printf
#define nl printf("\n")
#define ps(s) printf("%s",s.c_str())
#define mem(x,val) memset(x,val,sizeof x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

inline string getString(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string getLine(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
typedef long long ll;

const int S=200100;
int n,m;

int root[S+5];
int siz[S+5];

void Init()
{
	for(int i=0;i<=S;i++)root[i]=i,siz[i]=1;
}

int Find_root(int x)
{
    if(root[x]==x)return x;
    return root[x]=Find_root(root[x]);
}

void Union(int u,int v)
{
    u=Find_root(u);
    v=Find_root(v);
    if(u==v)return;

    if(siz[u]>siz[v])swap(u,v);
    siz[v]+=siz[u];
    siz[u]=0;
    root[u]=v;
}

int main()
{
	while(~sf("%d %d",&n,&m))
	{
		Init();
		for(int i=0;i<m;i++)
		{
			int u,v;
			sf("%d %d",&u,&v);
			if(Find_root(u)!=Find_root(v))Union(u,v);
		}

		int mx=*max_element(siz+1,siz+1+n);
		pf("%d\n",mx);
	}
    return 0;
}



































Measured memory_bytes: 5312
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int p, q, r;
    cin >> p >> q >> r;
    cout << min({p+q, q+r, r+p}) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e5;

int N;
vector<vector<int>> G;
vector<int> color;//0:見探索 1, -1:色分け
bool jdg;//二部グラフか否か

void Bipartite_Graph(int now, int pre){
    if(now != pre && color[now] != 0){
        if(color[now] == color[pre])jdg = false;
    }else{
        if(now == pre)color[now] = -1;
        color[now] = color[pre] * -1;
        for(auto v : G[now]){
            if(v == pre)continue;
            Bipartite_Graph(v, now);
        }
    }
    return;
}

void warshall_floyd(vector<vector<int>> &_Date){
    for(int k = 0; k < _Date.size(); k++){        //経由頂点
        for(int i = 0; i < _Date.size(); i++){    //始点
            for(int j = 0; j < _Date.size(); j++){//終点
                _Date[i][j] = min(_Date[i][j], _Date[i][k] + _Date[k][j]);
            }
        }
    }
}

int main(){
    cin >> N;
    G.assign(N, vector<int>());
    color.assign(N, 0);
    jdg = true;
    vector<vector<int>> dis(N, vector<int>(N, INF));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            char a;
            cin >> a;
            if(a == '1'){
                dis[i][j] = 1;
                G[i].push_back(j);
            }
        }
    }
    
    Bipartite_Graph(0, 0);
    int ans = -1;
    if(jdg){
        warshall_floyd(dis);
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                ans = max(ans, dis[i][j] + 1);
            }
        }
    }
    if(N == 2 && ans == 3)ans--;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int H, W, N;
    cin >> H >> W >> N;
    int ret;
    if (H > W) {
        ret = (int)(ceil(1.0 * N / H));
    } else {
        ret = (int)(ceil(1.0 * N / W));
    }
    cout << ret << endl;
    return 0;
}

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

int main(void){
  int i,N;
  cin >> N;
  long long sum=0;
  vector<int> a(N);
  rep(i,N) cin >> a[i];
  sort(a.rbegin(), a.rend());
  rep(i,N-1) sum += a[(i+1)/2];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 4056
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);
	// 入力

	int a = sca.nextInt();
	int b = sca.nextInt();


	if(a > b) {
		for(int i = 1; i <= a; i++) {
			System.out.print("" + b);
		}
	}
	else {
		for(int i = 1; i <= b; i++) {
			System.out.print("" + a);
		}
	}

	System.out.println("");
	// 後始末
	sca.close();
	}
}

Measured memory_bytes: 22996
#include <iostream>
#include <string>
using namespace std;
int a,b,c,k;
int main()
{
    cin>>a>>b>>c>>k;
    if(a>=b&&a>=c)
    while(k--) a=a*2;
    else if(b>=a&&b>=c)
    while(k--) b=b*2;
    else if(c>=b&&c>=a)
    while(k--) c=c*2;
    cout<<a+b+c<<endl;
    return 0;
}


Measured memory_bytes: 256
/*
    NEVER GIVE UP!
    THE EXPERT IN ANYTHING WAS ONCE A BEGINNER
*/

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;


void solve()
{
    string s,t;
    cin >> s >> t;
    ll l =sz(s);
    if(t.substr(0,sz(s)) == s && sz(t)-sz(s) == 1)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
#define mp make_pair
#define fi first
#define se second
#define All(x) (x).begin(),(x).end()
#define Y1 "YES"
#define N1 "NO"
#define ENDL '\n'
#define count2(x) _builtin_popcount(x)
int num[300000];
int ans[300000];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;++i)
	cin>>ans[i];
	for(int i=0;i<k;++i){
		int pass=1;
		for(int j=1;j<=n;++j)
		num[j]=0;
		for(int j=1;j<=n;++j){
			if(j-ans[j]<=1)num[1]++;
			else ++num[j-ans[j]];
			if(ans[j]+j<=n)num[ans[j]+j+1]--;
		}
		int sum=0;
		for(int j=1;j<=n;++j){
			sum+=num[j];
			ans[j]=sum;
			if(ans[j]!=n){
				pass=0;
			}
		}
		if(pass||i==k-1){
			for(int j=1;j<=n;++j)
			cout<<ans[j]<<" ";
			return 0;
		}
	}
	return 0;
}
/*
4 1
0 0 0 0
1 1 1 1
4 1
1 0 0 0
1 2 1 1
4 1
4 0 0 0
1 2 2 2
*/

Measured memory_bytes: 5204
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

template<int mod>
struct mint {
private:
    long long x;
public:
    mint(long long x = 0) :x(x%mod) {}
    mint(std::string s) {
        long long z = 0;
        REP(i, s.size()) {
            z *= 10;
            z += s[i] - '0';
            z %= mod;
        }
        this->x = z;
    }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    friend std::ostream& operator<<(std::ostream& os, const mint& n) {
        return os << n.x;
    }
    bool operator==(const mint a) const {
        return this->x == a.x;
    }
};

// comb (前計算O(NlogMOD) クエリO(1))
vector<mint<(int)1e9+7>> FACT, IFACT;
mint<(int)1e9+7> comb(int n, int r) {
    if (n < 0 || r < 0 || r > n)return 0;
    if (r > n / 2) r = n - r;
    return FACT[n] * IFACT[n - r] * IFACT[r];
}

//pow
template<typename T, typename U>
T pow(T k, U n, T unity = 1) {
    while (n > 0) {
        if (n & 1) {
            unity *= k;
        }
        k *= k;
        n >>= 1;
    }
    return unity;
}

int main() {
    const int MOD = 1e9 + 7;
    int n; cin >> n;
    vector<int> v(n+1);
    vector<int> cnt(n,0);
    int x;
    REP(i, n+1) {
        scanf("%d", &v[i]);
        v[i]--;
        if (cnt[v[i]] == 1) x = v[i];
        cnt[v[i]]++;
    }
    int a = 0, b = 0, c = 0;
    int f = 0;
    REP(i, n + 1) {
        if (v[i] == x) {
            if (f == 0) f = 1;
            else if (f == 1) f = 2;
        }
        else {
            if (f == 0) a++;
            else if (f == 1) b++;
            else c++;
        }
    }
    // 前計算(mainに)
    int MAX_N = a + b + c;
    FACT.resize(MAX_N + 1);
    IFACT.resize(MAX_N + 1);
    FACT[0] = 1;
    IFACT[0] = 1;
    for (int i = 1; i <= MAX_N; i++) {
        FACT[i] = FACT[i - 1] * i;
        IFACT[i] = pow(FACT[i], MOD-2);
    }
    cout << n << endl;
    FOR(k, 2, n + 2) {
        cout << comb(a + b + c, k) + comb(a + b + c, k - 1) * 2 - comb(a + c, k - 1) + comb(a + b + c, k - 2) << endl;
    }
    return 0;
}

Measured memory_bytes: 3584
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>

inline void read(int &T) {
	int x=0;bool f=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=!f;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	T=f?-x:x;
}

int n,m,x,cnt,sd[15];
int c[15],a[15][15];
int now[15];
long long ans=1e17;

void count() {
	long long tot=0;
	memset(now,0,sizeof now);
	for(int i=1;i<=cnt;++i) {
		tot+=c[sd[i]];
		for(int j=1;j<=m;++j) {
			now[j]+=a[sd[i]][j];
		}
	}
	for(int i=1;i<=m;++i) {
		if(now[i]<x) return;
	}
	if(tot<ans) ans=tot;
}

void dfs(int step) {
	if(step>n) {
		count();
		return;
	}
	for(int i=0;i<=1;++i) {
		if(i==1) {
			sd[++cnt]=step;
			dfs(step+1);
			--cnt;
		}else dfs(step+1);
	}
}

int main() {
	read(n),read(m),read(x);
	for(int i=1;i<=n;++i) {
		read(c[i]);
		for(int j=1;j<=m;++j) {
			read(a[i][j]);
		}
	}
	dfs(1);
	if(ans==1e17) puts("-1");
	else std::cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define show(x) cout<<#x" = "<<x<<endl;
#define show2(x,y) cout<<#x" = "<<x<<" "<<#y<<" = "<<y<<endl;
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> iipair;
typedef pair<unsigned,unsigned> uupair;
typedef vector<int> vec;
typedef vector<unsigned> uvec;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    unsigned n,a;
    cin>>n;
    bool flag=0;
    while(n--)
    {
        cin>>a;
        if(flag || a&1) continue;
        if(a%3 && a%5)  flag=1;
    }
    if(flag)    cout<<"DENIED";
    else cout<<"APPROVED";
}  

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
 
int main(){
    double a,b,c,d;
    scanf("%lf %lf %lf %lf",&a,&b,&c,&d);
    printf("%.8lf\n",sqrt(pow(c-a,2.0)+pow((d-b),2.0)));
}

Measured memory_bytes: 2744
import java.util.*;
import java.util.stream.Collectors;

import static java.lang.System.out;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Map<String,Integer> map = new HashMap<>();
        long n = sc.nextLong();
        for (int i = 0; i < n ; i++) {
            String s = sc.next();
            Integer score = map.getOrDefault(s, 0);
            score += 1;
            map.put(s,score);
        }
        long m = sc.nextLong();
        for (int i = 0; i < m ; i++) {
            String s = sc.next();
            Integer score = map.getOrDefault(s, 0);
            score -= 1;
            map.put(s,score);
        }

        int max = map.values().stream().max(Comparator.naturalOrder()).get();
        if(max < 0){
            out.print(0);
        }else{
            out.print(max);
        }
    }
}

Measured memory_bytes: 28244
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
     
    if(s.contains("ABC")){
      System.out.println("ARC");
  }else{
      System.out.println("ABC");
    }
       }
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a,b,c; cin >> a >> b >> c;
  int k; cin >> k;

  for(int bit = 0;bit<=(1<<(3*k));bit++){
    int ia=a,ib=b,ic=c;
    for(int i = 0;i<=3*k;i++){
      if(bit & (1<<i)){
	if(i%3==0){
	  ia *= 2;
	  i+=3;
	}
	else if(i%3==1){
	  ib *= 2;
	  i+=2;
	}
	else{
	  ic *= 2;
	  i+=1;
	}
      }
      if(ia<ib && ib<ic){
      cout << "Yes" << endl;
      return 0;
      }
    }
  }

  cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3588
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

/*
* Problem : 151A
* Acknowledgement : None
* Author : Deathnaught_
* Github : www.github.com/DeathNaughT-GitHub
* Complexity : O(1)
*/

public class Main
{
    static class FastReader 
    { 

        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 

        char nextChar()
        {
            return next().charAt(0);
        }
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 

        int[] nextArray(int rows)
        {
            int arr[] = new int[rows];            
            for (int i = 0; i < rows; i++)
            arr[i] = nextInt();
            return arr;
        }

        long[] nextLongArray(int rows)
        {
            long arr[] = new long[rows];            
            for (int i = 0; i < rows; i++)
            arr[i] = nextLong();
            return arr;
        }

        char[] nextCharArray(int rows)
        {
            char arr[] = new char[rows];
            for (int i = 0; i < rows; i++)
            arr[i] = next().charAt(0);
            return arr;
        }

        int[][] nextMatrix(int rows, int columns)
        {
            int mat[][] = new int[rows][columns];
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    mat[i][j] = nextInt();
                }
            }
            return mat;
        }

        char[][] nextCharMatrix(int rows, int columns)
        {
            char mat[][] = new char[rows][columns];
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    mat[i][j] = nextChar();
                }
            }
            return mat;
        }
    } 

    public static void main(String[] args) 
    {
        
        FastReader sc = new FastReader();
     	char C = sc.nextChar();
      	System.out.println((char)(C + 1));
    }
}

Measured memory_bytes: 21076
#include<stdio.h>

int main()
{
  int n;
  int a[100001];
  int i;
  int ans=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    while(i+1<n && a[i]==a[i+1]) i++;
    if(i+1<n && a[i]<a[i+1]){
      while(i+1<n && a[i]<=a[i+1]) i++;
    }
    else if(i+1<n && a[i]>a[i+1]){
      while(i+1<n && a[i]>=a[i+1]) i++;
    }
    ans++;
  }
  printf("%d",ans);
  return 0;
}


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

int main () {
	int N , A , B ;
	cin >> N >> A >> B ;
	int a = 0 , b = 0 , c = 0 ;
	for(int i = 0 ; i < N ; i++ ){
	int x ;
	cin >> x ;
	if(x<=A) a++ ;
	else if(x>B) c++ ;
	else b++ ;
	}
	cout << min({a,b,c}) << endl ;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
char A[110000];
char B[110000];
char C[110000];
char ret[110000];
int c[5];
int d[3];
int e[3];
int chk(){
    for(int i=0;i<3;i++)e[i]=d[i];
    int rem=c[1];
    int tmp=min(rem,e[2]);
    rem-=tmp;e[2]-=tmp;
    e[0]-=rem;e[1]-=rem;
    if(e[0]<0||e[1]<0)return 0;
    rem=c[2];
    tmp=min(rem,e[1]);
    rem-=tmp;e[1]-=tmp;
    e[0]-=rem;e[2]-=rem;
    if(e[0]<0||e[2]<0)return 0;
    rem=c[3];
    tmp=min(rem,e[0]);
    rem-=tmp;e[0]-=tmp;
    e[2]-=rem;e[1]-=rem;
    if(e[2]<0||e[1]<0)return 0;
    int mv=max(e[0],max(e[1],e[2]));
    int sum=e[0]+e[1]+e[2];
    int can=min(sum-mv,sum/2);
    if(can<c[4])return 0;
    return 1;
}
char ko[5];
int ty[110000];
int main(){
    int a,b;
    while(scanf("%d%d",&a,&b),a){
        scanf("%s%s%s",A,B,C);
        for(int i=0;i<5;i++)c[i]=0;
        for(int i=0;i<a;i++){
            if(A[i]==B[i]&&B[i]==C[i])ty[i]=0;
            else if(A[i]==B[i])ty[i]=1;
            else if(A[i]==C[i])ty[i]=2;
            else if(C[i]==B[i])ty[i]=3;
            else ty[i]=4;
            c[ty[i]]++;
        }
    //  for(int i=0;i<5;i++)printf("%d ",c[i]);
        for(int i=0;i<3;i++)d[i]=b;
        if(!chk()){
            printf("-1\n");continue;
        }
        ret[a]=0;
        for(int i=0;i<a;i++){
            c[ty[i]]--;
            ko[0]='A';ko[1]=A[i];ko[2]=B[i];ko[3]=C[i];
            std::sort(ko,ko+4);
            for(int j=0;j<4;j++){
                if(A[i]!=ko[j])d[0]--;
                if(B[i]!=ko[j])d[1]--;
                if(C[i]!=ko[j])d[2]--;
                if(chk()){ret[i]=ko[j];break;}
                if(A[i]!=ko[j])d[0]++;
                if(B[i]!=ko[j])d[1]++;
                if(C[i]!=ko[j])d[2]++;
            }
        }
        printf("%s\n",ret);
    }
}

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

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
int h, w;
vector<vector<bool>> mp;
vector<vector<ll>> dp;

const vector<vector<int>> dir = {{0, 1}, {1, 0}};

int main()
{
	cin >> h >> w;
	mp.resize(h + 2, vector<bool>(w + 2, true));
	dp.resize(h + 2, vector<ll>(w + 2));
	for(int i = 1; i <= h; i++) for(int j = 1; j <= w; j++) {
		char c; cin >> c; mp[i][j] = c == '#';
	}

	dp[1][1] = 1;
	queue<pair<int,int>> que;
	vector<vector<bool>> seen(h + 2, vector<bool>(w + 2));
	que.push({1,1});

//	cerr << "yay" << endl;

	while(que.size()) {

		int y = que.front().first, x = que.front().second;
		que.pop();
		for(auto d : dir) {
			int ny = y + d[0], nx = x + d[1];
			if(mp[ny][nx] || seen[y][x])continue;
			dp[ny][nx] += dp[y][x];
			dp[ny][nx] %= mod;
			que.push({ny, nx});
		}
		seen[y][x] = true;
	}

	cout << dp[h][w] << endl;
}

Measured memory_bytes: 8448
#include <iostream>

using namespace std;
int prime(int n){ 
        bool* notprime = new bool[n+1];
        int counter = 0;
        for(int i = 2 ; i <= n ; i++){ 
                if(!notprime[i]){
                        counter++;
                        for(int j = 2 ; j*i <= n ; j++){
                                notprime[j*i] = true;
                        }   
                }   
        }   
        return counter;
}
int main(){
        int n;
        while(cin >> n){ 
                cout << prime(n) << endl;
        }   
}

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

int main(){
  int n, l = 0, r = 0, sum = 0;
  long long ans = 0;
  cin >> n;
  int a[n];
  for(; r < n; r++){
    cin >> a[r];
    while(sum & a[r]){
      sum ^= a[l];
      l++;
    }
    sum ^= a[r];
    ans += r - l + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.Arrays;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(); 
    int K = sc.nextInt();
    
    int[] arr = new int[N];
    
    for(int i = 0; i < N; i++) {
      arr[i] = sc.nextInt();
    }
    Arrays.sort(arr);
    
    int sum = 0;
    for(int i = 0; i < K; i++) {
      sum += arr[i];
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 38868
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

template <typename T>
struct Edge {
  int src, dst;
  T weight;
  Edge(int src, int dst, T weight) :
    src(src), dst(dst), weight(weight) { }
};
template <typename T>
bool operator < (const Edge<T> &e, const Edge<T> &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

template <typename T>
struct Graph {
  int V;    // 頂点数
  vector<Edge<T>> *adj;
  bool directed;

  explicit Graph(int V, bool directed) {
    this->V = V;
    this->adj = new vector<Edge<T>> [V];
    this->directed = directed;
  }
  // 辺を追加
  void add_edge(int src, int dst, T weight) {
    assert(src >= 0 && src < V);
    assert(dst >= 0 && dst < V);

    adj[src].push_back(Edge<T>(src, dst, weight));
    if (!directed) {
      adj[dst].push_back(Edge<T>(dst, src, weight));
    }
  }
  // 辺があるかチェック
  bool has_edge(int src, int dst) {
    return any_of(adj[src].begin(), adj[src].end(),
                  [dst](Edge<T> e) { return e.dst == dst; });
  }
  // 辺を削除
  void remove_edge(int src, int dst) {
    adj[src].erase(remove_if(adj[src].begin(), adj[src].end(),
                             [dst](Edge<T> e) { return e.dst == dst; }),
                   adj[src].end());

    if (!directed) {
      adj[dst].erase(remove_if(adj[dst].begin(), adj[dst].end(),
                              [src](Edge<T> e) { return e.dst == src; }),
                     adj[dst].end());
    }
  }
  // 連結判定
  bool is_connected() {
    vector<bool> visited(V, false);
    queue<int> container;
    container.push(0);

    while (!container.empty()) {
      int p = container.front();
      container.pop();
      visited[p] = true;
      for (auto e : adj[p]) {
        if (!visited[e.dst]) {
          container.push(e.dst);
        }
      }
    }
    return all_of(visited.begin(), visited.end(),
                  [](bool v) { return v; });
  }
  // vector<T> shortest_path(int s);
  // vector<vector<T>> shortest_paths();
  // Graph<T> spanning_tree();
};

bool adj[51][51] = {};

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

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

  Graph<int> g(N, false);

  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g.add_edge(a, b, 1);
  }

  int result = 0;

  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (g.has_edge(i, j)) {
        g.remove_edge(i, j);
        if (!g.is_connected()) {
          result++;
        }
        g.add_edge(i, j, 1);
      }
    }
  }

  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		char[] mo = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
		int i;
		char a = stdIn.next().charAt(0);
		for(i=0 ; i<26 ; i++) {
			if(a == (mo[i])) {
				break;
			}
		}
		System.out.println(mo[i+1]);
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <vector>

using namespace std;

int main() {
    vector<char> v = {'a', 'e', 'i', 'o', 'u'};
    char c;
    cin >> c;
    if (find(v.begin(), v.end(), c) != v.end()) {
        cout << "vowel\n";
    } else {
        cout << "consonant\n";
    }
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np


def solve(N, C, AB):
    def edges_to_array(A, B, N, M):
        head = np.full(N + 1, -1, np.int32)
        nxt = np.empty(M + M, np.int32)
        to = np.empty(M + M, np.int32)
        for i in range(M):
            a = A[i]
            b = B[i]
            nxt[i << 1] = head[a]
            to[i << 1] = b
            head[a] = i << 1
            nxt[i << 1 | 1] = head[b]
            to[i << 1 | 1] = a
            head[b] = i << 1 | 1
        return head, nxt, to

    def EulerTour(head, nxt, to, root=1):
        N = len(head) - 1
        parent = np.zeros_like(head)
        ind_L = np.empty_like(head)
        ind_R = np.empty_like(head)
        tour = np.empty(N + N, np.int32)
        stack = np.empty(N + N, np.int32)
        stack[0] = -root
        stack[1] = root
        t = -1
        s = 2
        while s > 0:
            s -= 1
            v = stack[s]
            t += 1
            tour[t] = v
            if v > 0:
                ind_L[v] = t
                p = parent[v]
                k = head[v]
                while k != -1:
                    w = to[k]
                    if w == p:
                        k = nxt[k]
                        continue
                    parent[w] = v
                    stack[s] = -w
                    s += 1
                    stack[s] = w
                    s += 1
                    k = nxt[k]
            else:
                ind_R[-v] = t
        return tour, ind_L, ind_R, parent

    head, nxt, to = edges_to_array(AB[::2], AB[1::2], N, N - 1)
    tour, ind_L, ind_R, parent = EulerTour(head, nxt, to)
    removed = np.zeros(N + 1, np.int64)
    answer = np.full_like(removed, N * (N + 1) // 2)
    memo = np.zeros_like(answer)
    for v in tour:
        if v > 0:
            memo[v] = removed[C[parent[v]]]
        else:
            v = -v
            removed[C[v]] += 1
            p = parent[v]
            x = (ind_R[v] - ind_L[v]) // 2 + 1  # subtree size
            x -= removed[C[p]] - memo[v]
            answer[C[p]] -= x * (x + 1) // 2
            removed[C[p]] += x
    for i, x in enumerate(removed):
        x = N - x
        answer[i] -= x * (x + 1) // 2
    return answer


def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', '(i8,i4[:],i4[:])')(solve)
    cc.compile()


try:
  from my_module import solve
except:
  cc_export()
  exit()
N = int(readline())
C = np.zeros(N + 1, np.int32)
C[1:] = np.array(readline().split(), np.int32)
AB = np.array(read().split(), np.int32)
answer = solve(N, C, AB)
print('\n'.join(answer[1:].astype(str)))


Measured memory_bytes: 76384