akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
// #define mod 998244353
using namespace std;

set<pi> colored;
int h, w;

bool valid(int x, int y)
{
	if (x < 2 || y < 2 || x >= h || y >= w)
	{
		return 0;
	}
	return 1;
}

int count(int x, int y)
{
	int ans = 0;
	for (int i = -1; i <= 1; i++)
	{
		for (int j = -1; j <= 1; j++)
		{
			if (colored.find({x + i, y + j}) != colored.end())
			{
				ans++;
			}
		}
	}
	return ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> h >> w >> n;
	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		colored.insert({a, b});
	}
	set<pi> center[10];
	for (pi p : colored)
	{
		for (int i = -1; i <= 1; i++)
		{
			for (int j = -1; j <= 1; j++)
			{
				int x = p.first + i, y = p.second + j;
				if (valid(x, y))
				{
					center[count(x, y)].insert({x, y});
				}
			}
		}
	}
	ll ans = (h - 2);
	ans *= (w - 2);
	for (int i = 1; i <= 9; i++)
	{
		ans -= center[i].size();
	}
	cout << ans << endl;
	for (int i = 1; i <= 9; i++)
	{
		cout << center[i].size() << endl;
	}
	return 0;
}

Measured memory_bytes: 47104
'''
pow(base, exp[, mod])
base の exp 乗を返します; 
mod があれば、base の exp 乗に対する mod の剰余を返します 
(pow(base, exp) % mod より効率よく計算されます)。
二引数の形式 pow(base, exp) は、冪乗演算子を使った base**exp と等価です。
'''

url = 'https://tane-no-blog.com/976/'

# pow を実装したコード
# def pow(x,n):
    # res = 1
    # while n > 0:
        # if n&1 == 1:
            # res *= x
        # x *= x
        # n >>= 1
    # return res

n,a,b = map(int,input().split())

# pow を用いた組み合わせ計算の高速化
mod = 10**9 + 7
def comb(N,x):
    numerator = 1
    for i in range(N-x+1,N+1):
        numerator = numerator * i % mod
    denominator = 1
    for j in range(1,x+1):
        denominator = denominator * j % mod
    d = pow(denominator,mod-2,mod)
    return numerator * d

A = comb(n,a)
B = comb(n,b)

print((pow(2,n,mod)-1-A-B) % mod)

Measured memory_bytes: 64468
// ABC112_C
#include <iostream>
#include <vector>
#include <tuple>  // std::tuple std::get
#include <algorithm>
using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1

int main() {
    // input
    ll N, idx = 0;
    cin >> N;
    vector<ll> X(N), Y(N), H(N);
    REP(i, N) {
        cin >> X[i] >> Y[i] >> H[i];
        if (H[i] > 0) idx = i;  // 制約上，必ず1組は h_i > 0 となっている
    }
    
    // 中心座標を全探索
    ll now_H, d_i, tmp_h_i, tmp_d_i;
    bool flag;
    
    for (ll Cx = 0; Cx <= 100; ++Cx) {
        for (ll Cy = 0; Cy <= 100; ++Cy) {
            d_i = abs(X[idx] - Cx) + abs(Y[idx] - Cy);
            now_H = H[idx] + d_i;
            
            // 中心座標を固定した時，それが入力に合うかを求める
            flag = true;
            
            for (ll i = 0; i < N; ++i) {
                tmp_d_i = abs(X[i] - Cx) + abs(Y[i] - Cy);
                tmp_h_i = max(now_H - tmp_d_i, 0LL);
                if (H[i] != tmp_h_i) {
                    flag = false;  // 矛盾したら false
                    break;
                }
            }
            
            if (flag) {
                cout << Cx << " " << Cy << " " << now_H << "\n";
                return 0;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct happiness{
 int a,b,c;
};
/*int maxHappy(happiness arr[],int n,int startDay,int day){
  if(day==n+1){
    return 0;
  }
  int maxm = INT_MIN;
  if(startDay == 0){
    maxm = max(arr[day].a+maxHappy(arr,n,1,day+1),max(arr[day].b+maxHappy(arr,n,2,day+1),arr[day].c+maxHappy(arr,n,3,day+1)));
  }
  if(startDay == 1){
    maxm = max(arr[day].b+maxHappy(arr,n,2,day+1),arr[day].c+maxHappy(arr,n,3,day+1));
  }
  if(startDay == 2){
    maxm = max(arr[day].a+maxHappy(arr,n,1,day+1),arr[day].c+maxHappy(arr,n,3,day+1));
  }
  if(startDay == 3){
    maxm = max(arr[day].b+maxHappy(arr,n,2,day+1),arr[day].a+maxHappy(arr,n,1,day+1));
  }
 return maxm;
}*/
int maxHappydp(happiness arr[],int n,int startDay,int day,int dp[][4]){
 if(day == 0){
    return 0;
 }
 if(dp[day][startDay]!=0){
    return dp[day][startDay];
 }
 //recursive steps
 int maxm = INT_MIN;
 if(startDay == 0){
    maxm = max(arr[day].a+maxHappydp(arr,n,1,day-1,dp),max(arr[day].b+maxHappydp(arr,n,2,day-1,dp),arr[day].c+maxHappydp(arr,n,3,day-1,dp)));
 }
 if(startDay == 1){
    maxm = max(arr[day].b+maxHappydp(arr,n,2,day-1,dp),arr[day].c+maxHappydp(arr,n,3,day-1,dp));
  }
  if(startDay == 2){
    maxm = max(arr[day].a+maxHappydp(arr,n,1,day-1,dp),arr[day].c+maxHappydp(arr,n,3,day-1,dp));
  }
  if(startDay == 3){
    maxm = max(arr[day].b+maxHappydp(arr,n,2,day-1,dp),arr[day].a+maxHappydp(arr,n,1,day-1,dp));
  }
  return dp[day][startDay] = maxm;
}
int main(){
 int n;
 cin>>n;
 happiness arr[n+1];
 for(int i=1;i<=n;i++){
    int a1,b1,c1;
    cin>>a1>>b1>>c1;
    arr[i].a = a1;
    arr[i].b = b1;
    arr[i].c = c1;
 }
 int startDay = 0;
 int day = 1;
 int dp[n+1][4]={0};
 cout<<maxHappydp(arr,n,0,n,dp)<<endl;


}


Measured memory_bytes: 10752
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i, N) for (LL i = 0; i < N; ++i)
typedef long long int LL;

int main() {
  LL N;
  in >> N;
  std::vector<LL> a(N + 1);
  rep(i, N) in >> a[i + 1];

  std::vector<LL> ans(N + 1);
  for (LL i = N; i >= 1; --i) {
    LL sum = 0;
    for (LL j = i * 2; j <= N; j += i) sum += ans[j];
    sum %= 2;
    if (sum != a[i]) ans[i] = 1;
  }

  std::vector<LL> b;
  for (LL i = 1; i <= N; ++i) {
    if (ans[i] == 1) b.push_back(i);
  }
  out << b.size() << std::endl;
  rep(i, b.size()) out << b[i] << std::endl;
}


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

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define REP2(i,n) for(int i=0;i<(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP4(i,m,n,s) for(int i=m;(s>0 and i<(int)(n)) or (s<0 and i>(int)(n));i+=s)
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REPIT(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define PIS(x) printf("%d ",x)
#define PN() putchar('\n')
#define PRINTARR(a,b) for(int i=0;(a+i)!=(b);i++){cout << *(a+i) << " ";}PN();
#define MP make_pair
#define PB push_back
#define EB emplace_back

typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;

void RI() {}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d", &head);
    RI(tail...);
}
void RLL() {}
template<typename... T>
void RLL( LL& head, T&... tail ) {
    scanf("%lld", &head);
    RLL(tail...);
}
void print() {putchar('\n');}
template<typename T, typename... U>
void print(T head, U... tail) {
    cout << head << " ";
    print(tail...);
}

const int MOD = 1000000007;
#define MAX_N 105
char S[2][MAX_N];

int main()
{
    int n;
    RI(n);

    scanf("%s", S[0]);
    scanf("%s", S[1]);

    int cur = 0;
    LL ans = 1;
    int i = 0;
    while(i < n) {
        if(cur == 0) {
            if(S[0][i] == S[1][i]) {
                ans = (ans * 3) % MOD;
                cur = 1;
                i++;
            } else {
                ans = (ans * 6) % MOD;
                cur = 2;
                i += 2;
            }
        } else if(cur == 1){
            if(S[0][i] == S[1][i]) {
                ans = (ans * 2) % MOD;
                cur = 1;
                i++;
            } else {
                ans = (ans * 2) % MOD;
                cur = 2;
                i += 2;
            }
        } else {
            if(S[0][i] == S[1][i]) {
                cur = 1;
                i++;
            } else {
                ans = (ans * 3) % MOD;
                cur = 2;
                i += 2;
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var M = parseInt(input[0].split(" ")[1]);
  input.shift();
  var a = input.map(i => parseInt(i));
  var dp = new Array(N+1).fill(0);
  for(var i=0;i<M;i++){
    dp[a[i]]=-1;
  }
  if(dp[1]!=-1){
    dp[1]=1;
  }
  dp[0]=1;
  var mod = Math.pow(10,9)+7;
  for(var i=2;i<N+1;i++){
    if(dp[i]!=-1){
    dp[i]=(Math.max(0,dp[i-2])+Math.max(0,dp[i-1]))%mod;
    }
  }
  var ans=dp[N];
  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
	int K,N;
    cin>>N>>K;
  	double n=(double)N;
  	double k=(double)K;
  	int i;
 	for(i = 0; n>=1.0 ; i++) {
    	n=n/k;
  	}
  	cout<<i<<endl;
}

Measured memory_bytes: 256
/*
 * Codetest.cpp
 *
 *  Created on: 2018/01/21
 *      Author: Urakami
 */

#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<29;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
	int n;
	cin>>n;
	int a[n],b[n];
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	int ans=0;
	rep(i,n){
		int sum=0;
		rep(j,i+1)
		sum+=a[j];
		REP(j,i,n)
		sum+=b[j];
		ans=max(ans,sum);

	}
	cout<<ans<<endl;
	return 0;
  }


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

int a,b,k;

int main(){
	cin >>a >>b >>k;
  	
  int tmp=min(a,b);
  
  int cnt=0;
  rep(i,tmp){
  	int dv=tmp-i;
    if(a%dv==0 && b%dv==0){
    	cnt++;
    }
  	if(cnt==k){
		cout <<dv <<endl;
      	break;
    }
  }
  
  
  
  return 0;
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define in2(x, y) int x,y;cin>>x>>y
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;

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

#define lim5 100002
#define lim9 1000000002

#define deg(rad) (((rad)/2/M_PI)*360)

int main() {
	in(r);

	cout << r * r << endl;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
int n;
long long a , b;
long long arr[N];
int nxta[N];
int nxtb[N];
int valida[N];
int validb[N];
int dp[N][2];
void pre(long long x , int nxt[] , int valid[]){
	int ptr = n + 1;
	for(int i = n ; i >= 1 ; --i){
		while(arr[ptr - 1] - arr[i] >= x){
			--ptr;
		}
		nxt[i] = ptr;
	}
	nxt[0] = 1;
	valid[n] = n;
	for(int i = n - 1 ; i >= 1 ; --i){
		if(arr[i + 1] - arr[i] >= x){
			valid[i] = valid[i + 1];
		}
		else{
			valid[i] = i;
		}
	}
}
int main(){
	scanf("%d %lld %lld" , &n , &a , &b);
	for(int i = 1 ; i <= n ; ++i){
		scanf("%lld" , arr + i);
	}
	pre(a , nxta , valida);
	pre(b , nxtb , validb);
	dp[n + 1][0] = 1;
	dp[n + 1][1] = 1;
	for(int pos = n ; pos >= 1 ; --pos){
		int ql , qr;
		ql = max(pos , nxtb[pos - 1] - 1) + 1;
		qr = valida[pos] + 1;
		if(ql > qr){
			ql = qr + 1;
		}
		dp[pos][0] = dp[pos + 1][0] + dp[ql][1] - dp[qr + 1][1];
		ql = max(pos , nxta[pos - 1] - 1) + 1;
		qr = validb[pos] + 1;
		if(ql > qr){
			ql = qr + 1;
		}
		dp[pos][1] = dp[pos + 1][1] + dp[ql][0] - dp[qr + 1][0];
		dp[pos][0] -= (dp[pos][0] >= mod) * mod;
		dp[pos][0] += (dp[pos][0] < 0) * mod;
		dp[pos][1] -= (dp[pos][1] >= mod) * mod;
		dp[pos][1] += (dp[pos][1] < 0) * mod;
	}
	long long res = dp[1][0] - dp[2][0] + dp[1][1] - dp[2][1];
	res %= mod;
	res += mod;
	res %= mod;
	printf("%lld\n" , res);
}

Measured memory_bytes: 3328
#include <iostream>

using namespace std;
using ll = long long;

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

int dp[1005][1005];

const int mod = 1000000007;

int main() {
  int h, w;
  cin >> h >> w;

  bool a[h][w];
  rep(i, h) rep(j, w) {
    char c;
    cin >> c;
    a[i][j] = (c == '.');
  }

  dp[0][0] = 1;

  rep(i, h) rep(j, w) {
    if (a[i + 1][j]) {
      dp[i + 1][j] += dp[i][j];
      dp[i + 1][j] %= mod;
    }
    if (a[i][j + 1]) {
      dp[i][j + 1] += dp[i][j];
      dp[i][j + 1] %= mod;
    }
  }

  cout << dp[h - 1][w - 1] << endl;

  return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define RG register
#define LL long long
#define U(x,y,z) for(RG int x=y;x<=z;++x)
#define D(x,y,z) for(RG int x=y;x>=z;--x)
using namespace std;
template <typename T> void read(T &n){ bool f = 1; char ch = getchar(); n = 0; for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = 0; for (; isdigit(ch); ch = getchar()) n = (n << 1) + (n << 3) + (ch ^ 48); if (f == 0) n = -n;}
inline char Getchar(){ char ch; for (ch = getchar(); !isalpha(ch); ch = getchar()); return ch;}
template <typename T> inline void write(T n){ char ch[60]; bool f = 1; int cnt = 0; if (n < 0) f = 0, n = -n; do{ch[++cnt] = char(n % 10 + 48); n /= 10; }while(n); if (f == 0) putchar('-'); for (; cnt; cnt--) putchar(ch[cnt]);}
template <typename T> inline void writeln(T n){write(n); putchar('\n');}
template <typename T> inline void writesp(T n){write(n); putchar(' ');}
template <typename T> inline void chkmin(T &x, T y){x = x < y ? x : y;}
template <typename T> inline void chkmax(T &x, T y){x = x > y ? x : y;}
template <typename T> inline T Min(T x, T y){return x < y ? x : y;}
template <typename T> inline T Max(T x, T y){return x > y ? x : y;}
int h, w, a, b;
int main(){
	read(h), read(w), read(a), read(b);
	U(i, 1, b){
		U(j, 1, a)
			putchar('1');
		U(j, a + 1, w)
			putchar('0');
		putchar('\n');
	}
	U(i, b + 1, h){
		U(j, 1, a)
			putchar('0');
		U(j, a + 1, w)
			putchar('1');
		putchar('\n');
	}
    return 0;
}

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

int main(void) {
  ll N;
  cin >> N;

  const ll INF = 1LL << 60;
  vector<ll> dp(N + 1, INF);
  dp[0] = 0;
  REP(i, 0, N) {
    for(ll j = 1; i + j <= N; j *= 6) dp[i + j] = min(dp[i + j], dp[i] + 1);
    for(ll j = 1; i + j <= N; j *= 9) dp[i + j] = min(dp[i + j], dp[i] + 1);
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <deque>
#include <functional>
#include <algorithm>

using namespace std;

int main(){
    deque<int> inputs;
    int num;
    for(int i=0; i<10; i++) {
        cin >> num;
        inputs.push_back(num);
    }
    sort(inputs.begin(), inputs.end(), greater<int>());
    for(int i=0; i<3; i++) {
        cout << inputs[i] << endl;
    }
    return 0;
}

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

int main(){
    int N;
    vector<int> v_a(100001);
    vector<int> v_b(100001);

    cin >> N;
    for(int i=0;i<N;i++){
        int val = 0;
        cin >> val;
        if(i%2==0){
            v_a[val]++;
        }else{
            v_b[val]++;
        }
    }

    vector<int>::iterator max_a = max_element(v_a.begin(),v_a.end());
    int max_a_idx = distance(v_a.begin(),max_a);
    vector<int>::iterator max_b = max_element(v_b.begin(),v_b.end());
    int max_b_idx = distance(v_b.begin(),max_b);
//cout << max_a_idx << "," << max_b_idx << "\n";
    int ans = 0;
    ans = N/2-v_a[max_a_idx] + N/2-v_b[max_b_idx];
    if(max_a_idx==max_b_idx){
        int tmp_v_a_max = v_a[max_a_idx];
        int tmp_v_b_max = v_b[max_b_idx];
        v_a[max_a_idx]=0;
        v_b[max_b_idx]=0;

        vector<int>::iterator smax_a = max_element(v_a.begin(),v_a.end());
        int smax_a_idx = distance(v_a.begin(),smax_a);
        if(v_a[smax_a_idx]==0){
//            smax_a_idx = max_a_idx;
            v_a[max_a_idx] = tmp_v_a_max;
        }
        vector<int>::iterator smax_b = max_element(v_b.begin(),v_b.end());
        int smax_b_idx = distance(v_b.begin(),smax_b);
        if(v_b[smax_b_idx]==0){
//            smax_b_idx = max_b_idx;
            v_b[max_b_idx] = tmp_v_b_max;
        }
//       if(smax_a_idx!=smax_b_idx){
            ans = min( N/2-tmp_v_a_max+N/2-v_b[smax_b_idx],N/2-v_a[smax_a_idx]+N/2-tmp_v_b_max );
//        }else{
//            ans = min(N-tmp_v_a_max,N-tmp_v_b_max);
//        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int a[100005], freq[100005], health[100005];

int main() {
    int n, k, q;
    scanf("%d%d%d", &n, &k, &q);
    for(int i = 1; i <= q; i++) {
        scanf("%d", &a[i]);
        freq[a[i]]++;
    }
    for(int i = 1; i <= n; i++) {
        health[i] = k - (q - freq[i]);
        if(health[i] > 0) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }
}

Measured memory_bytes: 1792
n = gets.chomp.to_i

as = []

n.times{
	as << gets.chomp.to_i
}

sorted_a = as.sort{ |a,b| b <=> a}

max = sorted_a[0]
max_next = sorted_a[1]

as.each{ |x|
	if x == max then
		puts max_next
	else
		puts max
	end
}


Measured memory_bytes: 7784
#include "bits/stdc++.h"
using namespace std;
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()

int main() {
	int a, b, h;
	cin >> a >> b >> h;
	int sum = ((a + b) * h) / 2;
	cout << sum << endl;
}

Measured memory_bytes: 256
def main():
    temp=input()
    temp=input()
    temp=list(map(int,list(temp.split(" "))))    
    
    ans=0
    for n in temp:
        while(True):
            if n%2==0:
                n/=2
                ans+=1
            else:
                break
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 4212
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();
		Map<Integer, ArrayList<Integer>> map = new HashMap<>();
		for (int i = 0; i < M; i++) {
			int a = in.nextInt();
			int b = in.nextInt();
			if (map.containsKey(a)) {
				ArrayList<Integer> to = map.get(a);
				to.add(b);
			} else {
				ArrayList<Integer> to = new ArrayList<>();
				to.add(b);
				map.put(a, to);
			}
		}
		String ans = "IMPOSSIBLE";
		ArrayList<Integer> list = map.get(1);
		for (Integer from : list) {
			if (map.containsKey(from)) {
				if (map.get(from).contains(N)) {
					ans = "POSSIBLE";
					break;
				}
			}
		}
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 126596
N = int(input())
ans = 0
for i in range(1, N + 1):
    n = N // i  # 項数n
    cnt = (n * (2 * i + (n - 1) * i)) // 2  # 初項i, 項数n の等差数列の和の公式
    ans += cnt
print(ans)

Measured memory_bytes: 63500
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n;
	int[] a;

	void run(){
		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			a=new int[n];
			for(int i=0; i<n; i++){
				a[i]=sc.nextInt();
			}
			solve();
		}
	}

	void solve(){
		int swap=0;
		for(int j=n-1; j>=0; j--){
			for(int i=0; i<j; i++){
				if(a[i]>a[i+1]){
					int t=a[i];
					a[i]=a[i+1];
					a[i+1]=t;
					swap++;
				}
			}
		}
		println(""+swap);
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char a,b;
    cin>>a>>b;
    if(a=='H'&&b=='H') cout<<a<<endl;
    else if(a=='H' && b == 'D') cout<<b<<endl;
    else if(a=='D' && b == 'H') cout<<a<<endl;
    else if(a=='D' && b == 'D') cout<<'H'<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

int main() {
  ll N, M;
  cin >> N >> M;
  if(N == 1 && M == 1) {
    cout << 1 << endl;
  } else if(N == 1 || M == 1) {
    ll smaller = min(N, M);
    ll bigger = max(N, M);
    cout << bigger - 2 << endl;
  } else {
    ll ans = (N - 2) * (M - 2);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <iomanip>
#define F first
#define S second
#define PB push_back
#define PF push_front
#define MP make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int maxn = 1e6 + 5;
const int mod = 998244353;

int main() {
    ios_base::sync_with_stdio(false);
    int n, last = -1, cnt = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        if (a == last) {
            cnt ++;
            last = -1;
        }
        else
            last = a;
    }
    cout << cnt << endl;
}

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

int main(){
    int N;
    cin >> N;
    int s[N];
    int sum=0;
    for(int i=0;i<N;i++){
        cin >> s[i];
    }
    bool dp[11000]={};
    dp[0]=true;
    for(int i=0;i<N;i++){
        for(int j=10000;j>=0;j--){
            if(j-s[i]>=0){
                dp[j]|=dp[j-s[i]];
                //cout << dp[j] << endl;
            }
        }
    }
    for(int i=10000;i>=0;i--){
        //cout << dp[i] << endl;
        if(dp[i]&&i%10!=0){
            cout << i << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}

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

int main()
{
    int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int k; cin >> k;

    cout << arr[k-1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 3001
using namespace std;
int n;
double arr[N],dp[N][N];
double solve(int ind,int prev){
	if(ind == n){
		if(prev>(n/2)){
			return 1;
		}
		return 0;
	}
	if(dp[ind][prev]==-1){
		dp[ind][prev]=(solve(ind+1,prev+1)*arr[ind])+(solve(ind+1,prev)*((double)1.0-arr[ind]));
	}
	return dp[ind][prev];
}
int main(){
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			dp[i][j]=-1;
		}
	}
	printf("%.16lf\n",solve(0,0));
	return 0;
}

Measured memory_bytes: 70784
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#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 N, Q, ans = 0;
  cin >> N;
  vector<int> S(N);
  rep(i, N) cin >> S[i];
  cin >> Q;
  vector<int> T(Q);
  sort(S.begin(), S.end());
  rep(i, Q) cin >> T[i];

  rep(i, Q) {
    if (binary_search(S.begin(), S.end(), T[i]))
      ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3360
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int dp[1 << 15][15];
int n;
int m[15][15];

int rec(int s,int v){
  if(dp[s][v]>=0){
    return dp[s][v];
  }

  if(s ==((1 << n)-1) && v==0){
    //printf("v=0\n");

    return dp[s][v]=0;
  }

  int res = 1000*15+1;

  for(int u=0;u<n;u++){
    if((!(s >> u & 1)) && m[v][u]>=0){
      //printf("m:%d",m[v][u]);
      res = min(res,rec(s | (1 << u),u)+m[v][u]);
    } 
  }
  //printf("res=%d\n",res);
  return dp[s][v]=res;
}

int main(){
  int v,e;
  cin >> v >> e;
  n=v;
  
    memset(m,-1,sizeof(m));


  int s,t,d;
  for(int i=0;i<e;i++){
    cin >> s >> t >> d;
    m[s][t]=d;
  }
  
  memset(dp,-1,sizeof(dp));
  int ans=rec(0,0);
  if(ans==15001){
    printf("%d\n",-1);
  }
  else{
    printf("%d\n",ans);
  }
  
}

    

Measured memory_bytes: 3072
using System;
using System.Collections.Generic;
using System.IO;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int x = sc.NextInt();
        int y = sc.NextInt();
        int z = sc.NextInt();
        int k = sc.NextInt();
        long[] a = sc.LongArray();
        long[] b = sc.LongArray();
        long[] c = sc.LongArray();

        var lsAB = new List<long>();
        for (int i = 0; i < x; i++)
        {
            for (int j = 0; j < y; j++)
            {
                lsAB.Add(a[i] + b[j]);
            }
        }

        lsAB.Sort((l, r) => r.CompareTo(l));

        var lsABC = new List<long>();
        for (int i = 0; i < lsAB.Count && i < k; i++)
        {
            for (int j = 0; j < z; j++)
            {
                lsABC.Add(lsAB[i] + c[j]);
            }
        }

        lsABC.Sort((l, r) => r.CompareTo(l));

        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false});

        for (int i = 0; i < k; i++)
        {
            Console.WriteLine(lsABC[i]);
        }

        Console.Out.Flush();
    }

    public static void Main(string[] args) => new Program().Solve();
}


namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 97820
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		double length = 0;
		
		for (int i = 0; i < n; i++) {
			x[i] = scan.nextInt();
			y[i] = scan.nextInt();
		}
		
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				length += Math.sqrt(Math.pow(x[i] - x[j], 2) + Math.pow(y[i] - y[j], 2));
			}
		}
		
		System.out.println(length / n);
		scan.close();
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
int n;
cin>>n;
long long sum=0,ret=0;
map<long long,int> mp;
mp[0]++;
for(int i=1;i<=n;i++)
 {int a;
  cin>>a;
  sum+=a;
  ret+=mp[sum];
  mp[sum]++;
 }
cout<<ret;
system("pause");
return 0;
}

Measured memory_bytes: 12928
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

int main(){
	int c[3]={0,0,0};
	string s;cin>>s;
	for(auto x:s)c[x-'a']++;
	if((*max_element(c,c+3))-(*min_element(c,c+3))<=1)
		puts("YES");
	else
		puts("NO");

	return 0;
}


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

#define fto(i, a, b) for (int i = a; i <= b; ++i)
#define fdto(i, a, b) for (int i = a; i >= b; --i)
#define ff first
#define ss second
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define ll long long
#define oo 1000000007

using namespace std;

int main() {
//    #ifndef ONLINE_JUDGE
//        freopen("codef.inp", "r", stdin);
//        freopen("codef.out", "w", stdout);
//    #endif // ONLINE_JUDGE
    ll n; cin >> n;
    fto(x, 1, 3500) {
        bool found = 0;
        fto(y, x, 3500) {
            ll m = 4*x*y-n*y-n*x;
            if (m <= 0) continue;
            if ((n*x*y)%m == 0) {
                found = 1;
                cout << x << " " << y << " " << (n*x*y/m) << endl;
                break;
            }
        }
        if (found) break;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    long long s = 0;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    for (int i = 0; i < n-1; i++) {
        s += a[(i+1)/2];
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 4028
import itertools
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
r = [x - 1 for x in r]
d = [[float("inf")] * N for i in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c


def warshall_floyd(d):
    # d[i][j]: iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

warshall_floyd(d)
# print(d)
ans = float('inf')
for x in itertools.permutations(r):
    cost = 0
    # print(x)
    for i in range(len(x) - 1):
        # print(i)
        cost += d[x[i]][x[i+1]]
    ans = min(ans, cost)
print(ans)

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

if min(H, W) == 1:
    print(1)
    exit()

if H % 2 != 0 and W % 2 == 0:
    H, W = W, H

if H % 2 == 0:
    ans = W * (H // 2)
    print(ans)
else:
    ans = W * (H // 2) + (-(-W // 2))
    print(ans)


Measured memory_bytes: 2940
S=int(input())
x_1=0
y_1=0
x_2=10**9
y_2=1

if S%10**9==0:
    x_3=0
    y_3=S//10**9
else:
    x_3=10**9-S%10**9
    y_3=1+S//10**9

print(x_1,y_1,x_2,y_2,x_3,y_3)

Measured memory_bytes: 3060
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

vector<int> st;
string str;

void build(int node, int beg, int end){
	if(beg == end){
		st[node] = 1<<(str[beg]-'a');
		return;
	}
	int mid = beg + (end-beg)/2;
	build(2*node+1,beg,mid);
	build(2*node+2,mid+1,end);
	st[node]=st[2*node+1]|st[2*node+2];
}

void update(int node, int beg, int end, int pos, int x){
	if(beg==end){
        //debug2(x,pos);
		st[node] = 1<<x;
		return;
	}
	int mid = beg+(end-beg)/2;
	if(pos<=mid){
		update(2*node+1,beg,mid,pos,x);
	} else {
		update(2*node+2,mid+1,end,pos,x);
	}
	st[node] = st[2*node+1]|st[2*node+2];
}

int query(int node, int beg, int end, int ql, int qr){
	if(beg>qr || end<ql)
		return 0;
	else if(beg>=ql && end<=qr)
		return st[node];
	int mid = beg+(end-beg)/2;
	int a = query(2*node+1,beg,mid,ql,qr);
	int b = query(2*node+2,mid+1,end,ql,qr);
	return a|b;
}

int count_zeroes(int n){
	int ans = 0;
	for(int i=0;i<26;i++){
		ans=(n&1)?ans+1:ans;
		n>>=1;
	}
	return ans;
}

int main()
{
	fast;
	int n,q,x,y,z;
	char ch;
	cin>>n;
	cin>>str;
	cin.ignore();
	cin>>q;
	st.resize(4*n);
	build(0,0,n-1);
    //for(int i=0;i<14;i++)
    //    cout<<st[i]<<"\n";
    //debug1("Hello")
	while(q--){
		cin>>x>>y;
		--y;
		if(x==1){
			cin>>ch;
			z=ch-'a';
            //debug1(z)
			update(0,0,n-1,y,z);
		} else {
			cin>>z;
			--z;
			cout<<count_zeroes(query(0,0,n-1,y,z))<<"\n";
		}
	}
	return 0;
}

Measured memory_bytes: 8732
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

template<typename T> struct edge{
    int from, to; T cost;
    edge(int f, int t, T c): from(f), to(t), cost(c){}
};
 
template<typename T> struct Graph{
    vector<vector<edge<T>>> G;
    int n;
 
    Graph(int n_): n(n_){
        G.resize(n);
    }
 
    void add_edge(int f, int t, T c){
        G[f].emplace_back(f, t, c);
    }
};

template<typename T> 
pair<bool, vector<int>> topological_sort(Graph<T> &gr){
    vector<int> ret(gr.n, -1), in(gr.n, 0);
    rep(i, gr.n)for(edge<T> &e: gr.G[i]) ++in[e.to];
    int cur = 0;
    stack<int> st;
    rep(i, gr.n)if(!in[i]) st.push(i);
    if(st.empty()) return make_pair(false, ret);
    while(!st.empty()){
        int v = st.top(); st.pop();
        ret[cur++] = v;
        for(edge<T> &e: gr.G[v]){
            if(!in[e.to]) return make_pair(false, ret);
            --in[e.to];
            if(!in[e.to]) st.push(e.to);
        }
    }
    return make_pair(cur == gr.n, ret);
}

template<typename T>
bool has_cycle(Graph<T> &gr){
    return !topological_sort(gr).fi;
}

int n;

void solve(){
    string s[n];
    rep(i, n) cin >> s[i];
    Graph<int> gr(26);
    bool adj[26][26];
    rep(i, 26)rep(j, 26) adj[i][j] = false;
    rep(i, n)For(j, i+1, n){
        if(s[i] == s[j]) continue;
        if(s[i].substr(0, s[j].size()) == s[j]){
            puts("no");
            return;
        }
        rep(k, 20)if(s[i][k] != s[j][k]){
            int x = s[i][k] - 'a', y = s[j][k] - 'a';
            if(!adj[x][y]){
                gr.add_edge(x, y, 1);
                adj[x][y] = true;
            }
            break;
        }
    }
    puts(!has_cycle(gr) ? "yes" : "no");
}

int main(){
    while(scanf("%d", &n) && n){
        solve();
    }
}


Measured memory_bytes: 3308
def comb(N) :
    return N*(N+1)//2

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
        self.size = [1] * N
        self.connection = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        self.connection -= (comb(self.size[ra]) + comb(self.size[rb]))
        self.connection += comb(self.size[ra] + self.size[rb])
        if self.rank[ra] < self.rank[rb]:
            self.size[rb] += self.size[ra]
            self.parent[ra] = rb
        else:
            self.size[ra] += self.size[rb]
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1

N,M = map(int,input().split())
L = [list(map(int,input().split())) for i in range(M)]

UF = UnionFind(N)

ans = [N*(N-1)//2]

for i in range(M-1,-1,-1) :
    a,b = L[i]
    a -= 1
    b -= 1
    UF.unite(a,b)
    ans.append(ans[0] - UF.connection)

print(*ans[::-1][1:], sep="\n")


Measured memory_bytes: 37976
from sys import stdin


def main():
    a, b = [int(x) for x in stdin.readline().rstrip().split()]
    count = 0
    for i in range(1, 13):
        if i < a:
            count += 1
        elif i == a:
            if i <= b:
                count += 1
        else:
            break
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
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;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;

void solve()
{
  ll x;
  cin >> x;
  ll y = 100;
  ll cnt = 0;
  while (1)
  {
    y *= 1.01;
    ++cnt;
    if(y>=x){
      break;
    }
  }
  cout << cnt;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}



Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
#define N 1010
using namespace std;
int h, w, dp[N][N];
string A[N];
int fun(int a, int b){
	if(a >= h || b >= w)
		return 0;
	if(a == h - 1 && b == w - 1){
		return 1;
	}
	if(A[a][b] == '#')
		return 0;
	if(dp[a][b] != -1)
		return dp[a][b];
	return dp[a][b] = (fun(a + 1, b) + fun(a, b + 1)) % MOD;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> h >> w;
	for(int i = 0; i < h; i++)
		cin >> A[i];
	memset(dp, -1, sizeof(dp));
	cout << fun(0, 0) << '\n';

}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int K; cin >> K;
  string S; cin >> S;
  int n = S.size();
  if(n <= K){
    cout << S << endl;
  }else{
    REP(i, K){
      cout << S[i];
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3612
#!/usr/bin/env python3

from collections import defaultdict

def main():
    n = int(input())
    cnt = defaultdict(int)
    for i in range(1, n + 1):
        si = str(i)
        x = int(si[0])
        y = int(si[-1])
        cnt[(x, y)] += 1
    res = 0
    for x in range(1, 10):
        for y in range(1, 10):
            num_a = cnt[(x, y)]
            num_b = cnt[(y, x)]
            res += num_a * num_b
    print(res)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
class UnionFind {
private:
    int sz;
    vector<int> par, size_;
public:
    UnionFind(){}
    UnionFind(int node_size) : sz(node_size), par(sz), size_(sz, 1){
        iota(par.begin(), par.end(), 0);
    }
    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x,int y){
        x = find(x), y = find(y);
        if(x == y) return;
        if(size_[x] < size_[y]) swap(x,y);
        par[y] = x;
        size_[x] += size_[y];
    }
    int size(int x){
        x = find(x);
        return size_[x];
    }
    bool same(int x,int y){
        return find(x) == find(y);
    }
};
int main(){
    int n;
    cin >> n;
    vector<set<int> > st(1000005);
    vector<pair<int,int> > p(n);
    rep(i,n){
        int x,y;
        cin >> x >> y;
        st[y].insert(x);
        p[i] = MP(x,y);
    }
    sort(p.begin(),p.end());
    UnionFind uf(1000005);
    int pre = -1;
    rep(i,n){
        int x = p[i].first;
        int y = p[i].second;
        if(x==pre){
            int yy = p[i-1].second;
            if(!uf.same(y,yy)){
                int py = uf.find(y);
                int pyy = uf.find(yy);
                uf.unite(py,pyy);
                int aa = uf.find(py);
                if(aa!=py){
                    for(auto x:st[py]){
                        st[aa].insert(x);
                    }
                }else{
                    for(auto x:st[pyy]){
                        st[aa].insert(x);
                    }
                }
            }
        }
        pre = x;
    }
    vector<bool> flag(1000001);
    ll sm = 0;
    rep(i,1000001){
        if(flag[uf.find(i)])continue;

        flag[uf.find(i)] = true;
        sm += (ll)(st[uf.find(i)].size())*(ll)uf.size(i);
    }
    cout << sm-n << endl;
    return 0;
}

Measured memory_bytes: 49792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  string S,ans;
  cin >> S;

  ans = "Yes";
  int n = S.size();

  rep(i,n) {
    if (i%2 == 0 && S[i] == 'L') ans = "No";
    if (i%2 == 1 && S[i] == 'R') ans = "No";
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

int main(void){
    int n, r;
    cin >> n >> r;
    if(n >= 10) cout << r;
    else cout << r + 100*(10 - n);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, K;
  cin >> N >> K;
  long long p[N];
  for (int i = 0; i < N; i++) cin >> p[i];
  long long sum = 0;
  for (int i = 0; i < K; i++) sum += p[i];
  long long ans = sum;
  for (int j = K; j < N; j++) {
    sum -= p[j - K];
    sum += p[j];
    ans = max(ans, sum);
  }
  printf("%lf\n", (ans + K) * 0.5);
  return 0;
}


Measured memory_bytes: 5344
#include<bits/stdc++.h>
using namespace std;
int a[32] ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
	int k;
	scanf("%d",&k);
	printf("%d",a[k-1]);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, b1 = 0;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a.at(i);
    if (i % 2 == 0) {
      b1 += a.at(i);
    } else {
      b1 -= a.at(i);
    }
  }
  cout << b1;
  for (int i = 1; i < n; ++i) {
    int b = 2 * a.at(i-1) - b1;
    cout << " " << b;
    b1 = b;
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 1e6+1;
int n, q, from[N],pa[N], to[N], ID, id[N];
vector<int>g[N];
ll cm[N], an[N];
bool vis[N];

void dfs(int u, int v){
     ++ID;
     from[u] = ID;
     id[u] = ID;
     vis[u] = true;
     pa[u] = v;
     for(auto i: g[u]){
        if(!vis[i])dfs(i,u);
     }
     to[u]= ID;
}

void ad(int u, int p ,int x){
       cm[u] += x;
       for(auto j: g[u]){
         if(j != p)ad(j,u,x);
       }
}

int main(){
    scanf("%d%d",&n,&q);
    for(int i = 0; i<n-1; ++i){
         int u, v;
         scanf("%d%d",&u,&v);
         g[u].push_back(v);
         g[v].push_back(u);
    }
    dfs(1,0);
    for(int i=0;i<q; ++i){
         int p,x; 
         scanf("%d%d",&p,&x);
         int l = from[p],r = to[p];
         cm[l] = (ll)(cm[l] + x);
         cm[r+1] = (ll)(cm[r+1] - x);
    }    
    for(int i=1; i<=n;++i){
        cm[i] = (ll)cm[i-1] + cm[i];
    }
    for(int i=1;i<=n;++i)cout << cm[id[i]]<<" ";
}


Measured memory_bytes: 52992