akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strings"
)

const mod = 2019

var logger = log.New(os.Stderr, "", 0)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	s := io.Next()
	ans := solve(s)
	io.Println(ans)
}

func solve(s string) (ans int) {
	n := len(s)
	a := make([]int, n)
	pow := 1
	for i := range a {
		digit := int(s[n-1-i] - '0')
		a[n-1-i] = digit * pow % mod
		pow = pow * 10 % mod
	}
	cs := make([]int, n+1)
	for i := range a {
		cs[i+1] = (cs[i] + a[i]) % mod
	}
	cnt := map[int]int{}
	for i := range cs {
		ans += cnt[cs[i]]
		cnt[cs[i]]++
	}
	logger.Println("s", s)
	logger.Println("a", a)
	logger.Println("cs", cs)
	logger.Println("cnt", cnt)
	return ans
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 13300
#include <stdio.h>
#include <string.h>

int main(void){
  int i,j,to,sum;
  char x[10010];
  char cmp[2][4]={"JOI","IOI"};

  while(scanf("%s",x) != EOF){
    to = strlen(x)-2;
    for(i=0;i<2;i++){
      for(j=sum=0;j<to;j++){
	if(!strncmp(&x[j],cmp[i],3)) sum++;
      }
      printf("%d\n",sum);
    }
  }

  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>
#include <string>
#include <tuple>
#include <set>
#include <queue>

template <typename Weight>
struct edge {
  using value_type = Weight;
  size_t src, dst;
  value_type cost;

  edge(size_t src, size_t dst, value_type cost = 1):
    src(src), dst(dst), cost(cost)
  {}

  bool operator <(edge<value_type> const& rhs) const {
    if (cost != rhs.cost) return cost < rhs.cost;
    if (src != rhs.src) return src < rhs.src;
    return dst < rhs.dst;
  }
};

template <typename Weight>
struct graph: public std::vector<std::vector<edge<Weight>>> {
  using value_type = Weight;
  graph(size_t n): std::vector<std::vector<edge<value_type>>>(n) {}

  void connect_to(size_t src, size_t dst, value_type cost = 1) {
    (*this)[src].emplace_back(src, dst, cost);
  }

  void connect_with(size_t src, size_t dst, value_type cost = 1) {
    connect_to(src, dst, cost);
    connect_to(dst, src, cost);
  }
};

template <class Tp>
constexpr Tp inf = Tp(1) << (8*sizeof(Tp)-3);

template <class Tp, class Compare>
using priority_queue = std::priority_queue<Tp, std::deque<Tp>, Compare>;

template <class Weight>
std::vector<Weight> shortest(const graph<Weight>& g, size_t s) {
  // based on Dijkstra algorithm
  std::vector<Weight> res(g.size(), inf<Weight>);
  priority_queue<std::pair<Weight, size_t>, std::greater<>> q;
  res[s] = 0;
  q.emplace(0, s);
  while (!q.empty()) {
    Weight w;
    size_t v;
    std::tie(w, v) = q.top();
    q.pop();
    if (w > res[v]) continue;

    for (const auto& e: g[v]) {
      if (res[e.dst] > w + e.cost) {
        res[e.dst] = w + e.cost;
        q.emplace(res[e.dst], e.dst);
      }
    }
  }
  return res;
}

using vertex = std::tuple<int, int, size_t>;

int main() {
  size_t N, M;
  scanf("%zu %zu", &N, &M);

  graph<int> g(N);
  for (size_t i = 0; i < M; ++i) {
    size_t u, v;
    scanf("%zu %zu", &u, &v);
    --u;
    --v;
    g.connect_to(u, v);
  }

  size_t S, T;
  scanf("%zu %zu", &S, &T);
  --S;
  --T;

  int res = inf<int>;

  std::vector<std::vector<int>> d(N, std::vector<int>(3, inf<int>));
  d[S][0] = 0;
  std::priority_queue<vertex, std::vector<vertex>, std::greater<vertex>> q;
  q.emplace(0, 0, S);
  while (!q.empty()) {
    int w;
    int h;
    size_t v;
    std::tie(w, h, v) = q.top();
    q.pop();
    if (d[v][h] < w) continue;

    for (auto const& e: g[v]) {
      size_t nv = e.dst;
      int nh = (h + 1) % 3;
      int nw = w + e.cost;
      if (d[nv][nh] > nw) {
        d[nv][nh] = nw;
        q.emplace(nw, nh, nv);
      }
    }
  }

  // for (size_t i = 0; i < 3; ++i)
  //   for (size_t j = 0; j < N; ++j)
  //     fprintf(stderr, "%d%c", d[j][i], j+1<N? ' ':'\n');

  if (d[T][0] < inf<int>) {
    printf("%d\n", d[T][0] / 3);
  } else {
    puts("-1");
  }
}


Measured memory_bytes: 11136
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *AF = map(int, read().split())
    A = AF[:N]
    F = AF[N:]

    A.sort()
    F.sort(reverse=True)
    C = [a * f for a, f in zip(A, F)]

    def is_ok(cost):
        k = 0
        for c, f in zip(C, F):
            if c > cost:
                k += (c - cost + f - 1) // f
        return k <= K

    ok = max(C)
    ng = -1
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid

    print(ok)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 138360
s=[]
p=[]
a=i=0
for c in input():
 if"\\"==c:s+=[i]
 elif"/"==c and s:
  j=s.pop()
  t=i-j
  a+=t
  while p and p[-1][0]>j:t+=p[-1][1];p.pop()
  p+=[(j,t)]
 i+=1
print(a)
if p:print(len(p),*list(zip(*p))[1])
else:print(0)


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

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* main */
void Main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    for (int i = a; i <= b; i++)
    {
        if (c % i == 0)
            ans++;
    }
    cout << ans << endl;
}

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

    return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
int32_t main(){
    SPEED;
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = a - b;
    if(k & 1){
        cout << -ans;
    }
    else{
        cout << ans;
    }
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<numeric>
#include<queue>

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w, n, a;
	cin >> h >> w >> n;
	vector<int> ans;
	for (int i = 1; i <= n; i++) {
		cin >> a;
		for (int j = 0; j < a; j++) {
			ans.push_back(i);
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (i % 2) {
				cout << ans[i*w + (w-1-j)];
			}
			else {
				cout << ans[i*w + j];
			}
			if (j < w - 1) cout << " ";
		}
		cout << "\n";
	}

	return 0;
}

Measured memory_bytes: 384
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main (void) {
    int i;
    int n, m;
    int s, c;
    int num[3] = {-1, -1, -1};
    int ans=0;

    scanf("%d%d", &n, &m);

    if ( n == 1 ) {
        for ( i=0; i<m; i++ ) {
            scanf("%d%d", &s, &c);
            if ( num[s-1] == -1 )
                num[s-1] = c;
            else if ( num[s-1] != c )
                goto NOTEXIST;
        }
    }
    else {
        for ( i=0; i<m; i++ ) {
            scanf("%d%d", &s, &c);
            if ( num[s-1] == -1 )
                num[s-1] = c;
            else if ( num[s-1] != c )
                goto NOTEXIST;
        }
        if ( num[0] == -1 )
            num[0] = 1;
        if ( num[0] == 0 )
            goto NOTEXIST;
    }

    for ( i=0; i<n; i++ ) {
        if ( num[i] == -1 )
            continue;
        ans += pow(10, (n-i-1))*num[i];
    }

    printf("%d\n", ans);
    return EXIT_SUCCESS;
NOTEXIST:
    printf("-1\n");
    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        new Magatro().Solve();
    }
}

public class Magatro
{
    private long N, M;
    private long[] X, Y;
    const int Mod = 1000000007;
    public void Solve()
    {
        string[] s = Console.ReadLine().Split(' ');
        N = long.Parse(s[0]);
        M = long.Parse(s[1]);
        X = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        Y = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        long xS = 0;
        for(int i = 0; i < N; i++)
        {
            xS += (i*X[i]-(N-i+-1)*X[i]);
            xS %= Mod;
        }
        long yS = 0;
        for (int i = 0; i < M; i++)
        {
            yS += (i * Y[i] - (M - i-1) * Y[i]);
            yS %= Mod;
        }
        Console.WriteLine(xS * yS % Mod);
    }

    public void S()
    {
        string[] s = Console.ReadLine().Split(' ');
        N = long.Parse(s[0]);
        M = long.Parse(s[1]);
        s = Console.ReadLine().Split(' ');
        long x = long.Parse(s[N - 1]) - long.Parse(s[0]);
        s = Console.ReadLine().Split(' ');
        long y = long.Parse(s[M - 1]) - long.Parse(s[0]);
        long sq = (x * y);
        long ans = 0;
        for (int i = 0; i < 100000; i++)
        {
            ans = (sq * i) % Mod;
            if (ans == 835067060)
            {
                Console.WriteLine(i);
                return;
            }
        }
    }
}

Measured memory_bytes: 39204
import java.util.*;
public class Main {
  public static void main(String[] args) {
	Scanner in=new Scanner(System.in);
	int a=in.nextInt();
	int b=in.nextInt();
	int h=in.nextInt();
	int area=(a+b)*h/2;
	System.out.println(area);
}
}


Measured memory_bytes: 26904
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll,ll>
#define msi         map<string,ll>
#define mis         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define max(a,b)	(a>b?a:b)
#define min(a,b)	(a<b?a:b)

/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  100005

void solve()
{
	ll x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	vii v;
	ll z;
	rep(i,0,a)
	{
		cin>>z;
		v.pb({z,1});
	}
	rep(i,0,b)
	{
		cin>>z;
		v.pb({z,2});
	}
	rep(i,0,c)
	{
		cin>>z;
		v.pb({z,0});
	}
	sort(all(v));
	reverse(all(v));
	vi aa(3,0);
	ll ans=0;
	trav(i,v)
	{
		if(i.S==0)
		{
			aa[0]++;
			ans+=i.F;
		}
		else if(i.S==1)
		{
			if(aa[i.S]<x)
			{
				aa[i.S]++;
				ans+=i.F;
			}
		}
		else
		{
			if(aa[i.S]<y)
			{
				aa[i.S]++;
				ans+=i.F;
			}
		}
		if(aa[0]+aa[1]+aa[2]==x+y)
		{
			cout<<ans<<endl;
			return;
		}
	}
	return;
}
int main()
{
	FAST
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

Measured memory_bytes: 10348
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 998244353;
const ll  N = 2e5 + 5;

ll n,m,l[N],r[N],f[N],pre[N];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    for(int i=1;i<=m;i++) cin>>l[i]>>r[i];
    f[1]=pre[1]=1;
    for(int i=2;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(i>l[j]){
                f[i]=(f[i]+pre[i-l[j]]-pre[max(i-r[j]-1, 0ll)]+mod)%mod;
            }
        }
        pre[i]=(pre[i-1]+f[i])%mod;
        // cout<<"f["<<i<<"]="<<f[i]<<" pre["<<i<<"]="<<pre[i]<<'\n';
    }
    cout<<f[n]<<'\n';
    return 0;
}

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

#define ll long long



using namespace std;

string s;

int n;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    n = s.size();
    s = " " + s;
    int ans = n;
    for(int i = 1; i <= n; i++)
    {
        if(s[i] == s[i - 1])
        {
            ans--;
            i += 2;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 788
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;

#define MAX_N 1000001

int main() {

  // ---------------------
  // Input
  
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;

  ll sum = 0;

  for(int i = 1; i <= N; i++) {
  
    if (i % 3==0 || i % 5 == 0) {
      continue;
    }
    else sum += i;
    
  }
  
  cout << sum << endl;
  
  return 0;
  
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
    int N, W;
    cin >> N >> W;
    vector<pair<ll, ll>> wv(N);
    // i番目までの品物で、重さの総和がw以下での価値の総和の最大
    // dp[i][j] := i番目までの品物、重さがj以下のものの価値
    ll dp[105][100500];
    rep(i, N+4)rep(j, W+4) dp[i][j] = -1;
    rep(i, W+1) dp[0][i] = 0;

    rep(i, N){
        ll w, v;
        cin >> w >> v;
        wv[i] = make_pair(w, v);
    }
    rep(i, N)rep(j, W+1){
        pair<ll, ll> tmp = wv[i];
        if (j-tmp.first>=0) chmax(dp[i+1][j], dp[i][j-tmp.first] + tmp.second);
        
        chmax(dp[i+1][j], dp[i][j]);
    }

    cout << dp[N][W] << endl;

    return 0;
}


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

int main() {
    int64_t n, k; cin >> n >> k;
    int64_t ans;
    int64_t m = n/k;
    ans = m*m*m;
    if(k%2 == 0){
        int64_t l = (n+k/2)/k;
        ans += l*l*l;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <tuple>
#include <algorithm>

using namespace std;

typedef tuple<int, int, int, int> RECORD;

class Team
{
public:
	int _id;
	int _time;
	int _solveNum;
	vector<int> _probs;

	void init(int i, int M, int P, int R)
	{
		_id = i;
		_time = 0;
		_solveNum = 0;
		_probs.resize(P+1, 0);
	}

	void in(int time, int probNum, int b)
	{
		if (!b){
			_time += _probs[probNum] * 20 + time;
			_solveNum++;
		}
		else{
			++_probs[probNum];
		}
	}

	void dump() const
	{
		cout << "id=" << _id;
		cout << "time=" << _time;
		cout << "solvenum=" << _solveNum;
	}

	bool operator==(const Team& r)
	{
		if ( this->_solveNum == r._solveNum && this->_time == r._time ){
//			this->dump();
//			r.dump();
			return true;
		}
		return false;
	}
};

int main()
{
	while(1){
		int M, T, P, R;

		cin >> M >> T >> P >> R;
		if ( M+T+P+R == 0)
			break;
//		if ( R <= 0)
//			continue;

		vector<Team> teams(T);
		for(int i=0; i<T; ++i){
			teams[i].init(i+1, M, P, R);
		}

		for(int i=0; i<R; ++i){
			int time, teamNum, probNum, ret;
			cin >> time >> teamNum >> probNum >> ret;
			teams[teamNum-1].in(time, probNum, ret);
		}

		sort(teams.begin(), teams.end(), [](Team t1, Team t2) -> bool{
			int a = t1._solveNum - t2._solveNum;

			if (a > 0)
				return true;

			if (a < 0)
				return false;
			
			if ( t1._time < t2._time)
				return true;

			if (t1._time > t2._time)
				return false;

			if (t1._id > t2._id)
				return true;

			return false;
		});

		auto it = teams.begin();
		cout << (*it)._id;
		for(it += 1; it != teams.end(); ++it)
		{
			if ( *(it-1) == *(it) )
				cout << "=";
			else
				cout << ",";
			cout << (*it)._id;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1228
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <cstdio>

using namespace std;

typedef pair<int, int> Point;

map<int, int> ans;
bool data[1000][80];
int h, w, pi, dy[] = {-1, -1, 0, 1, 1, 1, 0, -1}, dx[] = {0, 1, 1, 1, 0, -1, -1, -1};
Point p[4];

bool check(int y, int x){
  if(y<0 || y>=h) return false;
  if(x<0 || x>=w) return false;
  return true;
}

void dfs(int y, int x, int di){
  data[y][x] = false;
  int ny = y + dy[di];
  int nx = x + dx[di];
  if(!check(ny, nx) || !data[ny][nx]){
    p[pi++] = Point(y, x);
    for(int i=0;i<7;i++){
      di = (di + 1) % 8;
      ny = y + dy[di];
      nx = x + dx[di];
      if(!check(ny, nx)) continue;
      if(data[ny][nx]){
        dfs(ny, nx, di);
        return;
      }
    }
  }else{
    dfs(ny, nx, di);
  }
}

void solve(){
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(data[i][j]){
        pi = 1;
        p[0] = Point(i, j);
        dfs(i, j, 2);
        ans[(p[3].first-p[0].first+1) * (p[1].second-p[0].second+p[2].second-p[3].second+2) / 2]++;
      }
    }
  }
}

main(){
  bool f = true;
  while(cin >> h && h){
    getchar();
    if(!f) cout << "----------" << endl;
    else f = false;
    ans.clear();
    fill(data[0], data[1000], false);
    for(int i=0;i<h;i++){
      string in;
      getline(cin, in);
      w = max(w, (int)in.size());
      for(int j=0;j<in.size();j++){
        if(in[j] == '*') data[i][j] = true;
      }
    }
    solve();
    map<int, int>::iterator ite = ans.begin();
    while(ite != ans.end()){
      cout << ite->first << ' ' << ite->second << endl;
      ite++;
    }
  }
}

Measured memory_bytes: 0
A, B, M = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
x = [0 for i in range(M)]
y = [0 for i in range(M)]
c = [0 for i in range(M)]
for i in range(M):
  x[i], y[i], c[i] = map(int, input().split())
non_coupon_val = min(a) + min(b)
coupon_val_arr = [0 for i in range(M)]
for i in range(M):
  coupon_val_arr[i] = a[x[i]-1] + b[y[i]-1] - c[i]
coupon_val = min(coupon_val_arr)
print(min([non_coupon_val, coupon_val]))

Measured memory_bytes: 27364
S = list(input())
T = list(input())
D = S*2
flag = 0

for i in range(len(T)):
    for j in range(len(T)):
        if D[i+j] != T[j]:
            break
    else:
        flag = 1

def yn(p):
    if p:
        return "Yes"
    else:
        return "No"
print(yn(flag == 1))

Measured memory_bytes: 39024
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;






int main(){
    ll n,l,t;
    cin>>n>>l>>t;
    vector<pll> a(n);
    ll cnt=0;
    for(auto &i:a){
        cin>>i.F>>i.S;
        if(i.S!=a[0].S){
            ll dist;
            if(a[0].S==1){
                dist=i.F-a[0].F;
            }
            else{
                dist=a[0].F+l-i.F;
            }
            ll move=2*t;
            if(dist<=move){move-=dist; cnt++; cnt+=move/l;}
        }
    }
    cnt%=n;
    if(a[0].S==2){
        cnt=n-cnt;
        cnt%=n;
        vector<pll> W(n);
        for(int i=0;i<n;i++){
            W[i].S=i;
            if(a[i].S==1){
                W[i].F=(a[i].F+t)%l;
            }
            else{
                W[i].F=(a[i].F-t)%l;
                if(W[i].F<0){W[i].F+=l;}
            }
        }
        sort(W.begin(),W.end());
        ll s=-1;
        for(int i=0;i<n;i++){
            if(W[i].S==0){s=(i-cnt+n)%n;}
        }
        for(ll i=s;i<n;i++){
            cout<<W[i].F<<endl;
        }
        for(ll i=0;i<s;i++){
            cout<<W[i].F<<endl;
        }
    }
    else{
        vector<pll> W(n);
        for(int i=0;i<n;i++){
            W[i].S=n-i;
            if(a[i].S==1){
                W[i].F=(a[i].F+t)%l;
            }
            else{
                W[i].F=(a[i].F-t)%l;
                if(W[i].F<0){W[i].F+=l;}
            }
        }
        sort(W.begin(),W.end());
        ll s=-1;
        for(int i=0;i<n;i++){
            if(W[i].S==n){s=(i-cnt+n)%n;}
        }
        for(ll i=s;i<n;i++){
            cout<<W[i].F<<endl;
        }
        for(ll i=0;i<s;i++){
            cout<<W[i].F<<endl;
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 4352
#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() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;

        int ans = 0;
        rep(i, n) {
            int x, y, h, w;
            cin >> x >> y >> h >> w;
            int len = x+y+h;
            if (len <= 60 && w <= 2) ans += 600;
            else if (len <= 80 && w <= 5) ans += 800;
            else if (len <= 100 && w <= 10) ans += 1000;
            else if (len <= 120 && w <= 15) ans += 1200;
            else if (len <= 140 && w <= 20) ans += 1400;
            else if (len <= 160 && w <= 25) ans += 1600;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3072
#template
from collections import Counter
def inputlist(): return [int(j) for j in input().split()]
#template
N = int(input())
a = inputlist()
c = Counter(a)
key = c.keys()
ans = 0
for i in key:
    if c[i] == i:
        continue
    if c[i] > i:
        ans += c[i]-i
    if c[i] < i:
        ans +=c[i]
print(ans)

Measured memory_bytes: 18668
#include <ctype.h>
#include <stdio.h>
#include <string.h>

#define N 10

int main() {
	static char s[N + 1];
	int n, i, i_, j, k, yes;

	scanf("%s", s);
	if (s[0] != 'A') {
		printf("WA\n");
		return 0;
	}
	n = strlen(s);
	yes = 0;
	for (i = 2; i < n - 1; i++)
		if (s[i] == 'C') {
			yes = 1;
			i_ = i;
			break;
		}
	if (!yes) {
		printf("WA\n");
		return 0;
	}
	for (j = 1; j < i_; j++)
		if (!islower(s[j])) {
			printf("WA\n");
			return 0;
		}
	for (k = i_ + 1; k < n; k++)
		if (!islower(s[k])) {
			printf("WA\n");
			return 0;
		}
	printf("AC\n");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    long long t,c=1,p=0,q=0;
    cin>>t;
    while(t--)
    {
        long long x;
        cin>>x;
        if(c!=0 && x<=(1000000000000000000)/c)
        {
            c=c*x;
        }
        else
        {
            p=1;
        }
        if(x==0)
        {
            q=1;
        }
    }
    if(p==1 && q==0)
        c=-1;
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define re register
struct eg
{
	int to,nx,v;
	long long c;
}e[200100];
int cnt,q[200100],la[200100],cur[200100],s,t,N;
long long ans;
int num,nm;
bool bo[200100];
long long d[200100];
unsigned short hd,ta;
inline void addE(re int a,re int b,re int c,re long long d)
{
	e[++cnt]=(eg){b,la[a],c,d};la[a]=cnt;
	e[++cnt]=(eg){a,la[b],0,-d};la[b]=cnt;
}
inline void addE1(re int a,re int b,re int mi,re int mx)
{
	if(mx<mi){nm=1<<30;return;}
	mi=std::max(mi,0);nm+=mi;addE(s,b,mi,0);addE(a,t,mi,0);addE(a,b,mx-mi,0);
}
bool bfs()
{
	q[0]=s;ta=1;
	for(re int i=1;i<=N;i++)d[i]=-1ll<<60,cur[i]=la[i],bo[i]=0;
	d[s]=0;bo[s]=1;
	for(hd=0;hd!=ta;hd++)
	{
		re int x=q[hd];//printf("*d*%d %lld\n",x,d[x]);
		for(re int j=la[x];j;j=e[j].nx)if(e[j].v&&d[e[j].to]<d[x]+e[j].c)
		{
			d[e[j].to]=d[x]+e[j].c;
			if(!bo[e[j].to])q[ta++]=e[j].to;
		}
		bo[x]=0;
	}
	return (d[t]>-1ll<<60);
}int dfs(re int a,re int fl)
{
	if(a==t)return fl;
	bo[a]=1;
	re int fi=fl;
	for(re int&i=cur[a];i;i=e[i].nx)if(e[i].v&&!bo[e[i].to]&&d[e[i].to]==d[a]+e[i].c)
	{
		re int t=dfs(e[i].to,std::min(e[i].v,fi));
		fi-=t;e[i].v-=t;e[i^1].v+=t;
		if(!fi)return fl;
	}
	return fl-fi;
}
void dinic()
{
	while(bfs())
	{
		re int x=dfs(s,1<<30);
		ans+=x*d[t];num+=x;
	}
}
int x[110],y[110],l1[410],l2[410],r1[410],r2[410];
long long c[110];
char ss[110];
int main()
{
	re int n,m,a,b;
	scanf("%d",&n);
	re long long as=0;
	for(re int i=1;i<=n;i++)scanf("%d%d%lld",&x[i],&y[i],&c[i]);
	for(re int i=1;i<=100;i++)l1[i]=l2[i]=r1[i]=r2[i]=n;
	scanf("%d",&m);
	for(re int i=1;i<=m;i++)
	{
		scanf("%s%d%d",ss,&a,&b);
		switch(ss[0])
		{
			case 'L':l1[a]=std::min(l1[a],b);break;
			case 'R':l2[a]=std::min(l2[a],b);break;
			case 'D':r1[a]=std::min(r1[a],b);break;
			case 'U':r2[a]=std::min(r2[a],b);break;
		}
	}
	for(re int i=2;i<=100;i++)l2[a]=std::min(l2[a],l2[a-1]),r2[a]=std::min(r2[a],r2[a-1]);
	for(re int i=99;i;i--)l1[a]=std::min(l1[a],l1[a+1]),r1[a]=std::min(r1[a],r1[a+1]);
	s=299;t=300;N=300;
	for(re int i=1;i<=n;i++)
	{
		cnt=1;nm=0;ans=0;num=0;
		for(re int j=1;j<=N;j++)la[j]=0;
		for(re int j=1;j<=n;j++)addE(x[j],101+y[j],1,c[j]);
		for(re int j=1;j<=100;j++)
		{
			addE1(j,j+1,i-l1[j],l2[j+1]);
			addE1(j+102,j+101,i-r1[j],r2[j+1]);
		}
		addE(210,1,1<<30,0);addE(102,211,1<<30,0);
		addE(s,210,i,0);addE(211,t,i,0);nm+=i;
		if(nm!=(1<<30))dinic();
		if(num!=nm)break;
		as=std::max(as,ans);
	}
	printf("%lld\n",as);
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int res = b-a;
		int height = 0;
		for(int i = 1; i <= res; i++) {
			height += i;
		}
		System.out.println(height-b);
	}

}

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

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

    float odd = 0;
    float even = 0;
    for (int i = 1; i <= N; i++ ){
        if (i %  2 == 0){
            even++;
        }
        else {
            odd++;
        }
    }

    float answer = odd / (odd + even);
    cout << setprecision(10) << answer << endl;
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

vector<int> num = {2, 5, 5, 4, 5, 6, 3, 7, 6};

const int MINF = -1e9;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<int> a(m);
    for(int i=0;i<m;i++) cin >> a[i];
    sort(a.rbegin(), a.rend());
    // maximum digits using i matches
    vector<int> dp(n+1);
    for(int i=0;i<=n;i++) dp[i] = MINF;
    dp[0] = 0;

    for(int i=1;i<=n;i++){
        int maxdp = MINF;
        for(int j=0;j<m;j++){
            if(i - num[a[j]-1] >= 0) maxdp = max(maxdp, dp[i - num[a[j]-1]] + 1);
        }
        if(maxdp != MINF) dp[i] = maxdp;
    }

    // cout << dp[n] << endl;

    // back track
    int idx = n;
    string ans = "";
    while(idx > 0){
        // cout << idx << endl;
        for(int j=0;j<m;j++){
            if(idx - num[a[j]-1] >= 0 && dp[idx] == dp[idx - num[a[j]-1]] + 1){
                ans += to_string(a[j]);
                idx = idx - num[a[j]-1];
                break;
            }
        }
    }
    cout << ans << endl;
}

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

int n;
string s;

int main(){
  cin >> n >> s;
  int cnt = 0;
  rep(i, 1000){
    char key[3] = {i / 100 + '0', (i%100)/10 + '0', i%10 + '0'};
    //cerr << key[0] <<" " << key[1] <<" " << key[2] <<" " << endl;
    int itr = 0;
    rep(j, n){
      char c = s.at(j);
      if(c == key[itr]){
        itr++;
      }
      if(itr == 3){
        //cerr << key[0] <<" " << key[1] <<" " << key[2] <<" " << endl;
        break;
      }
    }
    if(itr == 3){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int a,b,k,i,flg;
	scanf("%d",&k);
	scanf("%d %d",&a,&b);
	flg=0;
	for(i=a;i<=b;i++)	{
		if(i%k==0)	{
			flg=1;	break;
		}
	}
	if(flg==1)	printf("OK\n");
	else printf("NG\n");
	return 0;
}

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

using int64 = long long;

int main() {
  int64 n, m;
  cin >> n >> m;
  map<int64, int64> count;
  int64 sum = 0;
  count[0] = 1;
  for (int64 i = 0; i < n; ++i) {
    int64 a;
    cin >> a;
    sum = (sum + a) % m;
    count[sum] = count[sum] + 1;
  }

  int64 ret = 0;
  for (auto& c : count) {
    int64 k = c.second;
    ret += k * (k - 1) / 2;
  }
  cout << ret << "\n";
  return 0;
}


Measured memory_bytes: 4224
#include<iostream>
using namespace std;
#include<utility>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>

typedef pair<double, double> point;
typedef point* data;

inline double dist(const point &a, const point &b)
{
    double dx = a.first - b.first, dy = a.second - b.second;
    return sqrt(dx * dx + dy * dy);
}

bool sort_y(const point &P1, const point &P2){ return P1.second < P2.second; }

double closest(data P, int n)
{
    if(n <= 1) return 1000;
    if(n == 2) return dist(P[0], P[1]);
    int m = n / 2;
    sort(P, P + n, sort_y); // y_sort, down to up.
    double d = min(closest(P, m), closest(P + m, n - m));

    sort(P, P + m);
    sort(P + m, P + n);
    // x_sort, left to right.
    int a, b, u, v, i, j;
    a = u = i = 0, b = v = j = m;
    while(i < m && j < n){
        if(P[u].first < P[v].first){
            for(i = a; i < m; i++){
                if(P[i].first >= P[v].first){ u = i; break; }
                if(P[v].first - P[i].first >= d){ a++; }
                else{
                    d = min(d, dist(P[v], P[i]));
                }
            }
        }else{
            for(j = b; j < n; j++){
                if(P[j].first > P[u].first){ v = j; break; }
                if(P[u].first - P[j].first >= d){ b++; }
                else{
                    d = min(d, dist(P[u], P[j]));
                }
            }
        }
    };
    return d;
}

int main()
{
	int i, n;
	double x, y;
	scanf("%d", &n);
	data P;
	P = new point [n];

	for(i = 0; i < n; i++){
		scanf("%lf %lf", &x, &y);
		P[i] = make_pair(x, y);
	}
	printf("%.12f\n", closest(P, n));

	return 0;
}

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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans = 1;
  for (int i = 0; i < n; ++i) {
    if (1000000000000000000 / ans < a[i]) {
      cout << -1 << endl;
      return 0;
    }
    ans *= a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3964
#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 drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  while (true) {
    int h, w;
    cin >> h >> w;
    if (h == 0 && w == 0) break;
    rep(i,h) {
      rep(j,w) {
        cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3076
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

typedef long long ll;

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;
}

map<pair<ll, ll>, ll> m;

ll solve(const ll N) {
    for (int i = 1; i <= N; i++) {
        ll x = i % 10;
        ll y = i;
        while (y >= 100) {
            y /= 10;
        }
        if (y == 10) {
            y = 1;
        } else if (y > 10) {
            y /= 10;
        }

        m[make_pair(y, x)]++;
    }

    ll count = 0;
    for (auto &p1 : m) {
        ll ay = p1.first.first;
        ll ax = p1.first.second;
        ll acount = p1.second;
        // printf("(%lld, %lld): %lld\n", ay, ax, acount);

        if (ax == ay) {
            // printf("plus: %lld\n", acount * acount);
            count += acount * acount;
        } else {
            ll bcount = m[make_pair(ax, ay)];
            count += acount * bcount;
            // printf("plus: %lld\n", acount * bcount);
        }
    }

    return count;
}

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

    cout << solve(N) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int n,m;
  std::cin >> n >> m;
  vt<int> k(n);

  vvi a(n);
  rep(i,n) {
    std::cin >> k[i];
    rep(j,k[i]){
      int num;
      std::cin >> num;
      a[i].push_back(num);
    }
  }

  vt<int> cnt(m);
  rep(i,n)
    rep(j,k[i])
      cnt[a[i][j]-1]++;

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

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
N = int(input())
Tn = [int(input()) for i in range(N)]


def gcd(a, b):
    result = a
    k = 0
    n = b

    while True:
        k = result % n
        result = n
        n = k
        if k == 0:
            break

    return result


def gcd_n(numbers):
    l = numbers[0]

    for i in range(len(numbers)):
        l = gcd(l, numbers[i])

    return l


def lcm(a, b):
    g = gcd(a, b)

    return a * (b // g)


def lcm_n(numbers):
    l = numbers[0]

    for i in range(len(numbers)):
        l = lcm(l, numbers[i])

    return l


def main():
    print(lcm_n(Tn))
    return


main()


Measured memory_bytes: 3064
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    def moji_list(a, b):
        # アルファベット小文字 → (97, 123)
        # アルファベット大文字 → (65, 91)
        # 半角数字 → (48, 58)
        # ひらがな → (12353, 12436)
        # カタカナ → (12449, 12532+1)
        # 全角数字 → (65296, 65306)
        return [chr(i) for i in range(a, b)]


    n = int(readline())
    al = ['z'] + moji_list(97, 123)
    ans = ''
    for i in range(1, 10 ** 6):
        n, check = divmod(n, 26)
        if check == 0:
            n -= 1
        ans += al[check]
        if n == 0:
            print(ans[::-1])
            break


if __name__ == '__main__':
    main()


Measured memory_bytes: 61912
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#define LL long long
#define N 200010
#define INFINITY 0x3f3f3f3f
#define maxn 10005
#define mase(a,b) memset(a,b,sizeof(a))
#define MIN(a,b) (a<b?a:b)
#define MAX(a,b) (a>b?a:b)
using namespace std;
int a[N];
int main()
{
    int n;
    LL re;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    if(a[0]!=0)
    {
        printf("-1\n");
    }
    else
    {
        bool flag=true;
        re=0;
        for(int i=1;i<n;i++)
        {
            if(a[i]-a[i-1]>1)
            {
                printf("-1\n");
                flag=false;
                break;
            }
            if(a[i]-a[i-1]==1)
            {
                re+=1;
            }
            else
            {
                re+=a[i];
            }
        }
        if(flag)
        {
            printf("%lld\n",re);
        }

    }
    return 0;
}


Measured memory_bytes: 4596
// @skylag
//I am into me now ;)
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define SKY ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int
int power(int a,int n,int m)
{
    int res=1;
    while(n)
    {
        if(n&1)
        {
            res=((res)*(a));
            n--;
        }
        else
        {
            a=((a)*(a));
            n/=2;
        }
    }
    return res;
}

void solve(int t)
{
    
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    for(int i=0;i<=k;i++)
    {
        for(int j=0;j<=k;j++)
        {
            for(int x=0;x<=k;x++)
            {
                int a1=a*(1<<i);
                int b1=b*(1<<j);
                int c1=c*(1<<x);
                if(i+j+x<=k and b1>a1 and c1>b1)
                {
                    cout<<"Yes";
                    return;
                }
            }
        }
    }
    cout<<"No";
    return;

}
int32_t main()
{
    SKY;
    //freopen("/Users/skylags/Desktop/input.txt","r",stdin);
    //freopen("/Users/skylags/Desktop/output.txt","w",stdout);
    int t=1;
    //cin>>t;
    int flag=1;
    while(t--)
    {
        solve(flag);
        flag++;
    }
}
/*Codechef July Lunchtime (Div.2)*/
//cout<<"Case #"<<t<<":"<<"\n";
//int n;
//cin>>n;
//vector<pair<int,int>> v(n);
//for(int i=0;i<n;i++)
//{
//    cin>>v[i].F>>v[i].S;
//}
//int ans=0;
//int temp=0;
//sort(ALL(v));
//int start=0;
//unordered_map<int,int> forward,backward;
//for(int i=0;i<n;i++)
//{
//
//}
//while(1)
//{
//    int temp=0;
//    for(int i=start;i<n;i++)
//    {
//        temp+=v[i].S;
//
//    }
//}
//ans=max(ans,v[n-1].S);
//cout<<ans<<"\n";


Measured memory_bytes: 3636
N, K = map(int, input().split())
A = list(map(int, input().split()))


def C(x):
    return sum([max((Ai + x - 1) // x - 1, 0) for Ai in A])


A.sort()
left = 1
right = A[-1]
while left + 1 < right:
    mid = (left + right) // 2
    S = C(mid)
    if S <= K:
        right = mid
    else:
        left = mid
print(left if C(left) <= K else right)


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 61)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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 (b<a) { a=b; return 1; } return 0; }



int k, n, a[1010];
void solve(){
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a,a+n);
	int ans = 0;
	for(int i = 0; i < k; i++){
		ans += a[i];
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
//#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    vector<ll> a(n);
    ll x = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        x += pow(-1, i) * a[i];
    }
    cout << x << ' ';
    for(int i = 1; i < n; i++)
    {
        x = x * -1 + 2 * a[i - 1];
        cout << x << ' ';
    }

    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
vector<long long> divisor(long long n){
    vector<long long> res;
    for(long long i = 1; i * i <= n; i++) {
        if(n%i==0){
            res.push_back(i);
            if (!(i * i == n)) res.push_back(n / i);
        }
    }
    return res;
}
int main(){
ll n,m;
cin >> n >> m;
vector<ll> mp = divisor(m);
ll ans = 0;
for (auto i : mp) {
    if (i <= m / n) chmax(ans, i);
}
cout << ans << endl;
}

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

int main() {
    int N;
    int A[200];
    int cnt = 0;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    while (true) {
        bool odd = false;
        for (int i = 0; i < N; i++) {
            if (A[i] % 2 != 0) {
                odd = true;
            }
        }
        if (odd) {
            break;
        }

        for (int i = 0; i < N; i++) {
            A[i] = A[i] / 2;
        }
        cnt++;
    }

    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC092_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var DX = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var X = DX[1];

            for (int i = 0; i < N; i++)
            {
                var A = int.Parse(Console.ReadLine());
                for (int j = 1; j <= DX[0]; j+=A)
                    X++;
            }
            Console.WriteLine(X);
        }
    }
}


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

using i64 = int64_t;

constexpr i64 MOD = 1e9 + 7;

vector<i64> fact(2000003);

i64 extgcd(i64 a, i64 b, i64 &x, i64 &y) {
    i64 d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

i64 multi_inv(i64 a, i64 md) {
    i64 x, y;
    extgcd(md, a, x, y);
    return (y > 0 ? y : md + y);
}

i64 func(i64 a, i64 b){
    if(a == 0)return (b + 1) % MOD;
    i64 res = fact[a+b+2];
    res *= multi_inv(fact[a+1], MOD);
    res %= MOD;
    res *= multi_inv(fact[b+1], MOD);
    res %= MOD;
    res--;
    if(res < 0)res += MOD;
    return res;
}

void init_fact(i64 n){
    fact[0] = 1;
    for(i64 i=1;i<=n;++i){
        fact[i] = i * fact[i-1] % MOD;
    }
}

int main(){
    i64 r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    init_fact(r2+c2+2);
    i64 ans = func(r2, c2);
    //cerr << ans << endl;
    ans -= func(r1-1, c2);
    if(ans < 0)ans += MOD;
    //cerr << ans << endl;
    ans -= func(r2, c1-1);
    if(ans < 0)ans += MOD;
    //cerr << ans << endl;
    ans += func(r1-1, c1-1);
    ans %= MOD;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 15872