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

typedef vector<int> veci;
typedef pair<int, int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9 + 7)
#define fi first
#define se second
#define endl '\n'

struct UnionFind {
    vector<int> par;
    vector<int> rnk;

    UnionFind(int n) {
        par.resize(n);
        rnk.resize(n, 0);
        for (int i = 0; i < n; ++i) par[i] = i;
    }

    int find(int a) {
        if (par[a] == a) return a;
        par[a] = find(par[a]);
        return par[a];
    }

    void merge(int a, int b) {
        a = find(a);
        b = find(b);
        if (a == b) return;

        if (rnk[a] < rnk[b]) {
            par[a] = b;
        } else {
            par[b] = a;
            if (rnk[a] == rnk[b]) rnk[a] += 1;
        }
    }
};

void solve() {
    int n, m;
    cin >> n >> m;

    UnionFind uf(n);

    int a, b;
    for (int i=0; i<m; ++i) {
        cin >> a >> b;
        a--, b--;
        uf.merge(a, b);
    }

    int ans = 0;
    vector<int> cnt(n, 0);
    for (int i=0; i<n; ++i) {
        int g = uf.find(i);
        cnt[g] += 1;
        ans = max(ans, cnt[g]);        
    }

    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tcs;
    tcs = 1;
    while (tcs-- > 0) solve();
}


Measured memory_bytes: 5568
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation
#include<complex>
#include<math.h>
#include<sstream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep2(i, j, n) for (int i = j; i < (int)(n); i++)
using ll = long long int;
int main() {
	ll A, B, K;
	cin >> A >> B >> K;
	if (A >= K) {
		cout << A - K << ' '<< B << endl;
	}
	else if(A + B >= K){
		cout << 0 << ' ' << A + B - K << endl;
	}
	else {
		cout << 0 << ' '<< 0 << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
typedef long double LD;
#define LP(i, a, b) for (LL i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (LL i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-8
#define INF 1e9
#define LINF 1e18

LL const MaxSize = 1000 + 5;
LL const MOD =  998244353;

/*
 check B, W
 check

 ws,

 */

int N;
string s;

int main() {
	ios_base::sync_with_stdio(false);
	//freopen("/Users/georgeli/A_1.in", "r", stdin);
	cin >> N >> s;
	int wcnt = 0;

	LP(i, 0, N)
	{
		if (s[i] == '.')
			wcnt++;
	}

	int ans = min(wcnt, N - wcnt);
	int curW = 0;

	LP(i, 0, N)
	{
		if (s[i] == '.') {
			curW++;
			wcnt--;
		}

		int fh = (i + 1) - curW;
		int sh = wcnt;
		ans = min(ans, fh + sh);
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 720
#include<stdio.h>
int main(void)
{
	int n,m,cnt;
	scanf("%d",&n);
	while(n!=0) {
		m=1000-n;
		cnt=0;
		cnt=cnt+(m/500);
		m=m%500;
		cnt=cnt+(m/100);
		m=m%100;
		cnt=cnt+(m/50);
		m=m%50;
		cnt=cnt+(m/10);
		m=m%10;
		cnt=cnt+(m/5);
		m=m%5;
		cnt=cnt+m;
		printf("%d\n",cnt);
	scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{

    int N,A[110]={},M,sumv=0,b=0;

    cin>>N>>M;

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

    //降順に
    sort(A,A+N,greater<int>());

    int x = A[M-1];

    b=(sumv +(4*M) -1)/(4*M);

    if(x>=b){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
//If you are reading this then you are at wrong place.
#include<bits/stdc++.h>
#define mod 1000000007
#define lli long long int
using namespace std;
bool prime [1000001];
void debug(lli a){cout<<a<<endl;}
lli sieve(lli a){memset(prime,true,sizeof(prime));lli p,i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli find_max(lli __a,lli __b){return __a^((__a^__b) & -(__a<__b));}
lli add(lli __a,lli __b,lli MOD){lli x = (__a+__b)%MOD; return x; }
lli mul(lli a,lli b,lli MOD){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b,lli MOD){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b,lli MOD){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
int main()
{
	//ifstream cin("testcase.txt");
	//ofstream cout("output.txt");	
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);	
	cout.precision(20);
	lli t,i,j;
	//cin>>t;
	//memset(dp, -1, sizeof dp);
	t=1;
	lli counter1=0;
	while(t--)
	{
		counter1++;
		int a,b,c;
		cin>>a>>b>>c;
		if(c>=a && c<=b)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
		//cout<<"Case #"<<counter1<<" ";
		//cout<<endl;	
	}	
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toDouble()
    val a = readLine()!!.toLong()
    val b = readLine()!!.toLong()
    val c = readLine()!!.toLong()
    val d = readLine()!!.toLong()
    val e = readLine()!!.toLong()
    val bottleNeck = Math.min(a,Math.min(b, Math.min(c, Math.min(d, e))))
    val t = Math.ceil(n / bottleNeck.toDouble()).toLong()
    println(t+4)
}


Measured memory_bytes: 34668
from collections import Counter

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

cntD = Counter(D)
for t in T:
    if cntD[t] <= 0:
        print('NO')
        break
    cntD[t] -= 1
else:
    print('YES')

Measured memory_bytes: 41700
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int n, k;
vector<int> dq;

int main() {
    cin >> n >> k;
    dq.resize(n);
    rep(i, n) { cin >> dq[i]; }
    int ans = 0;
    rep(l, n + 1) {
        rep(r, n - l + 1) {
            if (l + r > k) break;
            priority_queue<int, vector<int>, greater<int>> pq;
            int sum = 0;
            rep(i, l) {
                sum += dq[i];
                pq.push(dq[i]);
            }
            rep(i, r) {
                sum += dq[n - 1 - i];
                pq.push(dq[n - 1 - i]);
            }
            int cd = k - l - r;
            rep(i, cd) {
                if (!pq.empty() && pq.top() < 0) {
                    sum -= pq.top();
                    pq.pop();
                } else {
                    break;
                }
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int cnt[7];

int main()
{
	int n;
	while( std::cin >> n, n )
	{
		memset( cnt, 0, sizeof( cnt ) );

		while( n-- )
		{
			int age;
			std::cin >> age;

			for( int i = 0; i != 7; ++i )
			{
				if( !i && age < 10 )
					++cnt[i];
				else if( i == 6 && age >= 60 )
					++cnt[i];
				else if( i * 10 <= age && age < ( i + 1 ) * 10 )
					++cnt[i];
			}
		}

		for( int i = 0; i != 7; ++i )
				std::cout << cnt[i] << std::endl;
	}
	
	return 0;
}

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

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
            var b = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
            var c = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();

            var total = 0;
            var pre = a[0] - 1;
            foreach(var i in a){
                var idx = i - 1;
                total += b[idx];
                if(pre + 1 == idx){
                    total += c[idx - 1];
                }
                pre = idx;
            }

            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 11220
import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
      	int n=sc.nextInt();
      	int[] x=new int[n];
      	int[] y=new int[n];
      	for (int i=0;i<n;i++){
        	x[i]=sc.nextInt();
          	y[i]=sc.nextInt();
        }

      	double o=0;
      	for(int i=0;i<n;i++){
          for(int j=i+1;j<n;j++){
            	o+=Math.sqrt(Math.pow(x[i]-x[j],2)+Math.pow(y[i]-y[j],2));
          }
        }
      	o*=2;
      	o/=n;
      	System.out.println(o);
    }
}

Measured memory_bytes: 23764
e,*v={}
$<.map{|l|y,x,a=l.split.map &:to_i;a ?[y,x+=R].map{|i|(e[i]||=[])<<[a,y^x^i]}:R||=y}
R.times{|z|q=[[z+1,0,c=[],d=[9e9]]]
(z,b,c,d=z
v[z]?v[z]==b||c<<-9e9:e[z]&.map{|a,w|q<<[w,a-b,d,c]}
c<<v[z]=b)while z=q.pop
c.min<-d.min&&$><<:No<<exit}
puts:Yes

Measured memory_bytes: 68604
#n=int(input())
#li=input().split()
#d=["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"]
#import numpy as np
#import math
#li=list(map(int,input().split()))
#S=input()

lis=[]
for i in range(5):
    lis.append(int(input()))
k=int(input())
lis.sort()
if lis[-1]-lis[0]>k:
    print(":(")
else:
    print("Yay!")


Measured memory_bytes: 2940
#include <stdio.h>
#include<string.h>

int main(void)
{
	int i,moji,total=0;
	char a[200001],b[200001];
	scanf("%s",a);
	scanf("%s",b);
	moji=strlen(a);
	for(i=0;i<moji;i++){
		if(a[i]!=b[i])total++;
	}
	printf("%d",total);
	return 0;
}

Measured memory_bytes: 2076
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String str = sc.nextLine();
    int[] a = new int[3];
    int count = 0;
    for(int i=0;i<3;i++){
      a[i] = Integer.valueOf(str.substring(i,i+1));
    }
    for(int j : a){
      if(j == 1) count++;
    }
    System.out.print(count);
  }
}

Measured memory_bytes: 35628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int n0 = 83;
int n, a[n0];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	ll money = 1000;
	for (int i = 1; i < n; i++) {
		if (a[i + 1] > a[i]) {
			money += (a[i + 1] - a[i]) * (money / a[i]);
		}
	}
	cout << money;
}


Measured memory_bytes: 3652
N, M = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(M)]

D = [0] * N

for a, b in ab:
  a -= 1
  b -= 1
  D[a] += 1
  D[b] += 1

ans = True
for x in D:
  if x % 2 == 1:
    ans = False

if ans:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 86092
#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)
{
    int a, b, c;
    cin >> a >> b >> c;

    if (a + b < c)
    {
        cout << b + a + b + 1 << endl;
    }
    else
    {
        cout << b + c << endl;
    }
}

Measured memory_bytes: 256
#include<algorithm>
#include<vector>
#include<cstdio>

int par[100], rank[100];

void init( int n )
{
	for( int i = 0; i != n; ++i )
	{
		par[i] = i;
		rank[i] = 0;
	}

	return;
}

int find( int x )
{
	if( x == par[x] )
		return x;
	else
		return par[x] = find( par[x] );
}

void unite( int x, int y )
{
	x = find( x );
	y = find( y );
	if( x == y )
		return;

	if( rank[x] < rank[y] )
		par[x] = y;
	else
	{
		par[y] = x;
		if( rank[x] == rank[y] )
			++rank[x];
	}

	return;
}

bool same( int x, int y )
{
	return find( x ) == find( y );
}

struct edge{ int from, to, cost; };

std::vector<edge> es;

bool compare( const edge& lhs, const edge& rhs )
{
	return lhs.cost < rhs.cost;
}

int main()
{
	int n, m;
	while( scanf( "%d", &n ), n )
	{
		es.clear();

		scanf( "%d", &m );

		for( int i = 0; i != m; ++i )
		{
			int a, b, c;
			scanf( "%d,%d,%d", &a, &b, &c );
			edge e = { a, b, c / 100 - 1 };
			es.push_back( e );
		}

		std::sort( es.begin(), es.end(), compare );

		init( n );

		int ans = 0;
		for( int i = 0; i != es.size(); ++i )
		{
			if( !same( es[i].from, es[i].to ) )
			{
				unite( es[i].from, es[i].to );
				ans += es[i].cost;
			}
		}

		printf( "%d\n", ans );
	}

	return 0;
}

Measured memory_bytes: 1180
a,b,c = gets.split(" ").map(&:to_i)
n = gets.to_i

result = "No"
for i in 0..n
  for j in 0..(n-i)
    k = n - i -j
    x = a * (2 ** i)
    y = b * (2 ** j)
    z = c * (2 ** k)
    if y > x && z > y
      result = "Yes"
      break
    end
  end
end

puts result

Measured memory_bytes: 14352
#include <stdio.h>
#include <stdlib.h>
#include <math.h>    
void kock(int,double,double,double,double);

int main()
{
  int n;
  double ret;
  double p1x = 0;
  double p1y = 0;
  double p2x = 100;
  double p2y = 0;
  scanf("%d",&n);
  printf("%.8f %.8f\n",p1x,p1y);
  kock(n,p1x,p1y,p2x,p2y);
  printf("%.8f %.8f\n",p2x,p2y);
  
  
  return 0;
}

void kock(int n,double p1x,double p1y,double p2x,double p2y){
  double sx,sy,tx,ty,ux,uy;
  double rad = sqrt(3.0);
  if(n==0) return;
  
  else{
    sx =(2*p1x + 1*p2x)/3;
    sy =(2*p1y + 1*p2y)/3;
    tx =(1*p1x + 2*p2x)/3;
    ty =(1*p1y + 2*p2y)/3;
    //    ux =(tx-sx)*cos(rad) - (ty-sy)*sin(rad)+sx;
    //    ux =(tx-sx)*sin(rad) + (ty-sy)*cos(rad)+sy;
    ux = sx + (-sx + rad*sy + tx - rad*ty)/2.0;
    uy = sy + (-rad*sx - sy + rad*tx + ty)/2.0;
 
    kock(n-1, p1x,p1y,sx,sy);
    printf("%.8f %.8f\n",sx,sy);
    kock(n-1, sx,sy,ux,uy);
    printf("%.8f %.8f\n",ux,uy);
    kock(n-1, ux,uy,tx,ty);
    printf("%.8f %.8f\n",tx,ty);
    kock(n-1, tx,ty,p2x,p2y);
    
  }
  
  
}

Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	int i;
	string a,b;
	cin>>a>>b;
	if(a.size()>b.size()) cout<<"GREATER";
	if(a.size()<b.size()) cout<<"LESS";
	if(a.size()==b.size()){
		for(i=0;i<a.size();i++){
			if(a[i]>b[i]){
				cout<<"GREATER";
				return 0;
			} 
			if(a[i]<b[i]){
				cout<<"LESS";
				return 0;
			} 
		}
		cout<<"EQUAL";
	}
	return 0;
}

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

int main()	{
	int N, A, B;
	cin >> N >> A >> B;
	if(N == 1 && A != B || A > B)
		cout << 0;
	else cout << (long long)abs((B - A)) * (N - 2) + 1;
	
	return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;

namespace ConsoleAppAtCoderABC171
{
    class Program
    {
        static void Main(string[] args)
        {
            var c = ReadLine()[0];

            if(Char.IsLower(c))
            {
                WriteLine("a");
            }
            else
            {
                WriteLine("A");
            }
        }
    }
}


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

bool cmp(char a, char b)
{
	return a>b;
}

int main(){
	string s,t;
	
	cin >> s;
	cin >> t;
	
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),cmp);
	
	if(s<t) cout<<"Yes";
	else  cout<<"No";
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double mt = 0.5 * (h * 60 + m);
  double ht = 6 * m;
  double t = abs(ht - mt);
  t = min(t, 360 - t);
  double pi = atan(1) * 4;
  double ans = sqrt(a * a + b * b - 2 * a * b * cos(t * pi / 180));
  printf("%.20f\n", ans);
}

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

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n,t,a,h[1010];

int main() {
    std::cin >> n;
    std::cin >> t>>a;
    for (int i = 0; i < n; i++) {
        std::cin >> h[i];
    }

    double value = 100000;
    ll ans = -1;
    for (int i = 0; i < n; i++) {
        if( value > abs( (t - h[i]*0.006) - a) ){
            value = abs( (t - h[i]*0.006) - a) ;
            ans = i+1;
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class BROTN {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            char[] s = in.next().toCharArray();

            for (int i = 0; i < s.length; i++) {
                s[i] += n;
                if (s[i] > 'Z')
                    s[i] -= 26;
            }

            out.println(String.valueOf(s));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23508
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <climits>
#include <cassert>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair


int main(){
    int N, W;
    cin >> N >> W;

    vector<int> vs(N);
    vector<int> ws(N);
    REP(i, N) cin >> vs[i] >> ws[i];

    // [??????????????§?????????][??????] = ??????
    vector<vector<int>> dp(N+1, vector<int>(W+1));

    FOR(n, 1, N+1) {
        auto weight = ws[n-1];
        auto value = vs[n-1];
        REP(w, W+1) {
            if (w >= weight) {
                dp[n][w] = max(dp[n-1][w - weight] + value,
                               max(dp[n-1][w],
                                   dp[n][w - weight] + value
                                   ));
            }
            else 
                dp[n][w] = dp[n-1][w];
        }
    }

    int ret = 0;
    REP(w, W+1) {
        ret = max(ret, dp[N][w]);
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 4956
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define repf(i, n) for(int i=1; i<(int)(n+1); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    int k, a, b;
    cin >> k >> a >> b;
    int now = 0;

    while(now*k <= b){
        if(now*k >= a && now*k <= b){
            cout << "OK" << endl;
            return 0;
        }
        else now++;
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    vector<vector<int>> dp(n+1, vector<int>(m+1, 0));
    rep(i, n)rep(j, m){
        if(s[i] == t[j]){
            dp[i+1][j+1] = dp[i][j] + 1;
        }else{
            dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
        }
    }
    string ans = "";
    int i = n;
    int j = m;
    while(i > 0 && j > 0){
        if(dp[i][j] == dp[i-1][j]){
            i--;
        }else if(dp[i][j] == dp[i][j-1]){
            j--;
        }else{
            ans = s[i-1] + ans;
            i--;
            j--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 38844
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>

#define all(x) x.begin(), x.end()
#define MOD 998244353

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

void solve()
{
    vector<int> a(5);

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

    for(int i = 0; i < 5; i++)
    {
        if(a[i] == 0)
        {
            cout << i + 1 << endl;
        }
    }
}

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

    int T = 1;
    //cin >> T;

    while (T--)
    {
        solve();
    }

    return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define var auto
using namespace std;
using ll = long long;
using P = pair<int, int>;
// sort(A.begin(), A.end(), cmp)
bool cmp(P a, P b) { return a.second < b.second; }
#ifdef DEBUG
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; cout << a << endl; return 1; } cout << a << endl; return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; cout << a << endl; return 1; } cout << a << endl; return 0; }
#else
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; }
#endif
const ll INF = 1LL << 60;
const int MAX_ITEM = 10e4+10; // 10^5
ll dp[MAX_ITEM] = {0};

int main() {
  int n;
  cin >> n;
  // vector<string> s;
  map<string, int> m;
  rep(i,n) {
    string ss;
    cin >> ss;
    // s.push_back(ss);
    m[ss] += 1;
  }

  // 最大値を出す
  int max = 0;
  vector<string> max_s;
  for (auto &mm : m) {
    if (mm.second > max) {
      max = mm.second;
      max_s = {mm.first};
    } else if (mm.second == max) {
      max_s.push_back(mm.first);
    }
  }

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

  for (auto &ss: max_s) {
    cout << ss << endl;
  }
  
  return 0;
}


Measured memory_bytes: 26868
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}
vector<ll> yak;
void yakusuu(ll x){
    for(ll i=1;i*i<=x;i++){
        if(x%i==0){
            yak.push_back(i);
            if(i*i!=x){
                yak.push_back(x/i);
            }
        }
    }
    sort(yak.begin(),yak.end());
}

int main(){
    ll n,m;cin>>n>>m;
    yakusuu(m);
    ll g=1;
    if(m==1){
        cout<<g<<endl;
    }else{
        for(ll i=1;i<yak.size();i++){
            if(yak[i]<=m/n){
                g=yak[i];
            }
        }
        cout<<g<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s: String,
    }

    let ans = if s == "RRR" {
        3
    } else if s.contains("RR") {
        2
    } else if s.contains('R') {
        1
    } else {
        0
    };

    println!("{}", ans);
}


Measured memory_bytes: 2160
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N =sc.nextInt();
        int A =sc.nextInt();
        int B =sc.nextInt();

        String S = sc.next();

        int countA=0;
        int countB=0;
        for(int i=0;i<N;i++)
            if (S.charAt(i) == 'a') {
                if(countA<A+B){
                    countA++;
                    System.out.println("Yes");
                    }
                else{
                    System.out.println("No");
                }
            }
            else if(S.charAt(i)=='b'){
                if(countA <A+B){
                    if(countB<B){
                        countA++;
                        countB++;
                        System.out.println("Yes");
                    }
                    else{
                        System.out.println("No");
                    }
                }else{
                    System.out.println("No");
                }
            }else{
                System.out.println("No");
            }
    }
}


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


int main() {
    int k, x;
    cin >> k >> x;
    int begin = x - (k-1);
    int end = x + (k-1);

    vector<int> v(2000001);
    for (int i = begin; i <= end; ++i) {
        cout << i << " "s;
    }
}

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

int main (){
  int a,b;
  cin>>a>>b;
  if(a<=b){
    cout<<"unsafe";
  }
  else{
    cout<<"safe";
  }
}


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

int cnt = 0;
string s;

void fnc(int f, int l)
{
    if (l+1 <= f) return;
    if (s[f] != s[l]) cnt++;

    //cout << s[f] << ' ' << s[l] <<"\n";

    fnc(f+1, l-1);
}

int main()
{
    cin >> s;
    fnc(0, s.size()-1);
    cout << cnt;
}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();


    int n;
    cin>> n;

    cout << ((n+ 110)/ 111) *111;
    nl;

    return 0;
}




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

using LL = long long;

#define debug(x) cout << #x << " : " << x << '\n'

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

  int ans = 0;
  int X;
  cin >> X;

  int root = sqrt(X);

  double temp = 0;
  for (int i = 1; i <= root; i++) {
    for (int j = 2; j < 10; j++) {
      temp = pow(i, j);

      if (temp > X) {
        break;
      }

      ans = max(ans, (int)temp);
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_map>
# include <unordered_set>
# include <thread>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ui32 = unsigned int;
constexpr ll INFLL = 1e18;

#define CHECK_IMPL1(cond)              \
if (!(cond)) {                         \
    DEBUG("expected cond: " << #cond); \
    assert(cond);                      \
}

#define CHECK_IMPL2(cond, message)                                            \
if (!(cond)) {                                                                \
    DEBUG("expected cond: " << #cond << " failed with message: " << message); \
    assert(cond);                                                             \
}
#define CHECK_IMPL(_1, _2, NAME, ...) NAME
#define CHECK(...) CHECK_IMPL(__VA_ARGS__, CHECK_IMPL2, CHECK_IMPL1, CHECK_IMPL0)(__VA_ARGS__)

#ifdef __APPLE__
#define DEBUG(message) std::cerr << message << "\n";
#else
#define DEBUG(message)
#endif

struct Solver {
  void solve() {
    int n;
    cin >> n;

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

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

    ll ans = 0;
    for (int i = 3 * n - 2, j = 0; j < n; i -= 2, j++) {
      ans += a[i];
    }

    cout << ans << "\n";
  }

  int n;
  int m;
  vector<vector<int>> g;
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef __APPLE__
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  int t = 1;
//  cin >> t;
  for (int i = 1; i <= t; i++) {
    Solver().solve();
  }
  return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)

ll modpow(ll a, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	vector<ll> bitcnt(60);
	ll n;
	cin >> n;
	FOR(i, 1, n) {
		ll a;
		cin >> a;
		int digit = 0;
		while (a) {
			if (a % 2) {
				bitcnt[digit]++;
			}
			a >>= 1;
			digit++;
		}
	}
	ll res = 0;
	FOR(i, 0, 59) {
		res += (bitcnt[i] * (n - bitcnt[i]) % MOD) * (modpow(2, i, MOD) % MOD) % MOD;
		res %= MOD;
	}
	pv(res);
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    for(int i=1;i<N;i++){
        int j = N - i;
        if(j < i) break;
        if(i!=j){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import math


def probability(init, K):
    if init >= K:
        return 1
    min_n = math.ceil(math.log(K/init, 2))
    p = 1 / (2 ** min_n)
    return p


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

p = 0
for init in range(1, N+1):
    p += 1/N * probability(init, K)

print(p)

Measured memory_bytes: 2940
#include<iostream>
#include<iomanip>
#include<string>
#include<typeinfo>
using namespace std;

int main(){
    string a;

    // processing inputs
    while(1){
        cin >> a;   // take input as string
        if(a=="0") break;
        else{
            int ans = 0; 
            for(int i=0; i<a.size(); i++){
                int num = a[i] - '0';
                ans += num;
            }
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
# define maxn 10000
int main() {
  int N,cnt(0);
  ll a[maxn]={0};
  cin>>N;
  for (int i(0);i<N;i++) cin>>a[i];
  for (int i(0);i<N;i++){
    while (a[i] !=0){
      if (a[i]%2==1)break;
      cnt++;
      a[i]/=2;
    }
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && a == c)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int gc (long long C, long long D) {
    return C % D == 0 ? D : gc(D, C % D);
}

int main () {
    long long A,B,C,D;
    cin >> A >> B >> C >>D;

    long long lcm = (C * D) / (C > D ? gc(C, D) : gc(D, C));
    long long Al = (A - 1) - ((A - 1) / C) - ((A - 1) / D) + ((A - 1) / lcm);
    long long Bl = B - (B / C) - (B / D) + (B / lcm);
    cout<< Bl - Al<<endl;
}   




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int s[200005];
int main(){
    int n;
    cin >> n;
    long long int a[n];
    long long int sum=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum+=a[i];
        s[i+1]=s[i]+a[i];
    }
    long long int ans=1e18;
    for(int i=1;i<n;i++)ans=min(ans,abs(sum-s[i]*2));
    cout << ans;
}

Measured memory_bytes: 6700
#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    char S[4];
    int a = 0;
    int b = 0;
    
    for (int i = 0; i < 4; i++) {
        cin >> S[i];
        if (S[i] == '+') {
            a += 1;
        }
        else if (S[i] == '-') {
            b += 1;
        }
    }
    
    cout << a - b << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  if (N == M)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#ifdef __GNUC__
#include <bits/stdc++.h>
#else
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#endif
using namespace std;
using ll = long long;

#define REPI(i, a, n)	for(int (i)=(a);(i)<(n);(i++))
#define REP(i,n) REPI(i,0,n)
#define REP1(i,n) REPI(i,1,n)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;

int vector_finder(std::vector<int> vec, int number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll fact(ll n) {
	int m;
	if (n == 0) {
		return 1;
	}
	m = fact(n - 1);
	return n * m;
}

int main() {
	unsigned long long x, y;
	cin >> y >> x;
	if (x == 1 || y == 1) cout << 1 << endl;
	else cout << (long long)ceill((double)(x*y) / 2) << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [0] + list(map(int, input().split())) + [0]


s = 0
for i in range(1, N+2):
    x = abs(A[i-1] - A[i])
    s += x

for i in range(1, N+1):
    x = abs(A[i-1] - A[i])
    y = abs(A[i] - A[i+1])
    z = abs(A[i-1] - A[i+1])
    print(s - x - y + z)


Measured memory_bytes: 14048
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
#include <map>
using namespace std;

int main()
{
	int K, X;
	cin >> K >> X;

	
	if (K == 1) {
		cout << X << endl;
		return 0;
	}

	for (int i = X - (K - 1); i < X + K; i++)
	{
		cout << i << " ";
	}
	cout << endl;
	return 0;


}




Measured memory_bytes: 256
#尺取を累積和にかえてみた
def 眠い():
	N,K=[int(_) for _ in input().split()]
	aS = [0]*N
	iS = 0
	iC = 0
	for s in input():
		if s == '0' :
			if iS % 2:
				aS[iS] = iC
				iS += 1
				iC = 1
			else:
				iC += 1
		else:
			if iS % 2:
				iC += 1
			else:
				aS[iS] = iC
				iS += 1
				iC = 1

	if iC:
		if s == '0' :
			if iS % 2:
				aS[iS]=0
				iS+=1
				aS[iS]=iC
			else:
				if len(aS) < iS +1 :
					aS.append(0)
					aS[iS]=iC
				else:
					aS[iS]=iC
		else:
			if iS % 2:
				if len(aS) < iS +1:
					aS.append(0)	
					aS[iS]=iC
				else:
					aS[iS]=iC
			else:
				aS[iS]=0
				iS +=1
				aS[iS]=iC
	aS=aS[:iS+1]
	iL = len(aS)
	accS = [0]*(iL+3)
	for i in range(iL):
		accS[i+1]=aS[i]+accS[i]
	accS[-2]=accS[-3]

	iLP=iL//2
	if iL % 2:
		iLP += 1
		if iLP <= K:
			print(N)
			exit()
	else:
		if iLP <= K:
			print(N)
			exit()
	print(max(accS[(i+K)*2]-accS[i*2 -1 ] for i in range(iLP-K+1)))

眠い()







Measured memory_bytes: 7788
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pi;
 
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
 
const int MOD = 1000000007;
const ll INF = 1e18;
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int H, A;
	cin >>H >>A;
	if(H%A==0) cout<<H/A<<endl;
	else cout<<H/A+1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000001145
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int ans=INF;
int n,m;
int a[211111];//iの順番
signed main(){
	
	cin>>n;
	rep(i,n){
		int num;
		cin>>num;
		a[num-1]=i;
	}
	int cnt=0;
	rep(i,n){
		if(a[i]<a[i+1])cnt++;
		else{
			cnt++;
			ans=min(ans,n-cnt);
			cnt=0;
		}
	}
	ans=min(ans,n-cnt);
	
	cout<<ans<<endl;
	
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <functional>
#include <numeric>
using namespace std;
#define rep(p,q) for(int i = p;i < q; i++)

int main(void) {
	int width = 0, height = 0;
	vector<long int> cost_w;
	vector<long int> cost_h;
	int count_w = 0, count_h = 0;
	long int total_cost = 0;
	cin >> width >> height;
	rep(0, width) {
		long int cost;
		cin >> cost;
		cost_w.push_back(cost);
	}
	rep(0, height) {
		long int cost;
		cin >> cost;
		cost_h.push_back(cost);
	}
	sort(cost_w.begin(), cost_w.end());
	sort(cost_h.begin(), cost_h.end());

	cost_w.push_back((long int)200000000);
	cost_h.push_back((long int)200000000);

	while (width != 0 || height != 0) {
		if (cost_w[count_w] <= cost_h[count_h]) {
			total_cost += cost_w[count_w] * (height + 1);
			width--;
			count_w++;
		}
		else {
			total_cost += cost_h[count_h] * (width + 1);
			height--;
			count_h++;
		}
	}
	cout << total_cost << endl;
}

Measured memory_bytes: 2548
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))

n, k = inm()
a = sorted(inl())
print(sum(a[:n-k]) if n > k else 0)

Measured memory_bytes: 31288
#include <stdio.h>

int main(void)
{
 int a, b, sum, keta;

 while(scanf("%d %d", &a, &b)!=EOF){
  sum=a+b;
  keta=1;
  while((sum/=10)>0) keta++;
  printf("%d\n", keta);
 }

 return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    VEC(int) A(N);
    READVEC(A);

    lint Total = 0;
    map<int, int> Counts;
    for (int a : A) {
        Total += Counts[a]++;
    }

    for (int a : A) {
        cout << Total - Counts[a] + 1 << endl;
    }
    return 0;
};

Measured memory_bytes: 8320
import numpy as np

n, m = map(int, raw_input().split())
ans = np.zeros(n)
for i in range(m):
    l = map(int, raw_input().split())
    ans[l[0] - 1] += 1
    ans[l[1] - 1] += 1

for i in ans:
    print int(i)

Measured memory_bytes: 19528