akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define ms(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10) 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge{ int from, to, cost; };

bool prime[2000000];
void hurui()
{
	memset(prime, true, sizeof(prime));
	prime[0] = prime[1] = false;

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

int main()
{
	hurui();
	int n;
	while (cin >> n, n)
	{
		int u, d;
		for (int i = n; i > 0; i--)
		{
			if (prime[i] == true)
			{
				d = i; break;
			}
		}
		for (int i = n; i > 0; i++)
		{
			if (prime[i] == true)
			{
				u = i; break;
			}
		}
		cout << u - d << endl;
	}
	return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

bool isOrder(string s){
  int n = s.size();
  rep(i,n){
    if(s[i]<=s[i+1]){
      return 0;
    }
  }
  return 1;
}

int main(){
  
  string s;
  cin >> s;
  int n = s.size();
  
  set<char> check;
  for(char c : s) check.insert(c);
  
  char next = 'a';
  while(check.count(next)>0){
    next ++;
  }
  
  if(n<26){
    cout << s << next << endl;
    return 0;
  }
  
  int stop = 0;
  
  for(int i=n-1;i>=0;i--){
    string sub = s.substr(i,n-i);
    if(!isOrder(sub)) break;
    stop = i;
  }
  
  if(stop == 0){
    cout << -1 << endl;
    return 0;
  }
  
  stop--;
  
  check = {};
  for(int i=0;i<stop;i++){
    check.insert(s[i]);
    cout << s[i];
  }
    
  next = s[stop]+1;
  while(check.count(next)>0) next ++;
  cout << next << endl;
  return 0;
}

Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
void solve() {
	int l, r, d;
	cin >> l >> r >> d;
	int ans = (l % d) ? 0 : 1;
	ans += (r / d) - (l / d);
	cout << ans;
}

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

Measured memory_bytes: 3656
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
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 INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, C = MAP()
L = [(0, 0)]
for i in range(N):
    x, v = MAP()
    L.append((x, v))
R = [(0, 0)]
for i in range(N, 0, -1):
    x, v = L[i]
    R.append((C-x, v))

# 左右について、片側に進んだ場合の累積max
accL = [0] * (N+1)
cur = 0
for i in range(1, N+1):
    x, v = L[i]
    dist = x - L[i-1][0]
    cur +=  v - dist
    accL[i] = max(accL[i-1], cur)
accR = [0] * (N+1)
cur = 0
for i in range(1, N+1):
    x, v = R[i]
    dist = x - R[i-1][0]
    cur +=  v - dist
    accR[i] = max(accR[i-1], cur)

ans = max(max(accL), max(accR))
# 両側に行く場合を確認
for i in range(N+1):
    # 先に左に行って、戻って右へ
    ans = max(ans, accL[i] - L[i][0] + accR[N-i])
    # 先に右に行って、戻って左へ
    ans = max(ans, accR[i] - R[i][0] + accL[N-i])
print(ans)


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

int main(){
  int H,W,D;
  cin >> H >> W >> D;
  vector<P> v(H*W);
  rep(i,H) rep(j,W) {
    int a;
    cin >> a;a--;
    v[a] = make_pair(i+1,j+1);
  }
  vector<ll> sum(H*W,0);
  for(int i = D; i < H*W; i++) {
    sum[i] = sum[i - D] + abs(v[i].first - v[i-D].first) + abs(v[i].second - v[i-D].second);
  }
  int Q;
  cin >> Q;
  rep(i,Q) {
    int l,r;
    cin >> l >> r;
    l--;r--;
    cout << sum[r] - sum[l] << endl;
  } 
  return 0;
}

Measured memory_bytes: 2560
/*
 *  Author : Jun_SH
 *  Solution for ABC 146 B
 */
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    int f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
int a[10010];
main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    n%=26;
    for(int i=0;s[i];++i){
        a[i]=(s[i]-'A'+n)%26;
    }
    for(int i=0;s[i];++i){
        s[i]=a[i]+'A';
    }
    cout<<s<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define retunr return
#define pb push_back
#define mp make_pair
#define null NULL
#define sc(x) scanf("%d", &x)
#define sc64(x) scanf("%lld", &x)
#define pr(x) printf("%d", (x))
#define pr64(x) printf("%lld", (x))
#define sp putchar(' ')
#define ln putchar('\n')
#define rep(i,l,r) for (int i = l, lim = r;i <= lim; ++i)
#define repr(i,l,r) for (int i = r, lim = l;i >= lim; --i)
#define fi first
#define se second
#define SET(__set, val) memset(__set, val, sizeof __set)
#define fill(a,v,n) memset((a),(v),sizeof(a[0])*(n))
#define copy(a,b,n) memcpy((a),(b),sizeof(a[0])*(n))
#define ALL(x) (x.begin(),x.end())
#define prf(x) printf("%.20f", x)
#define for_each_edge(u) for(int i = point[u];i;i=G[i].n)
typedef unsigned int uint;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define N 100010
#define M 1024
#define MOD 1000000007
void _add(int &a, int b){a = (a+b)%MOD;}
void _sub(int &a, int b){a = (a+MOD-b)%MOD;}
void _mul(int &a, int b){a = (ll)a*b%MOD;}
void _max(int &a, int b){a = max(a,b);}
void _min(int &a, int b){a = min(a,b);}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b,a%b);}
ll pw(ll a, ll b){ll res(1);while(b){if(b&1)res=res*a%MOD;a=a*a%MOD;b>>=1;}return res;}
ll pwM(ll a, ll b, ll mod){ll res(1);while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

const int infi = 2147483647;
const ll infl = 9223372036854775807ll;
const db PI = 3.14159265358979323846;

/*
struct E{
	int v, w, n;
}G[N];
int cnt, point[N];
void adde(int u, int v, int w = 0){
	G[++cnt]=(E){v,w,point[u]},point[u]=cnt;
	G[++cnt]=(E){u,w,point[v]},point[v]=cnt;
}
void Ginit(int n){
	cnt = 0;
	fill(point,0,n+1);
}
*/
/*
struct hh{
	int a, b;
	bool operator < (const hh &x) const{
		if(a==x.a)return b<x.b;
		return a<x.a;
	}
}a[N];
*/
int n, m, k,q;
int a[N];
int jc[N], inv[N];
int ans = 0;
int main(){
//	freopen("1", "r", stdin);
	n = 100000;
	jc[0] = 1;
	rep(i,1,n)jc[i] = (ll)jc[i-1]*i%MOD;
	rep(i,1,n){
		inv[i] = pw(i,MOD-2);
		_add(inv[i], inv[i-1]);
	}
	sc(n);
	rep(i,1,n){
		sc(a[i]);
		int tmp = 1;
		if(i >= 1){
			_add(tmp, inv[i]);
			_sub(tmp, inv[1]);
		}
		if(i <= n){
			_add(tmp, inv[n-i+1]);
			_sub(tmp, inv[1]);
		}
		_mul(tmp, jc[n]);
		_mul(tmp, a[i]);
		_add(ans, tmp);
//		pr(tmp),ln;
	}
	pr(ans),ln;
/*
	int Case;
	sc(Case);
	rep(ca, 1, Case){
	    printf("Case #%d: ", ca);
	}
*/
	return 0;
}


Measured memory_bytes: 1408
import bisect
n,k = map(int, input().split())
a = sorted(list(map(int, input().split())))

def cnt(x):
  ret = 0
  for ai in a:
    ret += (ai+(x-1))//x - 1
  return ret

ok, ng = a[-1], 0
while ok - ng > 1:
  nw = (ok + ng) // 2
  if cnt(nw)<=k:
    ok = nw
  else:
    ng = nw
    
print(ok)

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

int main(){
  double A,B,H,M;
  double angle,lenght;
  cin>>A>>B>>H>>M;
   H += (M/60);
  angle = (H/6 - M/30)*M_PI;
  lenght = sqrt(A*A + B*B - 2*A*B*cos(angle));
  printf("%.19f\n",lenght,"\n");
}

Measured memory_bytes: 4228
function Main (input) {
  var data = input.split("\n")
  var n = parseInt(data[0])
  var v = data[1].split(' ')

  function max (start) {
    var object1 = {}
    for (var i = start; i < n; i = i + 2) {
      if (!object1[v[i]]) {
        object1[v[i]] = 0
      }
      object1[v[i]]++
    }

    var m = maxObj(object1)

    return [m, object1]
  }

  function maxObj (object1) {
    var m = null
    var max = 0
    for (var k in object1) {
      if (object1[k] > max) {
        max = object1[k]
        m = k
      }
    }

    return m
  }


  var m0d = max(0)
  var m0 = m0d[0]
  var m0o = m0d[1]

  var m1d = max(1)
  var m1 = m1d[0]
  var m1o = m1d[1]

  if (m0 == m1) {
    var m0c = m0o[m0]
    var m1c = m1o[m1]

    delete m0o[m0]
    delete m1o[m1]

    var o0 = Object.keys(m0o).length === 0 ? 0 : m0o[maxObj(m0o)]
    var o1 = Object.keys(m1o).length === 0 ? 0 : m1o[maxObj(m1o)]

    if (m0c + o1 > m1c + o0) {
      console.log(n - m0c - o1)
    } else {
      console.log(n - m1c - o0)
    }

  } else {
    console.log(n - m0o[m0] - m1o[m1])
  }

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 41836
fn main() {
    q1();
}
fn q1() {
    fn read<T: std::str::FromStr>() -> T {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        s.trim().parse().ok().unwrap()
    }
    fn main() {
        let mut nk = read::<String>();
        let char_vec: Vec<char> = nk.chars().collect();
        for c in char_vec {
            if(c == '1') {
                print!("9");
            } else if(c == '9') {
                print!("1");
            } else {
                print!("{}", c);
            }
        }
        println!("")

    }
    main()
}

Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

type byX struct{ x, y, z []int }

func (b byX) Len() int           { return len(b.z) }
func (b byX) Less(i, j int) bool { return b.x[b.z[i]] < b.x[b.z[j]] }
func (b byX) Swap(i, j int)      { b.z[i], b.z[j] = b.z[j], b.z[i] }

type byY struct{ x, y, z []int }

func (b byY) Len() int           { return len(b.z) }
func (b byY) Less(i, j int) bool { return b.y[b.z[i]] < b.y[b.z[j]] }
func (b byY) Swap(i, j int)      { b.z[i], b.z[j] = b.z[j], b.z[i] }

type edge struct{ u, v, cost int }

type byE []edge

func (b byE) Len() int           { return len(b) }
func (b byE) Less(i, j int) bool { return b[i].cost < b[j].cost }
func (b byE) Swap(i, j int)      { b[i], b[j] = b[j], b[i] }

func (con *contest) main() error {
	var n int
	con.Scan(&n)
	x := make([]int, n)
	y := make([]int, n)
	z := make([]int, n)
	e := make([]edge, 0, n*2)
	for i := 0; i < n; i++ {
		con.Scan(&x[i], &y[i])
		z[i] = i
	}
	sort.Sort(byX{x, y, z})
	for i := 0; i < n-1; i++ {
		c := x[z[i+1]] - x[z[i]]
		e = append(e, edge{z[i], z[i+1], c})
	}
	sort.Sort(byY{x, y, z})
	for i := 0; i < n-1; i++ {
		c := y[z[i+1]] - y[z[i]]
		e = append(e, edge{z[i], z[i+1], c})
	}
	sort.Sort(byE(e))
	g := make([]int, n)
	for i := 0; i < n; i++ {
		g[i] = i
	}
	res := 0
	for _, a := range e {
		u := a.u
		for u != g[u] {
			u = g[u]
		}
		v := a.v
		for v != g[v] {
			v = g[v]
		}
		if u != v {
			res += a.cost
			g[u] = v
			u = v
		}
		for i := a.u; i != u; i, g[i] = g[i], u {
		}
		for i := a.v; i != v; i, g[i] = g[i], v {
		}
	}
	con.Println(res)
	return nil
}


Measured memory_bytes: 10368
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    pair<pair<string, int>, int> S[110];
    int N; cin >> N;
    rep(i, N) {
        cin >> S[i].first.first >> S[i].first.second;
        S[i].first.second = -S[i].first.second;
        S[i].second = i;
    }
    sort(S, S + N);
    rep(i, N) {
        cout << S[i].second + 1 << endl;
    }

    return 0;
}


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

int main(){
  int N,M;
  cin>>N;
  string s;
  vector<string> vs;
  vector<int> vc;

  cin>>s;
  vs.push_back(s);
  vc.push_back(1);
  //cout<<"vs:"<<vs.size()<<endl;//1
  for (int i=1;i<N;i++){
    cin>>s;
    for (int j=0;j<vs.size();j++){
      if (s==vs.at(j)){
        vc.at(j)++;
        break;
      }
      if(j==vs.size()-1){
        vs.push_back(s);
        vc.push_back(1);
        break;//忘れていた
      }
    }
  }
  /*for (int i=0;i<vs.size();i++){
    cout<<vs.at(i)<<':'<<vc.at(i)<<endl;//orange：２：おかしい
  }*/
  cin>>M;
  for (int i=0;i<M;i++){
    cin>>s;
    for (int j=0;j<vs.size();j++){
      if (s==vs.at(j)){
        vc.at(j)--;
        break;
      }
      if(j==vs.size()-1){
        vs.push_back(s);
        vc.push_back(-1);
        break;
      }
    }
  }
  //float inf = std::numeric_limits<float>::infinity();
  int ans=0;
  //cout<<"vs:"<<vs.size()<<endl;//2:ok
  for (int i=0;i<vs.size();i++){
    //cout<<vc.at(i)<<endl;
    if (vc.at(i)>ans){
      ans=vc.at(i);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
using namespace std;
#define MAXH 101
#define MAXW 101
#define INF 1000
#define MAXN 100001

int N, M;



int main(){
    cin >> N;
    long long sum = 0;
    for(int i = 1;i <= N;i++){
        if(i % 5 != 0 && i % 3 != 0){
            sum += i;
        }
    }

    printf("%lld\n", sum);
    
    return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define dump(x) cerr << #x << "=" << x <<endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);

void solve()
{
	/*--------------------------*/

	int N; cin >> N;
	map<string, int> mp;
	rep(i, N) {
		string s; cin >> s;
		sort(all(s));
		mp[s]++;
	}
	int ans = 0;
	each(p, mp) {
		int ps = p.second;
		ans += ps * (ps - 1) / 2;
	}
	cout << ans << endl;

	/*--------------------------*/
}

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}

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

int main(){
    int n, m;
    cin >> n >> m;
    int arr[m];
    int brr[m];
    for(int i=0; i<m; i++){
        cin >> arr[i] >> brr[i];
    }
    sort(arr, arr+m, greater<int>());
    sort(brr, brr+m);
    
    int sonuc = brr[0] - arr[0];
    if(sonuc >=0){
        cout << sonuc +1;
    }
    else
    {
        cout << "0";
    }
    
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    char str[105]={0};
    scanf("%s", str);
    long len=strlen(str);

    ll ans=0;
    long i, k;
    for(i=0; i<(1<<(len-1)); i++) {
        ll sum=0;
        ll curr=str[0]-'0';
        for(k=0; k<len-1; k++) {
            if(i & (1<<k)) {
                sum += curr;
                curr = (str[k+1]-'0');
            }
            else {
                curr=curr*10+(str[k+1]-'0');
            }
        }
        sum += curr;
        ans += sum;
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 128
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto N = RD;
	auto X = RD-1;
	auto Y = RD-1;

	auto d = Y - X - 1;
	foreach (i; 1..N)
	{
		long ans;
		foreach (j; 0..N-1)
		{
			if (abs(X-j) < i)
			{
				auto remain = i - abs(X-j) - 1;
				auto p1 = j+i;
				auto p2 = Y-remain;
				auto p3 = Y+remain;
				if (remain == 0)
				{
					if (p2 > p1)
						ans += 2;
					else if (p1 < N)
						++ans;
				}
				else
				{
					if (p1 >= p3)
					{
						if (p1 < N)
							++ans;
					}
					else
					{
						if (p3 < N)
							++ans;

						if (p2 > p1)
							ans += 2;
						else if (p2 == p1)
							++ans;
					}
				}
			}
			else if (j+i < N)
				++ans;
			debug writeln("i:", i, " j:", j, " ans:", ans);
		}
		writeln(ans);
	}

	stdout.flush;
	debug readln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0)
    {
        if(b&1)
            res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)
        return true;
    while(d!=n-1)
    {
        x=(x*x)%n;
        d*=2;
        if(x==1)
            return false;
        if(x==n-1)
            return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)
        return false;
    if(n<=3)
        return true;
    ll d=n-1;
    while(d%2==0)
        d/=2;
    for(int i=0; i<k; i++)
    {
        if(!miller_rabin(d,n))
            return false;
    }
    return true;
}
int n;
string s;
ll ans = 0;

void solve(ll x,ll y){
    if(x==n+1){
        ans += y;
        return;
    }
    ll cur = 0;
    for(ll i=x;i<=n;i++){
        cur = (10*cur) + (s[i]-'0');
        solve(i+1,y+cur);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,y;
    cin>>n>>x>>y;
    ll div=x+y;
    n-=(2*y);
    ll rem=n%div;
    if(rem>=x)cout<<(n/div)+1<<endl;
    else cout<<n/div<<endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007

using namespace std;

long long fast_power(long long base, long long power) {
    long long result = 1;
    while(power > 0) {

        if(power % 2 == 1) {
            result = (result*base) %MOD;
        }
        base = (base * base) %MOD;
        power = power / 2;
    }
    return result;
}

int main()
{
    int n;
    cin>>n;
 ll x=0,y=1;
 x=fast_power(10,n);
 x-=fast_power(9,n);
 if(x<0)
    x+=MOD;
 x-=fast_power(9,n);
 if(x<0)
    x+=MOD;
 y=fast_power(8,n);
 cout<<(x%MOD+y%MOD)%MOD<<endl;


}


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

int main(){
  int n;
  cin >> n;
  
  int a[n+1];
  
  for(int i = 0;i<n;i++)cin >> a[i];
    sort(a,a+n);
  int ans  = 0;
  for(int i = 0;i<n-2;i++)
    for(int j = i+1;j<n-1;j++)
      for(int k = j+1;k<n;k++)
      {
        if(a[i]<a[j]+a[k] && a[j]<a[i]+a[k] && a[k]<a[i]+a[j])ans++;
        else break;
      }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		
		//N=10, S= "aabbbbaaca"なら
		//abacaになるので、５
		//先頭からみて、色が変わるところでカウントして、１足せばいい。
		
		int ans = 1;//最初から1足しておく。
		
		for(int i=0;i<S.length()-1;i++) {
			if(S.charAt(i)!=S.charAt(i+1)) {
				ans++;
			}
		}
		
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 24912
# coding: utf-8
import sys
import numpy as np


def main(argv=sys.argv):

    _ = int(input())

    numbers = np.array(list(map(int, input().split(' '))))

    i = 0

    while True:

        sousa = numbers % (2 ** (i + 1))

        if sum(sousa) != 0:

            break

        else:

            i += 1

    print(i)

    return 0


if __name__ == '__main__':
    sys.exit(main())


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

int main(void)
{
	map<string, int> count;

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (count.find(s) == count.end())
			count[s] = 1;
		else
			count[s]++;
	}

	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		string s;
		cin >> s;
		if (count.find(s) == count.end())
			count[s] = -1;
		else
			count[s]--;
	}

	int max = 0;
	for (auto x : count) {
		if (max < x.second)
			max = x.second;
	}

	cout << max << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n;
string s[200010];
set<string>st;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>s[i];
        st.insert(s[i]);
    }
    cout<<st.size()<<endl;
    return 0;
}


Measured memory_bytes: 25436
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<vector<P>> g(100005);
constexpr int INF = 1e9 + 9;

vector<int> dijkstra(vector<vector<P>> &g, int s) {
	vector<int> dist(g.size(), INF);

	priority_queue<P, vector<P>, greater<P>> Q;

	dist[s] = 0;
	Q.emplace(0, s);
	while (!Q.empty()) {
		int u = Q.top().se; Q.pop();
		for (auto x: g[u]) {
			int v, cost;
			tie(v, cost) = x;
			if (chmin(dist[v], dist[u] + cost)) Q.emplace(dist[v], v);
		}
	}

	return dist;
}

int main(void) {
	int n, m, r;
	cin >> n >> m >> r;
	rep (i, m) {
		int s, t, d;
		cin >> s >> t >> d;
		g[s].eb(t, d);
	}

	vector<int> ans = dijkstra(g, r);

	rep (i, n) {
		if (ans[i] == INF) cout << "INF" << endl;
		else cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 13036
import heapq
class PriorityQueue:
	def __init__(self,num_list=None,reverse=False):
		self.reverse = reverse
		self.heap = []
		if num_list != None :
			for num in num_list:
				self.push(num)

	def push(self,num):
		heapq.heappush(self.heap,-num if self.reverse else num)

	def pop(self):
		num = heapq.heappop(self.heap)
		return -num if self.reverse else num
	
	def get_heap(self):
		return list(map(lambda x: x*(-1),self.heap))

n,m = map(int,input().split())
items = list(map(int,input().split()))
pq = PriorityQueue(num_list=items,reverse=True)

while m>0:
	item = pq.pop()
	pq.push(int(item/2))
	m -= 1
print(sum(pq.get_heap()))

Measured memory_bytes: 15176
import collections


def main(N, D):
    Dcounter = collections.Counter(D)
    a = [0, 24]
    b = []
    for i, v in Dcounter.items():
        if v > 2 or (i == 0 and v > 0) or (i == 12 and v > 1):
            print(0)
            return

        if v == 2:
            a.append(i)
            a.append(24-i)
        if v == 1:
            b.append(i)
    ans = 0
    for i in range(1 << len(b)):
        use = a.copy()
        for j in range(len(b)):
            if ((i >> j) & 1) == 1:
                use.append(b[j])
            else:
                use.append(24-b[j])
        use = sorted(use)
        distance = [use[i+1] - use[i] for i in range(len(use)-1)]
        ans = max(ans, min(distance))
    print(ans)

if __name__ == "__main__":
    N = int(input())
    D = list(map(int, input().split(" ")))
    main(N, D)


Measured memory_bytes: 3316
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

a,b = m()

co = 0

if a == 1:
    co += 300000
if b == 1:
    co += 300000
if a == 2:
    co += 200000
if b == 2:
    co += 200000
if a == 3:
    co += 100000
if b == 3:
    co += 100000
if a == 1 and b == 1:
    co += 400000
print(co)



Measured memory_bytes: 38384
use std::cmp;
use std::collections::*;
use std::io::{self, Read};

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock());

    let mut pqr: Vec<u32> = sc.read_vec(3).unwrap();
    pqr.sort();

    println!("{}", pqr[0] + pqr[1]);
}

struct Scanner<R: Read> {
    reader: R,
}

impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: std::str::FromStr>(&mut self) -> Option<T> {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse()
            .ok()
    }

    fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Option<Vec<T>> {
        (0..n).map(|_| self.read()).collect()
    }

    fn read_vec2d<T: std::str::FromStr>(&mut self, m: usize, n: usize) -> Option<Vec<Vec<T>>> {
        (0..m).map(|_| self.read_vec(n)).collect()
    }

    fn read_board(&mut self, n: usize) -> Option<Vec<Vec<char>>> {
        (0..n)
            .map(|_| {
                self.read::<String>()
                    .map(|s| s.chars().collect::<Vec<char>>())
            })
            .collect()
    }
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<algorithm>
#include<memory.h>
#include<vector>
#include<stdio.h>
#include<cstdlib>
#include<map>
#include <set>
#include<stack>
#include<cmath>
#include<queue>
#include<bitset>
using namespace std;
typedef long long ll;
const int inf = 1e9;
const int MOD = 1e9 + 7;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
const int N = 1e9 + 1;

int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };
char st[51][51];
int main() {
	int h, w; 
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; i++)
		scanf("%s", st[i]);

	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++){
			if (st[i][j] != '#')
				continue;
			bool bl = false;
			for (int k = 0; k < 4; k++){
				int tx = i + dx[k];
				int ty = j + dy[k];
				if (tx < 0 || ty < 0 || tx >= h || ty >= w || st[tx][ty] != '#')
					continue;
				bl = true; 
				break;
			}
			if (!bl){
				puts("No");
				return 0;
			}
		
		}
	puts("Yes");
	return 0;
}
	


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#include<iomanip>
#define rep(i,x) for(int i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 1001001001;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}


int main() {
    ll N, K;
    cin >> N >> K;
    ld ans = 0;
    for (int i = 1; i <= N; i++) {
        ll cnt = i;
        ld per = 1;
        while (cnt < K) {
            cnt *= 2;
            per /= 2;
        }
        ans += per;
    }
    cout << setprecision(12) << ans / N << endl;
}


Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    b = list(map(int, readline().split()))
    c = list(map(int, readline().split()))
    le = -10 ** 10
    t = 0
    for av in a:
        t += b[av-1]
        if av - le == 1:
            t += c[le-1]
        le = av
    print(t)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
# coding: utf-8
alphabet = 'abcdefghijklmnopqrstuvwxyz'
S = ''
while True:
    try:
        n = input()
        S += n
    except EOFError:
        break
ans_dict = {}
for char in alphabet:
    ans_dict[char] = S.count(char)
    ans_dict[char] += S.count(char.upper())
for k, v in sorted(ans_dict.items(), key=lambda x: x[0]):
    print('{} : {}'.format(k, v))

Measured memory_bytes: 7512
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

char grid[10][10];

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> n >> m >> k)
    {
		for(ll i = 0; i < n; i++) scanf("%s", grid[i]);

		ans = 0;

		for(ll i = 0; i < (1 << n); i++)
		{
			for(ll j = 0; j < (1 << m); j++)
			{
				ll cnt = 0;
				for(ll ii = 0; ii < n; ii++)
				{
					if(check(i,ii)) continue;

					for(ll jj = 0; jj < m; jj++)
					{
						if(check(j,jj)) continue;

						cnt += grid[ii][jj] == '#';
					}
				}

				if(cnt == k) ans++;
			}
		}

		cout << ans << '\n';
    }


}






Measured memory_bytes: 3716
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define per(i,n) for (int i = n - 1; i >= 0; --i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout() cout << std::fixed << std::setprecision(20);
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
static const double pi = 3.141592653589793;

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

  string s; cin >> s;
  int n = s.size() + 1;

  vector<ll> cnt(n, 0);

  rep(i, n - 1) {
    if(s[i] == '<') {
      chmax(cnt[i + 1], cnt[i] + 1);
    }
  }

  per(i, n - 1) {
    if(s[i] == '>') {
      chmax(cnt[i], cnt[i + 1] + 1);
    }
  }

  ll ans = 0;
  rep(i, n) {
    ans += cnt[i];
  }

  cout << ans << endl;
}


// < > > > < < > < < < < < > > > <
// 0 3 2 1 0 1 2 0 1 2 3 4 5 2 1 0



// < < < < <
// 0 1 2 3 4

// > > > > >
// 4 3 2 1 0

// < < < > >
// 0 1 2 3 1


Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define inf 1000000000
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define meM(y,a) memset(y,a,sizeof y)
#define sC(a) scanf("%d",&a)
#define alL(a) a.begin(),a.end()
#define prinT(a,sz)  cout<<a[0];for(int i=1;i<sz;i++)cout<<" "<<a[i];cout<<endl
#define ranD srand(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int>pi;
typedef pair<ll,ll>pll;
//int fx[]={0,0,1,-1};
//int fy[]={1,-1,0,0};
//int gx[]={0,0,1,1,1,-1,-1,-1};
//int gy[]={1,-1,0,1,-1,0,1,-1};
const int N=1000100;
vector<ll>v;
ll a[N],b[N],c[N];
int main()
{
    IOS;
    int x,y;
    cin>>x>>y;
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<m;i++)cin>>b[i];
    for(int i=0;i<k;i++)cin>>c[i];
    sort(a,a+n);
    sort(b,b+m);
    sort(c,c+k);
    for(int i=n-1;i>=n-x;i--)v.pb(a[i]);
    for(int i=m-1;i>=m-y;i--)v.pb(b[i]);
    for(int i=k-1;i>=max(k-x-y,0);i--)
        v.pb(c[i]);
    sort(alL(v));
    ll res=0;
    for(int i=v.size()-1;i>=v.size()-x-y;i--)
        res+=v[i];
    cout<<res<<endl;
}








Measured memory_bytes: 9720
from collections import Counter
N, K = map(int, input().split())

cnt = Counter()
for _ in range(N):
    a, b = map(int, input().split())
    cnt[a] += b

x = list(cnt.items())
x.sort()

now = 0
for k, v in x:
    now += v
    if K <= now:
        print(k)
        break

Measured memory_bytes: 20416
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k; cin >> n >> k;
	string s = "";
	int ans = 0;
	while (n >= 1) {
		ans++;
		n /= k;
	}
	dunk(ans);
	return 0;
}

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

int main(void){
    int a;
    int b;
    int m;
    int xm[100000];
    int ym[100000];
    int cm[100000];
    int ai[100000];
    int bi[100000];
    int x=100000;
    int y=100000;

    scanf("%d %d %d",&a,&b,&m);
    for(int i=0; i<a; i++){
        scanf("%d",&ai[i]);
        x=fmin(x,ai[i]);
    }
    for(int i=0; i<b; i++){
        scanf("%d",&bi[i]);
        y=fmin(y,bi[i]);
    }
    int s=x+y;
    for(int i=0; i<m; i++){
        scanf("%d %d %d",&xm[i],&ym[i],&cm[i]);
        s=fmin(s,(ai[xm[i]-1]+bi[ym[i]-1]-cm[i]));
    }
    printf("%d",s);
    
}

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

using namespace std;

#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)

const static llong MOD = 1000000000 + 7;

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

    llong n, m;
    cin >> n >> m;
    llong big = max(n, m), small = min(n, m);
    llong ans;
    if (big - small == 1) {
        llong tmp1 = big % MOD, tmp2 = small % MOD;
        for (llong i = big - 1; i >0; --i) {
            tmp1 = (tmp1 * i) % MOD;
        }
        for (llong i = small - 1; i >0; --i) {
            tmp2 = (tmp2 * i) % MOD;
        }
        ans = (tmp1 * tmp2) % MOD;
    } else if (big - small == 0) {
        llong tmp1 = big % MOD, tmp2 = small % MOD;
        for (llong i = big - 1; i >0; --i) {
            tmp1 = (tmp1 * i) % MOD;
        }
        for (llong i = small - 1; i >0; --i) {
            tmp2 = (tmp2 * i) % MOD;
        }
        ans = (2 * tmp1 * tmp2) % MOD;
    } else {
        ans = 0;
    }

    cout << (llong)ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int h,w,i,j;
 
  while(1){
    scanf("%d%d",&h,&w);
 
    if(!h&&!w)
    return 0;
 
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
    if(i==0||i==h-1||j==0||j==w-1)
      printf("#");
    else
      printf(".");
      }
      printf("\n");
    }      
    printf("\n");
  }
}

Measured memory_bytes: 572
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int main()
{
    int N; cin >> N;
    vector< vector<int> > happy(N, {0, 0, 0});
    for(auto &line : happy) cin >> line.at(0) >> line.at(1) >> line.at(2);

    vector< vector<int> > dp(N, {0, 0, 0});
    dp.at(0) = happy.at(0);
    for(int i = 1; i < N; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            for(int k = 0; k < 3; k++)
            {
                if(j != k) dp.at(i).at(j) = max(dp.at(i).at(j), dp.at(i-1).at(k) + happy.at(i).at(j));
            }
        }
    }
    cout <<  max(max(dp.at(N-1).at(0), dp.at(N-1).at(1)), dp.at(N-1).at(2))<< endl;

}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
  int64_t n, a, b;
  cin >> n >> a >> b;
  int64_t m = b-a; 
  if(m%2==0) cout << m/2 << endl;
  else{
    //int64_t s = min(n-b+1, a);
    int64_t nb = n-b+1;
    //if(a<nb) cout << a+(m-a)/2 << endl;
    //else cout << nb+(m-nb)/2 << endl;
    cout << min(nb+m/2, a+m/2) << endl;
    
  } 
  
}

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


int eval(const string& s, int &pos)
{
	if(s[pos] == '0') { ++pos; return 0; }
	if(s[pos] == '1') { ++pos; return 1; }
	if(s[pos] == '2') { ++pos; return 2; }
	if(s[pos] == '-') { ++pos; int v = eval(s, pos); return 2 - v;}
	if(s[pos] == '(') {
		++pos;
		int a = eval(s,pos);
		// evalの値には計算済みの値が帰ってくるはずだ
		char c = s[pos++];
		int b = eval(s,pos);
		++pos;
		if(c == '*') {return (a * b + 1) / 2; }
		if(c == '+') {return max(a, b); }
	}
	return 2;
}



int main (void)
{
	while(true)
	{
		string s, temp;
		cin >> s;
		if(s == ".") break;
		string p, q, r;
		int count = 0;
		int pos;
		
		for(int j = 0; j < 3; j++){
			if(j == 0) p = '0'; if(j == 1) p = '1'; if(j == 2) p = '2';
			for(int k = 0; k < 3; k++){
				if(k == 0) q = '0'; if(k == 1) q = '1'; if(k == 2) q = '2';
				for(int l = 0; l < 3; l++){
					if(l == 0) r = '0'; if(l == 1) r = '1'; if(l == 2) r = '2';
					temp = s;
					pos = 0;
					for(int i = 0; i < s.length(); i++){
						if(s.at(i) == 'P') { temp.replace(i, 1, p); }
						if(s.at(i) == 'Q') { temp.replace(i, 1, q); }
						if(s.at(i) == 'R') { temp.replace(i, 1, r); }
					}
					if(eval(temp, pos) == 2) count++;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}


Measured memory_bytes: 3144
N = int(input())
cards = list(map(int,input().split()))
cards_sort = sorted(cards,reverse = True)
Alice = 0
Bob = 0
for i in range(0,N,2):
    Alice += cards_sort[i]
for i in range(1,N,2):
    Bob += cards_sort[i]

ans  =Alice - Bob
print(ans)


Measured memory_bytes: 3060
module z_algorithm
contains
  function character_z_algorithm(s) result(res)
    character(*) :: s
    integer :: res(len_trim(s)), n, i, j, k
    res = 0
    n = len_trim(s)
    res(1) = n
    i = 1
    j = 0
    do while (i < n)
      do while (i + j < n .and. s(j + 1:j + 1) == s(i + j + 1:i + j + 1))
        j = j + 1
      end do
      res(i + 1) = j
      if (j == 0) then
        i = i + 1
        cycle
      end if
      k = 1
      do while (i + k < n .and. k + res(k + 1) < j)
        res(i + k + 1) = res(k + 1)
        k = k + 1
      end do
      i = i + k
      j = j - k
    end do
  end
  function integer_z_algorithm(s) result(res)
    integer :: s(:)
    integer :: res(size(s)), n, i, j, k
    res = 0
    n = size(s)
    res(1) = n
    i = 1
    j = 0
    do while (i < n)
      do while (i + j < n .and. s(j + 1) == s(i + j + 1))
        j = j + 1
      end do
      res(i + 1) = j
      if (j == 0) then
        i = i + 1
        cycle
      end if
      k = 1
      do while (i + k < n .and. k + res(k + 1) < j)
        res(i + k + 1) = res(k + 1)
        k = k + 1
      end do
      i = i + k
      j = j - k
    end do
  end
end module z_algorithm
program xor_shift
  use z_algorithm
  implicit none
  integer :: n, i
  integer, dimension(200000) :: a = 0, b = 0
  integer, dimension(600000) :: s = 0, z = 0
  read(*,*) n
  read(*,*) a(1:n)
  read(*,*) b(1:n)
  do i = 1, n - 1
    s(i) = xor(b(i), b(i + 1))
    s(i + n) = xor(a(i), a(i + 1))
  end do
  s(n) = xor(b(n), b(1))
  s(2 * n) = xor(a(n), a(1))
  do i = 1, n - 1
    s(i + 2 * n) = s(i + n)
  end do
  z(1:3 * n - 1) = integer_z_algorithm(s(1:3 * n - 1))
  do i = 1, n
    if (z(i + n) >= n) then
      write(*,'(i0,x,i0)') i - 1, xor(a(i), b(1))
    end if
  end do
end program xor_shift

Measured memory_bytes: 10476
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
string str;
cin>>str;
int ans = 0;
for(int i = 0 ; i < n ; i++){
	int r = 0 , b = 0 , g = 0 , fr = 0 , fb = 0 , fg = 0;
       int j = i-1 ; 
     while(j >= 0){
		 if(str[j] != str[i]){
		     if(str[j] == 'B')b++;
		     if(str[j] == 'G')g++;
		     if(str[j] == 'R')r++;
		 }
		 j--;
	 }
	 j = i+1;
	 while(j < n){
	   if(str[j] != str[i]){
	         if(str[j] == 'B')fb++;
		     if(str[j] == 'G')fg++;
		     if(str[j] == 'R')fr++;
	   }
	   j++;
	 }
	 if(str[i] == 'R'){
	    ans += b*fg;
	    ans += g*fb;
	 }
	 if(str[i] == 'G'){
	   ans += b*fr;
	   ans += r*fb;
	 }
	 if(str[i] == 'B'){
	    ans += g*fr;
	    ans += r*fg;
	 }
}
for(int i = 0 ; i < n ;i++){
   int j = i-1;
   while(j >= 0){
        if(str[j] != str[i]){
			if(2*i - j < n)
		  if(str[j] != str[i-j + i] && str[i-j+i] != str[i])ans--;
		}
		j--;
   }
}
cout<<ans;
}


Measured memory_bytes: 3652
import Data.List.Split

main :: IO ()
main = do
  s <- getLine
  putStrLn $ (judge . format) s
  
  where
    format :: String -> [Int]
    format s = map read $ splitOneOf "/" s

    judge :: [Int] -> String
    judge [y, m, d]
      | y < 2019 = "Heisei"
      | m <= 4 = "Heisei"
      | otherwise = "TBD"


Measured memory_bytes: 508