akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int k;
    cin>>s;
    cin>>k;
    int cnt=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!='1')
            break;
        else
            cnt++;
    }
    if(cnt>=k)
        cout<<1<<endl;
    else
        cout<<s[cnt]<<endl;

}


Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())
    P = [int(x) for x in input().split()]
    p_e = list()
    exp = 0
    #p_e.append(exp)
    # for p in P:
    #     exp += (1+p)/2
    #     p_e.append(exp)
    # maxv = p_e[k] - p_e[0]
    # for i in range(1, n-k+1):
    #     p_sum = p_e[k+i] - p_e[i]
    #     maxv = max(maxv, p_sum)
    # print(maxv)
    for p in P:
        # 期待値
        # 累積和
        exp += (1+p)/2
        p_e.append(exp)  
    if n == k:
        print(p_e[-1])
    else:
        # 初期値
        maxv = p_e[k-1] - 0
        for i in range(1, n-k):
            # 隣接するk個の期待値の和
            p_sum = p_e[k+i] - p_e[i]
            maxv = max(maxv, p_sum)
        print(maxv)

if __name__ == '__main__':
    main()

Measured memory_bytes: 32196
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<unordered_set>
#include<unordered_map>

using namespace std;

int n;
int m;

struct st{
	int a;
	int b;
	long long int s;
};

vector<st> ed;
#define MAX 100002
long long int ret[MAX];

bool us[MAX];
bool belong[MAX];

vector<int> v[MAX];

bool ng;

map<pair<int, int>, int> mp;

vector<pair<long long int, int> > po[MAX];


inline void dfs(int b,pair<long long int,int> val=make_pair(0,1) ){
	po[b].push_back(val);
	if (us[b])return;
	us[b] = true;
	for (int go : v[b]){
		long long int cost = mp[make_pair(b, go)];
		//A+val + node = cost
		//node=cost-val-A
		pair<long long int, int> nex = val;
		nex.first = cost - nex.first;
		nex.second = -nex.second;
		dfs(go,nex);
	}
}

int main(){
	cin >> n >> m;
	for (int i = 0; i < n; i++)ret[i] = INT_MAX;
	for (int i = 0; i < m; i++){
		int u, v1, s;
		scanf("%d%d%d", &u, &v1, &s);
		u--;
		v1--;
		mp[make_pair(u, v1)] = s;
		mp[make_pair(v1, u)] = s;
		ed.push_back({ u, v1, s });
		v[u].push_back(v1);
		v[v1].push_back(u);
	}
	dfs(0);
	long long int dw = LLONG_MAX;
	long long int up = 0;
	for (int i = 0; i < n; i++){
		sort(po[i].begin(), po[i].end());
		po[i].erase(unique(po[i].begin(), po[i].end()), po[i].end());
		if (po[i].size() > 2){
			puts("0");
			return 0;
		}
		if (po[i].size() == 2){
			//po[i][0].first+po[i][0].second*A=po[i][1].first+po[i][1].second*A
			//po[i][0].second*A-po[i][1].second*A=po[i][1].first-po[i][0].first
			//A=(po[i][1].first-po[i][0].first)/(po[i][0].second-po[i][1].second)
			long long int f1 = po[i][1].first - po[i][0].first;
			long long int f2 = po[i][0].second - po[i][1].second;
			if (f2 == 0LL){
				puts("0");
				return 0;
			}
			if (f1%f2 == 0LL){
				long long int A = f1 / f2;
				//assign
				for (int j = 0; j < n; j++){
					set<long long int> vs;
					for (int k = 0; k < po[j].size(); k++){
						vs.insert(po[j][k].first + po[j][k].second*A);
					}
					if (vs.size()>1){
						puts("0");
						return 0;
					}
					if ((*vs.begin()) <= 0){
						puts("0");
						return 0;
					}
				}
				puts("1");
				return 0;
			}
			else{
				puts("0");
				return 0;
			}
		}
		if (po[i][0].second == 1){
			//A+po[i][0].first>0
			up = max(up, -po[i][0].first);
		}
		else{
			//-A+po[i][0].first>0
			//+po[i][0].first>A
			dw = min(dw, po[i][0].first);
		}
	}
	dw--;
	up++;
	if (up <= dw){
		printf("%lld\n", dw - up + 1LL);
		return 0;
	}
	puts("0");
	return 0;
}

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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

int n,a[400],b[400];

bool vis_g[400][401];
mint memo_g[400][401];
mint g(int i,int j){ // Sum_{x_i=a_i}^{b_i} x_i^j
	if(vis_g[i][j]) return memo_g[i][j];
	vis_g[i][j]=true;

	mint res;
	for(int x=a[i];x<=b[i];x++) res+=pow(mint(x),j);
	return memo_g[i][j]=res;
}

bool vis_f[400][401];
mint memo_f[400][401];
mint f(int i,int c){
	if(i==n) return c==0?1:0;

	if(vis_f[i][c]) return memo_f[i][c];
	vis_f[i][c]=true;

	mint res;
	rep(j,c+1) res+=g(i,j)*f(i+1,c-j);
	return memo_f[i][c]=res;
}

int main(){
	int c; cin>>n>>c;
	rep(i,n) cin>>a[i];
	rep(i,n) cin>>b[i];

	cout<<f(0,c)<<'\n';

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(){
	int n;
	double x[100],y[100];
	cin>>n;
	while(n>0){
		for(int i=0;i<4;i++)cin>>x[i]>>y[i];
		if((y[0]-y[1])/(x[0]-x[1])==(y[2]-y[3])/(x[2]-x[3])){
			cout<<"YES"<<endl;
			n--;
		}
		else {
			cout<<"NO"<<endl;
			n--;
		}
	}
}

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


int main(){

	int K;
	cin>>K;
	
	string ans = "";
	
	rep(i,K)ans += "ACL";
	
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        long[] sumB = new long[s.length];
        
        long count = 0;
        if(s[0] == 'B') sumB[0] = 1;
        for(int i = 1;i < s.length;i++) {
            if(s[i] == 'B') sumB[i] = sumB[i - 1] + 1;
            else {
                sumB[i] = sumB[i - 1];
                count += sumB[i];
            }
        }
    
        System.out.println(count);
    }
}


Measured memory_bytes: 28660
letter=input()
def isKaibun(s):
  res = True
  for i in range(int((len(s))/2)):
    if s[i] != s[-1-i]:
      res = False
      break
  return res
if isKaibun(letter[0:int((len(letter)-1)/2)]):
  if isKaibun(letter[int((len(letter)+3)/2-1):]):
    if isKaibun(letter):
      print('Yes')
    else:
      print('No')
  else:
    print('No')
else:
  print('No')
  

Measured memory_bytes: 3064
#include<string.h>
#include<stdio.h>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;

int n,m,d;
int a[2111][2111];
int B=1010;
char ans[511][511];
int main()
{
    int i,j,k;
    
    cin>>n>>m>>d;
    
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            int xx,yy;
            xx=i+j+B;yy=i-j+B;
            xx/=d;yy/=d;
            if(xx%2==0 && yy%2==0)
            {
                ans[i][j]='R';
            }
            else if(xx%2==0 && yy%2==1)
            {
                ans[i][j]='Y';
            }
            else if(xx%2==1 && yy%2==0)
            {
                ans[i][j]='G';
            }
            else
            {
                ans[i][j]='B';
            }
        }
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            cout<<ans[i][j];
        }
        cout<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 768
n,k=map(int,input().split())
lists=list(map(int,input().split()))
for i in range(n):
    lists[i]=(lists[i]+1)/2
maxi=sum(lists[:k])
sub=sum(lists[:k])
for i in range(k,n):
    sub+=lists[i]
    sub-=lists[i-k]
    maxi=max(maxi,sub)
print(maxi)

Measured memory_bytes: 24812
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt"); return;
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var xl = new List<robo>();
        for(int i=0; i<n; i++) {
            xl.Add(new robo());
            var spl   = input.ReadLine().Split(' ');
            xl[i].x = long.Parse(spl[0]);
            xl[i].l = long.Parse(spl[1]);
        }

        xl.Sort();

        var tmp = new List<robo>();

        for (int i=0; i<n; i++) {
            var r = xl[i];

            if (tmp.Count == 0) {
                tmp.Add(r);
                continue;
            }
            var pre = tmp.Last();
            if(pre.x + pre.l <= r.x - r.l) {
                tmp.Add(r);
            } else {
                if(pre.x + pre.l > r.x + r.l) {
                    tmp[tmp.Count - 1] = r;
                }
            }
        }
        var c1 = tmp.Count;

        //tmp.Clear();
        
        //for (int i=n-1; i>=0; i--) {
        //    var r = xl[i];

        //    if (tmp.Count == 0) {
        //        tmp.Add(r);
        //        continue;
        //    }
        //    var pre = tmp.Last();
        //    if(pre.x - pre.l >= r.x + r.l) {
        //        tmp.Add(r);
        //    }
        //}
        var c2 = -1;// tmp.Count;

        return Math.Max(c1, c2);
    }

    class robo : IComparable<robo>
    {
        public long x;
        public long l;
        public bool del;

        public int CompareTo(robo other) {
            if (this.x - other.x > 0) return 1;
            if (this.x - other.x < 0) return -1;
            return 0;
        }

        public override string ToString() {
            return x+""; 
        }
    }
}


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

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

  if (400 <= X && X <= 599) {
    cout << 8 << endl;
  }
  else if (600 <= X && X <= 799) {
    cout << 7 << endl;
  }
  else if (800 <= X && X <= 999) {
    cout << 6 << endl;
  }
  else if (1000 <= X && X <= 1199) {
    cout << 5 << endl;
  }
  else if (1200 <= X && X <= 1399) {
    cout << 4 << endl;
  }
  else if (1400 <= X && X <= 1599) {
    cout << 3 << endl;
  }
  else if (1600 <= X && X <= 1799) {
    cout << 2 << endl;
  }
  else {
    cout << 1 << endl;
  }
  
}

Measured memory_bytes: 3644
#include <iostream>

using namespace std;

const int modulo = 1000*1000*1000 + 7;

int main()
{
  int nbLig, nbCol;
  cin >> nbLig >> nbCol;
  int nbPaths[nbLig][nbCol];
  bool stop = false;
  string ligne;
  cin >> ligne;
  for (int i = 0; i < nbCol; ++i)
  {
    if (ligne[i] == '#')
      stop = true;
    if (stop)
      nbPaths[0][i] = 0;
    else
      nbPaths[0][i] = 1;
  }
  for (int i = 1; i < nbLig; ++i)
  {
    cin >> ligne;
    for (int j = 0; j < nbCol; ++j)
    {
      if (ligne[j] == '#')
	nbPaths[i][j] = 0;
      else if (j == 0)
	nbPaths[i][j] = nbPaths[i-1][j];
      else
	nbPaths[i][j] = nbPaths[i-1][j] + nbPaths[i][j-1];
      nbPaths[i][j] %= modulo;
      //cout << nbPaths[i][j] << '\t';
    }
    //cout << '\n';
  }
  cout << nbPaths[nbLig-1][nbCol-1] << '\n';
}


Measured memory_bytes: 4096
#include<iostream>
#include<array>

using namespace std;

int main(){
    int n;
    array<int,200000>a;
    cin>>n;
    for(int i = 0; i < n; i++){
        cin>>a.at(i);
    }
    int max = 0,max2 = 0,num = 0;
    for(int i = 0; i < n; i++){
        if(a.at(i) > max){
            max2 = max;
            max = a.at(i);
            num = i;
        }else if(a.at(i) > max2){
            max2 = a.at(i);
        }
    }
    for(int i = 0; i < n; i++){
        if(i != num) cout<<max<<endl;
        else cout<<max2<<endl;
    }
}

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

// 参考：https://ei1333.github.io/algorithm/union-find.html
struct UnionFind{
    vector<int> data;

    UnionFind(int sz){
        data.assign(sz, -1);
    }

    bool unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y)
            return(false);
        if(data[x] > data[y])
            swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return(true);
    }

    int find(int k){
        if(data[k] < 0)
            return(k);
        return(data[k] = find(data[k]));
    }
    
    int size(int k){
        return(-data[find(k)]);
    }
};
 
int main(){
    int N, M;
    cin >> N >> M;
    int A[M], B[M];
    UnionFind uf(2*1000000);
    // UnionFind uf(N);
    for(int i=0;i<M;i++){
        cin >> A[i] >> B[i];
        uf.unite(A[i], B[i]);
    }
    
    for(int i=0;i<N;i++)
        uf.unite(i+1, 2*100000 + 2*i + 1);
    
    if(M == 0){
        cout << 1 << endl;
        return 0;
    }
        
    int ans = 0;
    
    for(int i=0;i<N;i++){
        int num = uf.size(i+1);
        if(num > ans)
            ans = num;
    }

    cout << ans/2 << endl;

}

Measured memory_bytes: 12692
py=[]
n,m=gets.split.map(&:to_i)
m.times{|i|py << gets.split.map(&:to_i)}
pre=0
id=1
py.sort.each{|city|
  if city[0]==pre
    id+=1
    city[1]=id
  else
    city[1]=1
    id=1
    pre=city[0]
  end
}
py.each{|p,y|
  printf("%06d%06d\n",p,y)
}


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

int main(){
    int n; cin >> n;
    string color; cin >> color;
    stack<char> s;
    rep(i,color.size()){
        if(s.empty()){
            s.push(color[i]);
            continue;
        }
        if(s.top()!=color[i]){
            s.push(color[i]);
        }
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 512
import numpy as np
import collections
import sys
day = input()
if day == 'SAT':
    print(1)
    sys.exit()
if day == 'FRI':
    print(2)
    sys.exit()
if day == 'THU':
    print(3)
    sys.exit()
if day == 'WED':
    print(4)
    sys.exit()
if day == 'TUE':
    print(5)
    sys.exit()
if day == 'MON':
    print(6)
    sys.exit()
if day == 'SUN':
    print(7)
    sys.exit()


Measured memory_bytes: 21500
n = int(input())
a = [int(input()) for i in range(n)]
index = a[0]-1
count = 1
flg = False
for i in range(len(a)):
    if index == 1:
        flg = True
        break
    index = a[index]-1
    count += 1
print(count if flg else -1)

Measured memory_bytes: 7084
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>

using namespace std;
int N;

long long rest(long long n) {
  long long ans = 1;
  long long num = pow(10,9) + 7;
  for (int i = 0; i < n; i++) {
    ans = (ans * 2) % num;
  }
  return ans;
}

int main() {

  long long n = pow(10, 9) + 7;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A, A+N);
  if(N % 2 == 0) {
    for (int i = 0; i < (N/2); i++) {
      if(A[2 * i] != 2 * i + 1 || A[2 * i +1] != 2 * i + 1 ) {
        cout << 0 << endl;
        return 0;
      }
    }
    cout << rest(N/2) << endl;
  }else {
    if(A[0] != 0) {
      cout << 0 << endl;
      return 0;
    }
    for (int i = 0; i < (N - 1)/2; i++) {
      if(A[2 * i + 1] != 2 * i + 2 || A[2 * i + 2] != 2 * i + 2) {
        cout << 0 << endl;
        return 0;
      }

    }
    cout << rest((N -1 )/2)<< endl;
  }
  return 0;
}

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

#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, n, m) for(int (i) = (n); (i) < (m); ++(i))

// constexpr int INF = 1e9;
constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

class xorShift{
    uint32_t x, y, z, w;
    static const double TO_DOUBLE;
public:
    xorShift(){
        x = 123456789;
        y = 362436069;
        z = 521288629;
        w = 88675123; 
    }
    xorShift(uint32_t seed){
        x = seed = 1812433253u * (seed ^ (seed >> 30));
        y = seed = 1812433253u * (seed ^ (seed >> 30)) + 1;
        z = seed = 1812433253u * (seed ^ (seed >> 30)) + 2;
        w = seed = 1812433253u * (seed ^ (seed >> 30)) + 3;
    }
    uint32_t nextInt(uint32_t n){
        uint32_t t = x ^ (x << 11);
        x = y; y = z; z = w;
        w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
        return w % n;
    }
    uint32_t nextInt(){
        uint32_t t = x ^ (x << 11);
        x = y; y = z; z = w;
        return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
    }
    double nextDouble(){
        return nextInt() * TO_DOUBLE;
    }
};
const double xorShift::TO_DOUBLE = 1.0 / (1LL << 32);

class Timer{
    chrono::time_point<chrono::system_clock>start;
public:
    Timer(){
        start = chrono::system_clock::now();
    }
    double duration(){
        return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()- start).count();
        //return chrono::duration<chrono::milliseconds>(chrono::system_clock::now()- start).count();
    }
};

Timer T;
xorShift rnd;
constexpr double TIME_LIMIT = 1900;

int D = 365;
vector<int> c(26);
vector<vector<int>> s(D, vector<int>(26));

struct Ans{
    vector<int> ans;
    int score;
    Ans(): score(0), ans(D){}

};

int cal_score(Ans& ans){
    int manzoku = 0;
    vector<int> last(26, 0);
    REP(i, D){
        manzoku += s[i][ans.ans[i]];
        last[ans.ans[i]]=i+1;
        REP(j, 26){
            manzoku -= c[j]*(i+1- last[j]);
        }
        cout << manzoku << endl;
    }
    return manzoku;
}
struct solver{
    Ans bestAns;
    solver(){
        
    }
};
int main(){
  cin >> D;
  REP(i, 26){
      cin >> c[i];
  }
  REP(i, D){
      REP(j, 26){
          cin >> s[i][j];
      }
  }
  Ans ans;
  REP(i, D){
      cin >> ans.ans[i];
      ans.ans[i]--;
  }
  cal_score(ans);
  return 0;
}


Measured memory_bytes: 3676
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
price_list = []

for i in range(M):
  x, y, c = map(int, input().split())
  price = a[x-1] + b[y-1] - c
  price_list.append(price)


a.sort()
b.sort()
price_list.append(a[0]+b[0])
min_price = price_list[0]

for n in price_list:
  if min_price >= n:
    min_price = n
  elif min_price < n:
    pass


print(min_price)

Measured memory_bytes: 25128
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <utility>
#include <set>
#include <tuple>

int dignum(int n) {
  int res = 0;
  while (n) {
    ++res;
    n /= 10;
  }
  return res;
}

int main() {
  int N;
  scanf("%d", &N);

  int res = 0;
  for (int i = 1; i <= N; ++i)
    if (dignum(i) % 2 == 1) ++res;

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


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include <stdio.h>
#include <time.h>
#include <queue>
#include <ctype.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(min(b,d)-max(a,c),0);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int f(const vi & v) {
  if (v.empty()) return 0;
  vector<array<int, 4>> d(v.size(), {0, 0, 0, 0});
  for (int i = 1; i < d.size(); ++i) {
//    d[i][0] = d[i][1] = d[i][2] = d[i][3] = d[i-1][1];
    d[i][0] = d[i-1][3];
    d[i][1] = max(d[i-1][3], max(1 + d[i-1][2], max(v[i-1] - 1 + d[i-1][1], v[i-1] + d[i-1][0])));
    if (v[i] > 1) d[i][2] = max(d[i][1], v[i] - 1 + d[i-1][2]);
    else d[i][2] = d[i][0];
    if (v[i] > 1) d[i][3] = max(d[i][2], v[i] + d[i-1][2]);
    else d[i][3] = d[i][1];
  }
  int res = d.back()[3];
//  for (int x : v) cerr << x << ' '; cerr << endl << res << endl;
  return res;
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  s += "00";
  n = s.size();
  vi v;
  int res = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == '1') {
      int c = 0;
      for (int j = i; j < s.size(); ++j) {
        if (s[j] == '1') ++c;
        else break;
      }
      v.push_back(c);
      i += c;
    } else {
      res += f(v);
      v.clear();
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1172
'use strict'

function main(s) {

  const num = Number(s);
  const ary = ['2', '1'];

  // MAX_SAFE_INTEGERを越えるため、配列にして筆算で解く
  const add_biggerInt = (a, b) => {

    const num1 = String(a).split('').map(n => Number(n)).reverse();
    const num2 = String(b).split('').map(n => Number(n)).reverse();

    const max_digit = Math.max(num1.length, num2.length);

    // 各桁の配列
    let ans = [...Array(max_digit + 1)].fill(0);

    // 桁上がり
    const checkCarry = () => {
      for (let i = ans.length - 1; i >= 0; i--) {
        if (ans[i] >= 10) {
          const upper = Number(String(ans[i]).split('')[0]);
          const lower = Number(String(ans[i]).split('')[1]);

          ans[i - 1] += upper;
          ans[i] = lower;
        }
      }
    }

    // 筆算
    for (let i = 0; i < max_digit; i++) {
      const digit = ans.length - i - 1;

      if (num1[i] && num2[i]) {
        ans[digit] += num1[i] + num2[i];

      } else if (num1[i]) {
        ans[digit] += num1[i];

      } else if (num2[i]) {
        ans[digit] += num2[i];
      }

      checkCarry();
    }

    // 有効桁のみ抜き出す
    for (let i = 0; i < ans.length; i++) {
      if (ans[i] !== 0) {
        ans = ans.slice(i);
        break;
      }
    }

    // 文字列として返す
    return ans.join('');
  }

  for (var i = 2; i <= 86; i++) {
    ary[i] = add_biggerInt(ary[i - 1], ary[i - 2]);
  }

  const answer = ary[num];

  console.log(answer);
}

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


Measured memory_bytes: 7912
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)
typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main(){
    priority_queue<int> sq;
    priority_queue<int,vector<int>,greater<int>> fq;
    int N;cin>>N;
    int a[3*N];REP(i,3*N)cin>>a[i];
    i64 sumf[N+1],sums[N+1];
    REP(i,N+1){
        sumf[i]=0;
        sums[i]=0;
    }
    REP(i,N){
        sumf[0]+=a[i];
        fq.push(a[i]);
        sums[N]+=a[3*N-1-i];
        sq.push(a[3*N-1-i]);
    }
    REP(i,N){
        fq.push(a[N+i]);
        sumf[i+1]=sumf[i]+a[N+i]-fq.top();
        fq.pop();
        sq.push(a[2*N-1-i]);
        sums[N-1-i]=sums[N-i]+a[2*N-1-i]-sq.top();
        sq.pop();
    }
    i64 ans=-1e15;
    REP(i,N+1) ans=max(ans,sumf[i]-sums[i]);
    cout<<ans<<endl;
}


Measured memory_bytes: 3964
n = gets.chomp.to_i
data = Array.new
max = -1000000000
min = 1000000000

n.times { |i|
	data[i] = gets.chomp.to_i
	
	if i!=0
		diff = data[i] - min
		if max<diff
			max=diff
		end
	end
	
	if min>data[i]
		min=data[i]
	end
}

puts max

Measured memory_bytes: 10552
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<cstring>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 200010;

struct edge{
	int x,nxt;
}e[N*2];
int h[N],tot;
int f[N];
int n;

void inse(int x,int y){
	e[++tot].x=y;
	e[tot].nxt=h[x];
	h[x]=tot;
}

bool vis[N];

void dfs(int x){
	f[x]=0;
	vis[x]=1;
	for(int p=h[x];p;p=e[p].nxt)
	if (!vis[e[p].x]){
		dfs(e[p].x);
		f[x]^=(f[e[p].x]+1);
	}
}

int main(){
	n=get();
	fo(i,1,n-1){
		int x=get(),y=get();
		inse(x,y);
		inse(y,x);
	}
	dfs(1);
	if (f[1])printf("Alice\n");
	else printf("Bob\n");
	return 0;
}

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

int main(){
    int n, i, c = 0;
    cin >> n;
    int d[n];
    for(i=0; i<n; i++){
        cin >> d[i];
    }
    sort(d, d+n);
    for(i=0; i<n; i++){
        if(i==0){
            c++;
        }else if(d[i-1] < d[i]){
            c++;
        }
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>

#define MOD 1000000007
#define INF INT_MAX
#define NINF INT_MIN
#define LLINF LLONG_MAX
using ll = long long;
using namespace std;

int main() {
    int X,m=0;
    cin >> X;
    for (int i = 2; i <= 10; i++)
    {
        for (int j = 1; j <= 31; j++)
        {
            int k = (int)pow(j, i);
            if (k <= X) {
                m = max(m, (int)pow(j, i));
            }
        }
    }
    cout << m << endl;
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
// #define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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; }

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    
    double a,b;
    cin>>a>>b;
    cout<<a/b<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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; }

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int cnt = 0;
  while (a>0 && c>0) {
    if(cnt%2==0) c -= b;
    else a -= d;
    cnt++;
  }
  if(cnt%2) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

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

int max(int a,int b){
  if(a > b)return a;
  else return b;
}

int lcs(char x[],char y[],int m,int n){
  int c[1001][1001];
  int i,j;
  int maxl = 0;

  for(i=1;i<=m;i++){
    c[i][0] = 0;
  }
  
  for(j=1;j<=n;j++){
    c[0][j] = 0;
  }
  

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(x[i-1] == y[j-1]){
        c[i][j] = c[i-1][j-1] + 1;
      }else{
        c[i][j] = max(c[i-1][j],c[i][j-1]);
      }
      maxl = max(maxl,c[i][j]);
    }
  }

  return maxl;
}


int main(){
  int n;
  int i;
  char x[1001],y[1001];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",x);
    scanf("%s",y);
    printf("%d\n",lcs(x,y,strlen(x),strlen(y)));
    
  }
  return 0;
  
}



Measured memory_bytes: 5640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestApp
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                
                var st = Console.ReadLine()
                    .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(x => int.Parse(x))
                    .ToArray();
                int n = st[0];
                int m = st[1];
                int p = st[2];
                if (n + m + p == 0)
                    break;
                var ls = new List<int>();
                var coun = 0;
                for (int i = 0; i < n; i++)
                {
                    var a = int.Parse(Console.ReadLine());
                    coun += a;
                    ls.Add(a);
                }
                var money = 100 * coun * 0.01 * (100 - p);
                if (ls[m - 1] != 0)
                    Console.WriteLine(((int)money / ls[m-1]));
                else
                    Console.WriteLine(0);
            }
        }
        
    }

}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.rbegin(),a.rend());
    int m=a[0];

    int d=INT32_MAX;
    int r=0;
    for(int i = 1; i < n; i++) {
        int td=abs(m-2*a[i]);
        if(td<d){
            r=i;
            d=td;
        }
    }
    cout << m << " " << a[r] << "\n";
    return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,cnt = 0, arr[3][3];
    for(int i = 0; i < 3; ++i){
        for(int j= 0; j <3; ++j){
            cin >> arr[i][j];
        }
    }
    cin >> n;
    int temp;
    for(int i = 0;i <n ; ++i ){
        cin >> temp;
        for(int k = 0; k < 3; ++k){
            for(int j= 0; j <3; ++j){
                if(arr[k][j]==temp){
                    arr[k][j] =-1;
                }
            }
        }
    }
    if(arr[0][2]==-1&&arr[1][1]==-1&&arr[2][0]==-1){
        cout<<"Yes";
    }
    else if(arr[0][0]==-1&&arr[1][1]==-1&&arr[2][2]==-1){
        cout<<" Yes";
    }
    else{
        for(int i = 0; i < 3; ++i){
            if(arr[i][0]==-1&&arr[i][1]==-1&&arr[i][2]==-1){
                cout<< "Yes";
                temp=-1;
                break; 
            }
            if(arr[0][i]==-1&&arr[1][i]==-1&&arr[2][i]==-1){
                cout<< "Yes";
                temp= -1;
                break; 
            }
        }
        if(temp != -1){
            cout << "No";
        }
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin>>s;

    bool answer=true;
    int count=0;

    if(s[0]!='A'){
        answer=false;
    }

    for (int i=1;i<s.size();i++) {
        if(isupper(s[i])){
            if(i==1||i==s.size()-1||s[i]!='C'){
                answer=false;
            }
            else if (s[i]=='C') {
               count++;
            }
        }
    }
    if(count==1&&answer==true){
        cout<<"AC"<<endl;
    }
    else {
        cout<<"WA"<<endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    final int N=sc.nextInt();
    int[] x=new int[N];
    for(int i=0;i<N;i++){
      x[i]=sc.nextInt();
    }
    Arrays.sort(x);
    int sum=0;
    for(int i=0;i<N-1;i++){
      sum+=x[i];
    }
    if(sum>x[N-1]){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23120
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb2l(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define  mat vector<vector<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



void solve(){
   ll n,k;
   cin>>n>>k;
   vll v(n);
   fr(i,0,n)
   cin>>v[i];
 // sort(v.begin(),v.end());
   double ans=0;
   //cout<<n-k<<endl;
   for(int i=0;i<k;i++){
       ans+=(v[i]+1.0)/2.0;
   }
   double mx=ans;
   fr(i,k,n){
       ans+=(v[i]+1.0)/2.0;
       ans-=(v[i-k]+1.0)/2.0;
       mx=max(ans,mx);
   }
   cout<<fixed;
   cout<<setprecision(12)<<mx<<endl;


  }
int main(){
    ll t=1;
   // cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

#include <stdio.h>
#include <string.h>

int main() {
    int N;
    scanf("%d", &N);
    char S[605][605], T[605][605];
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            char c;
            scanf(" %c", &c);
            S[i][j] = S[i + N][j] = S[i][j + N] = S[i + N][j + N] = c;
            T[j][i] = T[j + N][i] = T[j][i + N] = T[j + N][i + N] = c;
        }
    }

    int ans = 0;
    for (int a = 0; a < N; ++a) for (int b = 0; b < N; ++b) {
        int ok = 1;
        for (int i = 0; i < N; ++i) {
            if (memcmp(S[i + a] + b, T[i + b] + a, i + 1)) {
                ok = 0;
                break;
            }
        }
        ans += ok;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 896
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] d = new int[n];
		HashMap<Integer, Integer> hm1 = new HashMap<>();
		int tmp;
		for (int i = 0; i < n; i++) {
			tmp = sc.nextInt();
			if (hm1.containsKey(tmp)) {
				hm1.put(tmp, hm1.get(tmp) + 1);
			} else {
				hm1.put(tmp, 1);
			}
		}
		int m = sc.nextInt();
		for (int i = 0; i < m; i++) {
			tmp = sc.nextInt();
			if (hm1.containsKey(tmp)) {
				if (hm1.get(tmp) > 0) {
					hm1.put(tmp, hm1.get(tmp) - 1);
				} else {
					System.out.println("NO");
					return;
				}
			} else {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
}

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

const int maxn = 200010;

int n;

int ans[maxn];
int temp[maxn];

int main(void) {
    cin >> n;
    for (int i = 2; i <= n; i ++) {
        cin >> temp[i];
        ans[temp[i]] ++;
    }
    for (int i = 1; i <= n; i ++) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 5144
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use num_integer::*;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let n: usize = read!();
    let mut squares = Vec::with_capacity(n);

    for _ in 0..n {
        let square: usize = read!();
        squares.push(square);
    }

    let ans = squares
        .iter()
        .enumerate()
        .filter(|(index, num)| (*index + 1).is_odd() && num.is_odd())
        .count();
    
    println!("{}", ans);
}


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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string s; cin >> s;
    REP(i, (int)s.length()/2)
    {
        if(s[i] != s[s.length()-1-i])
        {
            No;
            return 0;
        }
    }
    Yes;
}

Measured memory_bytes: 3608
import java.util.Arrays;
import java.util.Scanner;

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

        // 全部一旦情報なしに初期化
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                A[i][j] = -1;
            }
        }

        for(int i=0;i<N;i++){
            int ansnum=sc.nextInt();
            for(int j=0;j<ansnum;j++){
                int x=sc.nextInt();
                int y=sc.nextInt();
                A[i][x-1]=y;
            }
        }

        for(int i=0;i<(1<<N);i++){      // i = 1010
            boolean ok=true;
            for(int j=0;j<N;j++){       // j = 2
                if((i&(1<<j))==0){
                    continue;
                }
                // j番目の人は正直者なので, その人の意見を聞きます
                for(int k=0;k<N;k++){
                    if(A[j][k]==-1){
                        continue;
                    }
                    if(A[j][k]!= (((i&(1<<k)) == 0) ? 0 : 1)){
                        ok=false;
                    }
                }
                if(ok==false){
                    break;//このiは間違い！
                }
            }
            if(ok==false){
                continue;
            }
            int karians=0;
            for(int l=0;l<N;l++){
                if((i&(1<<l))!=0){
                    karians++;
                }
            }
            if(ans<karians){
                ans=karians;
            }
        }
        System.out.println(ans);
	}

}


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

typedef long long ll;

// const ll MOD = 1000000007;
const ll MOD = 998244353;
const int MAX_N = 10000005;

ll pot(ll a, ll b) {
    ll w = 1;

    while(b > 0) {
        if(b & 1) {
            w = (w * a) % MOD;
        }
        a = (a * a) % MOD;
        b /= 2;
    }

    return w;
}

ll sil[MAX_N], odw[MAX_N];

ll newton(int n, int k) {
    ll w = (sil[n] * odw[n - k]) % MOD;
    w = (w * odw[k]) % MOD;
    return w;
}

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

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

//     for(int i = 0; i <= n; i++) cout << sil[i] << " ";
//     cout << endl << " ---------- \n";
    
    odw[n] = pot(sil[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        odw[i] = (odw[i + 1] * ll(i + 1)) % MOD;
    }
    
//     for(int i = 0; i <= n; i++) cout << odw[i] << " ";
//     cout << endl << " ---------- \n";
    
    ll w = pot(3, n);
    
    for(int k = 1 + n / 2; k <= n; k++) {
        w = (w - 2LL * newton(n, k) * pot(2, n - k) + MOD * MOD) % MOD;
    }
    
    cout << w;
    
    return 0;
}

Measured memory_bytes: 159800
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int y = (int)IntStream.range(a, b + 1).filter(i -> c % i == 0).count();
        System.out.println(y);
    }
}


Measured memory_bytes: 32424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
typedef pair<ll,pii> plii;
#define mkp make_pair
#define fi first
#define se second
int n,m,S;
ll d[53][5003],ans;
vector<piii>g[53];
int C[53],D[53];
bool vis[53][5003];
priority_queue <plii,vector<plii>,greater<plii> >pq;
void GO(int a,int b,ll c){
	if (c<d[a][b]){
		d[a][b]=c;
		pq.push(mkp(c,mkp(a,b)));
	}
}
int main(){
	cin>>n>>m>>S;
	S=min(S,5000);
	for (int i=0;i<m;i++){
		int u,v,a,b;cin>>u>>v>>a>>b;
		g[u].push_back(mkp(v,mkp(a,b)));
		g[v].push_back(mkp(u,mkp(a,b)));
	}
	for (int i=1;i<=n;i++) cin>>C[i]>>D[i];
	for (int i=0;i<53;i++) for(int j=0;j<5003;j++)d[i][j]=1e18;
	d[1][S]=0;
	pq.push(mkp(0,mkp(1,S)));
	while (!pq.empty()){
		plii x=pq.top();pq.pop();
		if (vis[x.se.fi][x.se.se]) continue;vis[x.se.fi][x.se.se]=1;
		GO(x.se.fi,min(5000,x.se.se+C[x.se.fi]),x.fi+D[x.se.fi]);
		for (int i=0;i<g[x.se.fi].size();i++)
			if (g[x.se.fi][i].se.fi<=x.se.se)
				GO(g[x.se.fi][i].fi,x.se.se-g[x.se.fi][i].se.fi,x.fi+g[x.se.fi][i].se.se);
	}
	for (int i=2;i<=n;i++){
		ans=1e18;
		for (int j=0;j<=5000;j++) ans=min(ans,d[i][j]);
		cout<<ans<<"\n";
	}
}

Measured memory_bytes: 9584
#include <stdio.h>

#define MAX 105
#define WHITE 0
#define BLACK 1
#define GRAY 2

int n,d[MAX],f[MAX],G[MAX][MAX],color[MAX],t=0;

void DFSVisit(int u){
  int v;
  
  color[u] = GRAY;
  t++;
  d[u] = t;
  
  for(v=1; v<=n; v++){
    if((G[u][v] == 1)&& (color[v] == WHITE)){
      DFSVisit(v);

    }
  }

  color[u] = BLACK;
  f[u]= ++t;
}

int main(){
  int i,j,u,v,k;
  
  scanf("%d",&n);

  /*array all 0*/
  for(i=1;i<= n; i++){
    for(j=1; j<= n; j++){
      G[i][j] = 0;
    }
  }

  for(i=1; i<= n; i++){
    scanf("%d%d",&u,&k);
    // u--;
    for(j=0; j<k; j++){
      scanf("%d",&v);
      // v--;
      G[u][v] = 1;
    }
  }

   for(i=1; i<=n; i++){
     color[i] = WHITE;
    }

   for(i=1; i<=n; i++){
     if(color[i] == WHITE) DFSVisit(i);
   }

  for(i=1; i<=n; i++){
    printf("%d ",i);
    printf("%d ",d[i]);
    printf("%d\n",f[i]);
  }
  
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    FOR(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    ll sol = 0;
    FOR(i, k) sol += p[i];
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;

/*
const ll M = 1000000007;
vector<ll> fac(3001);
vector<ll> ifac(3001);
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
 
ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0 || b < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}
*/


ll lcm(ll a,ll b){
 
  ll r, x, tmp;
  x = a * b;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return x/b;
}

ll gcd(ll a ,ll b){
    if(a==0){return b;}
    else if(b==0){return a;}
    else{
    ll tmp,r;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
    }
}




int main(void){
    const ll M = 1000000007;
    ll n,a,b,c;
    ll ans=0;
    string s;
    cin >> a >> b >> c;
    if(a<=b+c)ans = c-a+b;
    else ans = 0;
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin >> n;
    
    int result = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 2 == 1) {
            int sum = 0;
            for (int j = 1; j <= i; j++) {
                if (i % j == 0){
                    sum++;
                }
            }
            if (sum == 8) {
                result++;
            }
        }
    }
    
    cout << result << endl;

    return 0;   
}

Measured memory_bytes: 256
using System;

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);

            if (a < b && b< c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}

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

int main() {
  int h1,m1,h2,m2,k,t;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  t = (h2-h1)*60+m2-m1;
  int ans = t-k;
  cout << ans << endl;
}

Measured memory_bytes: 3556
#include <iostream>

using namespace std;

int main() {
  char x, y;
  cin >> x >> y;
  if (x > y) {
    cout << '>' << endl;
  } else if (x < y) {
    cout << '<' << endl;
  } else {
    cout << '=' << endl;
  }
  return 0;
}


Measured memory_bytes: 3044