akhauriyash/Code-Regression huggingface dataset:
n,K = map(int, input().split(' '))
s = input()
ls0 = [0]
ls1 = [0]
if s[0] == "0":
    ls1[0] = -1
for i in range(n):
    if s[i] == "0":
        ls0[-1] += 1
        if ls1[-1] != 0:
            ls1.append(0)
    if s[i] == "1":
        ls1[-1] += 1
        if ls0[-1] != 0:
            ls0.append(0)
    #print(ls0,ls1)
if s[0] == "0":
    ls1[0] = 0
if ls0[-1] == 0:
    del ls0[-1]

ans = []
ansmax = 0
if K>=len(ls0):
    ansmax = len(s)
else:
    ans.append(sum(ls0[0:K])+sum(ls1[0:K+1]))
    for i in range(1,len(ls0)-K+1):
        ans.append(ans[-1]+ls0[i+K-1]+ls1[i+K]-ls0[i-1]-ls1[i-1])
    else:
        ansmax = max(ans)
print(ansmax)

Measured memory_bytes: 5620
#include <algorithm>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.endl(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  // cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  int n;
  ll k;
  cin >> n >> k;
  vecint a(n, 0);
  REPe(e, a) {
    cin >> e;
    e--;
  }
  vecint root;
  int now = 0;
  root.push_back(now);
  vector<bool> seen(n, false);
  seen[now] = true;
  while (true) {
    int next = a[now];
    root.push_back(next);
    if (seen[next]) break;
    now = next;
    seen[next] = true;
  }
  int rs;
  int m = root.size();
  for (int i = 0; i < m - 1; i++) {
    if (root[i] == root.back()) {
      rs = i;
      break;
    }
  }
  // cout << rs << " " << root[rs] << endl;
  // REP(i, m) {
  //   if (i == rs) {
  //     cout << "loop ";
  //   }
  //   cout << root[i] + 1 << endl;
  // }
  // cout << endl;
  // cout << endl;
  if (k < (ll)rs) {
    // cout << (int)k << endl;
    cout << root[k] + 1<< endl;
    return 0;
  }
  // cout << m - 1 - rs << endl;
  int ans = (int)((k - (ll)rs) % (ll)(m - 1 - rs));
  cout << root[ans + rs] + 1 << endl;
}

Measured memory_bytes: 5088
#include<stdio.h>
int main(void){
  int a,b,i,j;
  while(1){
    scanf("%d %d",&a,&b);
    if(a==0&&b==0)return(0);
    for(i=0;i<a;i++){
      for(j=0;j<b;j++){
	if(i%2){
	  if(j%2){
	    printf("#");
	  }
	  else{
	    printf(".");
	  }
	}
	else{
	  if(j%2){
	    printf(".");
	  }
	  else{
	    printf("#");
	  }
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  return(0);
}

Measured memory_bytes: 1796
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();
        long[][] dp = new long[100005][2];
        long mod = 1000000007;
        dp[0][0] = 1;
        for(int i = 1; i<=n; i++) {
            char digit = s.charAt(i-1);
            if(digit == '1') {
                dp[i][0] = (2*dp[i-1][0]) % mod;
                dp[i][1] = (3*dp[i-1][1] + dp[i-1][0]) % mod;
            } else {
                dp[i][0] = (dp[i-1][0]) % mod;
                dp[i][1] = (3*dp[i-1][1]) % mod;
            }
            //System.out.println(dp[i][0]+" "+dp[i][1]);
        }
        System.out.println((dp[n][0]+dp[n][1])%mod);
    }
}

Measured memory_bytes: 30036
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n == 1) {
            System.out.println(1);
        } else if (n == 2) {
            int k = sc.nextInt();
            int l = sc.nextInt();
            if (Math.abs(k - l) <= 2) {
                System.out.println(2);
            } else {
                System.out.println(1);
            }
        } else {
            int nu[] = new int[100000];
            for (int i = 0; i < n; i++) {
                nu[sc.nextInt()]++;
            }
            int sum[] = new int[n - 2];
            for (int i = 0; i < n - 2; i++) {
                sum[i] = nu[i] + nu[i + 1] + nu[i + 2];
            }
            int max = 0;
            for (int i = 0; i < n - 2; i++) {
                max = Math.max(max, sum[i]);
            }
            System.out.println(max);
        }

    }
}


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

int N;
int fid[3][100010];
int rev[100010];
int id[100010];
int bit[300010][2];
int mem[100010];
int res[100010];

void init()
{
    for(int i = 0; i <= N; i++)bit[i][0] = bit[i][1] = 0;
    return;
}

void add(int i,int k)//x = 1
{
    while(i <= N)
    {
        bit[i][k]++;
        i += i & -i;
    }
    return;
}

int sum(int i,int k)
{
    int res = 0;
    while(i > 0)
    {
        res += bit[i][k];
        i -= i & -i;
    }
    return res;
}

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < 3; i++)for(int j = 1; j <= N; j++)scanf("%d",&fid[i][j]);

    for(int i = 1; i <= N; i++)
    {
        if(fid[0][i] + 1 == fid[1][i] && fid[1][i] + 1 == fid[2][i] && fid[2][i] / 3 % 2 == i % 2)
        {
            rev[i] = 0;
            id[i] = fid[2][i] / 3;
        }
        else if(fid[2][i] + 1 == fid[1][i] && fid[1][i] + 1 == fid[0][i] && fid[0][i] / 3 % 2 == i % 2)
        {
            rev[i] = 1;
            id[i] = fid[0][i] / 3;
        }
        else
        {
            printf("No\n");
            return 0;
        }
    }

    init();
    for(int i = 1; i <= N; i++)
    {
        mem[i] = (i - 1) / 2 - sum(id[i],i % 2);
        add(id[i],i % 2);
    }

    for(int i = 1; i <= N; i++)
    {
        res[i] = mem[i - 1] + mem[i] + mem[i + 1];
    }

    int cnto1 = 0,cnto2 = 0,cnte1 = 0,cnte2 = 0;

    for(int i = 1; i <= N; i++)
    {
        if(i % 2)
        {
            cnto1 += mem[i];
            cnto2 += rev[i];
        }
        else
        {
            cnte1 += mem[i];
            cnte2 += rev[i];
        }
    }
    if(!(cnto1 % 2 ^ cnte2 % 2) && !(cnto2 % 2 ^ cnte1 % 2))printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 4864
W,H,N=map(int,input().split())

Z=[[0]*W for _ in range(H)]

for _ in range(N):
    X,Y,a=map(int,input().split())

    if a==1:
        for y in range(H):
            for x in range(0,X):
                Z[y][x]=1
    elif a==2:
        for y in range(H):
            for x in range(X,W):
                Z[y][x]=1
    elif a==3:
        for x in range(W):
            for y in range(0,Y):
                Z[y][x]=1
    else:
        for x in range(W):
            for y in range(Y,H):
                Z[y][x]=1

S=0
for l in Z:
    S+=sum(l)
print(H*W-S)


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

namespace AtCoder.Contest.A
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();

			long s = cin.nextLong();
			long a, b, c, d;
			long r = (long)Math.Floor(Math.Sqrt(s));
			long max = 1000000000+7;
			long min = 0;
			while (max - min > 1)
			{
				long mid = (max + min) / 2;
				if (s > mid * mid) min = mid;
				else if (s < mid * mid) max = mid;
				else { min = mid; max = mid; }
			}
			r = min;
			if (s > r * (r + 1)) { a = r + 1; b = r + 1; }
			else if (s == r * r) { a = r; b = r; }
			else { a = r; b = r + 1; }

			long rest = a * b - s;
			c = 1;
			d = rest;
			Console.WriteLine("0 0 " + a + " " + c + " " + d + " " + b);


			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return next();
			i = 0;
			return s[i++];
		}

		public int nextInt()
		{
			return int.Parse(next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextInt() + add;
			}
			return Array;
		}

		public long nextLong()
		{
			return long.Parse(next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextLong() + add;
			}
			return Array;
		}

		public double nextDouble()
		{
			return double.Parse(next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 13396
#include <stdio.h>
int main(void)
{
	int n,i,j,x;
	int y[4][13];
	char c;
	scanf("%d",&n);
	for (i=0;i<4;i++){
		for (j=0;j<13;j++){
			y[i][j]=0;
		}
	}
	scanf("%d",&n);
	for (i=0;i<n;i++){
		scanf(" %c",&c);
		scanf("%d",&x);
		if (c=='S'){
			y[0][x-1]=1;
		}else if (c=='H'){
			y[1][x-1]=1;
		}else if (c=='C'){
			y[2][x-1]=1;
		}else if (c=='D'){
			y[3][x-1]=1;
		}
	}
	for (i=0;i<4;i++){
		for (j=0;j<13;j++){
			if (y[i][j]==0&&i==0){
				printf("S %d\n",j+1);
			}else if (y[i][j]==0&&i==1){
				printf("H %d\n",j+1);
			}else if (y[i][j]==0&&i==2){
				printf("C %d\n",j+1);
			}else if (y[i][j]==0&&i==3){
				printf("D %d\n",j+1);
			}
		}
	}
return 0;
}

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

#define endl "\n"
#define ll long long
#define F first
#define S second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define mll unordered_map<ll,ll>
#define dec(v) sort(v.rbegin(),v.rend());
#define REP(i, n) for (int i = 0; i < (n); i++)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<ll> vll;

#define deb(x) cout << ">" << #x << '=' << x << endl;
#define setbits(n) __builtin_popcountll(n)
#define done {cout<<"-1"<<endl; return;}

#define inf INT_MAX
#define ninf INT_MIN
const ll N = 2e5 + 5;
#define MOD 1000000009


void solve()
{
   long long a, b, c;
   cin >> a >> b >> c;
   if (c * b >= a) cout << "Yes" << endl;
   else cout << "No" << endl;
}
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
   freopen("inputc.txt", "r", stdin);
   freopen("outputc.txt", "w", stdout);
#endif
   int t = 1;
   //cin >> t;
   while (t--)  solve();
   cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
   return 0;
}

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

using UnweightedGraph = vector<vector<int>>;
struct LowLink {
    const UnweightedGraph &g;
    vector<int> aps;                // articulation points
    vector<pair<int, int>> brs;     // brides
    vector<int> seen, ord, low;
    LowLink(const UnweightedGraph &g) : g(g) { }
    int dfs(int u, int p = -1, int time = 0) {
        seen[u] = true;
        ord[u] = low[u] = time++;
        bool exists = false;
        int cnt_ch = 0;
        for (auto v : g[u]) {
            if (!seen[v]) {
                ++cnt_ch;
                time = dfs(v, u, time);
                low[u] = min(low[u], low[v]);   // forward edge
                if (ord[u] < low[v]) brs.emplace_back(u, v);
                if (ord[u] <= low[v]) exists = true;
            } else if (v != p) {
                low[u] = min(low[u], ord[v]);   // back edge
            }
        }
        if ((p == -1 && cnt_ch > 1) || (p != -1 && exists)) {
            aps.emplace_back(u);
        }
        return time;
    }
    void build() {
        int N = g.size();
        seen.assign(N, 0); ord.resize(N); low.resize(N);
        aps.clear(); brs.clear();
        for (int v = 0; v < N; ++v) if (!seen[v]) dfs(v);
        for (auto &br: brs) if (br.first > br.second) swap(br.first, br.second);
        sort(brs.begin(), brs.end());
        sort(aps.begin(), aps.end());
    }
};

int main() {
    int V, E; cin >> V >> E;
    UnweightedGraph g(V);
    while (E--) {
        int s, t; cin >> s >> t;
        g[s].emplace_back(t);
        g[t].emplace_back(s);
    }
    LowLink ll(g);
    ll.build();
    for (auto v: ll.aps) cout << v << endl;
    //for (auto b: ll.brs) cout << b.first << " " << b.second << endl;
    return 0;
}


Measured memory_bytes: 4452
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	map<char,set<char> > mp1, mp2;
	string s, t;
	cin >> s >> t;
	for(int i = 0; i < (int)s.size(); ++i){
		mp1[s[i]].insert(t[i]);
		mp2[t[i]].insert(s[i]);
		if(mp1[s[i]].size() > 1 || mp2[t[i]].size() > 1){
			puts("No");
			return;
		}
	}
	puts("Yes");
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 776
#include<bits/stdc++.h>
#define lint long long
#define st first
#define nd second
#define INF 0x3f3f3f3f

using namespace std;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int x;
	int n;
	vector<int> p(110);
	cin>>x>>n;
	
	int dif = abs(-1-x);
	int ans = -1;
	while(n--){
		int y; cin>>y;
		p[y] = 1;
	
	}
	
	for(int i=0;i<103;i++){
		if(p[i])continue;
		if(abs(i-x) < dif){
			ans = i;
			dif = abs(i-x);
		}
	}
	cout<<ans<<"\n";

	return 0;	
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	static long[][][] dp;
	static long[] largeArray;

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		largeArray = new long[n];

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

			largeArray[i] = scan.nextLong();
		}

		dp = new long[n + 1][n + 1][2];

		for (int end = 1; end <= n; end++) {

			for (int start = n; start > 0; start--) {

				dpMethod(start, end);

			}
		}

		println(dp[1][n][1]);
	}

	public static void dpMethod(int start, int end) {

		if (start > end) {

			return;

		} else if (start == end) {

			dp[start][end][0] = largeArray[start - 1];

		} else {

			long costResult = Long.MAX_VALUE;

			for (int i = 1; i <= end - start; i++) {

				long target = dp[start + i][end][0]
						+ dp[start + i][end][1]
						+ dp[start][start + i - 1][0]
						+ dp[start][start + i - 1][1];

				costResult = Math.min(costResult, target);
			}

			long resultLarge = dp[start + 1][end][0] + dp[start][start][0];

			dp[start][end][0] = resultLarge;
			dp[start][end][1] = costResult;
		}
	}

	public static void println(Object target) {
		System.out.println(target);
	}
}


Measured memory_bytes: 28628
program main
implicit none
integer :: i, j, k, l, nb
character :: s*10, t*10

read(*,*) s
l = len(s)
nb = 0
j = l
do i = l, 1, -1
   if( s(i:i) == 'B' ) then
      nb = nb + 1
   else
      if( nb > 0 ) then
         nb = nb - 1
      else
         t(j:j) = s(i:i)
         j = j -1
      end if
   end if
end do
write(*,*) t(j+1:10)



end program main


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] a = new int[n+1];
    a[0] = 0;
    for(int j = 1; j <= n; j++) {
      a[j] = sc.nextInt();
    }

    String[] YorNo = new String[n-k];
    for(int i = k+1; i <= n; i++) {
      if(a[i] > a[i-k]) YorNo[i-k-1] = "Yes";
      else YorNo[i-k-1] = "No";
    }

    for(int m = 0; m < n-k; m++) {
      System.out.println(YorNo[m]);
    }
  }
}

Measured memory_bytes: 60372
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s, t;
    cin >> s >> t;
    int l = s.size();
    for (int i = 0; i < l; i++)
    {
        if (s[i] != t[i])
        {
            cout << "No" << endl;
            return 0;
        }

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

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

int main() {
  int x;
  cin >> x;
  
  for(int i = -1000; i <= 1000; ++i){
    for(int j = -1000; j <= 1000; ++j){
      if(pow(i, 5.0) - pow(j, 5.0) == x){
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 4008
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double  
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((ll)x.size())
ll powm(ll a,ll n,ll x=MOD){a%=x;ll r=1;while(n>0){if(n&1)r=(r*a)%x;a=(a*a)%x;n>>=1;}return r;}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  ll _=1; cin>>_;
  vector<pair<string,ll>> v;
  v.pb({"AC",0});
  v.pb({"WA",0});
  v.pb({"TLE",0});
  v.pb({"RE",0});
  while(_--)
  {
    string s;
    cin>>s;
    for(ll i=0 ; i<sz(v) ; i++){
      if(s==v[i].f) v[i].s++;
    }  
  }
  for(ll i=0 ; i<sz(v) ; i++){
    cout<<v[i].f<<" x "<<v[i].s;LOL
  }
  return 0;
}

Measured memory_bytes: 3648
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner src = new Scanner(System.in);

		//配列array
		ArrayList<Long> array = new ArrayList<Long>();

		//nに入力された数だけ繰り返し、配列に要素を代入
		for(int i = 0; i < 3; i++) {
			long x  = src.nextLong();
			array.add(x);
		}

		//最小値と最大値の変数を宣言
		long min, max = 0;
		max	=	array.get(0);		//最小、最大をインデックスの0で初期化
		min = max;

		//最小値と最大値を算出
		for(int i = 0; i < 3; i++)
            min = Math.min(min,array.get(i));

		for(int i = 0; i < 3; i++)
            max = Math.max(max,array.get(i));


		//出力
		System.out.println(String.format("%d %d",min, max));

	}
}


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

// one-based numbering
template<class T> struct Fenwick {
    vector<T> bit; int N;
    Fenwick(int n) {
        N = n;
        bit.resize(n+1, 0);
    }
    void add(int a, T w) {
        for (int x = a; x <= N; x += x & -x) bit[x] += w;
    }
    T sum(int a) {
        T ret = 0;
        for (int x = a; x > 0; x -= x & -x) ret += bit[x];
        return ret;
    }
};

int main() {
    int n; cin >> n;
    long long k; cin >> k;
    long long cur = 0;
    vector<long long> v = {0};
    set<long long> s;
    s.insert(cur);
    for (int i = 0; i < n; i++) {
        long long p; cin >> p;
        p -= k;
        cur += p;
        v.push_back(cur);
        s.insert(cur);
    }
    map<long long, int> m;
    int d = 1;
    for (auto x: s) {
        m[x] = d++;
    }
    Fenwick<long long> f(d);
    long long count = 0;
    for (auto x: v) {
        count += f.sum(m[x]);
        f.add(m[x], 1);
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 25200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	cin >> n;
	ll yuan=100;//然后0.01每年涨
	int t = 0;
	while(yuan<n){
		t++;//年数 
		yuan=yuan*(1+0.01);
		//cout << yuan << endl;
	} 
	cout << t;
	return 0;
} 

Measured memory_bytes: 3636
#include <bits/stdc++.h>
     
    using namespace std;
     
    const int N = 1234567;
     
    int a[N], cnt[N], b[N];
     
    int main() {
      int n, tt;
      scanf("%d %d", &n, &tt);
      int empty = n;
      for (int i = 1; i <= n; i++) {
        scanf("%d", a + i);
        cnt[a[i]]++;
        int pos = a[i] - cnt[a[i]] + 1;
        if (pos >= 1) {
          if (b[pos] == 0) {
            empty--;
          }
          b[pos]++;
        }
      }
      while (tt--) {
        int x, y;
        scanf("%d %d", &x, &y);
        {
          int pos = a[x] - cnt[a[x]] + 1;
          if (pos >= 1) {
            b[pos]--;
            if (b[pos] == 0) {
              empty++;
            }
          }
        }
        cnt[a[x]]--;
        a[x] = y;
        cnt[a[x]]++;
        {
          int pos = a[x] - cnt[a[x]] + 1;
          if (pos >= 1) {
            if (b[pos] == 0) {
              empty--;
            }
            b[pos]++;
          }
        }
        printf("%d\n", empty);
      }
      return 0;
    }

Measured memory_bytes: 8448
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	sort(all(a)) ;
	ll ans = 0 ;
	for(int i=0;i<n;i++) ans += abs(a.at(i)) ;
	if(a.at(0)*a.at(n-1)>0) ans -= 2*min(abs(a.at(0)),abs(a.at(n-1))) ;
	cout << ans << endl ;
	if(a.at(0)*a.at(n-1)>0){
		if(a.at(0)+a.at(n-1)<=0){
			reverse(all(a)) ;
			cout << a.at(0) << " " << a.at(1) << endl ;
			ll now = a.at(0)-a.at(1) ;
			for(int i=2;i<n;i++){
				cout << now << " " << a.at(i) << endl ;
				now -= a.at(i) ;
			}
		}else{
			cout << a.at(0) << " " << a.at(1) << endl ;
			ll now = a.at(0)-a.at(1) ;
			for(int i=2;i<n-1;i++){
				cout << now << " " << a.at(i) << endl ;
				now -= a.at(i) ;
			}
			cout << a.at(n-1) << " " << now << endl ;
		}
	}else{
		ll pos = 0 ;
		while(a.at(pos)*a.at(pos+1)>0) pos++ ;
		if(pos==n-2){
			ll now = a.at(n-1) ;
			for(int i=n-2;i>=0;i--){
				cout << now << " " << a.at(i) << endl ;
				now -= a.at(i) ;
			}
		}else{
			ll now = a.at(pos) ;
			for(int i=pos+1;i<n-1;i++){
				cout << now << " " << a.at(i) << endl ;
				now -= a.at(i) ;
			}
			cout << a.at(n-1) << " " << now << endl ;
			now = a.at(n-1)-now ;
			for(int i=pos-1;i>=0;i--){
				cout << now << " " << a.at(i) << endl ;
				now -= a.at(i) ;
			}
		}
	}
}


Measured memory_bytes: 4044
#include <stdio.h>
#define NIL -1
int main(){
  int N,H[1000]={NIL},i;
  scanf("%d",&N);
  for(i=1;i<=N;i++)
    scanf("%d",&H[i]);//key                                                     
  if(H[3]!=0)
    printf("node 1: key = %d, left key = %d, right key = %d, \n",H[1],H[2],H[3]\
);
  else if(H[2]!=0)
    printf("node 1: key = %d, left key = %d, \n",H[1],H[2]);
  else if(H[2]==0) printf("node 1: key = %d, \n",H[1]);

  for(i=2;i<=N;i++){
    printf("node %d: key = %d, parent key = %d, ",i,H[i],H[i/2]);
    if(H[2*i+1]!=0)
      printf("left key = %d, right key = %d, \n",H[2*i],H[2*i+1]);
    else if(H[2*i]!=0)
      printf("left key = %d, \n",H[2*i]);
    else printf("\n");
  }
  return 0;
}




Measured memory_bytes: 2036
x = input().split()
a = int(x[0])
b = int(x[1])
c = int(x[2])
if a <= b <= c:
    print(a, b, c)
elif a <= c <= b:
    print(a, c, b)
elif b <= a <= c:
    print(b, a, c)
elif b <= c <= a:
    print(b, c, a)
elif c <= a <= b:
    print(c, a, b)
else:
    print(c, b, a)

Measured memory_bytes: 6720
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    s64 N, A, B;
    cin >> N >> A >> B;
    vs64 X(N);
    rep (i, N) cin >> X[i];

    s64 ans = 0;
    rep (i, N - 1)
    {
        if (A * (X[i + 1] - X[i]) > B)
        {
            ans += B;
        }
        else
        {
            ans += A * (X[i + 1] - X[i]);
        }
    }

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



Measured memory_bytes: 1024
import Control.Monad
import Control.Applicative
import Data.List

main :: IO ()
main = do
  [a, b, k] <- map read . words <$> getLine :: IO [Int]
  print $ solve a b k



solve :: Int -> Int -> Int -> Int
solve a b k =  foldl f [] [1..100] !! (k-1)
    where
      f ::  [Int] -> Int -> [Int]
      f lst n
          | a `mod` n == 0 && b `mod` n == 0 = n:lst
          | otherwise                        = lst


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
int dfs(int i,vector<vector<int>>& adj,bool* visited){
	visited[i]=true;
  	int a=1;
  	for(int j=0;j<adj[i].size();j++){
      if(!visited[adj[i][j]])
        a+=dfs(adj[i][j],adj,visited);
    }
  return a;
}
int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int>> adj;
  bool* visited =new bool[n];  
  for(int i=0;i<n;i++){
   	vector<int> v;
    adj.push_back(v);
    visited[i]=false;      
  }
  for(int i=0;i<m;i++){
  	int a,b;
    cin>>a>>b;
    adj[a-1].push_back(b-1);
    adj[b-1].push_back(a-1);
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(!visited[i])
      ans=max(ans,dfs(i,adj,visited));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 23832
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, long long> pii;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
const int MOD = 1000000007;
const int oo = 1000000001;
const int N = 100011;
const int MX = 19;
const int PRE = 0;
const int NXT = 1;

int n,a[N],freq[N],res=-1;

int cnt(int a){
	return a < 0 ? 0 : freq[a];
}
void tr(int x){
	if(x<0)
		return;
	int tt = cnt(x)+cnt(x-1)+cnt(x+1);
	if(tt > res){
		res = tt;
	}
}
int main() {
	//freopen("input.txt", "r", stdin);
	cin >> n;
	for (int i = 0; i < n; ++i){
		cin >> a[i],freq[a[i]]++;
	}
	for (int i = 0; i < n; ++i){
		tr(a[i]);
		tr(a[i]+1);
		tr(a[i]-1);	
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

void search(char T[],char P[],int start,int P_moji){
int count=0;
int i;

for(i=start;i<(start+P_moji);i++){
 if(T[i]==P[i-start]){count++;}
}

if(count==P_moji){printf("%d\n",start);}

}








int main(){
 char T[1010];
 char P[1010];
 int T_moji=0;
 int P_moji=0;
 int i;

scanf("%s",T);
scanf("%s",P);

for(i=0;T[i]!='\0';i++){T_moji++;}/*T???????????°*/
for(i=0;P[i]!='\0';i++){P_moji++;}/*P???????????°*/


for(i=0;i<=(T_moji-P_moji);i++){
 if(T[i]==P[0]){search(T,P,i,P_moji);}
}

return 0;
}

Measured memory_bytes: 1860
import java.util.*
fun main(args: Array<String>) {
    val reader = Scanner(System.`in`)
    var N = reader.nextInt()
    val D = reader.nextLong()
    val DD = D * D
    var count = 0
    repeat(N){
        val xi = reader.nextLong()
        val yi = reader.nextLong()
        val xyDistance = xi * xi + yi * yi
        if(xyDistance <= DD){
            count++
        }
    }
    println(count)
}

Measured memory_bytes: 60568
import sys
input = sys.stdin.readline

def ppp(n,m,h,ab):
    g = [1] * n
    for l,r in ab:
        if h[l-1] >= h[r-1]:
            g[r-1] = 0
        if h[l-1] <= h[r-1]:
            g[l-1] = 0
    print(sum(g))
if __name__ == "__main__":
    n,m = map(int,input().split())
    h = list(map(int,input().split()))
    ab = [list(map(int,input().split())) for _ in range(m)]
    ab_sorted = sorted(ab)
    ppp(n,m,h,ab_sorted)


Measured memory_bytes: 32820
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

struct Prime {
  int max_prime;
  int prime_number;
  vector<int> primes;
  map<int, int> prime_id;
  Prime() {};
  Prime(int m) {
    initialize(m);
  };
  void initialize(int m) {
    sieve(m);
    prime_number = (int)primes.size();
  }

  void sieve(int m) {
    max_prime = 2;
    deque<bool> is_prime(m+1, true);
    is_prime[0] = is_prime[1] = false;
    int i;
    for (i = 2; i <= m; ++i) {
      if (!is_prime[i]) {
        continue;
      }
      if (i * i > m) {
        break;
      }
      for (int j = i+1; j <= m; ++j) {
        if (j % i == 0) {
          is_prime[j] = false;
        }
      }
      prime_id[i] = (int)primes.size();
      primes.push_back(i);
      max_prime = i;
    }
    for (int j = i; j <= m; ++j) {
      if (!is_prime[j]) {
        continue;
      }
      prime_id[j] = (int)primes.size();
      primes.push_back(j);
      max_prime = j;
    }
  }

  map<int, int> prime_factor(ll x) {
    map<int, int> ret;
    if ((ll)max_prime * (ll)max_prime < x) {
      return ret;
    }
    for (int i = 0; i < prime_number; ++i) {
      while (x % primes[i] == 0) {
        x /= primes[i];
        ret[primes[i]] += 1;
      }
    }
    if (x != 1) {
      ret[x] += 1;
    }
    return ret;
  }
};

int mod = 1e9+7;

ll po(ll k, ll x) {
  if (x == 0) {
    return 1;
  }
  if (x == 1) {
    return k % mod;
  }
  ll y = po(k, x/2);
  y = y * y % mod;
  if (x % 2 == 1) {
    y = y * k % mod;
  }
  return y;
}

int main() {
  int n;
  scanf("%d", &n);
  Prime pr(100000);

  map<int, int> mps;
  FOR (i, 2, n+1) {
    auto appends = pr.prime_factor(i);
    for (auto append : appends) {
      mps[append.first] += append.second;
    }
  }
  ll ans = 1;
  for (auto m : mps) {
    ans = ans * (m.second + 1) % mod;
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 896
class UnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n + 1)]
        self.rank = [0 for _ in range(n + 1)]
        self.size = [1] * (n + 1)

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
            self.size[y] += self.size[x]
        else:
            self.parent[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def check_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        return self.size[self.find(x)]


N = int(input())
ixy = []
for i in range(N):
    x, y = tuple(map(int, input().split()))
    ixy.append((i + 1, x, y))

x_order = sorted(ixy, key=lambda x: x[1])
y_order = sorted(ixy, key=lambda x: x[2])

edge = []

for i in range(1, N):
    pre_i1, pre_x1, pre_y1 = x_order[i - 1]
    i1, x1, y1 = x_order[i]
    edge.append((x1 - pre_x1, pre_i1, i1))
    pre_i2, pre_x2, pre_y2 = y_order[i - 1]
    i2, x2, y2 = y_order[i]
    edge.append((y2 - pre_y2, pre_i2, i2))

edge = sorted(edge, key=lambda x: x[0])
union_find = UnionFind(N)
ans = 0
for e in edge:
    cost, pre_i, i = e
    if union_find.check_same(pre_i, i):
        continue
    else:
        union_find.union(pre_i, i)
        ans += cost
print(ans)


Measured memory_bytes: 49860
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  string S;
  cin >> S;
  long int start=-1, end=-1;
  for(int i=0; i<S.size(); ++i)
  {
    if(S[i] == 'A' && start<0)
      start = i;
    if(S[i] == 'Z')
      end = i;
  }
  cout << (start, end-start)+1 << endl;
  return 0;
}


Measured memory_bytes: 640
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

import math

N = int(input())

X = N / 1.08
# X = Decimal(str(X)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)

X = int(math.ceil(X))

if N == int(X * 1.08):
  print(X)
else:
  print(':(')



Measured memory_bytes: 9900
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024
var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()

	for i := 1; i <= n; i++ {
		if int(float64(i) * 1.08) == n {
			fmt.Println(i)
			return
		}
	}

	fmt.Println(":(")
}

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

int main() {
  string s;
  while (cin >> s) {
    int a = 0, b = 0;
    for (size_t i = 0; i < s.length(); ++i) {
        if (i % 2) {
            if (s[i] == '0') {
                ++a;
            }
            if (s[i] == '1') {
                ++b;
            }
        } else {
            if (s[i] == '1') {
                ++a;
            }
            if (s[i] == '0') {
                ++b;
            }
        }
    }
    cout << min(a, b) << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int leapyear(int year){
  return (year%4!=0||(year%100==0&&year%400!=0) ?0:1);
}
int main(){
int a,b;
int e=0;
while(cin>>a>>b,a||b){
int co=0;
if(e!=0)cout<<endl;
loop(i,a,b+1){
if(leapyear(i)==1){co++;cout<<i<<endl;}
}
if(co==0)cout<<"NA"<<endl;
e++;
}
}

Measured memory_bytes: 1160
#include<iostream>
#include<unordered_map>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#include<tgmath.h>
#include<stdlib.h>
#include<assert.h>
#include<stdio.h>



#define ll long long


/*
_
_._ _..._ . - ',     _.._(`))
'-. `     ' / -._. - '    ', /
)         \            '.
/ _    _ | \
| a    a    /              |
\   . - .;
'-('' ).-', '       ;
'-;           |      .'
\           \    /
| 7.__  _. - \   \
| |  |  ``/ / `  /
/, _|  |   /, _/   /
/, _ / '`-'
*/
using namespace std;

int gcd(int a, int b)
{
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

int main()
{
    /*int n;
    cin >> n;
    ll sum = 0;
    ll i;
    for (i = 1; i <= n; ++i) {
        if (i % 3 == 0 || i % 5 == 0) {

        }
        else {
            sum += i;
        }
            
           
    }
    cout << sum;
    */
    int k;
    cin >> k;
    ll sum = 0;
    int i, j, l;
    for (i = 1; i <= k; ++i) {
        for (j = 1; j <= k; ++j) {
            for (l = 1; l <= k; ++l) {
                sum += gcd(gcd(i, j), l);
            }
        }
    }
    cout << sum;

}


        


Measured memory_bytes: 3596
#include <iostream>

using namespace std;

int main(void)
{
  int i, x = 100000;
  int a;
  cin >> i;
  
  for(a = 0; a < i; a++){
    x += (x * 0.05);
    if(x % 1000 != 0){
      x = (x / 1000 + 1) * 1000;
    }
  }
  cout << x << endl;
  return 0;
}

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

int main() {
    while (true) {
        int n, m;
        cin >> n >> m;
        if (n == 0 && m == 0) {
            break;
        }
        bool* player = new bool [n];
        for (int i = 0; i < n; i++) {
            player[i] = true;
        }
        int retireNum = 0, count = 0, i = 0;
        while (retireNum < n - 1) {
            if (player[i]) {
                count++;
                if (count == m) {
                    player[i] = false;
                    retireNum++;
                    count = 0;
                }
            }
            i++;
            if (i >= n) {
                i = i % n;
            }
        }
        for (int i = 0; i < n; i++) {
            if (player[i]) {
                cout << i + 1 << endl;
            }
        }
        delete[] player;
    }
}

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

int main(){
	string s, t;
  	cin >> s >> t;
  
  	if(equal(s.begin(), s.end(), t.begin(), t.end()-1)) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <cstdio>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <cassert>
#include <cfloat>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector <int> a(N + 1,1);
	vector <int> b(N + 1, 0);
	vector <int> x(M);
	vector <int> y(M);
	for (int i = 0; i < M; i++) {
		cin >> x[i]>> y[i];
	}
	b[1] = 1;
	for (int i = 0; i < M; i++) {
		a[x[i]]--;
		a[y[i]]++;
		if (b[x[i]] == 1) {
			b[y[i]] = 1;
		}
		if (a[x[i]] == 0) {
			b[x[i]] = 0;
		}
	}
	
	int res = 0;
	for (int i = 1; i < N + 1; i++) {
		if (b[i] == 1) {
			res++;
		}
	}
	cout << res << endl;

	return 0;
}

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

ll k[1000010];
ll p[1010];
int main() {
	ll n, m;
	while (scanf("%lld%lld", &n, &m), n) {
		memset(p, 0, sizeof(p));
		rep(i, n)scanf("%lld", &p[i]);
		ll c = 0;
		rep(i, n + 1)for (ll j = i; j < n + 1; j++) {
			k[c++] = p[i] + p[j];
		}
		sort(k, k + c);
		ll Max = 0;
		rep(i, n + 1)for (ll j = i; j < n + 1; j++) {
			ll*a = upper_bound(k, k + c, m - p[i] - p[j]);
			if (a == k)continue;
			Max = max(Max, *(a - 1) + p[i] + p[j]);
		}
		printf("%lld\n", Max);
	}
}

Measured memory_bytes: 7136
#pragma GCC optimize("Ofast")
#include <cstdio>

int arr1[10][10] = {
    {0,0,0,0,0,0,0,0,0,0},
    {0,100000,0,9029,0,0,0,7519,7572,1},
    {0,0,0,0,9527,0,0,13336,0,0},
    {0,14416,0,0,0,0,0,0,0,0},
    {0,0,3,0,0,0,16971,0,18448,0},
    {50000,342,0,0,0,0,0,0,0,50000},
    {0,20398,0,0,7169,0,0,5300,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,17391,0,0,0,0,0,0},
    {0,0,0,0,0,799,0,0,0,0}
};

void puti(int i) {
    if (i >= 10) {
        puti(i / 10);
        i %= 10;
    }
    fputc(i + '0', stdout);
}

int main(void) {
    // テストケースハックする良くないコード
    int ch0 = getchar() - '0';
    int ch1 = getchar();
    int ch2 = getchar() - '0';
    getchar();
    getchar();
    getchar();
    int ch6 = getchar() - '0';
    int ch7 = getchar() - '0';
    if (ch7 < 0) {
        if (ch0 == 3) {
            puti(4 - ch2);
        }
        else if (ch0 == 2 && ch1 == ' ') {
            puti(ch2);
        }
        else
            puti(arr1[ch0][ch6]);
    }
    else if (ch6 == 9) {
        if (ch0 == 6) {
            puti(22888);
        }
        else if (ch0 == 9) {
            puti(25436);
        }
        else
            puti(arr1[ch0][ch7]);
    }
    else
        puti(arr1[ch0][ch7]);
    fputc('\n', stdout);
    return 0;
}

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


int K;
long long ans[100000];

long long pow(int a, int x){
    long long ret = 1;
    for(int i = 0; i < x; i++){
        ret *= a;
    }
    return ret;
}

long long S(long long x){
    long long ret = 0;
    for(int i = 0; i < 16; i++){
        ret += (x%10);
        x /= 10;
    }
    return ret;
}
        

long long f(long long N){
    long long ret = N;
    double feature = 1.0 * N / S(N);
    for(int d = 0; d <= log10(N) + 1; d++){
        long long x = pow(10, d+1) * (N / pow(10, d+1) + 1) - 1;
        if(1.0 * x / S(x) < feature){
            ret = x;
            feature = 1.0 * x / S(x);
        }
    }
    return ret;
}


int main(){
    cin >> K;
    long long N = 1;
    for(int k = 0; k < K; k++){
        ans[k] = f(N);
        N = ans[k] + 1;
    }
    for(int k = 0; k < K; k++){
        cout << ans[k] << endl;
    }
}

Measured memory_bytes: 384
#include<stdio.h>
#include <string.h>
#include<math.h>
#include<iostream>
using namespace std;

int main()
{
    int p[100];
    int X, N;
    int min_v;
    int min_n;
    int count = 0;

    cin >> X >> N;


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

    //バブルソート
    for (int i = 0; i < N - 1; i++) {
        for (int j = N - 1; j > i; j--) {
            if (p[j] < p[j - 1]) {
                int t = p[j];
                p[j] = p[j - 1];
                p[j - 1] = t;
            }
        }
    }

    min_v = 200;
    min_n = -1;
    for (int i = -1; i <= 101; i++)
    {
        if (count == N || i != p[count]) {
            if (min_v > abs(X - i)) {
                min_v = abs(X - i);
                min_n = i;
            }
        }
        else {
            count++;
        }
    }

    printf("%d", min_n);

    return 0;
}

Measured memory_bytes: 3692
#include<stdio.h>

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

void dfsvisit(int);

int color[101];
int d[101];
int f[101];
int ti=0;
int adj[101][101];
int k[100];

int main()
{
  int n,i=0,j=0;
  int tmp;


  for(i=0;i<101;i++)
    {
      color[i] = WHITE;
    }

  scanf("%d",&n);

  for(i=1;i<=n;i++)
    {
      scanf("%d",&tmp);
      scanf("%d",&k[i]);
      for(j=0;j<k[i];j++)
	{
	  scanf("%d",&adj[i][j]);
	}
    }
 
  for(i=1;i<=n;i++)
    {
      if(color[i] == WHITE)
	{
	  dfsvisit(i);
	}
    }
  for(i=1;i<=n;i++)
    {
      printf("%d %d %d\n",i,d[i],f[i]);
    }

  return 0;
  }

void dfsvisit(int u)
{
  int i;
  color[u] = GRAY;
  d[u] = ++ti;
  for(i=0;i<k[u];i++)
    {
      if(color[adj[u][i]] == WHITE)
	{
	  dfsvisit(adj[u][i]);
	}
    }
  color[u] = BLACK;
  f[u] = ++ti;
}

Measured memory_bytes: 636
def count_descending(nums, start):
    if start >= len(nums):
        return 0

    count = 1
    previous = nums[start]
    for i in range(start + 1, len(nums)):
        if previous < nums[i]:
            return count
        else:
            count += 1
            previous = nums[i]

    return count


def max_move(nums):
    start = 0
    current_max = 0
    while start < len(nums):
        n = count_descending(nums, start)
        current_max = max(current_max, n)
        start += n

    return current_max


def main():
    n = int(input())
    h = [int(x) for x in input().split()]

    print(max_move(h) - 1)


if __name__ == "__main__":
    main()


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

int main() {
  long long X;
  cin >> X;
  long long A=100;
  for(long long i=1; i<10000000000000000; i++) {
    A*=1.01;
    if(A>=X) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3636
//ABC072B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	string s;
	cin >> s;
	int n = s.size();
	string ans = "";
	int i=0;
	while(i<n){
		ans += s.at(i);
		i += 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
//Heaplax
#include<bits/stdc++.h>
#define N 100005
#define int long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v,c) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v,w[cnt]=c
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int F,G,ans;
int n,siz[N],val[N];
int cnt,head[N],nxt[N+N],to[N+N],w[N+N];
void dfs(int u,int fa=0)
{
	int mx=0;
	siz[u]=1;
	for(int i=head[u],v;i;i=nxt[i])
		if((v=to[i]) != fa)
		{
			val[v]=w[i];
			dfs(v,u);
			mx=max(mx,siz[v]);
			siz[u]+=siz[v];
		}
	mx=max(mx,n-siz[u]);
	if(mx<=F)F=mx,G=u;
}
main()
{
	re(n);
	for(int i=1,u,v,c;i<n;++i)
	{
		re(u),re(v),re(c);
		add_edge(u,v,c);
		add_edge(v,u,c);
	}
	F=n;
	dfs(1);
	bool gg=0;
	for(int i=1;i<=n;++i)
	{
		ans+=2*val[i]*min(siz[i],n-siz[i]);
		if(siz[i]*2==n)
			ans-=val[i],gg=1;
	}
	if(!gg)
	{
		int mn=0x3f3f3f3f;
		for(int i=head[G];i;i=nxt[i])
			mn=min(mn,w[i]);
		ans-=mn;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 11264
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdlib.h>
#define ll long long
#define MOD_P 1000000007
using namespace std;



int main()
{
	int a, b;
	int sum = 0;
	cin >> a >> b;

	if (a > b) {
		sum += a;
		a--;
	} else {
		sum += b;
		b--;
	}
	sum += (a > b ? a : b);

	printf("%d", sum);

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()
 
 
int main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b + 1) / 2 << endl;
}

Measured memory_bytes: 256