akhauriyash/Code-Regression huggingface dataset:
def is_ok(x,n):
  if x**2<=n:
    return True
  else:
    return False

def meguru_bisect(ng, ok,n):
  while (abs(ok - ng) > 1):
    mid = (ok + ng) // 2
    if is_ok(mid,n):
      ok = mid
    else:
      ng = mid
  return ok

def sqrt(n):
  return meguru_bisect(n,1,n)

Q = int(input())
for _ in range(Q):
  A,B  = list(map(int,input().split()))
  score = A*B-1
  maxA = score//(B+1)
  maxB = score//(A+1)
  crit = sqrt(score)
  ans = 0
  if maxA:
    if crit<maxA:
      ans += crit+(score//(crit+1)-score//maxA)+1
    else:
      ans += maxA
  if maxB:
    if crit<maxB:
      ans += crit+(score//(crit+1)-score//maxB)+1
    else:
      ans += maxB
  print(ans)

Measured memory_bytes: 73384
import scala.io.StdIn
import scala.math._
import scala.collection.mutable.ArrayBuffer


object Main {

  class Zero(var l: Int, var r: Int) {
    override def toString: String = s"[$l,$r]"
  }

  def main(args: Array[String]): Unit = {
    val Array(n: Int, k: Int) = StdIn.readLine.split(" ").map(_.toInt)
    val as = StdIn.readLine.map(_ == '1')

    val B = ArrayBuffer[Zero]()
    B += new Zero(-1, -1)  // Sentinel
    B += new Zero(-1, -1)

    REP(n) { i =>
      if (!as(i)) {
        if (B.last.l == -1) B.last.l = i
        B.last.r = i
      } else if (B.last.l != -1) {
        B += new Zero(-1, -1)
      }
    }
    if (B.last.l != -1) B += new Zero(-1, -1)
    B.last.l = n
    B.last.r = n

    debug(B.mkString(" "))

    var ans = 0
    REP(B.length - 1) { l =>
      val r = min(l + k + 1, B.length - 1)
      val len = B(r).l - 1 - (B(l).r + 1) + 1
      ans = max(ans, len)
    }
    println(ans)

    debug(n, k)
    as.foreach {i => debugNoNewline(i, "")}
  }

  def DEBUG(f: => Unit): Unit = {
    if (false) { f }
  }

  def debug(something: Any): Unit = DEBUG {
    System.err.println(something)
  }
  def debugNoNewline(something: Any): Unit = DEBUG {
    System.err.print(something)
  }

  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while (i < N) { f(i); i += 1 }
  }

}

Measured memory_bytes: 57848
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<map>
using namespace std;

int A,B,C;
struct node
{
	inline node(int _a = 0,int _b = 0,int _c = 0):a(_a),b(_b),c(_c) {}
	int a,b,c;
	friend inline bool operator <(const node &x,const node &y)
	{
		if (x.a != y.a) return x.a < y.a;
		else if (x.b != y.b) return x.b < y.b;
		else return x.c < y.c;
	}
};
map <node,bool> M;

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

inline void work(int a,int b,int c) { A = (b+c) >> 1,B = (a+c) >> 1,C = (a+b) >> 1; }

int main()
{
	//freopen("G.in","r",stdin);
	//freopen("G.out","w",stdout);
	int ans = 0;
	A = gi(),B = gi(),C = gi();
	while (!(A&1)&&!(B&1)&&!(C&1))
	{
		if (M.find(node(A,B,C)) == M.end()) M[node(A,B,C)] = true;
		else { puts("-1"); return 0; }
		++ans,work(A,B,C);
	}
	cout << ans << endl;
	// fclose(stdin); fclose(stdout);
	return 0;
}


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

int main() {
  int N;
  vector<int64_t> vec = {2, 1};
  
  cin >> N;

  for (int i = 0; i < N; i++) {
    int64_t lucas = vec.at(i + 1) + vec.at(i);
    vec.push_back(lucas);
  }
  
  cout << vec.at(N) << endl;
}


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

using namespace std;

//#define FILE_IO

typedef long long LL;

const LL INF = 1LL << 61;
const int mod = 1e9 + 7;

int N;
LL A, B;
LL v[100005];
int dp[100005][2];

int add(int x, int y) {x += y; if(x >= mod) x -= mod; return x;}
int sub(int x, int y) {x -= y; if(x < 0) x += mod; return x;}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    scanf("%lld%lld", &A, &B);
    if(A > B)   swap(A, B);
    v[0] = -INF;
    for(int i = 1; i <= N; i++) scanf("%lld", &v[i]);

    dp[1][0] = dp[1][1] = 1;
    int posB = 1;
    int lftA = 1;
    for(int i = 2; i <= N; i++)
    {
        if(v[i] - v[i - 1] >= A)    dp[i][0] = add(dp[i - 1][0], dp[i - 1][1]);
        else if(v[i] - v[i - 2] >= A)   dp[i][0] = dp[i - 1][1];
        else { if(i > 2) { printf("0\n"); return 0; } }

        while(v[i] - v[posB] >= B)  posB++;

        if(posB == i)   dp[i][1] = add(dp[i - 1][0], dp[i - 1][1]);
        else if(lftA <= posB)   dp[i][1] = dp[posB][0];

        if(v[i] - v[i - 1] >= A);
        else    lftA = i;
    }

    int ans = add(dp[N][0], dp[N][1]);
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 1792
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, X, Y = LI()
    X-=1
    Y-=1
    G = [[N+1 for _ in range(N)] for __ in range(N)]
    dists = []
    for i in range(N):
        for j in range(i, N):
            if i == j:
                continue
            # i->X->Y->j
            # i->j
            route = abs(X-i) + 1 + abs(Y-j)
            G[i][j] = min(abs(i-j), route)
            dists.append(G[i][j])
    c_dists = collections.Counter(dists)
    for i in range(1, N):
        print(c_dists[i])

main()



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

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const unsigned int mod = 1e9 + 7;

using namespace std;

int32_t main() {
	fastio;

	int n;
	cin >> n;
	int a[n + 1], freq[n + 1];
	memset(freq, 0, sizeof(freq));
	for(int i = 2; i <= n; ++i) cin >> a[i];
	for(int i = 2; i <= n; ++i) ++freq[a[i]];
	for(int i = 1; i <= n; ++i) cout << freq[i] << '\n';

	return 0;
}


Measured memory_bytes: 6704
#include<stdio.h>
int main(){
  int i,j,c=0,m=1e9;
  char s[100010];
  scanf("%s",s);
  for(i=0;i<2;i++){
    for(j=c=0;s[j];j++){
      if(s[j]=='0'+(i+j)%2)c++;
    }
    if(m>c)m=c;
  }
  printf("%d\n",m);
  return 0;
}
	     


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F         first
#define S          second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define hell        1000000007
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 1e9
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 10000;


using namespace std;
void solve();

void fastIO() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);


/*class CompareDist
{
public:
    bool operator()(pair<ll,int> a,pair<ll,int> b) {
        if(a.F!=b.F)
        return a.F<b.F;
        else
        return a.S>b.S;
    }
};*/

void solve(){

  int a,b;
  cin>>a>>b;
  if(a>=1&&b>=1&&a<=9&&b<=9){
    cout<<(a*b);
  }
  else{
    cout<<-1;
  }

}


///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll x,ll y){
  if(x==0)
  return y;
  else
  return gcd(y%x,x);
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1)%hell)*k%hell)%hell;
  else
  return ((pw(k,x/2)%hell)*(pw(k,x/2)%hell))%hell;
}

/*void sieve(){

  for(int i=2;i<=1000000;i++){
    if(prime[i]==true){
      for(int j=i*i;j<=1000000;j+=i)
      prime[j]=false;
    }
  }

}*/


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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int a, b;
	cin>>a>>b;
	int c = 1, ans = 0;
	while(c<b)
	{
		c--;
		c += a;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

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

using namespace std;

const long long sqrtN = 512;
struct SqrtDecomposition {
  long long N, K;
  vector<long long> data;
  vector<long long> bucketSum;
  SqrtDecomposition(long long n) : N(n) {
    K = (N + sqrtN - 1) / sqrtN;
    data.assign(K * sqrtN, 0);
    bucketSum.assign(K, 0);
  }
  void add(long long x, long long y) {
    long long k = x / sqrtN;
    data[x] += y;
    long long sum = 0;
    for (long long i = k * sqrtN; i < (k + 1) * sqrtN; ++i) {
      sum += data[i];
    }
    bucketSum[k] = sum;
  }
  // [x, y)
  long long getSum(long long x, long long y) {
    long long sum = 0;
    for (long long k = 0; k < K; ++k) {
      long long l = k * sqrtN, r = (k + 1) * sqrtN;
      if (r <= x || y <= l)
        continue;
      if (x <= l && r <= y) {
        sum += bucketSum[k];
      } else {
        for (long long i = max(x, l); i < min(y, r); ++i) {
          sum += data[i];
        }
      }
    }
    return sum;
  }
};

int main() {
    long long n,q,que,x,y;
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> q;
    SqrtDecomposition qq(n);
    rep(i,q) {
        cin >> que;
        if(que) {
            cin >> x >> y;
            cout << qq.getSum(x,y+1) << endl;
        } else {
            cin >> x >> y;
            qq.add(x,y);
        }
    }
    return 0;
}


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

using namespace std;

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

  int maxv;
  map<char, int> l, r;
  int cnt = 0;
  for (int i = 1; i < n; i++) {
    l.clear();
    r.clear();
    for (int j = 0; j < i; j++) {
      l[S[j] - 'a']++;
    }
    for (int j = i; j < n; j++) {
      r[S[j] - 'a']++;
    }

    cnt = 0;
    for (int j = 0; j < 26; j++) {
      if (l[j] && r[j]) {
        cnt++;
      }
    }
    maxv = max(maxv, cnt);
  }

  cout << maxv << endl;
  return 0;
}

Measured memory_bytes: 256
//Not Found

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / __gcd(a, b) * b
#define range(a) (a).begin(),(a).end()
const int inf = 2147483647;

int main (){
    string s;cin>>s;
    map<char,int> m{};
    rep(i,0,s.size()){
        m[s[i]]++;
    }
    for(char sa = 'a';sa<='z';sa++){
        if(m[sa]==0){
            cout << sa << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
  int K,L,N,M;
  cin>>N;
  vector<string> s(N);
  rep(i,N) cin>>s[i];
  cin>>M;
  vector<string> t(M);
  rep(i,M) cin>>t[i];

  L=0;  

  for(int i=0;i<N;++i){
  K=0;
  for(int j=0;j<N;++j){
  if(s[i]==s[j]){++K;}
  }
  for(int k=0;k<M;++k){
  if(s[i]==t[k]){--K;}
  }
  L=max(K,L);
  }

cout<<L<<endl;

}

Measured memory_bytes: 256
z,v,a=input,range,print
h,w,k=map(int,z().split())
r,s,t,u=map(lambda x:int(x)-1,z().split())
b=[z()for _ in v(h)]
l=[[-1]*w for _ in v(h)]
l[r][s]=0
from collections import*
d=deque([(r,s)])
while d:
  x,y=d.popleft()
  if(x==t)&(y==u):exit(a(l[x][y]))
  for e,f in[[1,0],[-1,0],[0,-1],[0,1]]:
    for i in v(1,k+1):
      p,q=x+e*i,y+f*i
      if not((0<=p<h)&(0<=q<w))or b[p][q]=="@" or 0<=l[p][q]<=l[x][y]:break
      if l[p][q]<0:d+=[(p,q)];l[p][q]=l[x][y]+1
a(-1)

Measured memory_bytes: 93928
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;

void solve()
{	
	map<int, int> pip;
	rep(i, 6)
	{
		int tmp; cin >> tmp;
		pip[tmp] = i;
	}
	int r[6][6];
	r[0][1]=r[1][5]=r[5][4]=r[4][0] = 2;
	r[0][4]=r[4][5]=r[5][1]=r[1][0] = 3;
	r[1][2]=r[2][4]=r[4][3]=r[3][1] = 0;
	r[1][3]=r[3][4]=r[4][2]=r[2][1] = 5;
	r[0][2]=r[2][5]=r[5][3]=r[3][0] = 4;
	r[0][3]=r[3][5]=r[5][2]=r[2][0] = 1;
	int n; cin >> n;
	vector<int> ans;
	rep(i, n)
	{
		int a, b; cin >> a >> b;
		int up = pip[a];
		int front = pip[b];
		int right = r[up][front];
		int next = [&]()
		{
			for(auto e: pip)
			{
				if(e.second == right)return e.first;
			}
			return 0;
		}();
		ans.push_back(next);
	}
	rep(i, n)cout << ans[i] << endl;
	return;
}

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



Measured memory_bytes: 3104
#include<stdlib.h>
#include<stdio.h>
#include<iostream>

using namespace std;
int main()
{
	int X, A;
	cin >> X >> A;
	if (X < A)
	{
		cout << "0";
	}
	else
	{
		cout << "10";
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int parent[50 * 50 + 5];
int length[50 * 50 + 5];
 
void init();
int getroot(int n);
bool samegroup(int n, int m);
bool unite(int n, int m);
 
int main(){
  int N, M;//N:ノードの数　M:エッジの数
  cin >> N >> M;
  vector<int> a(M), b(M);//データ数はMで数値はNまでの範囲
  for ( int i = 0; i < M ; i++) cin >> a.at(i) >> b.at(i);
  int ans = 0; //ブリッジとなるエッジの数
  
  for ( int i = 0; i < M ; i++){
    init(); //parent[k] = length[k] = k で初期化
    
    for ( int j = 0; j < M ; j++){
      if ( j == i ) continue;
      unite ( a[j],b[j]); //入力した全aj,bj間をエッジで連結
    }
    
    int parent = getroot(1);
    bool ok = true;
    for ( int i = 1; i <= N; i++){
      if ( !samegroup(parent, i)){
        ok = false;
        break;
      }
    }
    if(!ok) ans++;
  }
  cout << ans << endl;
}
 
void init(){
for ( int i = 0; i < 50 * 50 + 5; i++){
  parent[i] = i;
  length[i] = i;
}
  return;
}
int getroot(int n){
  if ( parent[n] == n){
    return n;
  } else{
    return getroot(parent[n]);
  }
}
bool samegroup(int n, int m){
  int nroot = getroot(n);
  int mroot = getroot(m);
  if ( nroot == mroot){
    return true;
  } else{
    return false;
  }
}
bool unite(int n, int m){
  if (samegroup(n, m)){
    return false;
  } else{
    int nroot = getroot(n);
    int mroot = getroot(m);
    if (length[nroot] == length[mroot]){
      parent[nroot] = mroot;
      length[mroot]++;
    } else if (length[nroot] > length[mroot]){
      parent[mroot] = nroot;
    } else {
      parent[nroot] = mroot;
    }
    return true;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <climits>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<long long int>
#define vc vector<char>
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(i = (a); i < (n); i++)
#define fi(i,a,n) for(i = (a); i <= (n); i++)
#define F first
#define S second
int main(){
    ll x,y;
    cin>>x>>y;
    ll c = 1;
    ll s = x;
    if(y==1){
        cout<<"0"<<endl;
        return 0;
    }
    while(s<y){
        s += x;
        s--;
        c++;
    }
    cout<<c<<endl;
}

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n,l;
  cin>>n>>l;
  vector<string> vs(n);
  for(int i=0;i<n;i++)cin>>vs[i];
  sort(vs.begin(), vs.end());
  for(int i=0;i<n;i++){
    cout<<vs[i];
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
N = list(input())
num = len(N)
if N.count('9') == num:
    print(9*num)
elif N.count('9') == num-1 and N[0] != '9':
    print(int(N[0])+9*(num-1))
else:
    if num <= 1:
        print(''.join(N))
    else:
        ans = int(N[0])-1
        ans += 9*(num-1)
        print(ans)

Measured memory_bytes: 9200
import math

#素因数分解
def prime_factorization(N):

    n = N
    sqrt = int(math.sqrt(n)) + 1
    m = {}
    for i in range(2, sqrt):
        if n % i == 0:
            cnt = 0
            while n % i == 0:
                cnt += 1
                n /= i
            m[i] = cnt

    # nが1になっていなければn自体が素数
    if n != 1:
        m[n] = 1

    return m

n = int(input())
m = prime_factorization(n)
ans = 0

for v in m.values():
    b = 1
    while v - b >= 0:
        ans += 1
        v -= b
        b += 1

print(ans)


Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

    ll n , m;
    cin>>n>>m;
    
	for (int i = 1, j = m; i < j; i++, j--){
        cout<<i<<" "<<j<<"\n";
	}
    for (int i = m + 1, j = 2 * m + 1; i < j; i++, j--){
        cout<<i<<" "<<j<<"\n";
    }
	return 0;
}


Measured memory_bytes: 3652
from sys import stdin, stdout
input = lambda: stdin.readline().rstrip()
write = stdout.write

def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    num = [a - i for i, a in enumerate(A, start=1)]
    num.sort()
    b = num[N//2]
    ans = sum([abs(a - (b + i)) for i, a in enumerate(A, start=1)])
    print(ans)

main()


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	double w,h,x,y;
	t = 1;
	while(t--) {
	 cin >> w >> h >> x >> y;
	 cout << fixed << setprecision(16);
	 cout << (w * h) / 2 << " " ;
	 if(w == 2 * x && h == 2 * y)
	  cout << 1 << endl;
	 else
	  cout << 0 << endl;
	}
	return 0;
}



Measured memory_bytes: 256
primes = [2]

x = int(input())
for i in range(3, x * 2):
    is_p = True
    for p in primes:
        if i < p * p:
            break
        if i % p == 0:
            is_p = False
            break
    if is_p:
        primes.append(i)

print([i for i in primes if i >= x][0])


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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;



int main(void) {
	
	while (1) {
		int M, T, P, R;
		int tmp1, tmp2;
		int dp[51][11] = {};
		int pos = 50;


		cin >> M >> T >> P >> R;
		if (M == 0) {
			break;
		}
		vector<int>m(R), t(R), p(R), j(R), time(T+1, 0), count(T+1, 0);
		vector< pair<int, int> > res(T);
		FOR(i, 0, R - 1) {
			cin >> m[i] >> t[i] >> p[i] >> j[i];
			if (j[i] == 0) {
				count[t[i]]++;
				time[t[i]] += dp[t[i]][p[i]] * 20 + m[i];
			}
			else {
				dp[t[i]][p[i]]++;
			}
		}
		FOR(i, 0, T - 1) {
			res[i].first = count[i + 1];
			res[i].second = i + 1;
		}
		sort(res.begin(), res.end());

		FOR(i, 0, T-2) {
			FOR(s, i + 1, T - 1) {
				if (res[i].first == res[s].first) {
					if (time[res[i].second] < time[res[s].second]) {
						tmp1 = res[i].second;
						res[i].second = res[s].second;
						res[s].second = tmp1;
					}
					if (time[res[i].second] == time[res[s].second]) {
						if (res[i].second > res[s].second) {
							tmp1 = res[i].second;
							res[i].second = res[s].second;
							res[s].second = tmp1;
						}
					}
				}
			}
		}
		

		bool flag = true;
		bool check = true;
		if (T == 1) {
			cout << 1 << endl;
		}
		else {
			RFOR(i, T - 1, 1) {
				if (res[i].first != res[i - 1].first) {
					if (check == false) {
						cout << "=" << res[i].second;
						check = true;
						continue;
					}
					check = true;
					if (flag == true) {
						cout << res[i].second;
						flag = false;
					}
					else {
						cout << "," << res[i].second;
					}
				}
				else if (time[res[i].second] != time[res[i - 1].second]) {
					if (check == false) {
						cout << "=" << res[i].second;
						check = true;
						continue;
					}
					check = true;
					if (flag == true) {
						cout << res[i].second;
						flag = false;
					}
					else {
						cout << "," << res[i].second;
					}
				}
				else {
					if (flag == true) {
						flag = false;
						if (check == true) {
							cout << res[i].second;
							check = false;
						}
						else {
							cout << "=" << res[i].second;
						}
						
					}
					else {
						if (check == true) {
							cout << "," << res[i].second;
							check = false;
						}
						else {
							cout << "=" << res[i].second;
						}
					}
				}
			}

			if (res[1].first != res[0].first) {
				cout << "," << res[0].second;
			}
			else if (time[res[1].second] != time[res[0].second]) {
				cout << "," << res[0].second;
			}
			else {
				cout << "=" << res[0].second;
			}

			cout << endl;
		}
		
	}
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	if(a+b>c*2){
		if(x==y)cout<<c*2*x<<endl;
		else if(x<y)cout<<c*2*x+min(b,c*2)*(y-x)<<endl;
		else cout<<c*2*y+min(a,c*2)*(x-y)<<endl;
	}
	else{
		cout<<a*x+b*y<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int n, t, l, b;
int cell[101];
double dp[101][101];

int main(){
	while(scanf("%d%d%d%d", &n, &t, &l, &b),n||t||l||b){
		rep(i,101) cell[i] = 0;
		rep(i,101) rep(j,101) dp[i][j] = 0.0;
		dp[0][0] = 1.0;
		rep(i,l){
			int tmp;
			scanf("%d", &tmp);
			cell[tmp] = 1;
		}
		rep(i,b){
			int tmp;
			scanf("%d", &tmp);
			cell[tmp] = 2;
		}
		for(int i = 1; i <= t; i++){
			dp[i][n] += dp[i-1][n];
			for(int j = 0; j < n; j++){
				for(int k = 1; k <= 6; k++){
					int to = j+k;
					if(to > n) to = 2*n-to;
					if(cell[to] == 0){
						dp[i][to] += dp[i-1][j]/6.0;
					} else if(cell[to] == 1){
						if(i == t) continue;
						dp[i+1][to] += dp[i-1][j]/6.0;
					} else{
						dp[i][0] += dp[i-1][j]/6.0;
					}
				}
			}
		}
		printf("%.9f\n", dp[t][n]);
	}
}

Measured memory_bytes: 1304
#include<stdio.h>
#define Max 1000

int main()
{
  int i,j,k,key,N,A[Max];

  scanf("%d",&N);

  for(i=0;i<N;i++) scanf("%d",&A[i]);
  
  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i!=N-1)printf(" ");
  }
  printf("\n");
  
  for(i=1;i<=N-1;i++){
    key = A[i];
    j = i-1;
    
    while(j >= 0 && A[j] > key){
      A[j+1]= A[j];
      j--;
      A[j+1] = key;
    }
    
    for(k=0;k<N;k++){
      printf("%d",A[k]);
      if(k != N-1) printf(" ");   
    }  
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 608
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<math.h>

#define DIV 1000000007
using namespace std;
using ll = long long;

int main(void) {
    double R;
    cin >> R;

    printf("%.10lf\n", 2*R *3.14159);
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (auto &&i : h) {
        cin >> i;
    }

    SORT(h);
    int ans = INF32;
    REP(i, N - K + 1) {
        int diff = h[i + K - 1] - h[i];
        chmin(ans, diff);
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1e9+7
#define pf2 pop_front
#define pb2 pop_back
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define sz size
#define eps 1e-7
#define fod find_by_order
#define fastio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ofk order_of_key
#define val(x) cout << "Value dari "<< #x << " adalah " << x  << "\n"
#define tr tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;

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

void readf(string x){
	freopen((x+".in").c_str(),"r",stdin);
	freopen((x+".out").c_str(),"w",stdout);
}

void pr(string x){
	freopen((x+".in").c_str(),"w",stdout);
}


int read()
{
	bool min = 0;
	int  result = 0;
	char ch;
	ch = getchar();
	while(1)
	{
		if(ch == '-') break;
		if(ch >='0' && ch <= '9') break;
		ch = getchar();
	}
	if(ch == '-') min = 1;else result = ch-'0';
	while(1)
	{
		ch =getchar();
		if(ch< '0' || ch>'9') break;
		result = result * 10 + (ch-'0');
	}
	if(min) return -result;
	return result;
}
//Reynaldo's Template

int main(){
	ll N,A,B;
	cin >> N >> A >> B;
	ll kiri = 1,kanan = 1e9;
	ll x[N+5];
	A = A - B;
	for(int i=1;i<=N;i++) cin >> x[i];
	while (kiri <= kanan){
		ll piv = (kiri + kanan) >> 1;
		ll b = B * piv;
		ll ans = 0;
		for(int i=1;i<=N;i++){
			ll a = x[i] - b;
			if(a <= 0) continue;
			ans = ans + 1 + (long long)(a-1)/A;
		}
//		cout << ans << " " << piv << "\n";
		if(ans <= piv){
			kanan =  piv - 1;
		}
		else kiri = piv+1;
	}
	cout << kanan + 1 << "\n";
}



Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(){
    string s;
    cin >> s;
    int ans = s.size();
    bool sw = false;
    for(int i=1;i<s.size();i++){
        if(!sw){
            if(s[i]==s[i-1]){
                ans --;
                i+=2;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
package main

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

func gcd(x, y int) int {
	if x < y {
		x, y = y, x
	}
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

func main() {
	A := readInt()
	B := readInt()

	N := gcd(A, B)
	if N == 1 {
		fmt.Println(1)
		return
	}

	result := 1
	r := int(math.Sqrt(float64(N)))
	for x := 2; x < r+1; x++ {
		if N%x == 0 {
			result++
			for N%x == 0 {
				N /= x
			}
			if N == 1 {
				break
			}
		}
	}
	if N != 1 {
		result++
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 1820
#include <bits/stdc++.h>
using namespace std;
int main() {
  set<int> S;
  int q;
  cin >> q;
  while (q--) {
    int op, x;
    cin >> op >> x;
    if (op == 0) {
      S.insert(x);
      cout << S.size() << endl;
    } else {
      cout << (S.find(x) != S.end()) << endl;
    }
  }
}


Measured memory_bytes: 12472
#include<stdio.h>
#include<string.h>
int main()
{
    int i,n,sum=0;
    scanf("%d",&n);
    char d[n];
     scanf("%s",d); 
    for ( i = 0; i < strlen(d)-1; i++)
    {
          if(d[i]!=d[i+1])
          {
              sum++;
          }
} 
 printf("%d\n",sum+1);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#define INF 1000000009
#define LINF 1000000000000000009
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmax(T &a, const T&b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T&b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

int main() {
	int a, b, n;
	cin >> a >> b >> n;
	cout << min((n + a - 1) / a, (n + b - 1) / b) << endl;
}



Measured memory_bytes: 764
#include<stdio.h>
int main(){
	int set;
	int tag;
	int mid;
	int agg[100];
	int i, j;
	int num_count = 0;
	int input_count = 0;
	
	for(i = 0;i < 100;i++){
		agg[i] = 0;
	}
	
	while(1){
		scanf("%d %d", &set, &tag);
		
		if(set == 0 && tag == 0){
			break;
		}
		
		
		for(i = 1;i < set;i++){
			for(j = i;j <= set;j++){
				mid = tag - (i + j);
				if(mid > i && mid < j){
					num_count++;
				}
			}
		}
		agg[input_count] = num_count;
		input_count++;
		num_count = 0;
	}
	for(i = 0;i < input_count;i++){
		printf("%d\n", agg[i]);
	}
	return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
/*    #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
//ll  t;cin>>t;while(t--)
{
  ll a,b=0,c,x=0;
  cin>>a>>b>>c;
  if(a==b)
  {
    cout<<c<<endl;
  }
  else if(a==c)
  {
    cout<<b<<endl;
  }
  else if(b==c)
  {
    cout<<a<<endl;
  }
  //cout<<(x*x)-a<<endl;
  
  
  
  

}
return 0;
}


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

int main(){
   int N,M,C;
   cin >> N >> M >> C;
   vector<int> B(M);
   for (int i = 0; i < M; i++){
       cin >> B.at(i);
   } 
   vector<vector<int>> A(N, vector<int>(M));
   for (int i = 0; i < N; i++){
       for (int j = 0; j < M; j++){
           cin >> A.at(i).at(j);
       }
   }
   int count = 0;
   for (int i = 0; i < N; i++){
       int sum = 0;
       for (int j = 0; j < M; j++){
           sum += A.at(i).at(j) * B.at(j);
       }
       if (sum + C > 0){
           count++;
       }
   }
   cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)  
{  
    char a[101][101];  
    int sum[100][100]={0};  
    int j,i,n,m;  
    scanf("%d%d",&n,&m);  
    for(i=0;i<n;i++)  
    {  
            scanf("%s",a[i]);getchar();  
    }           
    for(i=0;i<n;i++)  
    {  
        for(j=0;j<m;j++)  
        {  
            if(a[i][j]=='#')  
            {sum[i][j]=-1;  continue;  
            }   
            if(a[i-1][j-1]=='#')  
                 sum[i][j]++;  
            if(a[i-1][j]=='#')  
                 sum[i][j]++;  
            if(a[i-1][j+1]=='#')  
                 sum[i][j]++;  
            if(a[i][j-1]=='#')  
                 sum[i][j]++;  
            if(a[i][j+1]=='#')  
                 sum[i][j]++;  
            if(a[i+1][j-1]=='#')  
                 sum[i][j]++;  
            if(a[i+1][j]=='#')  
                 sum[i][j]++;  
            if(a[i+1][j+1]=='#')  
                 sum[i][j]++;                             
        }  
    }  
    for(i=0;i<n;i++)  
    {  
        for(j=0;j<m;j++)  
        {  
            if(sum[i][j]!=-1)  
                printf("%d",sum[i][j]);  
            else putchar('#');  
        }  
        putchar('\n');  
    }  
    return 0;  
}

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

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    int n = N;
    int sum = 0;
    int ans = 0;
    while (n >= 0) {
        int row = (sum + K - 1) / K;
        row = max(row, 1);
        // cout << n << " " << sum << " " << ans << " " << row << endl;
        if (row > n)
            break;
        else {
            ans++;
            n -= row;
            sum += row;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;



signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N, K;
  cin >> N >> K;
  int A = N % K;
  cout << min(A, K-A) << endl;

}

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

using namespace std;

typedef long long llint;

int main() {
  string s;
  cin >> s;
  int n = s.size() + 1;
  vector<llint> a(n), b(n);
  llint cnt = 0;
  if (s[0] == '<') {
    a[0] = 0, a[1] = 1, cnt = 1;
  } else {
    a[0] = 1, a[1] = 0, cnt = 0;
  }
  for (int i = 1; i < s.size(); i++) {
    if (s[i] == '<') {
      cnt++;
    } else {
      cnt = 0;
    }
    a[i + 1] = cnt;
  }
  if (s.back() == '<') {
    b[n - 1] = 1, b[n - 2] = 0, cnt = 0;
  } else {
    b[n - 1] = 0, b[n - 2] = 1, cnt = 1;
  }
  for (int i = n - 3; 0 <= i; i--) {
    if (s[i] == '>') {
      cnt++;
    } else {
      cnt = 0;
    }
    b[i] = cnt;
  }

  llint ans = 0;
  for (int i = 0; i < n; i++) {
    ans += max(a[i], b[i]);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 8708
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i,0,N) cin >> A[i];

    rep(i,K,N) {
        if (A[i] > A[i-K]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 4048
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        
        if(a + b <= 23) {
        System.out.println(a + b);
        }  else if (a + b >= 24) {
        System.out.println(a + b - 24);
        }
    }
}

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

using namespace std;

int main(){
    string src;
   
    int pos = 0;

    cin >> src;
    string rst(src.length()+1, 'x');
    int end = src.length();
    for(int i = 0; i < end + 1; i++){
        if(i == 4){
            rst[i] = ' ';
        }
        else{
            rst[i] = src[pos];
            pos++;
        }
    }
    rst[end+1] = '\n';
    printf("%s", rst.c_str());
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

[H, W] = [int(i) for i in input().split()]

gh = H - 1
gw = W - 1

S = []
for h in range(H):
    S.append(list(input()))

# 最短経路を求める
queue = [(0, 0, 0)]
min_route = 0
while len(queue) > 0:
    (y, x, r) = queue.pop(0)
    if S[y][x] == 'X':
        continue
    S[y][x] = 'X'
    r += 1

    if y == gh and x == gw:
        min_route = r
        break

    # 上下左右の移動可能マスをqueueにpush
    for (dy, dx) in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
        ny = y + dy
        nx = x + dx
        if ny >= 0 and ny < H and nx >= 0 and nx < W and S[ny][nx] == '.':
            queue.append((ny, nx, r))

if min_route == 0:
    print(-1)
    sys.exit()

#print(min_route)
# 最短経路分以外の白マスの数を回答
white_square = 0
for h in range(H):
    white_square += S[h].count('.')
    white_square += S[h].count('X')
#print(white_square)

ans = white_square - min_route
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a;
  cin>>a;
  vector<int>vec(a,0);
  for(long long k=1;k*k<a+3;k++){
    for(long long i=1;i*i<a+3;i++){
      for(long long j=1;j*j<a+3;j++){
        if(a+1>k*k+i*i+j*j+k*i+i*j+j*k>0){
          vec.at(k*k+i*i+j*j+k*i+i*j+j*k-1)+=1;
        }
      }
    }
  }
  for(long long i=0;i<a;i++){
    cout<<vec.at(i)<<endl;
  }
}

Measured memory_bytes: 3644
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    cout<<fixed<<setprecision(20);
    int n,k,ans=0; cin>>n>>k;
    vector<int> p(n,0),sum(n+1,0);
    rep(i,n){
        cin>>p[i]; sum[i+1]=sum[i]+p[i];
    }
    rep(i,n-k+1) ans=max(ans,sum[i+k]-sum[i]);
    cout<<(ld)(ans+k)/2<<endl;
}


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

int main()
{
    long long n,m;
    long long yu;
    
    scanf("%lld %lld",&n,&m);
    yu=n%m;
    if(yu<m-yu)
    {
        printf("%lld\n",yu);
    }
    else
    {
        printf("%lld\n",m-yu);
    }
    
    
    return 0;
}




Measured memory_bytes: 256
h,w=map(int,input().split())
s=[]
ans=0
white=0
for i in range(h):
    s.append(input())
    for j in s[-1]:
        if j==".":
            white+=1
    
from collections import deque
  
def dfs(field):
    q = deque([(0, 0, 1)])
    visited = [[False] * w for _ in range(h)]
    while q:
        i, j, d = q.popleft()
        if i == h - 1 and j == w - 1:
            return d
        if visited[i][j]:
            continue
        visited[i][j] = True
        if i > 0 and field[i - 1][j] == '.':
            q.append((i - 1, j, d + 1))
        if i < h - 1 and field[i + 1][j] == '.':
            q.append((i + 1, j, d + 1))
        if j > 0 and field[i][j - 1] == '.':
            q.append((i, j - 1, d + 1))
        if j < w - 1 and field[i][j + 1] == '.':
            q.append((i, j + 1, d + 1))
    else:
        return -1

ans=dfs(s)

if ans==-1:
    print(-1)
else:
    print(white-ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
/*
alias A='g++ -std=c++17 -O2 A.cpp'
alias b='g++ -std=c++17 -O2 B.cpp'
alias c='g++ -std=c++17 -O2 C.cpp'
alias d='g++ -std=c++17 -O2 D.cpp'
alias e='g++ -std=c++17 -O2 E.cpp'
alias a='./a.out'
cd programming
cd cpp
cd practice

*/
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
#define Sort(v) sort((v).begin(), (v).end())
using veci = vector<int>;
using vecs = vector<string>;
using vecd = vector<double>;
using vecl = vector<long long>;
using G = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
ll lINF = LLONG_MAX; ll lmINF = LLONG_MIN;
int INF = INT_MAX; int mINF = INT_MIN;
//9桁の数は1e9で表せる, その場合最初にcout.precision(桁数)として精度を指定する必要がある
double PI = acos(-1);
int main(){
    //cout.precision(10);
    cin.tie(0);//cin高速化
    int n; cin >> n;
    int cnt=0;
    int mcnt = 0;
    rep(i, n){
        int a, b;
        cin >> a >> b;
        if (a == b) cnt++;
        else cnt = 0;
        mcnt = max(cnt, mcnt);
    }
    if (mcnt >=3) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
  int n,a,b,sum=0;
  cin >> n >> a >> b;
  for ( int i=1; i<=n; i++ ) {
    int m=i,s=0;
    while ( m ) {
      s+=m%10;
      m/=10;
    }
    if ( s>=a&&s<=b ) sum+=i;
  }
  cout << sum << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    System.out.println(N * (N - 1) / 2 + M * (M - 1) / 2);
  }
}


Measured memory_bytes: 21844
A, B, C = map(int, input().split())
K = int(input())

for i in range(K):
  for ii in range(K - i):
    iii = K - i - ii
    a = A * (2 ** i)
    b = B * (2 ** ii)
    c = C * (2 ** iii)
    if a < b < c:
      print('Yes')
      exit(0)
print('No')




Measured memory_bytes: 8780
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

counter = 0

while True:
    even = True
    for i in a:
        if i % 2 != 0:
            even = False
            break
        else:
            even = True
    if even == False:
        break
    else:
        counter += 1
        a = list(map(lambda x: x / 2, a))

print(counter)

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

# B - Trick or Treat
n, k = map(int, input().split())
sunukes = [0] * (n + 1)

for i in range(k):
	d = int(input())
	a = list(map(int ,input().split()))
	
	for ai in a:
		sunukes[ai] += 1

ans = 0

for i in range(1, n + 1):
	if sunukes[i] == 0:
		ans += 1

print(ans)

Measured memory_bytes: 9216
fun main(args:Array<String>) {
    val abcde = (1..5).map { readLine()!!.toInt() }
    val fix = abcde.map { if(it % 10 == 0) it else (10 * (it/10 + 1)) }
    val diff = abcde.indices.map { fix[it] - abcde[it] }.max()!!
    val ans = fix.sum() - diff
    println(ans)
}

Measured memory_bytes: 33860
#include<iostream>
using namespace std;
const int DN=405;
long long n,a[DN],dp[DN][DN],s[DN];
int main() 
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		s[i]=s[i-1]+a[i];
	for(int l=2;l<=n;l++)
	{
		for(int i=1;i<=n;i++)
		{
			int j=i+l-1;
			if(j>n)
				break;
			dp[i][j]=1e18;
			for(int h=i;h<j;h++)
				dp[i][j]=min(dp[i][j],dp[i][h]+dp[h+1][j]);
			dp[i][j]+=s[j]-s[i-1];
		}
	}
	cout<<dp[1][n];
}

Measured memory_bytes: 1536
#include<stdio.h>
main( )
{int a, b, c,i ,num[3];
  for(i = 0 ; i < 3 ; i++)
    {scanf("%d",&num[i]);}     
  if( num[0] > num[1])
    { a = num[0];
  num[0] = num[1];
  num[1] = a ;} 
  if(num[1] > num[2])
    {b = num[1];
  num[1] = num[2];
  num[2] = b;
  if(num[0] > num[1])
    {c = num[0];
  num[0] = num[1];
  num[1] = c;}}
  printf("%d %d %d\n", num[0], num[1], num[2]);
  return 0;}

Measured memory_bytes: 596
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int A, B, C;
	cin >> A >> B >> C;
	cout << min(C, B / A) << "\n";
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    long long H, N;
    cin >> H >> N;
    vector<long long> A(N,0);
    long long sum_=0;
    for(auto &a:A){
        cin >> a;
        sum_+=a;
    }
    if(sum_>=H){
        cout << "Yes" <<endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 1024