akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <bitset>

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vi2;

int solve();

int main(void) {

	while (solve()){}

	return 0;

}

int solve() {

	int n;
	cin >> n;
	if (!n) { return 0; }

	//input
	vector<bool> visited((1 << n),false);


	vi x(n), y(n), r(n), c(n);
	vi2 con(n, vi(n,0));

	for (int i = 0; i < n; i++)
		cin >> x[i] >> y[i] >> r[i] >> c[i];

	//are circles touching
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int dx, dy, dr, d;
				dx = x[i] - x[j];
				dy = y[i] - y[j];
				dr = r[i] + r[j];
				d = dx*dx + dy*dy;
			if (dr*dr > d) {
				con[i][j] = 1;
			}
		}
	}

	//depth first search

	int ans = 0;

	stack<int> q;
	q.push( 0 );

	while ( !q.empty() && ans < n ) {

		int p = q.top();
		q.pop();
		visited.at(p) = true;

		ans = max(ans,(int)bitset<32>(p).count());
		
		//remove two disks
		for (int i = 0; i < n; i++) {

			if (p & (1 << i)) { continue; }

			for (int j = i+1; j < n; j++) {

				if (p & (1 << j)) { continue; }
				if (c[i] != c[j]) { continue; }

				bool b = false;
				for (int k = 0; k < i && b == false; k++) {
					b |= (con[k][i] != 0 && ( ( p & ( 1 << k ) ) == 0 ) );
				}
				for (int k = 0; k < j && b == false; k++) {
					b |= (con[k][j] != 0 && ( ( p & ( 1 << k ) ) == 0 ) );
				}

				if ( !b ) {

					int next = (p | (1 << i) | (1 << j));
					if (!visited.at(next)) {
						q.push(next);
					}

				}

			}
		}

	}
	cout << ans << endl;

	return 1;
}

Measured memory_bytes: 5132
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define rrep(i,a,b) for(int i = b; i --> (a);)
#define all(v) v.begin(),v.end()
#define trav(x,v) for(auto &x : v)
#define sz(v) (int)(v).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

struct UF {
	vi t;
	UF(int n){
		t.resize(n, -1);
	}

	int find(int a){
		return t[a]<0 ? a : t[a] = find(t[a]);
	}

	bool uni(int a, int b){
		a = find(a), b = find(b);
		if(a == b) return 0;
		if(t[a] < t[b]) swap(a,b);
		t[b] += t[a];
		t[a] = b;
		return 1;
	}
};

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vi xs(n), ys(n);
	rep(i,0,n) cin >> xs[i] >> ys[i];
	vi ps1(n), ps2(n);
	rep(i,0,n) ps1[i] = ps2[i] = i;
	sort(all(ps1), [&](int x, int y){
		return xs[x] < xs[y];
	});
	sort(all(ps2), [&](int x, int y){
		return ys[x] < ys[y];
	});
	ll cost = 0;
	vector<pair<int,pii>> es;
	rep(i,1,n) es.emplace_back(xs[ps1[i]]-xs[ps1[i-1]], pii(ps1[i],ps1[i-1]));
	rep(i,1,n) es.emplace_back(ys[ps2[i]]-ys[ps2[i-1]], pii(ps2[i],ps2[i-1]));
	UF uf(n);
	sort(all(es));
	trav(pa, es){
		int a = pa.second.first, b = pa.second.second;
		if(uf.uni(a,b)) cost += pa.first;
	}
	cout << cost << endl;
}

Measured memory_bytes: 6516
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<ll, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<ldouble, ldouble> pdd;

int n, A[10010], B[10010];

void solve() {
	scanf("%d", &n);
	for(int i=1;i<=n;i++) scanf("%d", A+i);
	for(int i=1;i<=n;i++) scanf("%d", B+i);
	ll c2 = 0, c1 = 0;
	for(int i=1;i<=n;i++) {
		if(A[i] > B[i]) c1 += A[i] - B[i];
		else if(A[i] < B[i]) {
			c2 += (B[i] - A[i]) / 2;
			if((B[i] - A[i]) % 2) c1++, c2++;
		}
	}
	if(c2 >= c1) puts("Yes");
	else puts("No");
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}




Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

int main()
{
	long long int H = 0,  ans = 0;

	std::cin >>H;

	long long int p = (long long int)std::log2((double)H);

	for (long long int i = p; i >= 0; i--){
		ans += (long long int)pow(2, i);
	}
	std::cout << ans << std::endl;

	return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

map<int,int> M;
int ret;
int n;

int main() {
	cin >> n;
	rep(i, n) {
		int x;
		cin >> x;
		++M[x];
	}

	for (auto p : M) {
		if (p.se >= p.fi) {
			ret += p.se - p.fi;
		} else {
			ret += p.se;
		}
	}
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
#define ll   long long int
#define T int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define PI 3.141592653589793238462643383
#define pb push_back
#define all(s) s.begin(),s.end()


int main (){
    fast;
    
    ll n, m = 1000000007;
    cin>>n;
    ll ten = 1,nine = 1,eight = 1;
    
    for(int i=0;i<n;i++){
        ten = (ten*(ll)10)%m;
        nine = (nine*(ll)9)%m;
        eight = (eight*(ll)8)%m;
    }
    
    ll ans = 0;
    ans = (ans + ten%m + eight%m - nine%m - nine%m + 10*m)%m;
    cout<<ans%m<<endl;


}

Measured memory_bytes: 3672
program sample
    implicit none
    character(100)::s,t
    integer(8) :: i,j,k,m,n
    integer(8)::a,b,c,d
    integer(8),allocatable::x(:),y(:)
  
    read(*,*) s
    
    if(s(1:1) .eq. s(3:3))then
        write(*,*)'Yes'
    else
        write(*,*)'No'
    endif
    
    stop
end program sample
  



Measured memory_bytes: 2852
#include<stdio.h>
int n,a[200000],flg=0,ans,j=1;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		}
	for(int i=1;i<=n;++i){
		j=a[j];
		ans++;
		if(j==2) {
			flg=1;
			break;
		}
	}
	if(flg==1)
	printf("%d",ans);
	else printf("-1");
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int a,b;
    cin >> a >> b;
    cout << (a-1) * (b-1) << '\n';
    return 0;   
}


Measured memory_bytes: 256
### constant

STD_BMI = 22

### main

while true
  n = gets.strip.to_i
  break if n == 0

  min_diff = 1000
  min_i = nil

  n.times.each do
    i, h, w = gets.strip.split(' ').map{|s| s.to_i}

    bmi = 10000.0 * w / (h * h)
    diff = (bmi - STD_BMI).abs

    if min_diff > diff
      min_diff = diff
      min_i = i
    end
  end

  puts min_i
end

Measured memory_bytes: 6140
program main
	implicit none
	integer :: N
	real(8), allocatable :: x(:)
	character(3), allocatable :: u(:)
	integer :: i
	real(8) :: Byen = 0.0d0, ans = 0.0d0
	
	read(*, *) N
	allocate(x(1:N), u(1:N))
	do i = 1, N
		read(*, *) x(i), u(i)
	end do
	
	do i = 1, N
		if(u(i) == "JPY" ) then
			ans = ans + x(i)
		else 
			Byen = Byen + x(i)
		end if
	end do
	ans = ans + 3.80d5 * Byen
	write(*, *) ans
end program main

Measured memory_bytes: 768
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import numpy as np
import copy
from collections import defaultdict, Counter
from itertools import product
from bisect import bisect_left, bisect_right

def s_inpl(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))

N, Q = s_inpl()
S = input()
l, r = [], []
for _ in range(Q):
    li, ri = s_inpl()
    l.append(li)
    r.append(ri)

ls = []
for i in range(N-1):
    ls.append(S[i]+S[i+1] == "AC")

res = list(np.cumsum(ls))
res.insert(0, 0)

for li, ri in zip(l, r):
    print(res[ri-1] - res[li-1])

Measured memory_bytes: 25588
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

const mod = 1000000007

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}
	ans := 0
	for k := 0; k < 60; k++ {
		zero := 0
		one := 0
		for i := 0; i < N; i++ {
			if a[i]>>uint(k)%2 == 1 {
				one++
			} else {
				zero++
			}
		}
		x := zero * one
		x %= mod
		for i := 0; i < k; i++ {
			x *= 2
			x %= mod
		}
		ans += x
		ans %= mod
	}
	out(ans)
}


Measured memory_bytes: 6912
h,w=map(int,input().split())
s=[input() for _ in range(h)]
for i in range(h):
    l=""
    for j in range(w):
        if s[i][j]=='#':
            l+='#'
        else:
            l+=str(sum([k[max(0,j-1):min(w,j+2)].count('#')  for k in s[max(0,i-1):min(h,i+2)]]))
    print(l)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define INF 1<<30


int main(){
	int x;
	cin >> x;
	int dp[100010] = {0};
	dp[0] = 1;

	for(int i = 100; i < 100010; i++){
		if(i >= 100 && i <= 105) {
			dp[i] = 1; continue;
		}
		for(int j = 0; j < 6; j++){
			dp[i] = dp[i] || dp[i-100-j];
		}
	}	
	cout << dp[x] << endl;
	return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long Int;

Int gcd(Int a, Int b) {
  Int r, tmp;
  if (a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }
  r = a%b;
  while (r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}

int main() {
  Int t;
  cin >> t;
  while (t--) {
    Int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a < b) {
      cout << "No" << endl;
      continue;
    }
    if (b > d) {
      cout << "No" << endl;
      continue;
    }
    if (c >= b) {
      cout << "Yes" << endl;
      continue;
    }
    Int g = gcd(b, d);
    if (c >= b-g+a%g) {
      cout << "Yes" << endl;
      continue;
    }
    else {
      cout << "No" << endl;
      continue;
    }
  }
    
 
  return 0;
}



Measured memory_bytes: 256
N, K = 5, 2

# N, K = 31415, 9265
#
# N, K = 10, 0

N, K = map(int, input().split())


def calculate(n, k):
    result = 0
    for b in range(1, N + 1):
        p = n // b
        s1 = p * max(0, (b - 1 - (k - 1)))
        s2 = max(0, (n % b) - (k - 1))

        res = s1 + s2
        if k == 0:
            result = result + res - 1
        else:
            result = result + res

    print(result)


calculate(N, K)


Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
void dbg_out(){
	cerr<<endl;
}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){
	cerr<<' '<< H; 
	dbg_out(T...);
}
#define ll long long 
int const MAXN=50, MOD=1e9+7;
int add(int a, int b){
	return (a%MOD+b%MOD)%MOD;
}
int mult(long long int a, long long int b){
	return (a%MOD*b%MOD)%MOD;
}
ll n, k;
void mult(int a[MAXN][MAXN], int b[MAXN][MAXN]){
	int c[MAXN][MAXN];
	memset(c,0,sizeof(c));
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			for(int z=0;z<n;z++)
				c[i][j]=add(c[i][j],mult(a[i][z],b[z][j]));
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			a[i][j]=c[i][j];
}
int a[MAXN][MAXN];
int dp[MAXN][MAXN];
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>a[i][j];
	for(int i=0;i<n;i++)
		dp[i][i]=1;	
	ll p=k;
	while(p>0){
		if(p%2==1) mult(dp,a);
		p/=2;
		mult(a,a);
	}		
	int ans=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			ans=(ans+dp[i][j])%MOD;
	cout<<ans;
}

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


int main() {
	int n, x;

	scanf("%d", &n);

	//int min = 1000001;
	//int MAX = -1000001;
	//int sum = 0;
	long sum = 0;
	long min = 1000001;
	long MAX = -1000001;
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		if (x < min) {
			min = x;
		}
		if (x > MAX) {
			MAX = x;
		}
		sum += x;
	}

	printf("%ld %ld %ld\n", min, MAX, sum);

	return 0;

}


Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <sstream>

using namespace std;

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

    int A[2][N];

    for(int j = 0; j < 2; j++)
        for(int i = 0; i < N; i++)
            cin >> A[j][i];

    int ans = 0;
    for(int i = 0; i < N; i++){
        int tmp = 0;
        for(int j = 0; j < N; j++){
            if(j < i){
                tmp += A[0][j];
            }else if(j == i){
                tmp += A[0][j];
                tmp += A[1][j];
            }else{
                tmp += A[1][j];
            }
        }
        ans = ans < tmp ? tmp: ans;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }
	if (n == r) { return 1; }

	if (r > n / 2) { r = n / 2; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int main() {
	int n,m; cin>>n>>m;
	if(n==m) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

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

    ll sum = 0;
    rep(i, n.size()) {
        sum += n[i] - '0';
    }
    if (sum % 9 == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 3e3 + 5;
int n, m, w[N], s[N], v[N], a[N];
ll dp[N][20001], ans;
int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		scanf("%d %d %d", w + i, s + i, v + i);
		a[i] = i;
	}
	sort(a + 1, a + 1 + n, [&](int i, int j) {
		return s[i] + w[i] < s[j] + w[j];
	});
	for (int i = 1; i <= n; ++i) {
		ans = max(ans, (ll)v[i]);
		dp[i][w[a[i]]] = max(dp[i - 1][w[a[i]]], (ll)v[a[i]]);
		for (int j = 0; j <= 20000; ++j) {
			dp[i][j] = dp[i - 1][j];
			if (j - w[a[i]] >= 0 && j - w[a[i]] <= s[a[i]])
				dp[i][j] = max(dp[i][j], dp[i - 1][j - w[a[i]]] + v[a[i]]);
			ans = max(ans, dp[i][j]);	
		}
	}
	cout << ans;
}



Measured memory_bytes: 157824
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    vector<ll> sum = A;
    for (ll i = 1; i < N; i++) {
        sum[i] = sum[i - 1] + A[i];
    }

    ll width = 4;

    ll ans = LLONG_MAX;
    for (ll i = 1; i < N - 1; i++) {
        //iが真ん中の切れ目
        auto left = upper_bound(sum.begin(), sum.end(), sum[i] / 2) - sum.begin();
        auto right = upper_bound(sum.begin(), sum.end(), (sum[N - 1] + sum[i]) / 2) - sum.begin();

        for (ll l = max(left - width, (ll)0); l <= min(left + width, i - 1); l++) {
            for (ll r = max(right - width, i + 1); r <= min(right + width, N - 1); r++) {
                ll P = sum[l];
                ll Q = sum[i] - P;
                ll R = sum[r] - sum[i];
                ll S = sum[N - 1] - sum[r];

                ll tmp = max({ P, Q, R, S }) - min({ P, Q, R, S });
                ans = min(ans, tmp);
            }
        }
    }

    cout << ans << endl;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  int x=0;
  vector<int> l(n);
  for(int i=0;i<n;i++){
    cin >> l.at(i);
  }
  sort(l.begin(),l.end());
  for(int i=0;i<k;i++){
    x = x + l.at(n-1-i);
  }
  cout << x << endl;
}


Measured memory_bytes: 256
def insertionSort(insert_list, num, g): 
    cnt = 0 
    for i in range(g, num):
        temp = insert_list[i]
        j = i - g 
        while (j >= 0 and insert_list[j] > temp):
            insert_list[j+g] = insert_list[j]
            j -= g
            cnt += 1
        insert_list[j+g] = temp
    return insert_list, cnt 

def shellSort(shell_list, num):
    cnt = 0 
    G = [1] 
    G_num = 1 
    for i in range(num):
        G_num = G_num*3 + 1 
        if G_num > num:
            break
        else:
            G.append(G_num)
    G.reverse()
    m = len(G)

    for i in range(m):
        shell_list, cnt_num = insertionSort(shell_list, num, G[i])
        cnt += cnt_num
    return m, G, cnt, shell_list    

if __name__ == "__main__":
    num = int(raw_input())
    num_list = [int(raw_input()) for i in range(num)]

    m, G, cnt, shell_list = shellSort(num_list, num)

    print m
    G = map(str, G)
    print " ".join(G)
    print cnt 
    for i in shell_list:
        print i

Measured memory_bytes: 77620
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	// cin.tie(nullptr);
	// ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	int N, M, L;
	int Q;
	vector<vector<int>> G;
	vector<vector<int>> dis;

	cin>>N>>M>>L;
	
	G.resize(N, vector<int>(N, INF));
	dis.resize(N, vector<int>(N, INF));
	
	for(int i = 0; i < M; i++){
		int A, B, C;
		
		cin>>A>>B>>C;
		
		A--, B--;
		
		G[A][B] = C;
		G[B][A] = C;
	}
	
	for(int k = 0; k < N; k++)
		for(int i = 0; i < N; i++)
			for(int j = 0; j < N; j++) G[i][j] = min(G[i][j], G[i][k]+G[k][j]);
	
	for(int i = 0; i < N; i++){ //cout<<i<<endl;
		queue<pair<int,int>> Q;
		
		dis[i][i] = -1;
		
		Q.push(make_pair(-1, i));
		
		while(!Q.empty()){
			pair<int,int> p = Q.front(); Q.pop();
			int now = p.second, d = p.first;
			
			if(dis[i][now] < d) continue;
			
			for(int j = 0; j < N; j++){
				if(G[now][j] > L) continue;
				
				if(dis[i][j] > d + 1) {
					dis[i][j] = d + 1;
					Q.push(make_pair(d+1, j));
				}
			}
		}
		
	}
	
	cin>>Q;
	
	for(int i = 0; i < Q; i++){
		int s, t;
		
		cin>>s>>t;
		
		s--, t--;
		
		cout<<(dis[s][t]==INF?-1:dis[s][t])<<endl;
	}
	return 0;
}

Measured memory_bytes: 1920
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n, m;
    int s[20][20];
    int k[20];
    int p[20];
    ll ans = 0;
    bool flag = true;

    cin >> n >> m;

    for (int i = 0; i < m; i++)
    {
        cin >> k[i];

        for (int j = 0; j < k[i]; j++)
        {
            cin >> s[i][j];
            s[i][j]--;
        }
    }

    for (int i = 0; i < m; i++)
    {
        cin >> p[i];
    }

    for (int i = 0; i < (1 << n); i++)
    {
        flag = true;
        for (int j = 0; j < m; j++)
        {
            int on = 0;

            for (int l = 0; l < k[j]; l++)
            {
                if ((1 << s[j][l]) & i)
                {
                    on++;
                }
            }

            if (on % 2 != p[j])
            {
                flag = false;
            }
        }

        if (flag)
        {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cassert>

#include <algorithm>

using namespace std;

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

template<typename T>
constexpr T divide_floor(T a, T b)
{
	T remainder = a % b;
	return (a - remainder) / b;
}

template<typename T>
constexpr T divide_ceil(T a, T b)
{
	T remainder = a % b;
	return remainder == 0 ? a / b : (a + (b - remainder)) / b;
}

int main()
{
	int64_t a, b, x;
	cin >> a >> b >> x;

	cout << divide_floor(b, x) - divide_ceil(a, x) + 1 << endl;

	return 0;
}

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

void replaceAToB(string str, string a, string b){
    int ix = 0;
    while( (ix = str.find(a, ix)) >= 0 ) {
        str.replace(ix, a.size(), b);
    }
}
std::string replaceAbcToXyzzz(const std::string &str)
{
    std::string str2(str);
    int ix = 0;
    while( (ix = str2.find("?", ix)) >= 0 ) {
        str2.replace(ix, strlen("?"), "a");
    }
    return str2;
}

int main(){
    string s, t;
    cin >> s >> t;
    set<string> st;
    for(int i=0; i<s.size()-t.size()+1; i++){
        bool isok = true;
        for(int j=0; j<t.size(); j++){
            if(!(s[i+j] == '?'  ||  s[i+j] == t[j])){
                isok = false;
            }
        }
        if(isok){
            string newStr = s;
            newStr.replace(i, t.size(), t);
            //replaceAToB(newStr, "?", "a");
            //st.insert(newStr);
            st.insert(replaceAbcToXyzzz(newStr));
        }
    }

    if(st.empty()){
        cout << "UNRESTORABLE" << endl;
    }else{
        auto itr = st.begin();
        cout << *itr << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 1e9 + 5; 
int main(){
	int n;
	cin>>n;
	vector<int>a(n);
	for(int &x:a){
		scanf("%d",&x);
	}
	vector<int>dp(n,INF);
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j:{i+1,i+2}){
			if(j<n){
			
			dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
		}
	}
	}
	cout<<dp[n-1];
	
	
	
	
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(){
    unsigned long long int a,b;
    scanf("%llu %llu",&a,&b);
    unsigned long long int ab = a * b;
    unsigned long long int hoge;
    if(a < b){
        hoge = a;
        a = b;
        b = hoge;
    }
    unsigned long long int fuga = a % b;
    while(fuga != 0){
        a = b;
        b = fuga;
        fuga = a % b;
    }
    printf("%llu",ab / b);
    return 0;
}

Measured memory_bytes: 128
n = int(input())

cnt = [set() for i in range(n+1)]

def f(x, y, z):
    return x*x+y*y+z*z+x*y+y*z+x*z

for x in range(1, n+1):
    if f(x,1,1) > n: break
    for y in range(1, n+1):
        if f(x,y,1) > n: break
        for z in range(1, n+1):
            t = f(x,y,z)
            if t > n: break
            cnt[t].add((x,y,z))

for i in range(1, n+1):
    print(len(cnt[i]))

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

typedef string::iterator State;

char buf[114514];
string s;

bool IsVoewl(char c) {
  return (c != '\0') && (strchr("aiueo", c) != NULL);
}

bool IsSoundless(string s) {
  return (s[0] != '\0') && (strchr("ksthp", s[0]) != NULL);
}

bool IsConsonant(char c) {
  return (c != '\0') && (strchr("kstnhmyrwgzdbp", c) != NULL);
}

vector<string> ParseSyllable(State itr) {
  vector<string> ret;

  while (itr != s.end()) {
    string t;
    if (IsVoewl(*itr)) {
      t += *itr++;
      ret.emplace_back(t);
      continue;
    }
    assert (IsConsonant(*itr));

    t += *itr++;
    if (*itr == 'y') {
      assert(t[0] != 'y' && t[0] != 'w');
      t += *itr++;
      assert(IsVoewl(*itr));
      assert(*itr == 'a' || *itr == 'u' || *itr == 'o');
      t += *itr++;
      ret.emplace_back(t);
      continue;
    }

    if (IsVoewl(*itr)) {
      if (t[0] == 'y') assert(*itr == 'a' || *itr == 'u' || *itr == 'o');
      if (t[0] == 'w') assert(*itr == 'a');
      t += *itr++;
      ret.emplace_back(t);
      continue;
    }

    if (IsConsonant(*itr)) {
      if (*itr == t[0]) {
        ret.emplace_back(t);
        continue;
      } else if (t[0] == 'n') {
        ret.emplace_back(t);
        continue;
      } else assert(0);
    }

    assert(itr == s.end() || *itr == '\'');
    if (*itr == '\'') itr++;
    ret.emplace_back(t);
  }

  return ret;
}

int main() {
  while (1) {
    scanf("%s", buf);
    s = buf;
    if (s[0] == '#') return 0;

    set<int> soundless;
    vector<string> lis = ParseSyllable(s.begin());
    bool canbe = true;
    char idx = 0;
    for (int i=0; i<lis.size(); i++) {
      int n = lis[i].size();
      char c = lis[i][n-1];

      idx += n;
      if (IsVoewl(c) && !canbe) {
        canbe = true;
        continue;
      }

      if (c == 'i' || c == 'u') {
        if (!IsSoundless(lis[i])) continue;
        if (i == lis.size()-1 || IsSoundless(lis[i+1])) {
          soundless.insert(idx-1);
          canbe = false;
          continue;
        }
      } else if (c == 'a' || c == 'o') {
        if (i == lis.size()-1) continue;
        if (!IsSoundless(lis[i])) continue;
        if (!IsSoundless(lis[i+1])) continue;
        if (lis[i+1][lis[i+1].size()-1] == c) {
          soundless.insert(idx-1);
          canbe = false;
          continue;
        }
      }
    }

    int off = 0;
    for (int i=0; i<s.size(); i++) {
      if (soundless.count(i-off)) {
        printf("(%c)", s[i]);
      } else printf("%c", s[i]);
      if (s[i] == '\'') off++;
    }puts("");
  }
}

Measured memory_bytes: 3276
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll n;
int l;

ll solve() {
    ll k = n;
    l = 0;
    while (k > 0) {
        l++;
        k >>= 1;
    }
    ll dp[l+1], m[l+1], mm[l+1], t[l+1];
    dp[0] = 2; m[0] = 1; mm[0] = 1;
    for (int i = 1; i < l; i++) {
        dp[i] = ((3 * dp[i-1] - m[i-1] - (((n>>(l-i-1))&1)==1?0:m[i-1]))%mod+mod)%mod;
        m[i] = (m[i-1] + (((n>>(l-i-1))&1)==1?0:mm[i-1])) % mod;
        mm[i] = (((n>>(l-i-1))&1)==1?m[i-1]+mm[i-1]:mm[i-1]);
    }
    return dp[l-1];
}

void input() {
    cin >> n;
}

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

    input();
    cout << solve() << endl;
}

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

int main(){
    int n;
    cin>>n;
    long long a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    long long w=0,h,ans,tmp=0,cnt=0;

    sort(a,a+n,greater<long long>());

    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1] && a[i]!=tmp){
            tmp=a[i];
            h=w;
            w=a[i];
            cnt++;
        }
        if(i+3<n && a[i]==a[i+3]){
            h=max(h,a[i]);
            w=max(w,a[i]);
            cnt=2;
        }
        if(cnt==2) break;
    }

    ans=h*w;
    cout<<ans;


}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

ll N, M, K;


const int MAX = 200001;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


// 0 .. n の合計
ll acc(ll n)
{
	return n*(n+1)/2;
}

int main(){
	cin >> N >> M >> K;
	COMinit();
	
	/*
	  2つの駒の配置コスト × 他の場所にK-2個を置く方法の数
	  他の場所にK-2個を置く方法の数 = (N*M-2)C(K-2)
	*/
	
	// 2つの駒の配置コスト の合計
	ll cost = 0;
	for ( ll i = 0; i < N; i++ ){
		ll  a = (acc(i) + acc(N-1-i))%MOD;
		a = a*M%MOD;
		a = a*M%MOD;
		cost = (cost + a)%MOD;
		
		//for ( ll j = 0; j < N; j++ ){
		//	cost = (cost + ((abs(i-j) * (i==j ? M-1 : M))%MOD)*M) % MOD;
		//}
	}
	for ( ll i = 0; i < M; i++ ){
		ll  a = (acc(i) + acc(M-1-i))%MOD;
		a = a*N%MOD;
		a = a*N%MOD;
		cost = (cost + a)%MOD;
		
		//for ( ll j = 0; j < M; j++ ){
		//	cost = (cost + ((abs(i-j) * (i==j ? N-1 : N))%MOD)*N) % MOD;
		//}
	}
	
	cout << ( (cost*finv[2]%MOD) * COM(N*M-2,K-2) )%MOD << endl;

	return 0;
}



Measured memory_bytes: 4992
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Set<Integer> list = new HashSet<>();
 
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if (list.contains(a)) {
				list.remove(a);
			} else {
				list.add(a);
			}
		}
 
		System.out.println(list.size());
 
		sc.close();
    }
}


Measured memory_bytes: 61412
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn=1e5+6;
const int inf=0x7fffffff;
int a[maxn],dp[maxn];
int n,ans;

int main() {
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	fill(dp, dp+n, inf);
	for(int i=0;i<n;i++){
		*lower_bound(dp, dp+n, a[i])=a[i];
	}
	cout<<lower_bound(dp, dp+n, inf)-dp<<endl;
	return 0;
}


Measured memory_bytes: 3848
#include <iostream>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;

int main(){
    int X, Y, Z;
    cin >> X >> Y >> Z;

    swap(X,Y);
    swap(X,Z);

    cout << X << " " << Y << " " << Z << endl;

    return 0;
}


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

int main(){
  int h,w;
  int tmp[10][10] = {};
  cin >> h >> w;

  for(int i = 0;i <= 9;i++)
    for(int j = 0;j <= 9;j++)
      cin >> tmp[i][j];


  for(int i = 0;i <= 9;i++)
    for(int j = 0;j <= 9;j++)
      for(int k = 0;k <= 9;k++)
        tmp[j][k] = min(tmp[j][k],tmp[j][i] + tmp[i][k]);

  long long ans = 0;
  int a;
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      cin >> a;
      if(a != -1){
        ans += tmp[a][1];
      }
    }
  }

  cout << ans << endl;

  return 0;
}




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

int main (){
    int a;
    int ans = 1;
    cin >> a;

    do{
        if(a == 1){
            break;
        }
        ans *= 2;
    }while(ans * 2 <= a);
    cout << ans << "\n";
    
    return 0;
}


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

int main()
{
	long long i = 0, j = 0, k = 0, ans = 0;
	long long N,A,B;
	cin >> N >> A >> B;

	if((A-B-1)%2)
		cout << "Alice" << endl;
	else
		cout << "Borys" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())

int main(){
	boost
	ll a,b,c,m;
	cin>>a>>b>>c;
	m=max(a,max(b,c));
	if(m==a){
	    cout<<((m*10)+b+c);
	}
	else if(m==b){
	    cout<<((m*10)+a+c);
	}
	else if(m==c){
	    cout<<((m*10)+b+a);
	}
	return 0;
}

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

int gcd(int p, int q) {
  if(p % q == 0)return q;
  return gcd(q, p % q);
}

int main()
{
  //入力
  int num;
  cin>>num;

  //操作と出力
  long int count=0;
  
  for(int i=1;i<=num;i++){
    for(int j=1;j<=num;j++){
      for(int k=1;k<=num;k++){
        count+=gcd(gcd(i,j),k);
      }
    }
  }
  cout<< count <<endl;
  
  return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>
int MIN(int a,int b){
    return a<b?a:b;
}

using namespace std;


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll xyz[3],K;
    cin >> xyz[0] >> xyz[1] >> xyz[2] >> K;
    vector<ll> A(xyz[0],0),B(xyz[1],0),C(xyz[2],0);
    ll tmp;
    for(int i = 0; i < xyz[0];i++){
        cin >> A[i];
    }
    for(int i = 0; i < xyz[1];i++){
         cin >> B[i];
    }
    for(int i = 0; i < xyz[2];i++){
         cin >> C[i];
    }
    vector<ll> ans(MIN(K,xyz[0]*xyz[1])*xyz[2],0),AB(xyz[0]*xyz[1],0);
    ll wa = 0;

    for(int i = 0; i < xyz[0];i++){
        for(int j = 0; j < xyz[1];j++){
            AB[wa] = A[i] + B[j];
            wa++;
        }
    }
    VSORT(AB);
    reverse(ALL(AB));
    wa = 0;
    for(int i = 0; i < MIN(K,xyz[0]*xyz[1]);i++){
        for(int j = 0; j < xyz[2];j++){
            ans[wa] = AB[i] + C[j];
            wa++;
        }
    }
    VSORT(ans);
    reverse(ALL(ans));

    for(int i = 0; i < K;i++){
        cout << ans[i] << endl;
    }
    

    return 0;
}

Measured memory_bytes: 31616
#include <stdio.h>
#define rep(i, n) for(int i = 0; i < n; ++i)

int main(void) {
  int h1, h2, k1, k2, a, b, c, d, h, k;
  scanf("%d%d%d%d%d%d%d%d", &h1, &h2, &k1, &k2, &a, &b, &c, &d);
  h = a * h1 + b * h2, k = a * k1 + b * k2;
  h1 /= 10, k1 /= 10, h2 /= 20, k2 /= 20;
  h += h1 * c + h2 * d, k += k1 * c + k2 * d;
  if(h > k) printf("hiroshi\n");
  else if(h < k) printf("kenjiro\n");
  else printf("even\n");
  return 0;
}


Measured memory_bytes: 2596
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,a,ans=99998989,cnt;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cnt=0;
		cin>>a;
		while(a%2==0)
		{
			a/=2;
			cnt++;
		}
		ans=min(ans,cnt);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;

int main(int argc, char* argv[]){
  int s;
  cin >> s;
  if(s == 7 || s == 5 || s == 3){
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO";
  return 0;
}

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

namespace _0077
{
    class Program
    {
        static void Main(string[] args)
        {
            var codedLetters = ReadData();
            var decodedLetters = DecodeRunLength(codedLetters);
            WriteData(decodedLetters);

        }

        static List<string> DecodeRunLength(List<string> codedLetters) 
        {
            var decodedLetters = new List<string>();
            foreach (var codedLetter in codedLetters)
            {
                var decodedLetter = "";
                var codedCharactors = codedLetter.ToCharArray();
                for (int i = 0; i<codedLetter.Count() ;i++ )
                {
                    if (codedCharactors[i] == '@')
                    {
                        int codedLength = (int)Char.GetNumericValue(codedCharactors[i + 1]);
                        for (int j = 0; j < codedLength; j++)
                        {
                            decodedLetter += codedCharactors[i + 2];
                        }
                        i += 2;
                    }
                    else 
                    {
                        decodedLetter += codedCharactors[i];
                    }
                }
                decodedLetters.Add(decodedLetter);
            }
            return decodedLetters;
        }

        /// <summary>
        /// データを読み込む
        /// </summary>
        /// <returns>読み込んだ入力群</returns>
        static List<string> ReadData()
        {
            var inputs = new List<string>();

            while (true)
            {
                var input = Console.ReadLine();
                if (string.IsNullOrEmpty(input))
                {
                    break;
                }
                inputs.Add(input);
            }
            return inputs;
        }

        /// <summary>
        /// データを書き出す
        /// </summary>
        /// <param name="outputs">書き出す出力群</param>
        static void WriteData(List<string> outputs)
        {
            foreach (var output in outputs)
            {
                Console.WriteLine(output);
            }
        }
    }
}

Measured memory_bytes: 5560
import collections
n = int(input())
s = []
for _ in range(n):
    s.append(input())

c = collections.Counter(s)
m = c.most_common()[0]

ans = []
for _c in c.items():
    if _c[1] == m[1]:
        ans.append(_c[0])

for v in sorted(ans):
    print(v)


Measured memory_bytes: 45036
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
static const long long MAX = 200001;
long long fact[MAX], fact_inv[MAX], inv[MAX];

// 繰り返し二乗法を用いて a の n 乗を算出する(ただし mod m の空間内)
long long modpow(long long a, long long n, long long mod)
{
    long long ret = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            ret *= a;
            ret = ret % mod;
        }
        a *= a;
        a = a % mod;
        n = (n >> 1);
    }
    return ret;
}

void InitmodnCk(long long mod)
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[0] = inv[1] = 1;
    for (long long i = 2; i < MAX; ++i)
    {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = (mod - inv[mod % i] * (mod / i) )% mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long modnCk(long long n, long long k, long long mod)
{
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    long long ret = fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
    if (ret < 0) ret = (ret + mod) % mod;
    return ret;
}

int main()
{
    long long N, M, K;
    cin >> N >> M >> K;
    static const long long mod =  998244353;
    InitmodnCk(mod);
    long long ans = 0;
    for (long long i = 0; i <= K; ++i)
    {
        long long col = (M * modpow(M - 1, N - i - 1, mod)) % mod;
        if (col < 0) col = (col + mod) % mod;
        long long comb = modnCk(N - 1, i, mod);
        ans += (col * comb) % mod;
        ans = ans % mod;
        if (ans < 0) ans = (ans + mod) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
    long long minu(long long a, long long b){
        return mod(mod(a)-mod(b));
    }
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }
    
    vector<int>dirX={-1,0,1};
    vector<int>dirY={-1,0,1};
 
 
    ll dp[2005];
    ll ok(int s){
        // cout<<"in "<<s<<"\n";
        if(s==0)
            return 1LL;
        else if(s==1 || s==2)
            return 0LL;
        else if(s>=3 && s<=5)
            return 1LL;
        else if(dp[s]!=-1)
            return dp[s];
        else{
            ll total=0;
            for(int i=3;i<=s;i++){
                if(s-i>=0)
                    total=add(total,ok(s-i));
            }
            return dp[s]=total;
        }
    }
    void solve(){
        int s;
        cin>>s;
        memset(dp,-1,sizeof(dp));
       // dp[0]=1;
        cout<<ok(s);
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
        //    cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

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

using namespace std;

const int N = 200010;

int a[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  if (a[0] > 0) {
    puts("-1");
    return 0;
  }
  long long ans = 0;
  for (int i = 0; i + 1 < n; i++) {
    if (a[i + 1] - a[i] > 1) {
      puts("-1");
      return 0;
    }
    if (a[i + 1] - a[i] == 1) {
      ans++;
    } else {
      ans += a[i + 1];
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1024
//#include <cmath>
//#include <cstdio>
//#include <vector>
//#include <map>
//#include <iostream>
//#include <algorithm>
//#include <set>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vb = vector<bool>;
using pli = pair<ll,int>; 		
#define fi first
#define v vector
#define se second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
int INF = 1e9+7;
ll inf = 1e18+7;
int MOD = 1e9+7;

void add_self(auto &a, auto b){
	a += b;
	if(a >= MOD){
		a -= MOD;
	}
}

void sub_self(auto &a, auto b){
	a -= b;
	if(a < 0)	a += MOD;
}

void max_self(auto &a, auto b){
	if(b > a)	a = b;
}

void min_self(auto &a, auto b){
	if(b < a)	a = b;
}

void topsort(int i, v<vi>& graph, vb& visit, stack<int>& res){
	visit[i] = true;
	
	for(int x : graph[i]){
		if(!visit[x])
		topsort(x,graph,visit,res);
	}
	res.push(i);
}
const int N  = 510;
ll dp[N][N];


void solve(){
	for(int i = 0; i < N; ++i){
		for(int j = 0; j < N; ++j){
			dp[i][j]=  inf;
		}
	}
	int n;
	scanf("%d",&n);
	v<ll> arr(n);
	v<ll> prefix;
	prefix.pb(0);
	for(int i = 0; i < n; ++i){
		scanf("%lld",&arr[i]);
		prefix.pb(prefix.back() + arr[i]);
	}
	
	
	for(int l = n-1; l >= 0; --l){
		for(int r = l; r < n; ++r){
			if(l == r){
				dp[l][r] = 0;
				continue;
			}
			for(int i = l; i <= r-1; ++i){
				min_self(dp[l][r], dp[l][i] + dp[i+1][r] + prefix[r+1] - prefix[l]);
			}
		}
	}
	
	
	
	
	printf("%lld\n", dp[0][n-1]);
}	



int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	//scanf("%d",&t);
	while(t--){
		solve();
	}
		
			
}


Measured memory_bytes: 5848
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <cmath>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

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

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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


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

    int R;
    cin >> R;
    if(R < 1200){
        cout << "ABC" << endl;
    }else if(R < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
    

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		scan.close();
		int cnt = 0;
		for(int i = a; i <= b; i++) {
			if(c % i == 0) {
				cnt ++;
			}
		}
		System.out.println(cnt);
	}
}


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

int main(){
  int N,ans=0,r,l;
  string str;
  cin >> N >> str;
  bool flag;
  
  l=1;r=N;
  while(l<r-1){
    int len=(r+l)/2;
    flag=false;
    map<string,int> smap;
    for(int i=0;i<N-len+1;i++){
      string stmp = str.substr(i,len);
      auto  target = smap.find(stmp);
      if(target==smap.end())smap[stmp]=i;
      else if(target->second+len<=i){flag=true;break;}
    }    
    if(flag){ ans = len; l=(l+r)/2;}
    else r=(l+r)/2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6672