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

bool search(string* array, int length,  string target)
{
  string array_last = array[length - 1];
  array[length - 1] = target;
  
  int i;
  for (i = 0; array[i] != target; i++)
  {
  }
  array[length - 1] = array_last;
  if (i < length-1)
  {
    return true;
  }
  else if (array_last == target)
  {
    return true;
  }
  else
  {
    return false;
  }
}

int main(void)
{
  bool open = false;
  int n;
  cin >> n;
  string* u = new string[n];
  for (int i = 0; i < n; i++)
  {
    cin >> u[i];
  }

  int m;
  cin >> m;
  for (int i = 0; i < m; i++)
  {
    string t;
    cin >> t;
    if (search(u, n, t) )
    {
      if (open)
      {
        cout << "Closed by ";
      }
      else
      {
        cout << "Opened by ";
      }
      open = !open;
    }
    else
    {
      cout << "Unknown ";
    }
    cout << t << endl;
  }

  delete[] u;
  return 0;
}

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

#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)

using ll = long long;
#define INF 1e9

int N;
vector<int> s;

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

  int sum = a+b+c;
  cout << sum - max(a, max(b,c)) << endl;

  return 0;
}


Measured memory_bytes: 256
import sys

N, T = map(int, input().split())

flag = False
min_c = sys.maxsize
for i in range(1, N + 1):
    c, t = map(int, input().split())

    if t > T:
        continue

    min_c = min(c, min_c)
    flag = True

if flag is True:
    print(min_c)
else:
    print("TLE")

Measured memory_bytes: 3060
def main():
    MOD = 10**9 + 7
    N = int(input())
    A = list(map(int, input().split()))
    hat_cnt = [0, 0, 0]
    ans = 1
    for a in A:
        t = len([c for c in hat_cnt if c == a])
        if t == 0:
            ans = 0
            break
        ans *= t
        ans %= MOD
        for i in range(len(hat_cnt)):
            if hat_cnt[i] == a:
                hat_cnt[i] += 1
                break
    print(ans)


if __name__ == '__main__':
    main()

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;

    ll a0[n] = {}, a1[n] = {};
    ll last = -mod;
    ll count = 1;
    rep(i, n) {
        if (last + c < i && s[i] == 'o') {
            a0[i] = count;
            count++;
            last = i;
            if (count == k + 1) {
                break;
            }
        }
    }

    last = mod;
    count = k;
    repb(i, n) {
        if (i < last - c && s[i] == 'o') {
            a1[i] = count;
            count--;
            last = i;
            if (count == 0) {
                break;
            }
        }
    }

    rep(i, n) {
        if (a0[i] == a1[i] && a0[i] != 0) {
            cout << i + 1 << endl;
        }
    }
    return 0;
}



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

int pow(int a, int n) {
    if (n == 0) return 1;
    
    if (n == 1) return a;
    
    if (n % 2 == 0) {
        int half = pow(a, n / 2);
        return half * half;
    }
    else return pow(a, 1) * pow(a, n - 1);
}

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

    long long ans = 0;
    for (int bit = 0; bit < pow(2, s.size() - 1); bit++)
    {
        int n = 0;
        for (int i = (int)s.size() - 1; i >= 0; i--)
        {
            ans += (long long)(s.at(i) - '0') * pow(10, n);
            n++;
            if (bit&(1<<((int)s.size() - 1 - i))) n = 0;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  int n, s=0;
  scanf("%d", &n);
  char c[n+1];
  scanf("%s", &c);
 
  char ct = 0;
  int i, j=0;
  for(i=0; i<n; i++){
    if(c[i]!=ct) s++; ct=c[i];
  }
  printf("%d", s);
  return 0;
}

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

#define NMAX 100005
using namespace std;

int v[NMAX], win[NMAX];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, k;
    cin >> n >> k;

    for(int i = 1; i <= n; ++i)
        cin >> v[i];

    for(int i = 1; i <= k; ++i)
        for(int j = 1; j <= n; ++j)
            if(i - v[j] >= 0 && !win[i - v[j]])
            {
                win[i] = 1;
                break;
            }
    cout << (win[k] == 1 ? "First\n" : "Second\n") << '\n';
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>


int main()
{
    int q,ope;
    long long num,L,R;
    std::cin>>q;
    std::multiset<long long> S;
    
    for(int i = 0; i < q; i++)
    {
        std::cin>>ope;
        if(ope==1){std::cin>>num; std::cout<<S.count(num)<<std::endl;}
        else if(ope==0){std::cin>>num; S.insert(num); std::cout<<S.size()<<std::endl;}
        else if(ope==2){std::cin>>num; S.erase(num);}
        else{
            std::cin>>L>>R;
            auto a = S.lower_bound(L);
            auto b = S.upper_bound(R);
            for(auto it = a; it!=b; it++){std::cout<<*it<<std::endl;}
        }
    } 
    return 0;
}



Measured memory_bytes: 12296
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define INF 1000000000
ll i,j,k,p;

ll mypow(ll a,ll b){
    ll num=1;
    while(b!=0){
        b--;
        num*=a;
    }
    return num;
}

int main(){
    ll h;cin>>h;
    ll divide=0;
    while(h>0){
        h/=2;
        divide++;
    }
    divide--;

    ll ans=0;
    for(i=0;i<=divide;i++){
        ans+=mypow(2,i);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys

X, N = map(int, input().split())
P = list(map(int, sys.stdin.readline().rsplit()))

m = 1000
for i in range(102):
    if i in P:
        continue
    if abs(X - i) < m:
        m = abs(X - i)
        res = i
    else:
        break

print(res)


Measured memory_bytes: 9112
import numpy as np

X=int(input())
n=0
count=0
ans=0

for i in range(X,10**6):
  n=np.sqrt(i)
  n=int(n)
  count=0
  for j in range(2,n+1):
    if i%j==0:
      break
    else:
      count+=1
  if count==n-1:
    ans=i
    break
  
print(ans)

Measured memory_bytes: 14440
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	cout << "#";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}


Measured memory_bytes: 3084
import java.util.*;
import java.io.*;


public class Main {
	
	public static long execute(long[] s, long n) {
		long m = n;
		for(int i = 0; i < s.length; i++) {
			m = m - (m % s[i]);
		}
		//System.err.println(n + " resulted in " + m);
		return m;
	}
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int m = Integer.parseInt(in.readLine());
		String[] s = in.readLine().split("\\s++");
		long[] k = new long[s.length];
		for(int i = 0; i < s.length; i++) {
			k[i] = Integer.parseInt(s[i]);
		}
		long hi = Long.MAX_VALUE;
		long lo = 2;
		long max = -1;
		long min = -1;
		long t;
		if(execute(k, hi) == 2) max = hi;
		else {
			// find first value that does not work due to exceeding
			while(lo < hi) {
				t = (hi / 2) + (lo / 2) + (((hi % 2) + (lo % 2))/2); // t = hi + lo / 2
				if(execute(k, t) <= 2) lo = t + 1;
				else hi = t;
			}
			max = hi - 1;
			hi = Long.MAX_VALUE;
			lo = 2;
		}
		if(execute(k, lo) == 2) min = lo;
		else {
			while(lo < hi) {
				//find last value that does not work due to under
				t = (hi / 2) + (lo / 2) + ((1 + (hi % 2) + (lo % 2))/2); // t = hi + lo / 2
				if (t < 0) {
					min = Long.MAX_VALUE;
					break;
				}
				if(execute(k, t) >= 2) hi = t - 1;
				else lo = t;
			}
			min = lo + 1;
		}
		if(min > max) System.out.println(-1);
		else System.out.println(min + " " + max);
	}
}

Measured memory_bytes: 48520
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer
import scala.util.control.Breaks
import scala.math.abs

object Main extends App {

  val sc = new Scanner(System.in)
  val n, m, x = sc.nextInt()
  sc.nextLine()


  val book = (1 to n).map { _ =>
    sc.nextLine().split(" ").map(_.toInt)
  }


  val ps = powerSet(book.toList)

  val res = ps.map(read).filter(_ >= 0).minOption match {
    case Some(value) => println(value)
    case None => println(-1)
  }

  def read(books: List[Array[Int]]): Int = {
    var price = 0
    val status = ArrayBuffer.fill(m)(0)
    books.foreach { book =>
      price += book(0)
      (1 to m).foreach { i =>
        status(i - 1) += book(i)
      }
    }
    if (status.forall(_ >= x)) price else -1
  }

  def powerSet[A](xs: List[A]): List[List[A]] =
    xs.foldLeft(List(Nil: List[A]))((accum, elem) => accum.flatMap(l => Seq(l, elem :: l)))
}


Measured memory_bytes: 60192
n, m = map(int, input().split())
L = list()
for i in range(m):
    x, y = map(int, input().split())
    if x > y:
        x, y = y, x
    L.append([x, y])
L = sorted(L, key=lambda x: x[1])
A = L[0]
i = 1
for v in L:
    if v[0] >= A[1]:
        A = v
        i += 1
print(i)

Measured memory_bytes: 22108
def resolve():
    (N,M,C)=(int(i) for i in input().split())
    B=[int(i) for i in input().split()]
    A=[[int(j) for j in input().split()] for i in range(N)]
    count=0
    for sc in A:
        count += 1 if sum([sc[i]*B[i] for i in range(M)])+C>0 else 0
    print(count)
if __name__ == "__main__":
    resolve()

Measured memory_bytes: 38384
S = input()

if len(S) == 1:
    print(0)
else:
    S0 = S[::2]
    S1 = S[1::2]

    tmp1 = sum([int(c) for c in S0]) + len(S1) - sum([int(c) for c in S1])
    tmp2 = len(S0) - sum([int(c) for c in S0]) + sum([int(c) for c in S1])
    
    print(min(tmp1,tmp2))

Measured memory_bytes: 3676
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    long long n, a, b;
    cin >> n >> a >> b;
    long long sum = a + b;
    long long cnt = n / sum;
    long long amari = n - cnt * sum;
    long long tmp = 0;
    if (amari > 0)
    {
        tmp = min(amari, a);
    }
    cout << cnt * a + tmp << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

vector<vector<int>> dista;

int recur(vector<int>& r, vector<bool>& flag, int d=0, int lastIndex=-1){
    int minDista = INT_MAX;
    bool endflag = true;
    for(int i=0;i<flag.size();++i){
        if(flag[i]){
            flag[i]=false;
            if(lastIndex==-1)
                minDista = min(minDista, recur(r, flag, d, r[i]));
            else
                minDista = min(minDista, recur(r, flag, d+dista[lastIndex][r[i]], r[i]));
            flag[i]=true;
            endflag = false;
        }
    }
    if(endflag)
        return d;
    return minDista;
}
int main(){
    int n, m, R;
    cin >> n >> m >> R;
    vector<int> r(R);
    for(int i=0;i<R;++i){
        cin >> r[i];
        --r[i];
    }
    dista = vector<vector<int>>(n, vector<int>(n, INT_MAX));
    for(int i=0;i<n;++i){
        dista[i][i]=0;
    }
    int a, b, c;
    for(int i=0;i<m;++i){
        cin >> a >> b >> c;
        --a, --b;
        dista[a][b]=c;
        dista[b][a]=c;
    }
    for(int k=0;k<n;++k){
        for(int i=0;i<n;++i){
            for(int j=0;j<n;++j){
                if(dista[i][k]!=INT_MAX && dista[k][j]!=INT_MAX)
                    dista[i][j] = min(dista[i][j], dista[i][k]+dista[k][j]);
            }
        }
    }
    vector<bool> flag(R, true);
    cout << recur(r, flag);

    return 0;
}

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

int main () {
  int H , W ;
  cin >> H >> W ;
  
  vector<string> line(H) ;
  for(int i = 0 ; i < H ; i++ ) cin >> line[i] ;
  
  for(int i = 0 ; i < W + 2 ; i++ ) cout << '#' ;
  cout << endl ;
  
  for(int i = 0 ; i < H ; i++ ) {
    cout << '#' << line[i] << '#' << endl ;
  }
  
  for(int i = 0 ; i < W + 2 ; i++ ) cout << '#' ;
  cout << endl ;
}

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


#define M_MAX 20
#define N_MAX 50000
#define INFTY 1 << 29

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


int main(){

int n;
long long int x;
cin >> n>>x ;

long long int xi[n];
set<long long int> lis;
for(int i=0;i<n;i++){
long long int temp;
cin >> temp;
lis.insert(temp);
}
lis.insert(x);
long long int pre=0;
long long int no=0;

set<long long int> lis2;

int flag=0;
for(long long int s:lis){
if(flag==1){
lis2.insert(s-pre);
}else{
flag=1;
}
pre=s;
}

long long int pr=0;
flag=0;
long long int res=0;

for(long long int s:lis2){
if(flag==0){
res=s;
flag=1;
continue;
}
res=gcd(res,s);

}

cout << res<<endl;

}


Measured memory_bytes: 4992
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll dp[100005];
int main(){
	int n,W;
	int w[105],v[105];
	scanf("%d%d",&n,&W);
	int sum = 0;
	for(int i = 1;i <= n;i++){
		scanf("%d%d",&w[i],&v[i]);
		sum += v[i];
	}
	for(int i = 1;i <= sum;i++) dp[i] = 0x3f3f3f3f;
	for(int i = 1;i <= n;i++){
		for(int j = sum;j >= v[i];j--){
		//	dp[j] = 0x3f3f3f3f;
			dp[j] = min(dp[j],dp[j - v[i]] + w[i]);//--
			//cout << j  << ' ' << dp[j] << endl;
		}
	}
	/*这道题为啥从1开始：
	因为如果dp[0] = 0x3f3f3f3f;
	dp[j] = min(0x3f3f3f3f,0x3f3f3f3f + w[i])
	就不用解释了
	只要dp[0] = 0;
	那么dp[v[i]] = min(0x3f3f3f3f,0 + w[i]);

	极大注意：尽量在循环外面进行初始化
	*/
	ll ans = 0;
	for(int i = sum;i >= 0;i--){
		if(dp[i] <= W){
			ans = i;
			break;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    ll x, y; cin >> x >> y;
    int cnt = 0;
    while (x <= y) {
        x *= 2;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

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

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N;
  cin >> N;
  ll p[N], q[N];
  rep(i, N){
    cin >> p[i];
    q[i] = p[i];
  }
  sort(q, q+N);

  vll diff;
  rep(i, N) if(p[i] != q[i]) diff.push_back(i);
  if(diff.size() == 0){
    puts("YES");
  }
  else if(diff.size() == 2 && p[diff[0]] == q[diff[1]]){
    puts("YES");
  }
  else{
    puts("NO");
  }
  return 0;
}


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

#define rep(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define repn(i, m, n) for (int (i) = (m) ; (i) < (int)(n) ; ++(i))
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define repn_rev(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= (m) ; --(i))

#define INF 2e9
#define ll long long
#define MOD 1e9+7

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

    if(s=="Sunny"){
        cout << "Cloudy" << endl;
    }
    else if(s == "Cloudy"){
        cout << "Rainy" << endl;
    }
    else{
        cout << "Sunny" <<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
(* let sl = Str.split (Str.regexp " ") @@ read_line () *)
(* let il = List.map int_of_string sl *)

(* let ar = Array.of_list il *)

let sl = Str.split (Str.regexp " ") @@ read_line ()
let il = List.map int_of_string sl

let ar = Array.of_list il

let area = ar.(0) * ar.(1)

let shu = (ar.(0) + ar.(1)) * 2

let () = print_int area;
  print_string " ";
  print_int shu;
  print_newline ()

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

#define ll long long
#define siz 100005
typedef pair<int ,int> pii;

int main(){

    ios_base::sync_with_stdio(0);
    //freopen("overcode.in","r",stdin);
    //freopen("out.txt","w",stdout);

    ll dp[siz];
    ll h[siz];
    int n; cin>>n;
    for(int i=0;i<n;i++){
        cin>>h[i];
        dp[i]=1e10;
    }
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        dp[i]=min((dp[i-1]+abs(h[i]-h[i-1])),(dp[i-2]+abs(h[i]-h[i-2])));
    }
    cout<<dp[n-1];

    return 0;
}


Measured memory_bytes: 1792
#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>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int p[110000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	printf("%d\n",(a-1+b-2)/(b-1));
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define P pair<int,int>
#define mk make_pair
#define en endl
#define RE return 0
#define int ll

vector<int> ve;
map<int,int> mp;

signed main(){
  int n; cin>>n;
  for(int i=0; i<n; i++){
    int a; cin>>a;
    ve.push_back(a);
    mp[a]++;
  }
  int sum=0;
  
  sort(ve.begin(), ve.end());
  ve.erase(unique(ve.begin(), ve.end()),ve.end());
  for(int i=0; i<ve.size(); i++){
    sum+=mp[ve[i]]-1;
  }
  int ans=sum%2==0?sum/2:sum/2+1;
  cout<<n-ans*2<<en;
}


Measured memory_bytes: 7284
// https://atcoder.jp/contests/abc085/tasks/abc085_b
"use strict"
function Main(input) {
  const args = input.split('\n');
  const n = args[0];
  const kagamiMoti = [];

  for(let i = 1;i<=n; i++) {
    const moti = args[i];
    // if(!kagamiMoti.includes(moti)) 
    if(kagamiMoti.indexOf(moti) === -1) {
      kagamiMoti.push(moti);
    }
  }

  console.log(kagamiMoti.length);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
// ITP1_7_C 表計算
#include <stdio.h>
void space(int c) {
    if (c != 0) {
        putchar(' ');
    }
}
int main() {
    int r, c, sumc = 0;
    scanf("%d%d", &r, &c);    
    int sumcd;
    int data[r][c];
    for (int rc = 0; rc < r; rc++) {
        for (int cc = 0; cc < c; cc++) {
            scanf("%d", &data[rc][cc]);
        }
    }
    for (int rc = 0; rc < r; rc++) {
        sumc = 0;
        for (int cc = 0; cc < c; cc++) {
            space(cc);
            printf("%d", data[rc][cc]);
            sumc += data[rc][cc];
        }
        sumcd+=sumc;
        printf(" %d\n", sumc);
    }
    int sumr;
    for (int ccc = 0; ccc < c; ccc++) {
        sumr = 0;
        for (int rcc = 0; rcc < r; rcc++) {
            sumr+=data[rcc][ccc];
        }
        space(ccc);
        printf("%d",sumr); 
    }
    printf(" %d\n", sumcd);
    return 0;
}



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

int main() {
	string s = "";
	cin >>s;
	int output = 0; int count = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if ((s[i] == 'A') || (s[i] == 'T') || (s[i] == 'G') || (s[i] == 'C'))
		{
			count++;//現在の継続数
		}
		else//継続ストップ
		{
			if(count > output)output=count;//最多なら書き換える
			count = 0;
		}
	}
	if (count > output)output = count;
	if ((output == 0) && count != 0)output = count;
	cout << output;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = list(input())

def check(s):
	#print(s)
	if s == []:
		print("YES")
	elif s[-7:] == list("dreamer"):
		del s[-7:]
		check(S)
	elif s[-6:] == list("eraser"):
		del s[-6:]
		check(s)
	elif any(s[-5:] == list(x) for x in ["dream", "erase"]):
		del s[-5:]
		check(s)
	else:
		print("NO")

check(S)

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define read(x) int x; cin>>x;
#define print(x) for(int i=0; i<(int) x.size(); i++) cout<<x[i]<<" "; cout<<endl;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;

const ll INFLL = (ll) 1e16;
const int INF = (int) 1e8;

bool is_month(int m) {
	return m>=1 && m<=12;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin>>s;
	
	int first = stoi(s.substr(0, 2));
	int second = stoi(s.substr(2));
	if(is_month(first) && is_month(second)) cout<<"AMBIGUOUS"<<endl;
	else if(is_month(first)) cout<<"MMYY"<<endl;
	else if(is_month(second)) cout<<"YYMM"<<endl;
	else cout<<"NA"<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys

ans = {
    'A':0,
    'B':0,
    'AB':0,
    'O':0,
}

for line in map(str.rstrip, sys.stdin):
    if line == '':
        break
    a,b = line.split(',')
    ans[b] +=1
for val in ans.values():
    print(val)



Measured memory_bytes: 5564
#include<bits/stdc++.h>
#define N 200050
#define M 200
#define int long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define coffee prince
#define sz(a) (int)a.size()
#define ll long long
#define SIZE N

using namespace std;
int ar[N],tot;

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n,k; cin>>n>>k;
	for(int i=0;i<n;i++)
	    cin>>ar[i];
	sort(ar,ar+n);
	for(int i=0;i<k;i++)
	    tot += ar[i];
    cout<<tot;
}


Measured memory_bytes: 3656
//

fun main() {
    abc171d()
}

fun abc171d() {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }
    val q = readLine()!!.toInt()
    var items = a.groupingBy { it }.eachCount().toMutableMap()
    var total = a.sum()
    repeat(q) {
        val (b, c) = readLine()!!.split(" ").map { it.toLong() }
        if (b in items) {
            val count = items[b]!!
            val temp = b * count
            total -= temp
            total += c * count
            items[b] = 0
            items[c] = count + items.getOrDefault(c, 0)
        }
        println(total)
    }
}


Measured memory_bytes: 72780
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n,m; cin >> n >> m;
	vector<int> a(n), v(n);
	rep(i,n){
		cin >> a[i], a[i]--;
		v[a[i]] = i;
	}
	vector<vector<int>> G(n);
	rep(i,n){
		REP(j,v[i]+1,n){
			if(a[j] < i){
				G[a[j]].push_back(i);
				G[i].push_back(a[j]);
			}
		}
	}
	vector<int> color(n,-1);
	vector<pii> sz;
	rep(i,n){
		if(color[i] != -1) continue;
		vector<int> cnt(2,0);
		queue<int> q;
		q.push(i);
		cnt[0] = 1;
		color[i] = 0;
		while(!q.empty()){
			int u = q.front(); q.pop();
			for(auto v : G[u]){
				if(color[v] != -1){
					if(color[v] == color[u]){
						cout << 0 << "\n";
						return 0;
					}
					continue;
				}
				color[v] = 1 - color[u];
				cnt[color[v]]++;
				q.push(v);
			}
		}
		sort(all(cnt));
		sz.emplace_back(cnt[0], cnt[1]);
	}
	int k = sz.size();
	vector<vector<int>> dp(k+1,vector<int>(m+1,0));
	dp[0][0] = 1;
	rep(i,k){
		rep(j,m+1){
			if(j+sz[i].first <= m) (dp[i+1][j+sz[i].first] += dp[i][j]) %= mod;
			if(j+sz[i].second <= m) (dp[i+1][j+sz[i].second] += dp[i][j]) %= mod;
		}
	}
	ll ans = 0;
	for(int i=n-m; i<=m; i++) (ans += dp[k][i]) %= mod;
	cout << ans << "\n";
}


Measured memory_bytes: 52160
import sys
import os
import itertools
import numpy as np
from collections import deque

def main():
    if os.getenv("ENV")=='LOCAL':
        sys.stdin = open(os.path.dirname(__file__)+'/input.txt', 'r')

    X=int(input())

    if X>=30:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 27156
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  char s[1001];
  scanf("%s", s);
  string ss = string(s);
  if (ss[ss.size() - 1] == 's')
    ss += "es";
  else
    ss += "s";
  printf("%s\n", ss.c_str());
  return 0;
}

Measured memory_bytes: 3692
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int data = sc.nextInt();
			boolean[] noserufundo = tennbinn(data);
			StringBuilder ans = new StringBuilder();
			for (int i=0; i < noserufundo.length; i++) {
				if (noserufundo[i]) {
					ans.append(fundo[i] + " ");
				}
			}
			System.out.println(ans.toString().trim());
		}
	}

	public static final int[] fundo =
		{1, 2, 4, 8, 16, 32, 64, 128, 256, 512};

	public static boolean[] tennbinn(int object) {
		int len = fundo.length;
		boolean[] noserufundo = new boolean[len];
		for (int i = len-1; 0 <= i && 0 < object; i--) {
			if (object - fundo[i] >= 0) {
				object = object - fundo[i];
				noserufundo[i] = true;
			}
		}
		return noserufundo;
	}
}

Measured memory_bytes: 26024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// 端点を間違えないように気をつけること!
#define FOR(i, m, n) for (ll i = (ll)(m); i <= (ll)(n); i++)
#define RFOR(i, m, n) for (ll i = (ll)(m); i >= (ll)(n); i--)
// 割り算をするときは自作関数syou,amariを使うこと!

int main()
{
    ll N;
    cin >> N;
    ll m = 1e15;
    ll A[5];
    FOR(i, 0, 4)
    {
        cin >> A[i];
        m = min(m, A[i]);
    }
    ll n = (N - 1) / m + 1;
    cout << n + 4 << endl;
}

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

const int N = 100005;
int n, num, a[N], b[N]; long long cnt;
int main () {
	cin >> n, cnt = 0;
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for (int i = 1, d; i <= n; ++i) {
		if (a[i - 1]) {
			d = min(a[i - 1], a[i]);
			cnt += d;
			a[i - 1] -= d, a[i] -= d;
			if (a[i - 1] > 0) cnt += a[i - 1] / 2;
		}
		cnt += a[i] / 2;
		a[i] &= 1;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N;
	cin >> N;
	int a;
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		cin >> a;
		while (a % 2 != 1) {
			a /= 2;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;

    vl x(n);
    rep(i, n) {
        cin >> x[i];
    }

    vl L(n-1);
    rep(i, n-1) {
        L[i] = x[i+1] - x[i];
    }

    ll ans = 0;
    rep(i, n-1) {
        ans += min(a*L[i], b);
    }

    out(ans);
    re0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fr(i,n) for(i=0;i<n;i++)
#define bi(n) __builtin_popcount(n)
#define bil(n) __builtin_popcountll(n)


typedef long long ll;
typedef pair<int,int> pii;
const int N = 100010;
ll mod = 1e9+7;
ll fmod(ll b,ll exp){
    ll res =1;
    while(exp){if(exp&1ll)res=(res*b)%mod;
    b =(b*b)%mod;exp/=2ll;
    }
    return res;
}
int dp[210];


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1,n,i,j,k;
    dp[0]=1;
    for(int i=0;i<=100;i++)if(dp[i]){
        dp[i+4]=1;
        dp[i+7]=1;
    }
    cin>>n;
    cout<<((dp[n]?"Yes\n":"No\n"));


    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))



int main(){
    int N;
    cin>>N;
    vector<LL>A(N),sum(N);
    LL allsum=0;
    const LL mod=1e9+7;
    REP(i,N){
        cin>>A[i];
        allsum+=A[i];
        allsum%=mod;
    }
    sum[0]=(allsum-A[0]+mod)%mod;
    FOR(i,1,N){
        sum[i]=(sum[i-1]-A[i]+mod)%mod;
    }
    LL res=0;
    
    REP(i,N){
        res+=(sum[i]*A[i])%mod;
        res%=mod;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 6428
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        long k = sc.nextLong();

        int n = 50;
        long a[] = new long[n];

        long t = k / n;
        int mod = (int) (k % n);
        for (int i = 0; i < n - mod; i++) {
            a[i] = n + t - 1 - mod;
        }
        for (int i = n - mod; i < n; i++) {
            a[i] = 2 * n + t - mod;
        }

        System.out.println(n);
        System.out.println(Arrays.toString(a).replaceAll("\\[|\\]|,", ""));
    }

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


Measured memory_bytes: 22992
A = map(int,input().split(' '))
Vs = list(map(int,input().split(' ')))
Cs = list(map(int,input().split(' ')))

m = 0

for V,C in zip(Vs,Cs):
	if(V > C):
		m = m + V - C
	else:
		pass

print(m)

Measured memory_bytes: 2940
#include <cfenv>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair

using namespace std;


int main() {
	int n, len = 0;
	cin >> n;
	vector<double> l;
	double t;

	while (cin >> t) {
		l.push_back(t);
	}

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

	for (int i = l.size()-2, c = 0; c < n; i-=2, c++) {
		len += l[i];
	}

	cout << len << endl;

	return 0;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
nums = []
N.times do |i|
    nums << gets.chomp.to_i
end

min_num = nums[0]
max_num = -1000000000
nums.each_with_index do |num, i|
    # puts "#{max_num},#{min_num}"
    if i < nums.length && i >= 1
        max_num = num - min_num > max_num ? num - min_num : max_num
        min_num = num < min_num ? num : min_num
    end
end
p max_num



Measured memory_bytes: 8560
#template
from collections import Counter
def inputlist(): return [int(k) for k in input().split()]
#template
N,M = inputlist()
A = inputlist()
count = 0
s = sum(A)
for i in range(N):
    if A[i] >= s/(4*M):
        count +=1
if count >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3444
=begin
－－－－－－－－－－－－－－
  S = 入力文字列
  ans = 最大ACGT文字数 
－－－－－－－－－－－－－－
  1: S を一文字づつ取り出す
  2: S[i] が ACGT文字で...
    ある場合: cnt += 1
    ない場合: 現在の cnt と ans を比べる...
      cnt > ansの場合: ans に cnt を代入
      cnt を 0 に戻す
  3: ans を出力
=end

S = gets.chomp
ans = 0
cnt = 0

S.length.times do |i|
  case S[i]
  when 'A','C','G','T'
    cnt += 1
  else
    ans = cnt if ans < cnt
    cnt = 0
  end
end

ans = cnt if ans < cnt

puts ans

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 10000000000000007LL
#define ll long long
using namespace std;
ll par[114514];
ll rankk[114514];
ll siz[114514];
void init(int n){
	for(int i=0;i<n;i++){
		par[i] = i;
		rankk[i]=0;
		siz[i] = 1;
	}
}
ll find(ll x){
	if(par[x] == x){
		return x;
	}else{
		return par[x] = find(par[x]);
	}
}
void unite(ll x, ll y){
	x = find(x);
	y = find(y);
	if(x==y)return;
	if(rankk[x]<rankk[y]){
		par[x]=y;
		siz[y] = siz[x]+siz[y];
	}else{
		par[y]=x;
		siz[x]=siz[x]+siz[y];
		if(rankk[x]==rankk[y])rankk[x]++;
	}
}
signed main(){
	int n,m;
	cin>>n>>m;
	init(n);
	vector< pair<int,int> > v;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		v.pb( mp(x,y) );
	}
	ll ans = 0;
	vector<int> res;
	res.pb(ans);
	for(int i=v.size()-1;i>=1;i--){
		int cx = v[i].first;
		int cy = v[i].second;
		//cout<<cx<<" "<<cy<<endl;
		int sx = siz[ find(cx) ];
		int sy = siz[ find(cy) ];
		//cout<<sx<<" "<<sy<<endl;
		if( find(cx) != find(cy) ){
			ans += sx*sy;
		}
		unite(cx,cy);
		res.pb(ans);
	}
	reverse(res.begin(),res.end());
	int ful = n*(n-1)/2;
	for(int i=0;i<res.size();i++){
		cout<<ful-res[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int N;cin>>N;
    string s, t; cin >> s >> t;
    int ans=2*N;
    for(int i=N;i>=1;i--){
        if(s.substr(N-i,i) == t.substr(0,i)) {cout << ans-i << endl; break;}
        if(i==1) cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	deque<int> deq;
	int a;
	for (int i = 0; i < N; i++) {
		cin >> a;
		if (N & 1 ^ i & 1) deq.emplace_front(a);
		else deq.emplace_back(a);
	}

	for (const auto &e : deq) cout << e << " ";

	return 0;
}

Measured memory_bytes: 3072
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)


int main(){
    ll ans=0;
    ll N,M;cin>>N>>M;
    //S全部使える場合
    if(N*2<=M){
        ans += N;
        M -= 2*N;
        //残りのcを使う
        ans += M/4;
    }
    //使えない時
    else{
        ans += M/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << (a > 8 or b > 8 ? ":(" : "Yay!") << endl;
    
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
# include <bits/stdc++.h>
using namespace std;
long long powerexp(long long base, long long exp, int mod) {
   long long res = 1;
   while (exp > 0) {
      if (exp % 2 == 1)
         res= (res * base) % mod;
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}
int gcd(int a, int b)
{
    int c = a % b;
    while(c != 0)
    {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}
void PrintVector(vector<long long int> v,long long int n)
{
 
    for(int i=0;i<v.size();i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void Takevector(vector<long long int> &v,long long int n)
{
  for(long long int i=0;i <n;i++)
  { long long int number;
    cin>>number;
    v.push_back(number);
  }
}
typedef long long int ll;
typedef vector<long long int> vi;
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define scl(x)         ll x;       scanf("%lld", &x);
#define scll(x, y)     ll x, y;    scanf("%lld %lld", &x, &y);
#define sclll(x, y, z) ll x, y, z; scanf("%lld %lld %lld", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define rep(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
#define repi(i, x, y)  for (__typeof(x) i = x; i >= y; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
#define nl cout<<"\n";
int min(int x, int y)  
{  
    return (x < y)? x: y;  
      
}  

int main()
{
	int flag=1,flag1=0;
  ll sum=0,tot=0,ans=0;
  unordered_map<ll,ll>mp;
  vi v,v1;
  unordered_multiset<int>st,st1;
  string s;
  
  sci(n);
  rep(i,0,n-1)
  {
  	cin>>ans;
  	mp[ans]++;
  	mp[ans+1]++;
  	mp[ans-1]++;
  }
  for(auto it=mp.begin();it!=mp.end();it++)
  {
  	v.push_back(it->second);
  }
  sort(v.begin(),v.end(),greater<int>());
  cout<<v[0];
  // int max=0;
  // for(auto it=st.begin();it!=st.end();it++)
  // {
  // 	if(st.count(*it)>max) max=st.count(*it);
  // }
  // cout<<max;








return 0;
}

Measured memory_bytes: 5796
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 >= 13){
            System.out.println(B);

        }
        else if(A >= 6){
            System.out.println(B / 2);
        }
        else{
            System.out.println("0");
        }

    }
}

Measured memory_bytes: 24276
// @samraj2k #2ksr 
//Not showoff, but solid.
//Not handsome, but likeable.
//Not intelligent, but hardworking.
//Not with good speaking skills, but great thoughts.
//This is me.
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define see(x) cout << (#x) << " is " << (x) << endl
#define see2(x,y) cout << (#x) <<" "<<(#y)<< " are " << (x) <<" "<<(y)<< endl
#define samraj2k ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

int main()
{  
  samraj2k;
  int n,k;
  cin>>n>>k;
  int arr[n];
  for(int i=0;i<n;i++)  cin>>arr[i];
  int dp[n];
  dp[0]=0;
  dp[1]=abs(arr[1]-arr[0]);
  for(int i=2;i<n;i++)
  { int mini=10e8;
    for(int j=1;j<=k;j++)
    {
      if(i-j>=0)
        mini=min(mini,abs(arr[i]-arr[i-j])+dp[i-j]);
    }
    dp[i]=mini;
  }
  cout<<dp[n-1];
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define N 123456
using namespace std;
typedef long long ll;
int main(void)
{
//    freopen("in.txt","r",stdin);
    ll a[10];
    for(ll i=1;i<=5;i++) cin>>a[i];
    for(ll i=1;i<=5;i++) {
        if(a[i]==0)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3620
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  int ans = 0;
  rep(i, a + 1) {
    rep(j, b + 1) {
      int res = 500 * i + 100 * j;
      res = x - res;
      res /= 50;
      if (0 <= res && res <= c) ans++;
    }
  }
  cout << ans << endl;



  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力
            var input = Console.ReadLine();
            var array = input.Split(' ');

            var hp = double.Parse(array[0]);
            var atk = double.Parse(array[1]);
            // 加工&出力
            Console.WriteLine(Math.Ceiling(hp / atk));
        }
    }
}

Measured memory_bytes: 13140
const main = (input) => {

  input = input.trim().split('\n')
  let n = parseInt(input[0], 10)
  const nums = input[1].split(' ').map(Number).sort((a, b) => b - a)

  let ans = 0
  for (let i=1; i<n; i++) ans += nums[Math.floor(i/2)]

  return console.log(ans)
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 53180
import java.util.Scanner;

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

    	if (a < b){
    		System.out.println("a < b");
    	}

    	if (a == b){
    		System.out.println("a == b");
    	}

    }
}

Measured memory_bytes: 26180
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for i in range(N):
    if B[i] <= A[i]:
        ans += B[i]
        A[i] -= B[i]
    else:
        ans += A[i] + min(B[i] - A[i], A[i + 1])
        A[i + 1] = max(A[i + 1] - (B[i] - A[i]), 0)
        A[i] = 0

print(ans)


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

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

    if(n%2==1){cout << "No" << endl;return 0;}

    string half = s.substr(n/2);

    cout << ((s == half+half) ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
    
class Program
{
    static void Main(string[] args)
    {
        int X = int.Parse(Console.ReadLine());

        if(X>=30) {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 27528
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    string s;cin>>s;
    if(s.at(1)==s.at(0) && s.at(1)==s.at(2)) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


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

int main(){
    int n;
    cin >> n;
    char s[100];
    for(int i=0;i<n;i++){
        cin >> s[i];
        if(s[i]=='Y'){
            puts("Four");
            return 0;
        }
        }
        puts("Three");
}

Measured memory_bytes: 256
#include <stdio.h>

int getLB(int a[],int k,int head,int tail){
    if(a[0]>=k)return 0;
    
    if(head>tail)return -1;
    
    int mid=(head+tail)/2;
    if(a[mid]<k)head=mid+1;
    else if(a[mid]>=k){
        if(a[mid-1]<k)return mid;
        tail=mid-1;
    }
    
    return getLB(a,k,head,tail);
}

int main(void){
    int i;
    
    int n;
    scanf("%d\n",&n);
    int a[n];
    for(i=0;i<n;i++)scanf("%d ",&a[i]);
    
    int q;
    scanf("%d\n",&q);
    
    int k,LB;
    while(q--){
        scanf("%d\n",&k);
        LB=getLB(a,k,0,n-1);
        if(LB==-1)LB=n;
        printf("%d\n",LB);
    }

    return 0;
}



Measured memory_bytes: 2188