akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

typedef struct atai{ll nxt,n,c;}atai;
atai x[200010];

//*
//プラキュー（二分ヒープ）（最低限バージョン）
//int PQhikaku(int i,int j);//jの方が優先度が高いならtrueを返す
int PQhikaku(ll*heap,int i,int j){return x[heap[i]].nxt>x[heap[j]].nxt;}
void heap_utod(ll*heap,int n){
	if(2*n>heap[0])return;
	int rflag=(2*n+1<=heap[0])&&(PQhikaku(heap,2*n,2*n+1));
	if(PQhikaku(heap,n,2*n+rflag)){
		ll temp=heap[2*n+rflag];
		heap[2*n+rflag]=heap[n];
		heap[n]=temp;
		heap_utod(heap,2*n+rflag);
	}
}
void heap_dtou(ll*heap,int n){
	if(n==1||PQhikaku(heap,n,n/2))return;
	ll temp=heap[n];
	heap[n]=heap[n/2];
	heap[n/2]=temp;
	heap_dtou(heap,n/2);
}
ll PQpop(ll*heap){
	ll rr=heap[1];
	heap[1]=heap[heap[0]--];
	heap_utod(heap,1);
	return rr;
}
void PQpush(ll*heap,ll n){
	heap[++heap[0]]=n;
	heap_dtou(heap,heap[0]);
}
//*/

ll a[200010];
ll b[200010];
ll h[200010];
int main(){
	ll n,m;
	scanf("%lld%lld",&n,&m);
	rep(i,0,n){
		int t;
		scanf("%d",&t);
		a[t]++;
	}
	rep(i,0,m){
		int t;
		scanf("%d",&t);
		b[t]++;
	}
	int cnt=0;
	rep(i,0,200005)if(b[i]){
		x[cnt].nxt=i;
		x[cnt].n=i;
		x[cnt].c=b[i];
		PQpush(h,cnt);
		cnt++;
	}
	
	ll ans=0,temp=0,pre=0;
	rep(i,0,200005)if(a[i]){
		temp+=(i-pre)*m;
		pre=i;
		while(x[h[1]].nxt<=i){
			int k=PQpop(h);
			ll nnxt=(i+x[k].n)/x[k].n*x[k].n;
			temp-=(nnxt-x[k].nxt)*x[k].c;
			x[k].nxt=nnxt;
			PQpush(h,k);
		}
		ans+=temp*a[i];
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 10976
package main

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

const N = 100

func min(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	p := make([]int, N+1)
	m := make([][]int, N+1)
	for i := range m {
		m[i] = make([]int, N+1)
	}
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 1; i <= n; i++ {
		scanner.Scan()
		p[i-1], _ = strconv.Atoi(scanner.Text())
		scanner.Scan()
		p[i], _ = strconv.Atoi(scanner.Text())
	}
	for i := 1; i <= n; i++ {
		m[i][i] = 0
	}
	for l := 2; l <= n; l++ {
		for i := 1; i <= n-l+1; i++ {
			j := i+l-1
			m[i][j] = 1 << 21
			for k := i; k <= j-1; k++ {
				m[i][j] = min(m[i][j], m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j])
			}
		}
	}
	fmt.Println(m[1][n])
}


Measured memory_bytes: 1228
#include <bits/stdc++.h>
#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 _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
using Graph = vector<vector<int>>;

int main() {
  ll n, p; cin >> n >> p;
  string s; cin >> s;

  //p = 2, 5 の場合
  if(p == 2 || p == 5){
    ll ans = 0;
    rep(i, 0, n){
      if((s[i] - '0') % p == 0 ) ans += i+1;
    }
    cout << ans << endl;
    return 0;
  }

  //p != 2, 5 の場合
  vector<int> d(n+1);
  d[n] = 0;
  ll cnt = 1;
  for(int i = n-1; i >= 0; i--){
    ll a = (s[i]-'0')*cnt % p;
    d[i] = (d[i+1] + a) % p;
    cnt *= 10;
    cnt %= p;
  }

  //組み合わせの数を計算
  vector<int> sum(p, 0);
  ll ans = 0;
  Rep(i, 0, n){
    ans += sum[d[i]];
    sum[d[i]]++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1412
#include<bits/stdc++.h>
	using namespace std;
	#define xxx ios::sync_with_stdio(),cin.tie(0),cout.tie(0)
	#define rep(i,n) for(int i=0;i<n;i++)
	#define repeq(i,j,n) for(int i=j;i<n;i++)
	#define int long long
	int bp(int a, int b, int m) {
   		a %= m;
   		int res = 1;
    	while (b > 0) {
        	if (b & 1)
            	res = res * a % m;
       		a = a * a % m;
       	 	b >>= 1;
 	    }
    return res;
	}
	int max(int a, int b){
		return (a>b)?a:b;	
	}
	int csb( int n) 
{ 
    int count = 0; 
    while (n) { 
        count += n & 1; 
        n >>= 1; 
    } 
    return count; 
} 
	int solve(int x){
		int r=0;
		while(x>0){
			int t=csb(x);
			x%=t;
			r++;
		}
		return r;
	}
	string mkstr(int n,char c){
		string s;
		s+=c;
		if(n==1 || n==0) return s;
		string s1,s2;
		s1=mkstr(n/2,c);
		s2=mkstr(n/2,c);
		return s1+s2;
	}
	int fun(string s,int n,char c){
		if(n==1){
			if(s[0]==c) return 0;
			else return 1;
		}
		else if(n==0) return 0;
		string s1=s.substr(0,n/2);
		string s2=s.substr(n/2,n);
		int ans1=0,ans2=0;
		for(int i=0;i<n/2;i++){
			if(s1[i]!=c) ans1++;
			if(s2[i]!=c) ans2++;
		}
		ans1+=fun(s2,n/2,c+1);
		ans2+=fun(s1,n/2,c+1);
		return min(ans1,ans2);

	}
	// void dfs(int v,vector<int> visited,vector<vector<int>> adjd,vector<vector<int>> adjud) {
    	
 //    	visited[v] = 1;
 //    	for (int u : adjd[v]){
 //        	if (color[u] == 0){
 //        	    dfs(u);
 //        	}
 //    	}
    	

 //   	 	visited[v] = 2;
    	
	// }
	signed main(){
		int test=1;
		//cin>>test;
		while(test--){
			int n,k,q;
			cin>>n>>k>>q;
			int a[n]={0};
			rep(i,n) a[i]=k-q;
			for(int i=0;i<q;i++){
				int x;
				cin>>x;
				
				a[x-1]++;
			}
			for(int i=0;i<n;i++){
				if(a[i]>0) cout<<"Yes"<<endl;
				else cout<<"No"<<endl;
			}
		}
		return 0;
	}

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

typedef long long ll;
const ll INF = 1LL << 60;

ll N;
vector<ll> A;
int main() {
    cin >> N;
    A.resize(N);
    rep(i, N) cin >> A[i];

    string ans = "APPROVED";
    rep(i, N) {
        if (A[i] % 2 == 1) continue;

        if (A[i] % 3 == 0 || A[i] % 5 == 0) {

        } else {
            ans = "DENIED";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n=gets.to_i
a=gets.split.map(&:to_i).sort
b=gets.split.map(&:to_i).sort
c=gets.split.map(&:to_i).sort

lower_bound=->d,v{
	res=0
	k=2**30
	while k>0
		res+=k if d[res+k] && d[res+k]<v
		k/=2
	end
	d[res]<v ? [d[res], res] : nil
}

upper_bound=->d,v{
	k=2**30
	res=k*2-1
	while k>0
		res-=k if res-k>=d.size || d[res-k]>v
		k/=2
	end
	res>=d.size || d[res]<=v ? nil : [d[res], res]
}


res=0
b.each{|x|
	y, i=lower_bound[a, x]
	z, j=upper_bound[c, x] if y
	res+=(i+1)*(n-j) if z
}
p res


Measured memory_bytes: 30696
#include<stdio.h>
#include<math.h>

int main(void){
 	int num=0;
  	int ans=0;
  	int co500=0;
  	int	co5=0;
  	scanf("%d",&num);
  	ans=num;
	co500=ans/500;
  	ans=ans%500;
	co5=ans/5;
  	int re=co5*5+co500*1000;
  printf("%d",re);
  
  
  
}


Measured memory_bytes: 128
def solve():
  w, h = map(int, input().split())
  base = list(map(int, input().split()))
  if abs(2 * base.count(0) - w) >= 2:
    return False
  
  same = 1
  for _ in range(h - 1):
    line = list(map(int, input().split()))
    flag = (base[0] == line[0])
    same += flag
    if flag and line != base:
      return False
    if not flag and any([i == j for i, j in zip(line, base)]):
      return False
  
  return abs(2 * same - h) <= 1

print("yes" if solve() else "no")


Measured memory_bytes: 5664
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/
#include <assert.h> /*確認*/
#include <ctype.h>  /*文字操作*/
#include <stdbool.h>/*bool型*/
#include <limits.h>/*限界*/

#define rep(i, n) for(int  i = 0; i < (n); i++)
#define max(a,b) ((a>b)?a:b)
#define ABS(a) (((a)>(0))?a:-(a))
#define LL long long
#define MOD 1000000007//10^9+7(素数)

int main(void)
{
  int N;
  int s[100] = {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};
  scanf("%d", &N);
  printf("%d\n", s[N-1]);
}


Measured memory_bytes: 128
using System;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            long ans = 0;
            for (int i = 0; i < n; i++)
            {
                var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
                ans += inp[1] - inp[0] + 1;
            }
            Console.WriteLine(ans);
        }
    }
}

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

using namespace std;

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

#ifdef ONLINE_JUDGE
#define DEBUG false
#else
#define DEBUG true
#endif

#define pb emplace_back
#define lb lower_bound
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second

#define ALL(c) (c).begin(),(c).end()

#define DBG0(x)    {if(DEBUG){ cout << #x << ": " << x << "\t"; }}
#define DBG(x)     {if(DEBUG){DBG0(x); cout << endl;}}
#define DBG2(x, y) {if(DEBUG){DBG0(x); DBG(y);}}
#define DBG3(x, y, z) {if(DEBUG){DBG0(x); DBG2(y, z);}}
#define DBG4(w, x, y, z) {if(DEBUG){DBG0(w); DBG3(x, y, z);}}

const double EPS = 1.0e-11;
template <class T>
ostream& operator<<(ostream& os, vector<T> xs){ for(T x: xs) os << x << ' '; return os; }
template <class S, class T>
ostream& operator<<(ostream& os, pair<S,T> st){ os << "(" << st.first << "," << st.second <<")"; return os; }

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;

typedef complex<long long> Point;
istream& operator>>(istream& is, Point &pt){
    double a, b;
    is >> a >> b;
    pt.real(a * 1000000); pt.imag(b* 1000000);
    return is;
}

ostream& operator<<(ostream& os, const Point &pt){
    os << make_pair(pt.real(), pt.imag());
    return os;
}

inline long long cross(const Point &a, const Point &b){
    return (a.real()*b.imag() - a.imag()*b.real());
}

int main(void){

    int n;
    cin >> n;
    while(n-->0){
        Point a,b,c,d;
        cin >> a >> b >> c >> d;
//      DBG4(a, b, c, d);
//      DBG(cross(b - a, d - c));
        if(cross(b - a, d - c) == 0)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}

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

int main(void) {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int b;
		cin >> b;
		ans += b;
	}
	
	for (int i = 1; i < n; i++) {
		int c;
		cin >> c;
		for (int j = 0; j < n; j++) {
			if (a[j] == i && a[j+1] == i + 1) ans += c;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    int n;
    cin>>n;
    vi l(n);
    int ans=0;
    rep(i,n)cin>>l[i];
    sort(all(l),greater<int>());

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(abs(l[i]-l[j])<l[k]){
                    if(l[k]<l[i]+l[j])ans++;
                }
                else break;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int n, k;
	string s;
	cin >> n >> k >> s;
	if (s[k - 1] == 'A') {
		s[k - 1] = 'a';
	}
	else if (s[k - 1] == 'B') {
		s[k - 1] = 'b';
	}
	else if (s[k - 1] == 'C') {
		s[k - 1] = 'c';
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
n,x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
s = [0]*(n+1)
n.times{|i| s[i+1] = s[i]+a[i]}

min = 10**18

1.upto(n){|i|
  tot = x*n + x*i
  left = n
  step = 1
  while left > 0
    if step==1
      tot += 5*(s[left]-s[[left-i,0].max])
    else
      tot += (2*step+1)*(s[left]-s[[left-i,0].max])
    end
    left -= i
    step += 1
  end
  min = tot if min > tot
}

p min

Measured memory_bytes: 23564
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		return F?n:-n;
	}
}
int a[222222];
int main()
{
	int n=io::F();
	for(register int i=1;i<=n;++i)a[i]=io::F();
	if(a[1]!=0)puts("-1"),exit(0);
	long long ans=0;
	for(register int i=1;i<=n;++i)
	{
		if(i==n||a[i]>=a[i+1])ans+=a[i];
		if(i!=n&&a[i+1]-a[i]>1)puts("-1"),exit(0);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
# https://atcoder.jp/contests/abc082/tasks/abc082_a

import itertools
import collections
import bisect
import math
import sys
input = sys.stdin.readline

def main():
    a, b = map(int, input().split())
    print(math.ceil((a + b) / 2))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main() {
  int x, a, b, ans;
  cin >> x >> a >> b;
  ans = abs(x - a);
  if (ans > abs(x - b)) {
    cout << "B";
  } else {
    cout << "A";
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a,b,c,t,n;
	while(1){
		scanf("%d",&n);
		if(n==0){
			return 0;
		}
		for(t=0;t<n;t++){
			scanf("%d %d %d",&a,&b,&c);
			if( (a==100) || (b==100) || (c==100) ||
			(a+b>=180) || (a+b+c>=240) ){
				printf("A\n");
			}
			else if( (a+b+c>=210) ||
			( (a+b+c>=150)&&( (a>=80)||(b>=80) ) ) ){
				printf("B\n");
			}
			else{
				printf("C\n");
			}
		}
	}
}
			
			

Measured memory_bytes: 584
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int N;
vector<int> A;

int calc(int b) {
	int ret = 0;
	rep(i, N) {
		ret += abs(A[i] - (b + i + 1));
	}
	return ret;
}

signed main() {
	cin >> N;

	inputVector(A, N);

	int low = -1000000000;
	int high = 1000000000;
	int mid1 = low + (high - low) / 3;
	int mid2 = low + 2 * (high - low) / 3;
	while (mid2 - mid1 > 3) {
		int val1 = calc(mid1);
		int val2 = calc(mid2);

		if (val1 > val2) {
			low = mid1;
		} else {
			high = mid2;
		}

		mid1 = low + (high - low) / 3;
		mid2 = low + 2 * (high - low) / 3;
	}

	int ret = LLONG_MAX;
	REP(b, mid1 - 5, mid1 + 5) {
		ret = min(ret, calc(b));
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 1792
# coding: utf-8

import math

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

lower = math.ceil(a / 0.08)
upper = math.ceil(a / 0.08 + 12.5) - 1

if upper >= b * 10 and lower <= b * 10 + 9:
    print(max(b * 10, lower))
else:
    print(-1)

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

int main()
{
  string s;
  cin >> s;
  int count = 0;
  for (int i = 0; i < 3; i++)
  {
    if (s.at(i) == '1')
    {
      count++;
    }
  }
  cout << count << endl;
}


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

#define MOD 1000000007

using lint = long long int;
using pii = std::pair<int, int>;

using std::vector;
int check[100100];

lint my_pow(lint a, lint b, lint mod) { //a^b % mod
	lint ret = 1;
	a %= mod;
	while (b != 0) {
		if (b % 2 == 0) {
			a = (a * a) % mod;
			b /= 2;
		}
		else {
			ret = (ret * a) % mod;
			b--;
		}
	}
	return ret;
}

lint get_mod_inverse(lint div, lint mod) {
	return my_pow(div, mod - 2, mod);
}

int main(void) {
	int N;
	scanf("%d", &N);
	int left, right;
	for (int i = 1; i <= N + 1; i++) {
		int temp;
		scanf("%d", &temp);
		if (check[temp] == 0) {
			check[temp] = i;
		}
		else {
			left = check[temp];
			right = i;
		}
	}

	left -= 1;
	right = N + 1 - right;

	int hap = left + right;

	lint cur = N + 1, sub_cur = 1;
	printf("%d\n", N);
	for (int i = 2; i <= hap + 1; i++) {
		cur = cur * (N + 2 - i) % MOD;
		cur *= get_mod_inverse(i, MOD);
		cur %= MOD;

		sub_cur = sub_cur * (hap + 2 - i) % MOD;
		sub_cur *= get_mod_inverse(i - 1, MOD);
		sub_cur %= MOD;

		printf("%lld\n", (cur - sub_cur + MOD) % MOD);
	}
	for (int i = hap + 2; i <= N + 1; i++) {
		cur = cur * (N + 2 - i) % MOD;
		cur *= get_mod_inverse(i, MOD);
		cur %= MOD;
		printf("%lld\n", cur);
	}

	return 0;
}

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

int main() {
  double a, b, x, ans;
  cin >> a >> b >> x;
  double pi = atan(1.0) * 4;
  if(x > a * a * b / 2)
    ans = atan2(2 * b - 2 * x / (a * a), a) * 180 / pi;
  else
    ans = atan2(b, 2 * x / (a * b)) * 180 / pi;
  printf("%.10f\n", ans);
}

Measured memory_bytes: 256
h, w, k = map(int, input().split())
C = []
for _ in range(h):
    C.append(input())
ans = 0
for hbit in range(1<<h): # red row bit
    for wbit in range(1<<w): # red col bit
        c = 0
        for i in range(h):
            for j in range(w):
                if hbit>>i & 1 and wbit>>j & 1 and C[i][j] == '#': c += 1
        if c == k: ans += 1
print(ans)


Measured memory_bytes: 9112
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")



def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

s = ri()
t = ri()

ans = 0
for i in range(len(s)):
    if s[i] != t[i]:
        ans+=1

print(ans)

Measured memory_bytes: 70184
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var X = Sarray()[0];
            var i = 1;
            var ans = 0;
            while((i*X)%360!=0)
            {
                i++;
            }
            WriteLine(i);
        }
    }
}

Measured memory_bytes: 18836
#include<stdio.h>
#include<stdlib.h>
#define inf 100100100
int min(int a,int b){return a < b ?a:b;}
int main(){
    int n;
    scanf("%d",&n);
    int h[n];
    for(int i = 0; i < n; i++)
        scanf("%d",&h[i]);
    int dp[n];
    for(int i = 2; i < n; i++)
        dp[i] = inf;
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    for(int i = 2; i < n; i++)
        dp[i] = min(dp[i - 1] + abs(h[i -1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
    printf("%d\n",dp[n - 1]);
    return 0;
}

Measured memory_bytes: 1024
import scala.io.{StdIn => in}

object Main extends App {
  val out = new java.io.PrintWriter(System.out)
  val Array(a, b, k) = in.readLine.split(" ").map(_.toInt)

  val ans = ((a to b).take(k) ++: (a to b).takeRight(k)).distinct
  ans.foreach(out.println)
  out.flush
}

Measured memory_bytes: 27324
#include <bits/stdc++.h>
#define ll long long
#define N 100005
using namespace std;
ll a[N];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,s=0,i,x;
    cin>>n;
    for(i=1; i<=n+1; ++i)
        cin>>a[i];
    for(i=1; i<=n; ++i){
        cin>>x;
        if(x>=a[i])
            s+=a[i], x-=a[i];
        else s+=x, x=0;
        if(x>=a[i+1])
            s+=a[i+1], a[i+1]=0;
        else s+=x, a[i+1]-=x;
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 1024
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main()
{
    int a,b,k;cin>>a>>b>>k;

    int now=0;
    for(int i=min(a,b);;i--){
        if(a%i==0 && b%i==0){
            now++;
        }
        if(now == k){
            cout<<i<<endl;
            return;
        }

    }
    
	return;
}

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

Measured memory_bytes: 3656
//Moh_K_Imar .......
//24/08/2020  ... 5,40 .
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll a,b;
    cin>>a>>b;
    if(a==b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}



Measured memory_bytes: 3588
#include<stdio.h>
#include<algorithm>
#include<vector>

using namespace std;

vector<int > graph[1000];

int myf(int a)
{
	return a*(a-1)/2;
}

int main(void)
{
	int n; scanf("%d",&n);
	int l=0; int r=1000;
	int k; bool chk=false;
	while(l<=r)
	{
		int mid = (l+r)/2;
		if(myf(mid)==n)
		{
			k=mid; chk=true;
			break;
		}
		if(myf(mid)>n)	r=mid-1;
		if(myf(mid)<n)	l=mid+1;	
	}

	if(chk)
	{	
		int sz = k-1;
		printf("Yes\n%d\n",k);
		int pos=1;
		for(int i=0;i<k-1;i++)
		{
			for(int j=i+1;j<k;j++)
			{
				graph[i].push_back(pos);
				graph[j].push_back(pos);
				pos++;				
			}
		}
		for(int i=0;i<k;i++)
		{
			printf("%d",sz);
			for(int j=0;j<sz;j++)
				printf(" %d",graph[i][j]);
			printf("\n");
		}
	}
	else printf("No");
	return 0;
}

Measured memory_bytes: 2304
using System;

class Program {
    private static int Main() {
        var input = Console.ReadLine();
        var values = input.Split( ' ' );

        int x = int.Parse( values[ 0 ] );
        int y = int.Parse( values[ 1 ] );

        int area = x * y;
        int length = ( x + y ) * 2;

        var output = string.Format( "{0} {1}", area, length );
        Console.WriteLine( output );

        return 0;
    }
}

Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,k,a[100005];
int main(){
	cin>>n>>k;
	rep(i,n){
		cin>>a[i];
	}
	sort(a,a+n);
	int ans = INF;
	for(int i=k-1;i<n;i++){
		ans = min(ans,a[i]-a[i+1-k]);
	}
	cout<<ans<<endl;}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {

        Scanner scan=new Scanner(System.in);

        String s=scan.next();
        int cnt=0;
        for(int i=1;i<s.length();i++){
            if(s.charAt(i-1)!=s.charAt(i))
                cnt++;
        }
            System.out.println(cnt);


    }
}

Measured memory_bytes: 13360
using System;
using System.Collections.Generic;

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1004


public class Test
{
	public static void Main()
	{
		while(true){
		  string str1 = Console.ReadLine();
		  if(str1 == null) break;
		  
		  int n = int.Parse(str1); 

		  //Console.WriteLine("???????????? N = {0} P = {1} Ai = {2}", n, p, a);
		  Console.WriteLine(calc(n));
		
		
		}

	}

  public static int calc(int n) {
	  if(n==1) return 0;
	  if(n==2) return 0;
	  if(n==3) return 1;
	  
	  int s = 0;
	  if((n%2)==0) {
        if(IsPrime(n-1)) {
	  	  s = 2;
	    }
	  } else {
	    for(int i=3; i<=(n/2); i+=2){
          if(IsPrime(i) && IsPrime(n+1-i)) s++;
	    }
 
        if(IsPrime((n/2)+1)) {
	  	s = 2*s+1;
	    } else {
	  	s = 2*s;
	    }
	  }



	  return s;
  }
  
  public static bool IsPrime(int num)
  {
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // ??¶??°????????????????????????

    double sqrtNum = Math.Sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // ?´???°??§?????????
            return false;
        }
    }

    // ?´???°??§??????
    return true;
  }
  

}

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main() {
 
  int64_t H,W; cin >> H >> W;
  int64_t ans = 0;
  if(H == 1 || W == 1){
    ans = 1;
    cout << ans << endl;
  }else{
    ans = (W*H + 1)/2;
    cout << ans << endl;
  }

}

Measured memory_bytes: 384
def gcd(a, b):
  while b:
    a, b = b, a % b
  return a

A, B, K = map(int, input().split())
G = gcd(A, B)
count = 0
for i in range(G, 0, -1):
  if G % i == 0:
    count += 1
    if count == K:
      print(i)


Measured memory_bytes: 2940
import java.util.*;
public class Main {

	String rotated(String s, int i , int length)
	{
	String beg = s.substring(0, i);
	String end = s.substring( i , length);
	String last = end+ beg;
	return last;
	}
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		Main one = new Main();
		String a, b;
		a = scan.next();
		b= scan.next();
		int alength = a.length();
//		System.out.println(one.rotated(a, alength-1, alength));
		boolean found = false;
		for( int i=0; i<alength ;i++)
			{
				if(a.charAt(i)==b.charAt(0))
				{
					String compare = one.rotated(a, i, alength);
					if(compare.equals(b))
					{
						found = true;
						break;
					}
				}
			
			}
		if(found)
			System.out.println("Yes");
		else
			System.out.println("No");

	
		scan.close();
	}

}


Measured memory_bytes: 22868
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
		int[] b = new int[m];
		int[][] a = new int[n][m];
		for (int i = 0; i < m; i++) {
			b[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		int sum = 0;
		int count = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				sum += a[i][j] * b[j];
			}
			if (sum + c > 0) {
				count++;
			}
			sum = 0;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <queue>
#include <cstring>
#include <set>
#define MAX_N 1001
using namespace std;


bool mat[MAX_N][MAX_N];
int h,w;
char ch;
typedef pair<int,int> P;
P arr[MAX_N*MAX_N];
P arr_new[MAX_N*MAX_N];
int cnt;
int new_cnt;
int res;
bool inBound(int x, int y)
{
    if(x<0 || x>=h || y<0 || y>=w)return false;
    return true;
}
void solve()
{
    for(int i = 0;i<h;i++)
        for(int j = 0;j<w;j++)
            if(mat[i][j]){
                arr[cnt++] = P(i,j);
            }
    
    while(cnt>0){
        new_cnt = 0;
        for(int i = 0;i<cnt;i++){
            int x = arr[i].first;
            int y = arr[i].second;
            int xx,yy;
            xx = x-1;yy= y;
            if(inBound(xx,yy)&&!mat[xx][yy]){
                mat[xx][yy] =true;
                arr_new[new_cnt++] = P(xx,yy); 
            }
            
            xx = x+1;yy= y;
            if(inBound(xx,yy)&&!mat[xx][yy]){
                mat[xx][yy] =true;
                arr_new[new_cnt++] = P(xx,yy); 
            }
            xx = x;yy= y+1;
            if(inBound(xx,yy)&&!mat[xx][yy]){
                mat[xx][yy] =true;
                arr_new[new_cnt++] = P(xx,yy); 
            }
            xx = x;yy= y-1;
            if(inBound(xx,yy)&&!mat[xx][yy]){
                mat[xx][yy] =true;
                arr_new[new_cnt++] = P(xx,yy); 
            }
        }
        for(int i = 0;i<new_cnt;i++){
            arr[i] = arr_new[i];
        }
        cnt = new_cnt;
        if(cnt>0)
            res++;
    }
}

int main()
{
    cin>>h>>w;
    for(int i = 0;i<h;i++){
        for(int j = 0;j<w;j++){
            cin>>ch;
            if(ch =='#')mat[i][j]=true;
        }
    }
    /*
    for(int i = 0;i<h;i++){
        for(int j = 0;j<w;j++)
            cout<<mat[i][j];
        cout<<endl;
    }
    */
    solve();
    cout<<res<<endl;
}


Measured memory_bytes: 14720
# Union-Find木
# 木構造を用いて、グループ分けを行うデータ構造
# 同じ木に属している場合、同じグループであるということになる
# 同じ木に属しているかどうかは、根となるノードが同じであるかどうかで判定をする
# 同じグループに属しているかどうかを、根ノードの値を参照するだけなのでO(1)で求められる
class UnionFind
  def initialize(size)
    @rank = Array.new(size, 0)
    @parent = Array.new(size, &:itself)
    @size = Array.new(size, 1)
  end

  # node_xとnode_yを連結し、同じグループにする
  def unite(id_x, id_y)
    x_parent = get_parent(id_x)
    y_parent = get_parent(id_y)
    return if x_parent == y_parent

    if @rank[x_parent] > @rank[y_parent]
      @parent[y_parent] = x_parent
      @size[x_parent] += @size[y_parent]
    else
      @parent[x_parent] = y_parent
      @size[y_parent] += @size[x_parent]
      @rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
    end
  end

  # node_xの親ノードの番号を取得する
  def get_parent(id_x)
    @parent[id_x] == id_x ? id_x : (@parent[id_x] = get_parent(@parent[id_x]))
  end

  # node_x, node_yが連結しているか確かめる
  def same_parent?(id_x, id_y)
    get_parent(id_x) == get_parent(id_y)
  end

  def size(id_x)
    @size[get_parent(id_x)]
  end
end

def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

require 'set'

n, m, k = input_a
#a, b = m.times.map{gets.split.map(&:to_i)}.transpose
#c, d = k.times.map{gets.split.map(&:to_i)}.transpose
union = UnionFind.new(n)

alreadys = Array.new(n).map {Set.new}


m.times do
  a, b = input_a
  a = a - 1
  b = b - 1
  union.unite(a, b)
  alreadys[a].add(b)
  alreadys[b].add(a)
end

k.times do
  c, d = input_a
  c = c - 1
  d = d - 1
  next if !union.same_parent?(c, d)
  alreadys[c].add(d)
  alreadys[d].add(c)
end

n.times do |i|
  # 連結成分の大きさ(指定されたノードに繋がっているノードの数。not隣接で、nホップ以上を含む)
  # ※連結成分から自分自身を取り除いているので-1
  graph = union.size(i) - 1
  friends = graph - alreadys[i].size
  print "#{friends} "
end

Measured memory_bytes: 66172
//libraries begin
#include<bits/stdc++.h>
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<utility>
#include<set>
#include<iterator> 
#include <cctype>
//libaries end


//selfddefined macros begin
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define forn(i, n) for (ll i = 0; i < ll(n); i++)
#define for1(i, n) for (ll i = 1; i <= ll(n); i++)
#define s_s stable_sort 
#define ss sort
#define endl "\n"
typedef long long ll;

//selfdefined macros end


using namespace std;
const ll N=1e18;




int32_t main()
{      

    fio;
   ll a[5];
   forn(i,5) 
   {
   cin>>a[i];
   if(a[i]==0)
   {
   cout<<i+1;
   break;
   }
   }
   
    return 0;
} 

Measured memory_bytes: 3636
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")



#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include <ext/rope>
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define Find order_of_key
// #define at find_by_order
#define x first
#define y second
#define ll long long
#define lll __int128
#define ull unsigned long long
#define ulll unsigned __int128
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define gu getchar_unlocked()
#define pu putchar_unlocked()
#define all(x) x.begin(),x.end()
#define endl '\n'


const int mod=998244353;
ll Pow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}return res;
}
const ll base=Pow(9,mod-2);
int n;
struct segtree {
	static const int maxn = 200005;
	ll t[maxn << 2] = {0}, lazy[maxn << 2] = {0};
	void init() {
		memset(t, 0, sizeof t);
		memset(lazy, -1, sizeof lazy);
	}
	void build(int node = 1, int l = 1, int r = n) {
		if (l == r) {t[node] = 1; return; }
		int mid = l + r >> 1;
		build(node << 1, l, mid);
		build(node << 1 | 1, mid + 1, r);
		// t[node] = t[node << 1] + t[node << 1 | 1];
		t[node] = (t[node << 1]*Pow(10,r-mid)+t[node << 1 | 1])%mod;
	}
	void shift(int node, int l, int r) {
		int L=(r-l+1);
		if(lazy[node]!=-1){
			t[node] = (((lazy[node]*(Pow(10,L)-1))%mod)*base)%mod;
			if (l != r) {
				lazy[node << 1] = lazy[node];
				lazy[node << 1 | 1] = lazy[node];
			} lazy[node] = -1ll;
		}
	}
	void update( int i, int j, ll v, int node = 1, int l = 1, int r = n) {
		shift(node, l, r);
		if (l > j || r < i) return;
		if (i <= l && r <= j) {
			lazy[node] = v;
			shift(node, l, r);
			return;
		} int m = l + r >> 1, L = node << 1, R = node << 1 | 1;
		update( i, j, v, L, l, m);
		update( i, j, v, R, m + 1, r);
		// t[node] = t[L] + t[R];
		t[node] = (t[node << 1]*Pow(10,r-m)+t[node << 1 | 1])%mod;
	}
	ll query( int i, int j, int node = 1, int l = 1, int r = n) {
		shift(node, l, r);
		if (r < i || l > j) return 0;
		if (i <= l && r <= j) return t[node];
		int m = l + r >> 1, L = node << 1, R = node << 1 | 1;
		ll X=query( i, j, L, l, m);
		ll Y=query(i, j, R, m + 1, r);
		return  (X*Pow(10,r-m)+Y)%mod ;
	}
} t;


int main(){
	int q;
	cin>>n>>q;
	t.init();
	t.build();
	while(q--){
		int l,r,d;
		cin>>l>>r>>d;
		t.update(l,r,d);
		cout<<t.query(1,n)<<endl;
	}
}

Measured memory_bytes: 16128
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const double PI = acos(-1);



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	int ans = 0;

	int r = 0;
	while (1) {
		if (ans == 0) {
			r += k;
		}
		else {
			r += k - 1;
		}
		ans++;
		if (r >= n) {
			break;
		}
	}

	out(ans);

	return 0;
}

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

int main(void){
    char s[102], t[102];
    cin >> s >> t;
    
    int len = strlen(s);
    
    int i;
    for(i = 0; i < len; i++){
        if(!strncmp(&s[0], &t[i], len - i) && !strncmp(&s[len - i], &t[0], i)){
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o set

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,m; cin >> n >> m;
    ll k; cin >> k;
    ll suma[n+1];
    vector<ll> sumb(m+1);
    suma[0]=0; sumb[0]=0;
    rep(i,n){
        ll a; cin >> a;
        suma[i+1]=suma[i]+a;
    }
    rep(i,m){
        ll b; cin >> b;
        sumb[i+1]=sumb[i]+b;
    }
    int ans=0;
    rep(i,n+1){
        ll res=k-suma[i];
        if(res<0) break;
        int p=upper_bound(ALL(sumb),res)-sumb.begin();
        p--;
        chmax(ans,p+i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6364
#include<math.h>
int main()
{
  int a,b,c;
  char op;

  while(1){
  scanf("%d %c %d",&a,&op,&b);

  if(op == '?')
    break;
  else if(op == '+')
    printf("%d\n",c = a + b);
  else if(op == '-')
    printf("%d\n",c = a - b);
  else if(op == '/')
    printf("%d\n",c = a / b);
   else if(op == '*')
    printf("%d\n",c = a * b);
}

return 0;
}


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

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

  vector<int> a(n + 2);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += abs(a[i] - a[i - 1]);
  }
  sum += abs(a[n + 1] - a[n]);

  for (int i = 1; i <= n; i++)
    cout << sum - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) +
                abs(a[i + 1] - a[i - 1])
         << endl;
}

Measured memory_bytes: 1664
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
even = Counter(v[1::2]).most_common(2)
odd = Counter(v[0::2]).most_common(2)
# print(even)
# print(odd)
if even[0][0] != odd[0][0]:
    print(n - even[0][1] - odd[0][1])
else:
    if len(even) == 1 or len(odd) == 1:
        print(n//2)
    else:
        print(n - max(even[0][1]+odd[1][1], even[1][1]+odd[0][1]))


Measured memory_bytes: 15588
#include <iostream>
#include <string>

int main()
{
    int a,b,c,counter = 0;
    std::cin >> a >> b >> c;
    if(a==b) counter++;
    if(a==c) counter++;
    if(b==c) counter++;
    if(a==b&&b==c) counter =2;
    std::cout << 3-counter << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

int main() {
  string s;
  cin >> s;
  
  int maxl = 0;
  int l = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
      l++;
    } else {
      l = 0;
    }
    maxl = max(maxl, l);
  }
  cout << maxl << endl;
  return 0;
}



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

using namespace std;

int main()  {
	long long int n;
	cin >> n;
	vector<long long int> a(n);
	for (long long int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long int c = 0;
	long long int aa = 1;
	for (long long int i = 0; i < n; i++) {
		if (a[i] > aa) {
			c += a[i]/aa;
			if (a[i] % aa == 0) {
				c--;
			}
			if (aa == 1) {
				aa++;
			}
		} else if (a[i] == aa) {
			aa++;
		}
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 1024
num = int(input('')) #input()で入力を受け取ってint()で数字型に変換します。

ans_sum = 0

for now_num in range(num+1):
    if now_num % 3 != 0 and now_num % 5 != 0:
        ans_sum = ans_sum + now_num
    
print(ans_sum)


Measured memory_bytes: 9100
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ac = 0;
        int wa = 0;
        int tle = 0;
        int re = 0;

        String res;

        for (int i = 0; i < N; i++) {
            res = sc.next();

            if (res.equals("AC")) {
                ac++;
            } else if (res.equals("WA")) {
                wa++;
            } else if (res.equals("TLE")) {
                tle++;
            } else {
                re++;
            }
        }

        System.out.println("AC x " + ac);
        System.out.println("WA x " + wa);
        System.out.println("TLE x " + tle);
        System.out.println("RE x " + re);
    }

}


Measured memory_bytes: 58740
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  vector<int>num(N,0);
  
  for(int i=0;i<N;i++){
    cin >> num[i];
  }
  
  int ans_min = 99999999;
  
  for(int i=-100;i<=100;i++){
    int ans = 0;
    for(int j=0;j<N;j++){
      ans += (num[j] - i) * (num[j] - i);
    }
    if(ans < ans_min)
      ans_min = ans;
  }
  
  cout << ans_min << endl;
  
  return 0;
}

      

Measured memory_bytes: 256
using System;

namespace B___Collecting_Balls__Easy_Version_
{
    class Program
    {
        static void Main (string[] args)
        {
            var n = int.Parse (Console.ReadLine ());
            var k = int.Parse (Console.ReadLine ());
            var x = 0;
            var ans = 0;
            var input = Console.ReadLine ().Split (' ');
            for (var i = 0; i < n; i++)
            {
                x = int.Parse (input[i]);
                ans += Math.Min (k - x, x - 0) * 2;
            }
            Console.WriteLine (ans);
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>

#define MAX 100001

typedef struct {
  int p;
  int r;
  int l;
}Node;

Node T[MAX];

void Preorder(int);
void Inorder(int);
void Postorder(int);


int main(){
  int n,i,mun,root;

  for(i=0;i<100001;i++) T[i].p=T[i].l=T[i].r=-1; /* T の要素の初期化 */

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&mun);
    scanf("%d%d",&T[mun].l,&T[mun].r);

    T[T[mun].l].p=mun;
    T[T[mun].r].p=mun;
  }
  
  for(i=0;i<n;i++){/* 根を見つける */
    if(T[i].p==-1) root=i;
  }

  printf("Preorder\n");
  Preorder(root);
  printf("\n");
  
  printf("Inorder\n");
  Inorder(root);
  printf("\n");

  printf("Postorder\n");
  Postorder(root);
  printf("\n");

  return 0;
}

void Preorder(int key){
  
  printf(" %d",key);
  if(T[key].l!=-1) Preorder(T[key].l);
  if(T[key].r!=-1) Preorder(T[key].r);

}

void Inorder(int key){

  if(T[key].l!=-1) Inorder(T[key].l);
  printf(" %d",key);
  if(T[key].r!=-1) Inorder(T[key].r);

}

void Postorder(int key){

  if(T[key].l!=-1) Postorder(T[key].l);
  if(T[key].r!=-1) Postorder(T[key].r);
  printf(" %d",key);

}



Measured memory_bytes: 3028
n,x,m = gets.strip.split.map(&:to_i)
v = Array.new(m,0)
c = Array.new(m,0)
a = Array.new(m,0)
ans = 0
n.times do |i|
  break if x == 0
  ans += x
  y = x * x % m
  if v[x] == 0
    v[x] = y
    c[x] = i
    a[x] = ans
  else
    l = ans - a[x]
    s = i - c[x]
    z = (n - i - 1)/s
    ans += z * l
    (i+z*s+1).upto(n-1) do
      ans += y
      y = v[y]
    end
    p ans
    exit
  end
  x = y
end
p ans


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

int main(){

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

	int h,w,n;
	cin>>h>>w>>n;

	cout<< min( (h+n-1)/h , (w+n-1)/w );
}

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

#define MAXINF 1000000005
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repc(it, x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rrepc(it, x) for(auto it = (x).rbegin(); it != (x).rend(); ++it)
#define all(x) (x).begin(), (x).end()
#define P pair<int, int>

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[] = {
        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 << a[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256