akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
int main(void)
{
    long long n, top, count, i = 0, x = 0, y = 0, z = 0;
    cin >> n;
    while (i < n)
    {
        top = sqrt(i);
        count = 0;
        x = 0;
        while (x < top - 1) {
            y = 0;
            while (y < x+1) {
                z = 0;
                while (z < y+1) {
                    if ((x+1)*(x+1) + (y+1)*(y+1) + (z+1)*(z+1) + (x+1)*(y+1) + (y+1)*(z+1) + (z+1)*(x+1) == i+1) {
                        if (x+1 == y+1 and y+1 == z+1) {
                            count += 1;
                        } else if (x+1 != y+1 and y+1 != z+1 and z+1 != x+1) {
                            count += 6;
                        } else {
                            count += 3;
                        }
                        
                    }
                    z++;
                }
                y++;
            }
            x++;
        }
        cout << count << endl;
        i++;
    }
}

Measured memory_bytes: 3492
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Sat Mar 24 02:08:24 2018
//
package main

import (
	"fmt"
)

var A, B, C int

func main() {
	fmt.Scan(&A, &B, &C)

	if C <= A+B {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

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

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N;
	std::string S;
	std::cin >> N >> S;

	int result = 0;
	for (int i = 1; i < S.size(); ++i) {
		bool left[26] = {};
		bool right[26] = {};
		for (int j = 0; j < i; ++j) {
			left[S[j]-'a'] = true;
		}
		for (int j = i; j < S.size(); ++j) {
			right[S[j]-'a'] = true;
		}
		int ndup = 0;
		for (int j = 0; j < 26; ++j) {
			if (left[j] && right[j]) {
				++ndup;
			}
		}
		result = std::max(result, ndup);
	}
	std::cout << result << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;

int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int> A(N + 1);
  for (int i = 1; i <= N; ++i)
    cin >> A[i], --A[i];
  for (int i = 0; i < N; ++i)
    (A[i + 1] += A[i]) %= K;

  long ans = 0;
  map<int, int> m;
  queue<int> q;
  for (int i = 0; i <= N; ++i)
  {
    ans += m[A[i]];
    ++m[A[i]];
    q.push(A[i]);
    if (q.size() == K)
    {
      --m[q.front()];
      q.pop();
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  vector<double> g(a);
  for(int i = 0;i < a;i++){
    cin >> g.at(i);}
  sort(g.begin(),g.end());
  double ans = g.at(0);
   for(int i = 1;i < a;i++){
     ans = (g.at(i)+ans)/2;
   }
  cout << ans << endl;
     

    
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
  int A, B;
  cin >> A >> B;

  if((A*B)%2 == 1) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm> 
using namespace std;
int main()
{
    long long x,a,b,c,ans=0;
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++)
        for(int j=0;j<=b;j++)
            for(int z=0;z<=c;z++){
                int k=i*500+j*100+z*50;
                if(k==x)
                   ans++;
                if(k>x)
                   break;
            }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int64_t a, b, k;
  cin >> a >> b >> k;
  if (a >= k) {
    cout << a - k << " " << b << endl;
  } else if (a + b >= k) {
    cout << 0 << " " << a + b - k << endl;
  } else {
    cout << 0 << " " << 0 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << (x) << endl
using namespace std;

using ull = unsigned long long;
using ll = long long;

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

const Double PI  = 3.141592653589793238463;
const Int MOD = 1000000007;
const Int INF = numeric_limits<Int>::max() / 3;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec){
        is >> x;
    }
    return is;
}

Int solve(Int n, V& ds){
    Int x = 0;
    for(Int i = 0; i < n; i++){
        for(Int j = i; j < n; j++){
            if(i == j){
                continue;
            }
            x += ds[i] * ds[j];
        }
    }
    return x;
}

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    Int n;
    cin >> n;
    V ds(n);
    cin >> ds;
    cout << solve(n, ds) << "\n";

    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

    int zero = 0;
    rep(i, n) if(a[i] == 0) zero++;
    if(zero > 0) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    rep(i, n) {
        if(a[i] <= 1000000000000000000 / ans) ans *= a[i];
        else {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4052
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;//998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	int N, M;
	get(N, M);

	int ans = 1900 * M;
	ans += (100 * (N - M));

	while (M) {
		ans *= 2;
		M--;
	}

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


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

void kshuffle( int* a, int n, int k )
{
    int b[2*n], j = 0;
    for( int i = k; i < 2 * n; i++ )
    {
        b[j] = a[i];
        j++;
    }
    for( int i = 0; i < k; i++ )
    {
        b[j] = a[i];
        j++;
    }
    for( int i = 0; i < 2 * n; i++ )
        a[i] = b[i];
}

void riffleShuffle( int* a, int n )
{
    int b[2*n], i = 0, j = n, k = 0;

    while( i < n )
    {
        b[k] = a[i];
        b[k+1] = a[j];
        i++;
        j++;
        k += 2;
    }

    for( int i = 0; i < 2 * n; i++ )
        a[i] = b[i];
}

int main()
{
    int n, m, a;

    cin >> n >> m;

    int card[2*n];
    for( int i = 0; i < 2 * n; i++ )
        card[i] = i + 1;

    for( int i = 0; i < m; i++ )
    {
        cin >> a;
        if( a == 0 )
            riffleShuffle( card, n );
        else
            kshuffle( card, n, a );
    }

    for( int i = 0; i < 2 * n; i++ )
        cout << card[i] << endl;

    return 0;
}


Measured memory_bytes: 3124
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#define ll long long
ll read()
{
	ll tmp=0; char f=1,c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1; c=getchar();}
	while('0'<=c&&c<='9'){tmp=tmp*10+c-'0'; c=getchar();}
	return tmp*f;
}
using namespace std;
int cnt[200010]={0};
int n,m;
int main()
{
	int i,k;
	n=read(); m=read();
	for(i=1;i<=n;i++)k=read(),++cnt[k];
	for(i=1;i<=n;i++)if(!cnt[i])cnt[i]=1<<30;
	sort(cnt+1,cnt+n+1);
	for(i=1;i<=n;i++)if(cnt[i]==1<<30)break;
	int tot=i-1;
	if(tot<=m)printf("0\n");
	else{
		int ans=0;
		for(i=1;i<=tot-m;i++)ans+=cnt[i];
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 896
import numpy as np
N,K = [int(i) for i in input().split()]
nums = np.arange(1,N+1)
a =nums[nums%K==0]
ans = len(a)**3
if K%2 == 0:
  a = nums[nums%K==K/2]
  ans += len(a)**3
  
print(ans)

Measured memory_bytes: 16584
#n = int(input())
n,m = map(int,input().split())
a_L = list(map(int,input().split()))

flag = True
diff = 0
s = sum(a_L)
a_L = list(sorted(a_L))



for i in range(n):

    if float(a_L[i]) >= s/(4*m):
        diff += 1

if diff >=m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
    int n,a,b,c;
    while(scanf("%d",&n)==1)
    {
        a=n%10;
        b=(n/10)%10;
        c=n/100;
        if(a==c)
        {
            printf("Yes\n");
        }
        else
            printf("No\n");
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    int left = 0, right = 0;
    for (int i = 0; i < m; i++)
    {
        int a;
        cin >> a;
        if (a < x)
        {
            left ++;
        }
        else if (a > x)
        {
            right ++;
        }
    }
    cout << min(left, right) << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    string s;
    int k;
    cin>>s>>k;
    string t=s;
    t.erase(unique(all(t)),t.end());
    if(t.length()==1){
        cout<<s.length()*k/2<<endl;
        return;
    }
    int n=s.length();
    int ans=0;
    int cnt=1;
    Rep(i,1,n){
        if(s[i]!=s[i-1]){
            ans+=cnt/2;
            cnt=1;
        }
        else cnt++;
    }
    ans+=cnt/2;
    ans*=k;
    if(s[0]==s[s.length()-1]){
        int a=1;
        for(int i=0;s[i]==s[i+1];i++,a++);
        int b=1;
        for(int i=n-1;s[i]==s[i-1];i--,b++);
        ans-=(a/2+b/2-(a+b)/2)*(k-1);
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
//suhan lee,saitama university

#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <complex>
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef long long ll;
typedef pair<ll,ll> teki;


#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define repn(i,n) for(int i=0;i<n;i++)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
#define pb push_back 
#define pf push_front
int tekisort(teki a,teki b){
  return a.first*b.second<a.second*b.first;
}

int main(){
  ll n,shuh,shua,shud,shus;
  ll tmph,tmpa,tmpd,tmps,zentan;
  zentan=0;
  vector<teki> enemies;
  cin>>n>>shuh>>shua>>shud>>shus;
  zentan=shuh;
  int arienai=false;
  for(ll i=0;i<n;i++){
    cin>>tmph>>tmpa>>tmpd>>tmps;
    ll tmpdd=shua-tmpd;
    if(tmpdd<=0) {
      if(tmpa-shud<=0){
	n--;
	i--;
	arienai=true;
	continue;
      }
      
      cout<<-1<<endl;
      return 0;
    }
    ll tmpt=tmph/tmpdd;
    if(tmph%tmpdd) tmpt+=1;
    if(tmps>shus) shuh-=max(tmpa-shud,(ll)0);
    enemies.pb(make_pair(tmpt,max(tmpa-shud,(ll)0)));     if(shuh<=0)  {cout<<-1<<endl;
      return 0;}
  }
  sort(enemies.begin(),enemies.end(),tekisort);
  ll imamade=0;
  for(ll i=0;i<n;i++){
    //    cout<<shuh<<" "<<enemies[i].second<<"debug\n";  
    imamade+=enemies[i].first;
    shuh-=(imamade-1)*enemies[i].second;
    if(shuh<=0)  {cout<<-1<<endl;
      return 0;
    }
  }
  cout<<zentan-shuh<<endl;
  return 0;
}

Measured memory_bytes: 2048
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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 N, C;
int D[40][40];
int c[510][510];
int diff[5][40];

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

  rep( i, C ) rep( j, C )
    scanf( "%d", &D[i][j] );

  rep( i, N ) rep( j, N )
    scanf( "%d", &c[i][j] ), --c[i][j];

  rep( col, C )
  {
    rep( i, N ) rep( j, N )
      diff[(i+1+j+1)%3][col] += D[c[i][j]][col];
  }

  int ans = 1<<30;

  rep( col1, C ) rep( col2, C ) rep( col3, C )
  {
    if( !(col1 != col2 && col2 != col3 && col3 != col1) )
      continue;

    ans = std::min( ans, diff[0][col1]+diff[1][col2]+diff[2][col3] );
  }

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

  return 0;
}

Measured memory_bytes: 1152
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep1(i, n) for (int i = 0; i < (int)(n); i++)


int main(){
  int n;
  cin >> n;
  string c;
  cin >> c;
  int ans = 0;
  int n_red = count(c.begin(), c.end(), 'R');
  char white = 'W';
  rep1(i, n_red){
    char moji = c[i];
    
    if(moji == white){
      ans++;
    }
  }
    
  cout << ans;

}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int N, M;
vector<int> G[100005];
int cost[3][100005];

struct E {
  int src, dst;
  int dist;
};
bool operator>(const E& a, const E& b){
  return a.dist > b.dist;
}

int dijkstra(int S, int T){
  rep(i,3) rep(j,100005) cost[i][j] = -1;

  priority_queue<E,vector<E>,greater<E>> que;
  que.push((E){-1,S,0});
  while(!que.empty()){
    E e = que.top(); que.pop();

    if(cost[e.dist%3][e.dst] != -1) continue;
    cost[e.dist%3][e.dst] = e.dist;

    rep(i,G[e.dst].size()){
      int nxt = G[e.dst][i];
      if(cost[(e.dist+1)%3][nxt] == -1){
        que.push((E){e.dst,nxt,e.dist+1});
      }
    }
  }
  if(cost[0][T] == -1) return -1;
  return cost[0][T] / 3;
}


int main(){
  cin >> N >> M;
  rep(i,M){
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
  }

  int S, T;
  cin >> S >> T;

  cout << dijkstra(S, T) << endl;
  
  return 0;
}


Measured memory_bytes: 8948
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int[] x = new int[5];
            for (int i = 0; i < x.length; i++) {
                x[i] = sc.nextInt();
            }

            for (int i = 0; i < x.length; i++) {
                if (x[i] != (i + 1)) {
                    System.out.println(i + 1);
                }
            }
        }
    }
}


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

int main() {
  int N;
  cin >> N;
  
  for(int x=0; x<=N/7+1; x++) {
    for(int y=0; y<=N/4+1; y++) {
      if(7*x+4*y == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
      
		int X=sc.nextInt();
		int A=sc.nextInt();
		int B=sc.nextInt();
		
		int ans= (X-A)%B;
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 23636
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define int long long
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e7 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int a , b , c ; 
    cin >> a >> b >> c ; 
    if ( (c - a - b) > 0 && 4 * a * b < (c - a - b) * (c - a - b) ){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
typedef long long ll;
using namespace std;
 
int main(){
    int n,a[5001];
    int ans;
    a[0]=0;
    while(cin>>n&&n){
        ans = INT_MIN;
        for(int i=1;i<=n;i++){
            cin>>a[i];
            a[i] += a[i-1];
        }
        for(int i=1;i<=n;i++){
            for(int j=i;j<=n;j++){
                ans = max(ans,a[j]-a[i-1]);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3104
import collections


def solve(string):
    n, *v = map(int, string.split())
    if len(set(v)) == 1:
        return str(n // 2)
    else:
        odds = v[1::2]
        _o = collections.Counter(odds)
        r_o = {str(v): k for k, v in _o.items()}
        evens = v[::2]
        _e = collections.Counter(evens)
        r_e = {str(v): k for k, v in _e.items()}
        ans1 = 0
        tmp = max(_o.values())
        ans1 += len(odds) - tmp
        key = r_o[str(tmp)]
        if key in _e.keys():
            _e[key] = 0
        ans1 += len(evens) - max(_e.values())

        ans2 = 0
        _o = collections.Counter(odds)
        r_o = {str(v): k for k, v in _o.items()}
        _e = collections.Counter(evens)
        r_e = {str(v): k for k, v in _e.items()}
        tmp = max(_e.values())
        ans2 += len(evens) - tmp
        key = r_e[str(tmp)]
        if key in _o.keys():
            _o[key] = 0
        ans2 += len(evens) - max(_o.values())

        return str(min(ans1, ans2))


if __name__ == '__main__':
    print(solve("\n".join([input(), input()])))


Measured memory_bytes: 70632
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<iostream>
using namespace std;
int main(){
    string s;
    int sum=700;
    cin>>s;
    for(int i=0;i<3;i++){
        if(s[i]=='o') sum+=100;
    }
    cout<<sum<<endl;
return 0;}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}




fn solve(a: char, b: char) -> char {
    if a == 'H' {
        if b == 'H' {
            'H'
        } else {
            'D'
        }
    } else {
        if b == 'H' {
            'D'
        } else {
            'H'
        }
    }
}


fn main() {
    input! {
        a: chars,
        b: chars,
    }
    println!("{}", solve(a[0], b[0]));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

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

  ll n;
  cin >> n;

  cout << (n * (n - 1) / 2) << en;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

void solve()
{
	ll a, b, n;
	cin >> a >> b >> n;
	ll x = min(b - 1, n);
	ll ans = (a * x) / b - a * (x / b);
	cout << ans << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve();
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 3652
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int x,y,p,q,tmp;
        x=scan.nextInt();
        y=scan.nextInt();
        
        p=Math.max(x,y);
        q=Math.min(x,y);
        while(p%q!=0){
            tmp=p%q;
            p=q;
            q=tmp;
        }
        System.out.println(q);
    }
}


Measured memory_bytes: 26376
#include<iostream>
#include<cmath>

using namespace std;
int main()
{
  int q,z,n;
  cin>>q>>z;
  n=(q+z)/2;
  if(abs(q-n)==abs(z-n))
   cout<<n;
  
  else
 cout<<"IMPOSSIBLE"<<endl;
 
    return 0;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<string>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for (int i=a; i<=b; i++)
#define per(i,a,b) for (int i=a; i>=b; i--)
using namespace std;
typedef long long LL;

inline int read() {
    int x=0,f=1; char ch=getchar();
    while (!(ch>='0'&&ch<='9')) {if (ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9') {x=x*10+(ch-'0'); ch=getchar();}
    return x*f;
}

const int N = 500005;
const double eps = 1e-8;

int n,head=0,tail=0;
double L,q[N][2];

int main() {

 

    n=read(); L=read();
    double S=0,V=0;
    rep(i,1,n) {
        int t=read(),v=read();
        V+=v; S+=(double)t*v;
        while (V>L&&head<tail) {
            if (V-L>=q[head][0]) {
                V-=q[head][0]; S-=q[head][0]*q[head][1];
                head++;
            } else {
                q[head][0]-=V-L; S-=(V-L)*q[head][1]; V=L;
                break;
            }
        }
        q[tail][0]=v; q[tail++][1]=t;
        printf("%lf\n",S/L);
        while (tail-head>=2) {
            if (q[tail-1][1]>q[tail-2][1]) break;
            q[tail-2][1]=(q[tail-2][0]*q[tail-2][1]+q[tail-1][0]*q[tail-1][1])/(q[tail-2][0]+q[tail-1][0]);
            q[tail-2][0]+=q[tail-1][0];
            tail--;
        }
    }

    return 0;
}

Measured memory_bytes: 16384
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    long double a,b,c;
    in(a,b,c);
    yn((a+b+2*sqrt(a*b))/c<1);
}

Measured memory_bytes: 3748
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int main(){
	string S;
	cin >> S;
	long long ans=0;
	int N = S.size()-1;
	for(int s=0;s<(1<<N);s++){
		string tmp=S;
		int cnt=0;
		for(int i=0;i<N;i++){
			if(s & (1<<i)){
				tmp.insert(i+1+cnt,"+");
				cnt++;
			} 
		}
		int pos=0;
		while(tmp.find("+",pos)!=string::npos){
			int next_pos = tmp.find("+",pos);
			ans+=stoll(tmp.substr(pos,next_pos-pos));
			pos = next_pos+1;
		}
		ans+=stoll(tmp.substr(pos));
	}
cout <<ans<<endl;
	}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>
#include <memory.h>
#include <map>
#include <math.h>
#include <utility>
#include <set>

#pragma warning(disable:4996)
using namespace std;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;
const double PI = 3.141592653589793238;
const Int INF = 999999999999;
typedef pair<int, int> P;

int S[3][3] = {
		{ 0, 1, 0 },
		{ 1, 1, 1 },
		{ 0, 1, 0 },
};
int M[3][3] = {
		{ 1, 1, 1 },
		{ 1, 1, 1 },
		{ 1, 1, 1 },
};
int L[5][5] = {
		{ 0, 0, 1, 0, 0 },
		{ 0, 1, 1, 1, 0 },
		{ 1, 1, 1, 1, 1 },
		{ 0, 1, 1, 1, 0 },
		{ 0, 0, 1, 0, 0 },
};

int tile[10][10];

int main()
{
	int x, y, size;
	while (scanf("%d,%d,%d", &x, &y, &size) != EOF){
		int a = 0;
		int b = 0;
		int a_ = 0;
		int b_ = 0;
		if (size == 1){
			while (x + a - 1 < 0)++a;
			while (y + b - 1 < 0)++b;
			while (x + 2 + a_ > 10)--a_;
			while (y + 2 + b_ > 10)--b_;

			for (int i = y - 1 + b; i < y + 2 + b_; ++i){
				for (int j = x - 1 + a; j < x + 2 + a_; ++j){
					tile[i][j] += S[i + 1 - y][j + 1 - x];
				}
			}
		}
		if (size == 2){
			while (x + a - 1 < 0)++a;
			while (y + b - 1 < 0)++b;
			while (x + 2 + a_ > 10)--a_;
			while (y + 2 + b_ > 10)--b_;

			for (int i = y - 1 + b; i < y + 2 + b_; ++i){
				for (int j = x - 1 + a; j < x + 2 + a_; ++j){
					tile[i][j] += M[i + 1 - y][j + 1 - x];
				}
			}
		}
		if (size == 3){
			while (x + a - 2 < 0)++a;
			while (y + b - 2 < 0)++b;
			while (x + 3 + a_ > 10)--a_;
			while (y + 3 + b_ > 10)--b_;

			for (int i = y - 2 + b; i < y + 3 + b_; ++i){
				for (int j = x - 2 + a; j < x + 3 + a_; ++j){
					tile[i][j] += L[i + 2 - y][j + 2 - x];
				}
			}
		}
	}
	int white = 0;
	int max_ = -1;

	REP(i, 10){
		REP(j, 10){
			if (!tile[i][j])
				++white;
			max_ = max(tile[i][j], max_);
		}
	}

	cout << white << endl << max_ << endl;

	return 0;

}

Measured memory_bytes: 1200
function main()
  n, m = map(s -> parse(BigInt, s), split(readline()))
  answer = big(1)
  i = big(2)
  while i * i <= m
    if mod(m, i) == 0
      count = big(0)
      while mod(m, i) == 0
        count += 1
        m /= i
      end
      answer *= comb(n + count - 1, count)
    end
    i += 1
  end
  if m > 1
    answer *= n
  end
  println(mod(answer, big(10^9 + 7)))
end

function comb(n, k)
  if n - k < k return comb(n, n - k) end
  numer = one(n)
  denom = one(n)
  for i = 0:k-1
    numer = numer * (n - i)
    denom = denom * (i + 1)
  end
  return div(numer, denom)
end

main()


Measured memory_bytes: 117524
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    string s;
    int cnt = 0;

    while (cin >> s) {
        string r = s;
        reverse(r.begin(), r.end());
        
        if (s == r)
            cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1192
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int q,h,s,d,n,a,b;
	long long kin;
	scanf("%d %d %d %d",&q,&h,&s,&d);
	scanf("%d",&n);
	h=min(q*2,h);
	s=min(h*2,s);
	d=min(s*2,d);
	a=n/2;	b=n%2;
	kin=(long long)a*d+b*s;
	printf("%lld\n",kin);
	return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	int n;
	cin >> n;
	REP(i, n) {
		double h, m;
		char c;
		cin >> h >> c >> m;

		double hr = 30*h+30*(m/60);
		double mr = 6*m;

		double res = max(hr, mr)-min(hr, mr);
		res = min(res, 360-res);

		if(res < 30) {
			cout << "alert" << endl;
		} else if(res < 90) {
			cout << "warning" << endl;
		} else {
			cout << "safe" << endl;
		}
	}

	return 0;
}

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

int n, m;
bool mr[150], mk[150];
string s[150];
int main(){
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
//  freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE
  cin >> n >> m;
  for(int i = 0; i < n; ++i) cin >> s[i];
  for(int i = 0; i < n; ++i){
    int a = 0;
    for(int j = 0; j < m; ++j){
      a |= (s[i][j] == '.' ? 1:(1<<1));
    }
    if(a == 1) mr[i] = true;
  }
  for(int i = 0; i < m; ++i){
    int a = 0;
    for(int j = 0; j < n; ++j){
      a |= (s[j][i] == '.' ? 1:(1<<1));
    }
    if(a == 1) mk[i] = true;
  }
  for(int i = 0; i < n; ++i){
    if(mr[i]) continue;
    for(int j = 0; j < m; ++j){
      if(!mk[j]) cout << s[i][j];
    }
    cout << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const ll mod = 1e9+7;
long double PI = acosl(-1);
const ll infl = 1e18;
const int inf = 2e9;
const int nmax = 1e5+5;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;



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

    int h,w,k;
    cin>>h>>w>>k;
    vector<string>g(h);
    for(int i=0; i<h; i++) cin>>g[i];
    int bhalu = 0;
    for(int msk=0; msk<(1<<(h+w)); msk++){
        vector<string>tmp=g;
        for(int i=0; i<h; i++) if(msk>>i&1){
            for(int j=0; j<w; j++) tmp[i][j] = '.';
        }
        for(int j=0, k=h; k<h+w; j++, k++) if(msk>>k&1) {
            for(int i=0; i<h; i++) tmp[i][j] = '.';
        }
        int cnt = 0;
        for(int i=0; i<h; i++) for(int j=0; j<w; j++) if(tmp[i][j]=='#') cnt++;
        if(cnt==k) bhalu++;
    }
    cout<<bhalu<<endl;

}
/*

*/


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

int main(){
    // todo n=2

    ll K, N;
    cin >> K >> N;
    vector<ll> A(N+1,0), d(N+1);

    ll mx = 0;
    rep(i, 1, N+1) cin >> A[i];
    rep(i, 1, N+1){
        ll d;
        if(i != N) d = A[i+1] - A[i];
        else d = K - A[N] + A[1];
        mx = max(mx, d);
    }

    cout << K - mx << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;

#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}



signed main(){
	IOS();
	vector<string>ans;
	vector<char>c(26*2);
	rep(i,0,26)c[i]='a'+i;
	rep(i,26,52)c[i]='A'+i-26;
	while(1){
		int N;
		cin>>N;
		if(!N)break;
		vector<int>a(N);
		REP(i,N)cin>>a[i];
		string s;
		cin>>s;
		string t="";
		rep(i,0,s.size()){
			int tmp;
			if('a'<=s[i]&&s[i]<='z')tmp=s[i]-'a';
			else tmp=s[i]-'A'+26;
			t+=c[(tmp-a[i%N]+52)%52];
		}
		ans.push_back(t);
	}
	for(auto e:ans){
		cout<<e<<endl;
	}
}


Measured memory_bytes: 3232
#include <iostream>
#include <vector>
using namespace std;
int main ()
{
	int n, m, acc=0, pen=0; cin>>n>>m;
	bool test[n+1]={false};
	int arr[n+1]={0};
	int p[m];
	string s[m];
	for (int i=0; i<m; i++)
	{
		cin>>p[i];
		cin>>s[i];
		if (test [p[i]]==false && s[i]=="AC")
		{
			test[p[i]]=true;
			acc++;
			pen+=arr[p[i]];
		}
		if (test[p[i]]==false && s[i]=="WA")
		{
			arr[p[i]]++;
		}
	}
	cout<<acc<<endl<<pen<<endl;
	return 0;
}

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

using namespace std;

int n,a,ans;

int main(){
	scanf("%d",&n);
	int t=0;
	for (int i=1;i<=n;++i){
		scanf("%d",&a);
		int j=0; for (;1<<j<a;++j);
		if (j>t){
			ans+=j-t;
			t=j;
		}
		else{
			if (1<<j==a) t=j;
			else t=j-1;
		}
	}
	printf("%d\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		//		new Main().solveB();
		new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();

			System.out.println((numA - 1) * (numB - 1));

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			int count = 0;
			for (int i = 1; i <= numN; i++) {
				if (i % 2 == 0) {
					continue;
				}
				int wk = i;
				Map<Integer, Integer> wkMap = new HashMap<Integer, Integer>();
				for (int j = 2; j < i;) {
					if (wk % j == 0) {
						wk /= j;
						wkMap.put(j, wkMap.get(j) == null ? 1 : wkMap.get(j) + 1);
					} else {
						j++;
					}
				}
				int wkRes = 1;
				for (Integer val1 : wkMap.values()) {
					wkRes *= (val1 + 1);
				}
				if (wkRes == 8) {
					count++;
				}
			}

			System.out.println(count);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		String wkS;
		long count = 0;

		try {
			scanner = new Scanner(System.in);
			wkS = scanner.next();
			count = scanner.nextLong();

			if (count > wkS.length()) {
				for (int i = 0; i < wkS.length(); i++) {
					if (wkS.charAt(i) != '1') {
						System.out.println(wkS.charAt(i));
						return;
					}
				}
			} else {
				String wk = wkS.substring(0, (int) count);
				for (int i = 0; i < wk.length(); i++) {
					if (wk.charAt(i) != '1') {
						System.out.println(wk.charAt(i));
						return;
					}
				}
			}
			System.out.println(1);
		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 22996
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
    int s[5],k;
    for(int i=0;i<3;i++)
        scanf("%d",&s[i]);
    scanf("%d",&k);
    sort(s,s+3);
    for(int i=1;i<=k;i++)
    {
        s[2]=s[2]*2;
    }
    printf("%d\n",s[0]+s[1]+s[2]);
}


Measured memory_bytes: 128
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#include<vector>
using namespace std;
int main(){
    int a1,a2,a3; cin >> a1 >> a2 >> a3;
    //Aiの小さいタスクから順に、または Ai の大きいタスクから順に完了したときに最小となり、
    //A1, A2, A3 の最大値と最小値の差が答えになります
    //★ひらめきの問題
    cout << max({a1,a2,a3}) - min({a1,a2,a3}) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int n, m,ans;
string s;
int l[500000];

void read() {
	cin >> n;
	getline(cin, s);
	getline(cin, s);
}
void prep() {
	l[0] = 0;
	for (int i = 1; i <= n; i++) {
		l[i] = l[i - 1] + (s[i-1] == '#');
	}
	ans = l[n];
	int sum = 0;
	for (int i = n-1; i >=0; i--) {
		sum += (s[i] == '.');
		if (sum + l[i] < ans)ans = sum + l[i];
	}
}
void run(){

}
void print() {
	cout << ans ;
}
int main(){
	read();
	prep();
	run();
	print();
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
int main(){
  int c,q,i,j,z=0,k=1,m[1001][1001]={0},e[6][2]={0};
  for(i=0;i<6;i++){
    cin>>q>>c;
    if(q>c)m[q][c]++;
    else m[c][q]++;
  }
  for(i=0;i<1001;i++)for(j=0;j<1001;j++){
    if(m[i][j]){
      if(m[i][j]%2==0)for(c=0;c<m[i][j]/2;c++){e[z][0]=i;e[z++][1]=j;}
      else {e[z][0]=i;e[z++][1]=j;}
    }
  }
  if(e[0][0]!=e[2][1]||e[1][0]!=e[2][0]||e[0][1]!=e[1][1])k=0;
  if(k)cout<<"yes"<<endl;
  else cout<<"no"<<endl;
}

Measured memory_bytes: 7020
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>




typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)



ll fast_pow(ll x,ll n,ll mod){
    if (n==0) return 1;
    ll res=fast_pow(x*x %mod,n/2,mod);
    if (n&1) res=res*x%mod;
    return res;
}

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

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

const int mod=1e9+7;
int dp[10000010][2]; 
//[0]は上からi桁目まで見てその数と一致
//[1]はその数未満であることが確定
//以上は今回考えない

int main(){
    int n;
    string s;
    cin>>s;
    n=s.size();
    dp[0][0]=1;
    rep(i,n){
        //a+b==0
        {
          if (s[i]=='0'){
            	dp[i+1][0]=dp[i][0];
            	dp[i+1][1]=dp[i][1];
            } else {
                dp[i+1][1]=(dp[i][0]+dp[i][1])%mod;
            }
        }
        //a+b==1
        {
          if (s[i]=='0'){
            dp[i+1][1]+=(dp[i][1]*2)%mod;
            dp[i+1][1]%=mod;
        } else {
            dp[i+1][0]+=(dp[i][0]*2)%mod;
            dp[i+1][1]+=(dp[i][1]*2)%mod;
            dp[i+1][0]%=mod;dp[i+1][1]%=mod;
        }
        }
    }
    cout<<(dp[n][0]+dp[n][1])%mod<<endl;
    
    return 0;
}


Measured memory_bytes: 1280
def main():
    n, m = map(int, input().split())
    sc_list = [list(map(int, input().split())) for _ in range(m)]
    ans = []
    for i in range(0, 10 ** n):
        tmp = str(i)
        if n == len(tmp):
            if all([tmp[s - 1] == str(c) for s, c in sc_list]):
                ans.append(i)
    if not ans:
        print(-1)
    else:
        print(min(ans))
main()

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

using namespace std;
const int MOD = 1e6 * 2 + 7;


int main() {
    int n;
    cin >> n;
    int d = n%10;
    if (d == 2 || d == 4 || d == 5 || d == 7 || d == 9) {
        cout << "hon" << "\n";
    }
    else if (d == 0 || d == 1 || d == 6 || d == 8) {
        cout << "pon" << "\n";
    }
    else if (d == 3) {
        cout << "bon" << "\n";
    }
    

    return 0;
}

Measured memory_bytes: 3616
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long ans = Math.max(A + B, A - B);
		ans = Math.max(ans, A * B);
		System.out.println(ans);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 22996
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

int n;

vector <ll> v;

ll x, sum;

int main() {
	scanf("%d",&n);
	REP(i, 3 * n) {
		scanf("%lld",&x);
		v.push_back(x);
	}

	sort(all(v));

	int it = 0;
	REP(i, n) {
		v.pop_back();
		sum += v.back();
		v.pop_back();
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 6524
#include<stdio.h>
#include<algorithm>
using namespace std;
int s(int x,int y){
    if(x<=y) return y-x;
        else return x-y+2;
}
int main(){
    int x,y;
    scanf("%d %d",&x,&y);
    printf("%d\n",min(s(x,y),min(s(-x,y)+1,min(s(x,-y)+1,s(-x,-y)+2))));
    return 0;
}

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

using namespace std;

int main() {
    int n, m, sum = 0, p, x;
    cin >> n;
    vector<int> t(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> t.at(i);
        sum += t.at(i);
    }
    cin >> m;
    for (int i = 0; i < m; ++i) {
        cin >> p >> x;
        cout << sum - t.at(p) + x << endl;
    }
    return 0;
}


Measured memory_bytes: 256