akhauriyash/Code-Regression huggingface dataset:
// vjudge 259381 B
#include <cstdio>

int H, W, flag1[110], flag2[110];
char map[110][100];

int main() {
	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; i++) {
		scanf("%s", map[i]);
		for (int j = 0; j < W; j++)
			if (map[i][j] == '#') flag1[i] = flag2[j] = 1;
	}
	for (int i = 0; i < H; i++) {
		int out = 0;
		for (int j = 0; j < W; j++) 
			if (flag1[i] && flag2[j]) putchar(map[i][j]), out = 1;
		if (out) putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/perl
#abc85_b.pl
#Sun Jan  7 20:56:31 2018
#

use warnings;
use strict;

my $n = <STDIN>;
chomp $n;

my $loopnum = $n;

my @mochi;

while ($loopnum > 0){
	my $stdin = <STDIN>;
	chomp $stdin;
	push (@mochi, $stdin);
	$loopnum--;
}

my @mochisorted = sort {$b <=> $a} @mochi;

my $answer = 0;
my $prevmochi = 101;
foreach (@mochisorted){
	if ($_ < $prevmochi){
		$answer++;
		$prevmochi = $_;
	}
}

print $answer,"\n";

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

class D
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		int n = h[0], k = h[1];
		var a = new int[n].Select(_ => int.Parse(Console.ReadLine())).ToArray();

		var kM = 300000;

		var r = 0L;
		var st = new ST_RangeMax(kM + 1);

		for (int i = 0; i < n; i++)
			st.Set(Math.Max(0, a[i] - k), Math.Min(kM + 1, a[i] + k + 1), st[a[i]] + 1);

		for (int x = 0; x <= kM; x++)
			ST.Chmax(ref r, st[x]);
		Console.WriteLine(r);
	}
}

class ST
{
	public struct Node
	{
		public int i;
		public static implicit operator Node(int i) => new Node { i = i };

		public Node Parent => i >> 1;
		public Node Child0 => i << 1;
		public Node Child1 => (i << 1) + 1;
	}

	// Power of 2
	protected int n2 = 1;
	public long[] a;

	public ST(int n)
	{
		while (n2 < n) n2 <<= 1;
		a = new long[n2 <<= 1];
	}

	public void InitAllLevels(long v) { for (int i = 1; i < a.Length; ++i) a[i] = v; }

	protected Node Actual(int i) => (n2 >> 1) + i;
	public long this[Node n]
	{
		get { return a[n.i]; }
		set { a[n.i] = value; }
	}
	public virtual long this[int i] => this[Actual(i)];

	// 階層の降順
	public void ForLevels(int i, Action<Node> action)
	{
		for (i += n2 >> 1; i > 0; i >>= 1) action(i);
	}

	// 範囲の昇順
	public void ForRange(int minIn, int maxEx, Action<Node> action)
	{
		int l = (n2 >> 1) + minIn, r = (n2 >> 1) + maxEx;
		while (l < r)
		{
			var length = l & -l;
			while (l + length > r) length >>= 1;
			action(l / length);
			l += length;
		}
	}

	// 範囲の降順 (階層の降順)
	public void ForRange(int maxEx, Action<Node> action)
	{
		var i = (n2 >> 1) + maxEx;
		if (i == n2) { action(1); return; }
		for (; i > 1; i >>= 1) if ((i & 1) != 0) action(i - 1);
	}

	public static void Chmax(ref long x, long v) { if (x < v) x = v; }
	public static void Chmin(ref long x, long v) { if (x > v) x = v; }
}

class ST_RangeMax : ST
{
	public ST_RangeMax(int n) : base(n) { }

	public void Set(int minIn, int maxEx, long v) => ForRange(minIn, maxEx, n => this[n] = Math.Max(this[n], v));

	public override long this[int i]
	{
		get
		{
			var r = 0L;
			ForLevels(i, n => Chmax(ref r, this[n]));
			return r;
		}
	}
}


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

using namespace std;

#define EPS 1e-10
#define equal(a,b) (fabs(a-b) < EPS)
#define lt(a,b) (a-b < -EPS)
#define le(a,b) (lt(a,b) || equal(a,b))
typedef long long ll;

class Point{
public:
  Point(){}
  Point(double x,double y,double z) : x(x), y(y), z(z) {}
  
  Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y,z+p.z); }
  Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y,z-p.z); }
  Point operator * (double k)const{ return Point(x*k,y*k,z*k); }
  Point operator / (double k)const{ return Point(x/k,y/k,z/k); }
  double x,y,z;
};

double dot(const Point &a,const Point &b){
  return a.x*b.x + a.y*b.y + a.z*b.z;
}

Point cross(const Point &a,const Point &b){
  return Point(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);
}

double norm(const Point &p){
  return dot(p,p);
}

double abs(const Point &p){
  return sqrt(norm(p));
}

istream &operator >> (istream &is,Point &p){
  return is >> p.x >> p.y >> p.z;
}

class Line{
public:
  Line(){}
  Line(Point s,Point t) : s(s), t(t) {}
  Point s,t;
};

Point projection(const Line &l,const Point &p){
  Point b = l.t - l.s;
  double t = dot(p-l.s,b)/norm(b);
  return l.s + b*t;
}

double distanceLP(const Line &l,const Point &p){
  return abs(p-projection(l,p));
}

class Cube{
public:
  Cube(){}
  Cube(Point p,double r) : p(p), r(r) {}
  Point p;
  double r;
};

#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
typedef Point Vector;
 
int ccw(Point p0,Point p1,Point p2){
  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if(abs(cross(a,b)) > EPS){ return COUNTER_CLOCKWISE; }
  if(abs(cross(a,b)) < -EPS){ return CLOCKWISE; }
  if(dot(a,b) < -EPS){ return ONLINE_BACK; }
  if(norm(a) < norm(b)){ return ONLINE_FRONT; }
  return ON_SEGMENT;
}

bool isIntersectCL(const Cube &c,const Line &l){
  vector<Point> vec;
  double d = distanceLP(l,c.p);
  if(le(d,c.r)){
    Point p = projection(l,c.p);
    Point v = (l.t - l.s) / abs(l.t - l.s);
    d = sqrt(c.r*c.r-d*d);
    vec.push_back(p - v*d);
    vec.push_back(p + v*d);
    for(int i = 0 ; i < (int)vec.size() ; i++){
      if(ccw(l.s,l.t,vec[i]) == ON_SEGMENT){
        return true;
      }
    }
  }
  return false;
}

class Obj{
public:
  Obj(){}
  Obj(Cube c,ll l) : c(c), l(l) {}
  Cube c;
  ll l;
};

int main(){
  int N,Q;
  cin >> N >> Q;
  vector<Obj> obj(N);
  for(int i = 0 ; i < N ; i++){
    cin >> obj[i].c.p >> obj[i].c.r >> obj[i].l;
  }
  for(int i = 0 ; i < Q ; i++){
    Line l;
    cin >> l.s >> l.t;
    ll res = 0LL;
    for(int j = 0 ; j < N ; j++){
      if(isIntersectCL(obj[j].c,l)){
        res += obj[j].l;
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1240
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))

import itertools as iter
import math
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N,K = nums()
H = nums()
H.sort(reverse=True)
print(sum(H[K:]))

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	 cin>>arr[i];
	 long long res=0;
	 for(int i=0;i<n-1;i++)
	   for(int j=i+1;j<n;j++)
	     res+=(arr[i]*arr[j]);
	 cout<<res;
	return 0;
}

Measured memory_bytes: 256
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def lcm(a, b):
    return a * b / fractions.gcd(a, b)


def main():
    a, b = map(int, input().split())
    grid = [["." for i in range(100)] for j in range(100)]
    for i in range(50):
        for j in range(100):
            grid[i][j] = "#"

    for i in range(0, 50, 2):
        for j in range(0, 100, 2):
            if a == 1:
                break
            grid[i][j] = "."
            a -= 1
        if a == 1:
            break

    for i in range(51, 100, 2):
        for j in range(0, 100, 2):
            if b == 1:
                break
            grid[i][j] = "#"
            b -= 1

        if b == 1:
            break
    print(100,100)
    for i in range(100):
        print("".join(map(str, grid[i])))
        





if __name__ == '__main__':
    main()


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

using namespace std;
#define ll long long int

const int N = (int)4000+5;
const ll inf = (int)1e15+15;

ll dp[N][N];
string str1;
string str2;
string ans="";

string lcs(int m,int n) {
    if (m == 0 || n == 0) {
        return "";
    }
    if (str1[m-1] == str2[n-1]) {
        return lcs(m-1,n-1) + str1[m-1];
    }
    if (dp[m-1][n] > dp[m][n-1]) {
        return lcs(m-1,n);
    }
    return lcs(m,n-1);
}

int main() {
    cin >> str1 >> str2;

    for (int i = 1; i <= (int)str1.size(); i++) {
        for (int j = 1; j <= (int)str2.size(); j++) {
            if (i == 0 || j == 0) {
                dp[i][j] = 0;
                continue;
            }
            if (str1[i-1] == str2[j-1]) {
                dp[i][j] = dp[i-1][j-1] + 1;
            }else {
                dp[i][j] =  max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    int m =  str1.size();
    int n = str2.size();


    cout << lcs(m,n) << endl;

    return 0;
}

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

int main(){
	
	int S;
	int h, m, s;
	cin >> S;
	
	h = S / 3600;
	S = S % 3600;
	m = S / 60;
	s = S % 60;

	cout << h << ":" << m << ":" << s << endl;
	
	return 0;
}

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

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

int main()
{
int i;
int N;
int d;
set<int> sNum;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	rep( i, N )
	{
		cin >> d;
		sNum.insert( d );
	}

	cout << sNum.size() << endl;

	return 0;
}


Measured memory_bytes: 256
fun main() {
    var (a, b, c) = readLine()!!.split(" ")
        .map { it.toInt() }.sorted()

    var answer = 0

    val operation1 = (c - b) / 2
    answer += operation1
    b += operation1 * 2

    val operation2 = (c - a) / 2
    answer += operation2
    a += operation2 * 2

    if (a == b && b == c) {
        print(answer)
        return
    }

    if (a == b) {
        answer += 1
    }

    if (b == c) {
        answer += 2
    }

    if (a == c) {
        answer += 2
    }
    print(answer)
}


Measured memory_bytes: 39036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using Tuple = tuple<int, int, int>;




int main() {
    ll n,k; cin >> n >> k;

    n = n%k;

    while(abs(n-k) < n) {
        n = abs(n-k);
    }

    cout << n << endl;

    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE TupleSections #-}

import qualified Data.ByteString.Char8 as B
import           Data.Maybe (fromJust)
import qualified Data.Map.Strict as M
import           Control.Monad (replicateM)

modT :: Int
modT = 1000000007

main :: IO ()
main = do
  n <- getInt
  m <- M.fromListWith (+) . fmap ((, 1) . convert) <$> replicateM n getInts
  print . solve $ m

convert :: [Int] -> (Int, Int)
convert [a, b]
  | a == 0 && b == 0 = (0, 0)
  | a == 0 = (0, 1)
  | b == 0 = (1, 0)
  | otherwise = let gcd' = gcd a b
                in if b < 0
                   then (-div a gcd', -div b gcd')
                   else (div a gcd', div b gcd')

solve :: M.Map (Int, Int) Int -> Int
solve map = let zero = M.findWithDefault 0 (0, 0) map
                ans = solve' . M.delete (0, 0) $ map
            in (fromIntegral zero + ans - 1) `mod` modT

solve' :: M.Map (Int, Int) Int -> Int
solve' map =
  if M.null map
  then 1
  else let ((a, b), count) = M.elemAt 0 map
           inv = if a > 0
                 then (-b, a)
                 else (b, -a)
           count' = M.findWithDefault 0 inv map
           ncount = solve' . M.delete (a, b) . M.delete inv $ map
           ccount = ((pow2 count `mod` modT) + (pow2 count' `mod` modT) - 1)
             `mod` modT
       in (ncount * ccount) `mod` modT

getInt = fst . fromJust . B.readInt <$> B.getLine

getInts = fmap (fst . fromJust . B.readInt) . B.words <$> B.getLine

pow2 0 = 1
pow2 n = 2 * pow2 (n - 1) `mod` modT


Measured memory_bytes: 251492
#include "bits/stdc++.h"
#define rep(i, s, n)    for (int i = (s); i < (n); ++i)
using namespace std;

int V, E;
vector<int> G[1005];
enum {
    NEW, ACTIVE, FINISHED
} stat[1005];

bool dfs(int u) {
    stat[u] = ACTIVE;
    for (const int v : G[u]) {
        if (stat[v] == ACTIVE || dfs(v)) return true;
    }
    stat[u] = FINISHED;
    return false;
}

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

    cin >> V >> E;
    rep(i, 0, E) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
    }

    rep(u, 0, V) {
        if (stat[u] == NEW && dfs(u)) {
            cout << 0 << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

const int maxn = 10000+5;
pair<int,int> P[maxn];
struct Edge
{
    int from,to;
    double cost;
    Edge() {}
    Edge(int a,int b,double c):from(a),to(b),cost(c) {}
};
Edge es[maxn*100];
int N,M,father[maxn];
double res;

void init()
{
    for(int i=1; i<=N; ++i)
        father[i]=i;
}

bool cmp(Edge a,Edge b)
{
    return a.cost>b.cost;
}

int find(int x)
{
    if(x == father[x])
        return x;
    int temp = father[x];
    father[x] = find(father[x]);
    x = temp;
    return father[x];
}

void Kruskal()
{
    sort(es+1,es+1+M,cmp);
    init();
//    for(int i=1;i<=M;++i)
//        printf("%d %d %.3lf\n",es[i].from,es[i].to,es[i].cost);
    double ans=0;
    for(int i=1; i<=M; ++i)
    {
        Edge e = es[i];
        int x=find(e.from),y=find(e.to);
//        cout<<"before : "<<e.from<<" "<<e.to<<" "<<x<<" "<<y<<endl;
        if(x!=y)
        {
            father[x]=y;
            ans+=e.cost;
//            cout<<"after : "<<x<<" "<<y<<" "<<find(x)<<" "<<find(y)<<endl;
        }
    }
//    cout<<res<<" "<<ans<<endl;
    printf("%.3lf\n",res-ans);
}

int main()
{
    res=0;
    scanf("%d%d",&N,&M);
    for(int i=1; i<=N; ++i)
    {
        scanf("%d%d",&P[i].first,&P[i].second);
    }
    for(int i=1; i<=M; ++i)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        double temp = sqrt((P[a].first - P[b].first)*(P[a].first - P[b].first)+(P[a].second - P[b].second)*(P[a].second - P[b].second));
        res+=temp;
        es[i] = Edge(a,b,temp);
    }
    Kruskal();
}

Measured memory_bytes: 3756
#include<stdio.h>
int main()
{
	int n[100], i, j;
	scanf("%d", &j);

	for (i = 0;i < j;i++)
	{
		scanf("%d", &n[i]);
	}

	for (i = j;--i >= 0;)
	{
		printf("%d%s", n[i], i == 0 ? "\n" : " ");
	}
	return 0;
}


Measured memory_bytes: 2056
#include<bits/stdc++.h> 
#define ll unsigned long long 
using namespace std; 
ll Q,H,S,D,N; 
int main() 
{ 
    cin>>Q>>H>>S>>D>>N; 
    Q*=4; 
    H*=2; 
    Q=min(Q,min(H,S)); 
    if(Q*2<=D)return cout<<Q*N,0; 
    if(N&1)cout<<(N-1)/2*D+Q; 
    else cout<<N/2*D; 
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b;
    char c;
    scanf("%d",&a);
    scanf(" %c",&c);
    scanf("%d",&b);
    if(c=='+'){
        printf("%d\n",a+b);
    }
    else{
        printf("%d\n",a-b);
    }
    return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
//////////////

void solve() {
	int A, B;
	cin >> A >> B;
	int ans = 0;
	if (A <= 5) {
		ans = 0;
	}
	else if (A <= 12) {
		ans = B / 2;
	}
	else {
		ans = B;
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


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


int main (){
    int N;
    string S, T;
    cin>>N>>S>>T;
    for(int i=0; i<N; i++){
        cout<<S.at(i)<<T.at(i);
    }
}



Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
int main(){
  double vx,vy,v,x1,x2,y1,y2;
  scanf("%lf%lf%lf%lf", &x1,&y1,&x2,&y2);
  vx=(x2-x1)*(x2-x1);
  vy=(y2-y1)*(y2-y1);
  v=vx+vy;
  printf("%0.8f\n",sqrt(v));
  return 0;
}

Measured memory_bytes: 1088
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int main(void) {
	ll n, k;
	cin >> n;
	vector<ll> x(n), y(n), h(n), dh(n);
	rep(i, 0, n)cin >> x[i] >> y[i] >> h[i];
	rep(cx, 0, 101) {
		rep(cy, 0, 101) {
			bool ok = true;
			rep(i, 0, n) {
				if(h[i] > 0)k = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
			}
			rep(i, 0, n) {
				if (max(k - abs(x[i] - cx) - abs(y[i] - cy), 0ll) != h[i]) {
					ok = false;
					break;
				}
			}
			if (ok) {
				printf("%d %d %lld\n", cx, cy, k);
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll n; cin >> n;
  vector<ll> v;
  for(ll i = 1; i*i <= n; ++i){
    if(n%i==0)v.push_back(i);
    if(i*i == n)continue;
    if(n%i==0)v.push_back(n/i);
  }
  ll ans = 0;
  for(auto e:v){
    if(e==1)continue;
    ll m = e-1;
    ll x = n/e;
    if(n/m==x&&n%m==x)ans += m;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
string s; 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>s;
	if(s[0]=='7'||s[1]=='7'||s[2]=='7')cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 3612
import sys
input = sys.stdin.readline
from operator import itemgetter

n = int(input())
li = []
for i in range(n):
    a,b = map(int,input().split())
    li.append([b-a,b,a])
li.sort(reverse=True,key=itemgetter(1))
for i in range(n-1):
    if li[i][0] < li[i+1][1]:
        li[i+1][1] = li[i][0]
        li[i+1][0] = li[i+1][1] - li[i+1][2]
if li[-1][0] < 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 80988
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

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

string s;

int main() {
  cin >> s;
  int ans = s.size();
  rep(i,0,26) {
    int cnt = 0;
    int sm = 0;
    rep(j,0,s.size()) {
      if(s[j] - 'a' == i) {
        cnt = 0;
      } else {
        cnt++;
      }
      sm = max(sm, cnt);
    }
    ans = min(ans, sm);
  }
  P(ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define NIL (-1)
#define MaxN 1000003 // 100万以上で最小の素数
using namespace std;

int str2int(string key){
    int ans = 0;
    int j = 0;

    while(1){
        if (key[j] == 'A'){
            ans += 1 * pow(5, j);
        }else if (key[j] == 'C'){
            ans += 2 * pow(5, j);
        }else if (key[j] == 'G'){
            ans += 3 * pow(5, j);
        }else if (key[j] == 'T'){
            ans += 4 * pow(5, j);
        }else{
            break;
        }
        j++;
    }
    return ans;
}

// string int2str(int keyval){
//     string ans = "";

//     while(1){
//         if (keyval % 5 == 1){
//             ans += "A";
//         } else if (keyval % 5 == 2){
//             ans += "C";
//         } else if (keyval % 5 == 3){
//             ans += "G";
//         }else if (keyval % 5 == 4){
//             ans += "T";
//         }
//         keyval /= 5;
//         if (keyval == 0) break;
//     }

//     return ans;
// }

int hashval(int keyval, int i){
    int hash1 = keyval % MaxN;
    int hash2 = 1 + keyval % (MaxN - 1);

    return (hash1 + i * hash2) % MaxN;
}


void insert(int keyval, int Tab[]){
    int i = 0;
    while(Tab[hashval(keyval, i)] != NIL){
        i++;
    }
    Tab[hashval(keyval, i)] = keyval;
}

int find(int keyval, int Tab[]){
    int i = 0;
    while(1){
        if (Tab[hashval(keyval, i)] == keyval){
            // cout << "Yes" << endl;
            // return;
            return 1;
        }else if ( (Tab[hashval(keyval, i)] == NIL) || (i >= MaxN) ){
            // cout << "No" << endl;
            // return;
            return 2;
        }else{
            i++;
        }
    }
}


int main(){
    int n;
    cin >> n;
    string order;
    string str;
    int val;
    int findres;
    int T[MaxN];
    rep(i, MaxN) T[i] = NIL;
    
    rep(i, n){
        cin >> order >> str;
        val = str2int(str);

        if (order[0] == 'i'){

            insert(val, T);   // insert 命令

        }else if(order[0] == 'f'){
            findres = find(val, T);
            if (findres == 1){   // find 命令
                cout << "yes" << endl;
            }else if (findres == 2){   // find 命令
                cout << "no" << endl;
            }
        }

    }
    return 0;
}


Measured memory_bytes: 7260
N, M, Q = map(int, input().split())
L = []
for i in range(Q):
    L.append(list(map(int, input().split())))
 
def f(s):
    if len(s) == N:
        return [s]
    yy = []
    if s == '':
        r = 0
    else:
        r = int(s[-1])
    for i in range(r, M):
        yy.extend(f(s + str(i)))
    return yy
 
ans = 0
V = f('')
for s in V:
    A = [int(c) + 1 for c in s]
    t = 0
    for a, b, c, d in L:
        if A[b - 1] - A[a - 1] == c:
            t += d
    ans = max(ans, t)
print(ans)

Measured memory_bytes: 15876
#include <bits/stdc++.h>
#define JN ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define mod 1000000007

#define pb push_back
#define mp make_pair

using namespace std;
typedef unsigned long long int ull;
typedef long long int          ll;

int n, W;


ll dp[3005][3005];





int main()
{
    JN;


    string s, t;
    cin >> s;
    cin >> t;

    string result="";

    for(int i=1; i<=s.size(); i++)
    {
        
        for(int j=1; j<=t.size(); j++)
        {
            if(s[i-1] == t[j-1])
            {
                dp[i][j] = dp[i-1][j-1] + 1;
                
            }
            else
            {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    int i=s.size(), j=t.size();

    while(i>0 and j>0)
    {
        if(s[i-1] == t[j-1])
        {
            result+=s[i-1];
            i--;
            j--;
        }

        else if(dp[i-1][j] >  dp[i][j-1])
            i--;
        else
            j--;
    }
    

    reverse(result.begin(), result.end());
    cout << result << "\n";
    
    
    return 0;

}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1000000007;
int main() {
	ll i,j,k,l,m,n,t;
	ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string a, b;
  cin >> a >> b;
  n = a.length();
  m = b.length();
  ll ansi = 0, ansj = 0, ans=0;
  vector<vector<ll> > dp(n+1, vector<ll>(m+1, 0));
  pair<char, pair<ll, ll> > prev[n + 1][m + 1];
  for (i = 1; i <= n; i++)
  {
    for (j = 1; j <= m; j++)
    {
      prev[i][j] = make_pair(' ', make_pair(-1, -1));
      if (a[i - 1] == b[j - 1])
      {
        dp[i][j] = 1 + dp[i-1][j-1];
        prev[i][j] = make_pair(a[i-1], make_pair(i-1, j-1));
      }
      if (dp[i][j] < dp[i][j - 1]){
        dp[i][j] = dp[i][j-1];
        prev[i][j] = make_pair(' ', make_pair(i, j-1));
      }
      if (dp[i][j] < dp[i-1][j]){
        dp[i][j] = dp[i-1][j];
        prev[i][j] = make_pair(' ', make_pair(i-1, j));
      }
      if (dp[i][j] > ans)
      {
        ans = dp[i][j];
        ansi = i;
        ansj = j;
      }
      // cout << i << ' ' << j << ' ' << dp[i][j] << ' ' << prev[i][j].first << prev[i][j].second.first<< prev[i][j].second.second << endl;
      // ans = max(ans, dp[i][j]);
    }
  }

  string sol;
  while (ansi > 0 && ansj > 0)
  {
    char c = prev[ansi][ansj].first;
    if (c!= ' ')
    {
      sol = c + sol;
    }
    // cout << ansi << ' ' << ansj << ' ' << c << endl;
    ll newj = prev[ansi][ansj].second.second;
    ansi = prev[ansi][ansj].second.first;
    ansj = newj;
  }
  cout << sol<< endl;

  return 0;
}

Measured memory_bytes: 281856
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		partA();
		
	}
	
	public static void partA() {
		Scanner scA = new Scanner(System.in);
		int N = scA.nextInt();
		
		if (N <= 999) {
			System.out.println("ABC");
		}else if(N <= 1998) {
			System.out.println("ABD");
		}
	}
}

Measured memory_bytes: 21844
S = list(str(input()))
T = list(str(input()))
moji = "abcdefghijklmnopqrstuvwxyz"
tmp_1 = []
tmp_2 = []
for i in range(26):
  count = S.count(moji[i])
  tmp_1.append(count)
for i in range(26):
  count = T.count(moji[i])
  tmp_2.append(count)
tmp_1.sort()
tmp_2.sort()
if tmp_1 == tmp_2:
  print("Yes")
else:
  print("No")

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

int main()
{
	int N, T;
	cin >> N >> T;
	vector<int> t(N);
	for (int i = 0; i < N; i++) {
		cin >> t[i];
	}
	int res = T;
	for (int i = 1; i < N; i++) {
		res += min(T, t[i] - t[i - 1]);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define printd(x) printf("%.12f\n", ans);
#define print(x) cout << (x) << endl;
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
#define all(x) (x).begin(),(x).end()
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main(void) {
    int n, r;
    cin >> n >> r;

    cout << (n >= 10 ? r : r + 100 * (10 - n)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);

struct block {
	int h, w;
	vector<vector<char>> b;
};

block b[4];
char ori[4][10];
char cur[4][10];
bool match(int x, int y, int id) {
	//cout << x << " " << y << " " << id << endl;
	int h = b[id].h, w = b[id].w;
	rep(i, h) {
		rep(j, w) {
			if (b[id].b[i][j] == '#') {
				//cout << x + i << " " << y + j << endl;
				if (x + i >= 4 || y + j >= 10)return false;
				if (cur[x + i][y + j] == '#')return false;
			}
		}
	}
	//cout << x << " " << y << " " << id << endl;
	return true;
}
void paint(int x, int y, int id) {
	int h = b[id].h, w = b[id].w;
	rep(i, h) {
		rep(j, w) {
			if (b[id].b[i][j] == '#') {
				cur[x + i][y + j] = '#';
			}
		}
	}
}
void solve() {
	rep(i, 4) {
		cin >> b[i].h >> b[i].w;
		b[i].b.resize(b[i].h);
		
		rep(j, b[i].h) {
			b[i].b[j].resize(b[i].w);
			rep(k, b[i].w) {
				cin >> b[i].b[j][k];
			}
		}
	}
	int n; cin >> n;
	rep(aa, n) {
		rep(i, 4) {
			rep(j, 10) {
				cin >> ori[i][j];
			}
		}
		vector<int> a = { 0,1,2,3 };
		string ans = "No";
		while (true) {
			int id = 0;
			rep(i, 4)rep(j, 10)cur[i][j] = ori[i][j];
			bool valid = true;
			rep(i, 4) {
				rep(j, 10) {
					if (match(i, j, a[id])) {
						paint(i, j, a[id]); id++;
					}
					if (cur[i][j] == '.') {
						valid = false; break;
					}
				}
				if (!valid)break;
			}
			if (valid) {
				ans = "Yes"; break;
			}
			if (!next_permutation(a.begin(), a.end()))break;
		}
		cout << ans << endl;
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}




Measured memory_bytes: 3216
#include <iostream>
#include <algorithm>
#include <functional>
#define rep(i, a, n) for(int i = a;i < n;i++)
#define repr(i, a, n) for(int i = a;i > n;i--)
using namespace std;


int e, f, g, h, i, j, k, l, m;

bool solve(){
	if(!(e - k == f - l && f - l == g - m && e - k == g - m)) return false;
	if(!(e - h == f - i && f - i == g - j && e - h == g - j)) return false;
	if(!(h - k == i - l && i - l == j - m && h - k == j - m)) return false;
	return true;
}


int main(){
	cin >> e >> f >> g >> h >> i >> j >> k >> l >> m;

	if(solve()) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;


string A, B, C;
int a_now = 0, b_now = -1, c_now = -1;
void calc(char c){
    if(c == 'z') return;
    if(c == 'a'){
        a_now++;
        calc(A[a_now]);
    }else if(c == 'b'){
        b_now++;
        calc(B[b_now]);
    }else{
        c_now++;
        calc(C[c_now]);
    }

}
int main(){
    cin >> A >> B >> C;
    A.append("z");
    B.append("z");
    C.append("z");
    calc(A[0]);
    if(A[a_now] == 'z') puts("A");
    else if(B[b_now] == 'z') puts("B");
    else puts("C");
}

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

int a[111111];
int main(){
    int N; scanf("%d",&N);
    for(int i=1;i<=N;i++) scanf("%d",a+i);

    int s = 0;
    for(int i=0;i<=N;i++) s += abs(a[i]-a[i+1]);
    for(int i=1;i<=N;i++){
        printf("%d\n", s - (abs(a[i-1]-a[i]) + abs(a[i]-a[i+1]) - abs(a[i-1]-a[i+1])));
    }
}


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

#define INF  						1e15
#define EPS   						1e-9
#define MOD 						1000000007
#define Pi 							3.14159265358979323846264338327950288419716939937510

#define umap 						unordered_map
#define uset 						unordered_set
#define fi 							first
#define se 							second
#define ll 							long long 
#define vi 							vector<int>
#define pii 						pair<int,int>
#define vll 						vector<ll>
#define pll							pair<ll,ll>
#define pb 							push_back
#define pob 						pop_back
#define pf 							push_front
#define pof 						pop_front
#define maxE(a,n) 					*max_element(a,a+n);
#define minE(a,n) 					*min_element(a,a+n);
#define all(x) 						x.begin(), x.end()

#define fast 						ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fori(i,a,n) 				for (ll  i=a;i<n;i++)
#define ford(i,a,n) 				for (ll  i=n-1;i>=a;i--)


using namespace std;

vector<ll> edges[200005];
vector<bool> visited(200005);

void dfs(ll sv){
	visited[sv] = true;

	for(auto v: edges[sv]){
		if(visited[v] == false){
			dfs(v);
		}
	}

	return;
}

void solve(){

	ll n,m;
	cin>>n>>m;

	for(ll i=0;i<m;i++){
		ll u,v;
		cin>>u>>v;

		edges[u-1].pb(v-1);
		edges[v-1].pb(u-1);
	}
	
	fori(i,0,n){
		visited[i] = false;
	}

	vector<ll> temp;
	for(ll i=0;i<n;i++){
		if(visited[i] == false){
			temp.pb(i);
			dfs(i);
		}
	}

	ll count = temp.size() - 1;
	cout<<count<<endl;
	return;
}


int main(){

	fast;
	ll t = 1;

	while(t--){
		solve();
	}
}

Measured memory_bytes: 12792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		sc.close();

		int cnt = 0;
		for(int i = A;i <= B;i++) {
			String s1 = String.valueOf(i);
			String s2 = "";
			char[] ch = String.valueOf(i).toCharArray();
			for(int j = ch.length-1;j >= 0;j--) {
				s2 += ch[j];
			}
			if(s1.equals(s2)) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	ll N,K; cin >> N >> K;
	vector<int> A(N);
	for(int i = 0; i < N; ++i) {
		cin >> A[i];
		A[i]--;
	}
	int x = 0;
	for(int i = 0; i < min(K,300000LL); ++i){
		x = A[x];
	}
	corner(K<=300000,x+1);
	K -= 300000;
	vector<int> B(N,-1),C;
	B[x] = 0;
	C.push_back(x);
	while(1) {
		int y = A[x];
		if(B[y]!=-1) break;
		B[y] = B[x]+1;
		x = y;
		C.push_back(x);
	}
	int cnt = B[x]+1;
	cout << C[K%cnt] + 1 << endl;

    return 0;
}


Measured memory_bytes: 5352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int five = 0, seven = 0;
  if(a == 5){
    five++;
  }
    if(a == 7){
    seven++;
    }
  if(b == 5){
    five++;
  }
    if(b == 7){
    seven++;
    }
    if(c == 5){
    five++;
  }
    if(c == 7){
    seven++;
    }
  if(five == 2 && seven == 1){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  return(0);
}

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

typedef long long ll;

int n,x[15],y[15],p[15],D[15],d[15];
ll ans[16];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>p[i];
    memset(ans,0x3f,sizeof(ans));
    ans[0]=0;
    for(int i=0;i<n;i++){
        D[i]=min(abs(x[i]),abs(y[i]));
        ans[0]+=(ll)p[i]*D[i];
    }
    for(int s=0;s<1<<n;s++){
        for(int t=s;t;t=(t-1)&s){
            memcpy(d,D,sizeof(d));
            for(int i=0;i<n;i++){
                if(s>>i&1){
                    if(t>>i&1){
                        for(int j=0;j<n;j++){
                            d[j]=min(d[j],abs(x[i]-x[j]));
                        }
                    }else{
                        for(int j=0;j<n;j++){
                            d[j]=min(d[j],abs(y[i]-y[j]));
                        }
                    }
                }
            }
            ll cur=0;
            for(int i=0;i<n;i++){
                cur+=(ll)d[i]*p[i];
            }
            ans[__builtin_popcount(s)]=min(ans[__builtin_popcount(s)],cur);
        }
        {
            int t=0;
            memcpy(d,D,sizeof(d));
            for(int i=0;i<n;i++){
                if(s>>i&1){
                    // if(t>>i&1){
                    //     for(int j=0;j<n;j++){
                    //         d[j]=min(d[j],abs(x[i]-x[j]));
                    //     }
                    // }else{
                        for(int j=0;j<n;j++){
                            d[j]=min(d[j],abs(y[i]-y[j]));
                        }
                   // }
                }
            }
            ll cur=0;
            for(int i=0;i<n;i++){
                cur+=(ll)d[i]*p[i];
            }
            ans[__builtin_popcount(s)]=min(ans[__builtin_popcount(s)],cur);
        }
    }
    for(int i=0;i<=n;i++)cout<<ans[i]<<'\n';

    return 0;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
  if(a < b) {
    a= b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if(a > b) {
    a= b;
    return 1;
  }
  return 0;
}
ll mod= 998244353;

ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M)%M;
}

int main() {
  ll ans= 1;
  ll n;
  cin >> n;
  ll a[n]= {};
  ll b[n];
  ll ma=0;
  rep(i, n) {
    cin >> b[i];
    a[b[i]]++;
    chmax(ma,b[i]);
  }
  rep(i,ma+1)if(a[i]==0){cout<< 0 << endl; return 0;}//一番近い頂点同士との距離が2以上は存在してはいけない
  if(a[0]!=1){cout << 0 <<endl;return 0;}//頂点1との距離0は1個でないといけない
  if(b[0]!=0){cout << 0 <<endl;return 0;}//頂点1が0でないといけない
  
  for(int i=1;i<=ma;i++){
      ans=ans*RepeatSquaring(a[i-1],a[i],mod)%mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5104
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Debug.Trace
import Data.Array.IArray
import Data.Array.IO
     
getInts :: IO [Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine
     
inf = 1000000000
     
solve es arr = length [() | [a,b,c] <- es, arr!(a,b) /= c]

main = do
  [n,m] <- getInts
  dt <- newArray ((1,1),(n,n)) inf :: IO (IOArray (Int,Int) Int)
  es <- replicateM m getInts
  forM_ es $ \[a,b,c] -> do
    writeArray dt (a,b) c
    writeArray dt (b,a) c
  forM_ [1..n] $ \k ->
    forM_ [1..n] $ \i ->
      forM_ [1..n] $ \j -> do
        a <- readArray dt (i,k)
        b <- readArray dt (k,j)
        pv <- readArray dt (i,j)
        writeArray dt (i,j) (min pv (a+b))
  arr <- freeze dt :: IO (Array (Int,Int) Int)
  print $ solve es arr


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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define OUT(a) cout << (a) << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);
const long long MOD = 1000000007;

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    queue<ll> q;
    ll k, ans;

    cin >> k;

    REP(i, 9){
        q.push(i+1);
    }

    REP(i, k){
        ans = q.front();
        q.pop();
        if (ans%10 != 0){
            q.push(10*ans + ans%10 - 1);
        }

        q.push(10*ans + ans%10);

        if(ans%10 != 9){
            q.push(10*ans + ans%10 + 1);
        }
    }

    cout << ans << endl;

    return 0;
}

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

const int MAX=1000001;
int N;
int A[MAX];
int count=0;
vector<int>F;
void insertionsort(int A[],int g){
	
	for(int i=g;i<N;i++){
		int j=i-g;
	   while(j>=0 && A[j]>A[j+g]){
         swap(A[j],A[j+g]);
		 j=j-g;
		count++;
	   }
	}
}

void shellsort(int A[]){
  for(int h=1;;)
  {
	  if(h>N)break;
	  F.push_back(h);
	  h=3*h+1;
  }
  for(int i=F.size()-1;i>=0;i--){
	insertionsort(A,F[i]);
  }
}



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

	cout<<F.size()<<endl;
	cout<<F[F.size()-1];
	for(int i=F.size()-2;i>=0;i--)
		cout<<" "<<F[i];
	cout<<endl;
	cout<<count<<endl;
	for(int i=0;i<N;i++)
		cout<<A[i]<<endl;
	return 0;

}

Measured memory_bytes: 7036
require 'matrix'

def gcd(m, n)
	if m < n 
		gcd(n, m)
	elsif n == 0
		m
	else
		gcd(n, m % n)
	end 
end

loop do
	eq = gets.chomp.chop
	break if eq == ""

	alph = (?a..?z).to_a + (?A..?Z).to_a
	rename = {}

	eq.gsub!(/[A-Z][a-z]?/){|a| rename[a] ||= alph.shift}
	eq.gsub!(/[a-zA-Z](?!\d)/){|x| "#{x}1"}
	eq.gsub!(/\((.+?)\)(\d*)/){
		as, k = $1, $2.to_i
k = 1 if k == 0
		as.gsub(/([a-zA-Z])(\d+)/){"#{$1}#{$2.to_i * k}"}
	}

	moles = eq.split(/->/).map{|ms| ms.split(?+)}
	l = moles[0].size
	moles.flatten!

	atoms = rename.values
	m = atoms.size
	n = moles.size - 1

	a = Matrix.build(m, n){|m, n|
		atom = atoms[m]
		k = 0
		moles[n].scan(/#{atom}(\d+)/).each{|arr|
			k += arr[0].to_i
		}

		if k > 0
			Rational(n >= l ? -k : k)
		else
			Rational(0)
		end
	}.to_a

	v = [0] * m
	moles[-1].scan(/([a-zA-Z])(\d+)/).each{|a, k|
		v[atoms.index(a)] = Rational(k.to_i)
	}

	order = (0..m-1).to_a
	(0..[m,n].min-1).each do |i|
		pivot = (i..m-1).max_by{|k| a[k][i].abs}
		break if a[pivot][i] == 0
		a[i], a[pivot] = a[pivot], a[i]
		v[i], v[pivot] = v[pivot], v[i]
		((0..m-1).to_a - [i]).each do |j|
			r = a[j][i] / a[i][i]	
			(i..n-1).each do |k|
				a[j][k] -= r * a[i][k]
			end
			v[j] -= r * v[i]
		end
	end

	while a.last.all?{|x| x == 0}
		a.pop
		v.pop
	end

	ans = (Matrix[*a].inv * Vector[*v]).to_a + [Rational(1)]

	ds = ans.map(&:denominator)
	lcm = ds.inject{|g, x| g * x / gcd(g, x)}
	puts ans.map{|x| (x * lcm).to_i} * ' '
end

Measured memory_bytes: 9876
import math

a, b, c = map(float,input().split())

print(a*b*math.sin(c*math.pi/180)/2)
print(math.sqrt(a*a+b*b-2*a*b*math.cos(c*math.pi/180))+a+b)
print(a*b*math.sin(c*math.pi/180)/a)


Measured memory_bytes: 5692
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

set<int> idxs[26];

bool isKaibun(const string &s) {
    REP(i, s.size() / 2) {
        if (s[i] != s[s.size() - i - 1]) {
            return false;
        }
    }
    return true;
}

int main(void) {
    string s;
    cin >> s;
    int ans = 0;
    int l = 0, r = (int)s.size() - 1;
    while (l < r) {
        while (l < r && s[l] == s[r]) {
            l++;
            r--;
        }
        if (l >= r) break;
        if (s[l] == 'x') {
            l++;
            ans++;
        } else if (s[r] == 'x') {
            r--;
            ans++;
        } else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512