akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> X = new ArrayList<>();
        double sum = 0;
        for(int i=0;i<N;i++){
            X.add(sc.nextInt());
            sum+=X.get(i);
        }
        sum/=X.size();
        sum = Math.round(sum);
        int opt = 0;
        for(int i=0;i<N;i++) opt+=Math.pow(X.get(i)-sum,2);
        System.out.println(opt);
    }
}

Measured memory_bytes: 23764
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))

a_list=[]
for i in range(n):
 a_list+=[(i+1)]*a[i]

inx=0
ans=[0]*w
for i in range(h):
 if i%2==0:
  for j in range(w):
   ans[j]=a_list[inx]
   inx+=1
 else:
  for j in range(w-1,-1,-1):
   ans[j]=a_list[inx]
   inx+=1

 print(*ans)

Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

ll v[50];
ll C[52][52];
signed main() {
	C[0][0] = 1;
	for (int i = 1; i <= 50; i++)for (int j = 0; j <= i; j++) {
		if (j == 0 || j == i)C[i][j] = 1;
		else C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
	}
	int n, a, b; scanf("%d%d%d", &n, &a, &b);
	rep(i, n)scanf("%lld", &v[i]);
	sort(v, v + n, greater<>());
	ll sum = 0;
	int cnt = 0;
	rep(i, a) {
		sum += v[i];
		if (v[i] == v[a - 1])cnt++;
	}
	int k = 0;
	rep(i, n) {
		if (v[i] == v[a - 1])k++;
	}
	printf("%.12lf\n", sum / (double)a);
	if (v[0] == v[a - 1]) {
		ll ans = 0;
		for (int i = a; i <= min(k, b); i++)ans += C[k][i];
		cout << ans << endl; return 0;
	}
	cout << C[k][cnt] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,m,a[N],st[N],b[N],hs[N],tot,head[N],nex[N<<1],to[N<<1],wi[N<<1];
void add(int u,int v,int w){to[++tot]=v;nex[tot]=head[u];head[u]=tot;wi[tot]=w;}
bool vis[N],use[N];
int lowb(int x)
{
    return lower_bound(hs+1,hs+1+n,x)-hs;
}
int uppb(int x)
{
    return upper_bound(hs+1,hs+1+n,x)-hs;
}
bool dfs(int u)
{
    vis[u]=true;
    int x=b[u];
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];
        if(!vis[v]&&dfs(v))
        {
            x^=1;use[wi[i]]=true;
        }
    }
    return x;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&a[i],&b[i]),hs[i]=a[i];
    sort(hs+1,hs+1+n);
    for(int i=1;i<=n;i++)
        a[i]=lowb(a[i]),st[a[i]]=b[i];
   // for(int i=n+1;i>=1;i--)
   //     st[i]^=st[i-1];
    for(int i=1;i<=n+1;i++)
        if(st[i]==st[i-1])
            b[i]=0;
    else b[i]=1;
    //for(int i=1;i<=n+1;i++)
    //    printf(i==n+1?"%d\n":"%d ",b[i]);
    for(int i=1;i<=m;i++)
    {
        int l,r;scanf("%d%d",&l,&r);
        l=lowb(l);
        r=uppb(r)-1;
        if(l<=r)
            add(l,r+1,i),add(r+1,l,i);
    }
    for(int i=1;i<=n+1;i++)
        if(!vis[i]&&dfs(i))
    {
        printf("-1\n");return 0;
    }
    int ans=0;
    for(int i=1;i<=m;i++)
        if(use[i]) ans++;
    printf("%d\n",ans);
    for(int i=1;i<=m;i++)
    if(use[i])
        printf("%d ",i);
}


Measured memory_bytes: 11008
a,b,c,x,y = map(int,raw_input().split(" "))

ans = 10**1000

dat3 = [0, x*2,y*2]

for cc in dat3:
  aa = x - cc/2
  if aa < 0:aa = 0
  bb = y - cc/2
  if bb < 0:bb=0
  p = aa*a + bb*b + cc*c
  if p < ans:
    ans = p
print ans

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int H,W;
char field[60][60];
int dis[60][60];
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

void BFS() {
  dis[0][0] = 0;
  queue<P> que;
  que.push(make_pair(0,0));
  while (!que.empty()) {
    P p = que.front();
    que.pop();
    for (int i = 0; i < 4; i++) {
      int nx = p.F + dx[i];
      int ny = p.S + dy[i];
      if (0 <= nx && nx < H && 0 <= ny && ny < W) {
        if (field[nx][ny] == '.' && dis[nx][ny] > dis[p.F][p.S] + 1) {
          dis[nx][ny] = dis[p.F][p.S] + 1;
          que.push(make_pair(nx,ny));
        }
      }
    }
  }
  return ;
}

int main() {
  cin >> H >> W;
  int ans = 0;
  int cnt = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> field[i][j];
      if (field[i][j] == '.') {
        cnt++;
      }
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      dis[i][j] = 99999999;
    }
  }
  BFS();
  ans = cnt - dis[H-1][W-1] - 1;
  if (dis[H-1][W-1] == 99999999) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxx=500100;
int A[maxx];
int n;

void max_heap(int i){
	int left=2*i,right=2*i+1,x;
	if(left<=n && A[left]>A[i]) x=left;
	else x=i;
	if(right<=n && A[right]>A[x] ) x=right;
	if(x!=i){
		swap(A[x],A[i]);
		max_heap(x);
	}
	return ;
}

int main (){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>A[i];
	for(int i=n/2;i>=1;i--) max_heap(i);
	for(int i=1;i<=n;i++) cout<<" "<<A[i];
	cout<<endl;
	return 0;
}


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

#define dbg(x) cerr << #x"=" << x << endl;

int main() {
	//freopen("in.txt", "r" , stdin);
	int n,a,b,x;
	int cnt[3];
	while(cin >> n >> a >> b){
        memset(cnt, 0, sizeof cnt);
        for(int i = 0; i < n; ++i) {
            cin >> x;
            if(x <= a){
                cnt[0]++;
            } else if(x >= a+1 && x <= b){
                cnt[1]++;
            } else cnt[2]++;
        }
        cout << *min_element(cnt, cnt+3) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import scala.collection.mutable
import scala.io.StdIn._

case class Edge(to: Int, cost: Int)

object Main extends App {
  val n = readInt()
  val edges = for (i <- 0 until n) yield {
    val (_ :: k :: rest) = readLine().split(" ").map(_.toInt).toList
    for (j <- 0 until k) yield {
      Edge(rest(j * 2), rest(j * 2 + 1))
    }
  }

  val que = mutable.PriorityQueue(Edge(0, 0))(Ordering.by((e: Edge) => e.cost).reverse)
  val d = mutable.Seq.fill(n)(Int.MaxValue)
  d(0) = 0

  while (que.nonEmpty) {
    val edge = que.dequeue()
    if (d(edge.to) >= edge.cost) {
      edges(edge.to).foreach(e => {
        if (d(e.to) > d(edge.to) + e.cost) {
          d(e.to) = d(edge.to) + e.cost
          que.enqueue(e)
        }
      })
    }
  }

  d.zipWithIndex.foreach {
    case (x, i) => println(s"$i $x")
  }
}

Measured memory_bytes: 251860
#include<iostream>
#include<map>
#include<algorithm>
#include<set>
using namespace std;
int main(){
	string s;
	map<const char,int> mp;
	cin>>s;
	for(int i=0;i<(int)s.size();i++){
		mp[s[i]]++;
	}
	cout<<min(min(mp['K'],mp['U']),min(mp['C'],mp['P']))<<endl;
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
using namespace std;

int main()
{
	string s;

	cin >> s;

	s = 'W' + s + 'B';

	list<int> l;
	int len = s.length();

	int b = 0;
	int w = 0;
	int i = 0;
	while (i < len)
	{
		int c = 0;
		char tmp = s[i];
		while (s[i] == tmp)
		{
			c++;
			i++;
		}
		l.push_back(c);
		if (tmp == 'B')
		{
			b += c;
		}
		if (tmp == 'W')
		{
			w += c;
		}
	}

	w -= l.front();
	b -= l.back();
	l.pop_front();
	l.pop_back();

	int pos = 0, maxpos = 0;

	for (auto p = l.begin(); p != l.end(); p++)
	{
		pos += *p;
		if (maxpos < pos)
		{
			maxpos = pos;
		}
		p++;
		pos -= *p;
	}

	unsigned long long cnt = 0;
	unsigned long long tmpw = w;

	for (auto p = l.begin(); p != l.end(); p++)
	{
		cnt += *p * tmpw;
		p++;
		tmpw -= *p;
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 100000;
vector<int> G[N];

int d[N],par[N],dp[N];
void dfs(int now, int p)
{
    par[now] = p;

    if(p==-1) d[now]=0;
    else d[now] = d[p]+1;

    dp[now] = 1;
    for(int nx:G[now])if(nx!=p)
    {
        dfs(nx,now);
        dp[now] += dp[nx];
    }
}

int main()
{
    int n;
    cin >>n;
    rep(i,n-1)
    {
        int a,b;
        cin >>a >>b;
        --a; --b;
        G[a].pb(b);
        G[b].pb(a);
    }

    dfs(0,-1);

    int v=n-1;
    rep(i,(d[n-1]-1)/2) v = par[v];

    string ans = "Fennec";
    if((n+1)/2<=dp[v]) ans = "Snuke";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13184
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない


int main() {

	string s, t;

	cin >> s >> t;
	int r1[26], r2[26];
	rep(i, 0, 26) {
		r1[i] = r2[i] = -1;
	}

	

	rep(i, 0, s.size()) {
		if (r1[(int)s[i] - 97] < 0) {
			r1[(int)s[i] - 97] = (int)t[i] - 97;
		}
		else if (r1[(int)s[i] - 97] != (int)t[i] - 97){
				No; return 0;
		}

		if (r2[(int)t[i] - 97] < 0) {
			r2[(int)t[i] - 97] = (int)s[i] - 97;
		}
		else if (r2[(int)t[i] - 97] != (int)s[i] - 97) {
				No; return 0;
		}
	}

	Yes;

	return 0;
}

Measured memory_bytes: 776
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>

using namespace std;

int main(){

	long long int must_amount,budget,price_aizu,price_normal,aizu_limit,left,right,max_aizu,max_normal,m,tmp_normal;

	while(true){
		scanf("%lld",&must_amount);
		if(must_amount == 0)break;

		scanf("%lld %lld %lld %lld",&budget,&price_aizu,&price_normal,&aizu_limit);

		max_aizu = 0;

		left = 1,right = aizu_limit;
		m = (left + right)/2;

		while(left <= right){
			if(price_aizu*m > budget){
				right = m - 1;
				m = (left + right)/2;
			}else{
				tmp_normal = (budget - price_aizu*m)/price_normal;
				if(tmp_normal + m >= must_amount){
					max_aizu = m;
					max_normal = tmp_normal;
					left = m + 1;
					m = (left + right)/2;
				}else{
					if(price_aizu < price_normal){
						left = m + 1;
						m = (left + right)/2;
					}else{
						right = m - 1;
						m = (left + right)/2;
					}
				}
			}
		}

		if(max_aizu == 0)printf("NA\n");
		else{
			printf("%lld %lld\n",max_aizu,max_normal);
		}
	}
	return 0;
}

Measured memory_bytes: 2684
use std::io::*;
use std::sync::Mutex;

pub struct Scanner {
    source: Mutex<Bytes<BufReader<Stdin>>>,
}

impl Scanner {
    pub fn new() -> Scanner {
        Scanner {
            source: Mutex::new(Read::bytes(BufReader::new(stdin()))),
        }
    }
    pub fn source(&mut self) -> &Mutex<Bytes<BufReader<Stdin>>> {
        return &self.source;
    }
}

#[allow(unused_macros)]
macro_rules! rin {
    ( from $scanner:ident, $( $rep:tt )* ) => {
        let mut locked_stdin = $scanner.source().lock().unwrap();
        #[allow(unused_mut)]
        let mut buf = move || -> String {
            locked_stdin
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        rin_parse!{buf, $($rep)*}
        drop(buf);
    };
}

#[allow(unused_macros)]
macro_rules! rin_parse {
    ( $buf:expr ) => {};
    ( $buf:expr, ) => {};
    ( $buf:expr, $type:tt : $var:tt, $($r:tt)* ) => {
        rin_read!($buf, $type, $var, false);
        rin_parse!($buf, $($r)*);
    };
    ( $buf:expr, mut $type:tt : $var:tt, $($r:tt)* ) => {
        rin_read!($buf, $type, $var, true);
        rin_parse!($buf, $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! rin_read {
    ( $buf:expr, $type:tt, $var:ident, false ) => {
        let $var = read_value!($buf, $type);
    };
    ( $buf:expr, $type:tt, [$($var:ident),*], false ) => {
        $( let $var = read_value!($buf, $type); )*
    };

    ( $buf:expr, $type:tt, $var:ident, true ) => {
        let mut $var = read_value!($buf, $type);
    };
    ( $buf:expr, $type:tt, [$($r:tt)*], true ) => {
        $( let mut $var = read_value!($buf, $type); )*
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ( $next:expr, ( $($t:tt),* ) ) => {
        ( $(read_value!($next, $t)),* )
    };
    ( $next:expr, [ $t:tt ; [$d1:expr, $d2:expr] ] ) => {
        (0..$d1).map(|_| read_value!($next, [$t; $d2])).collect::<Vec<_>>()
    };
    ( $next:expr, [ $t:tt ; $len:expr ] ) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };   
    ( $next:expr, chars ) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ( $next:expr, usize1 ) => {
        read_value!($next, usize) - 1
    };
    ( $next:expr, $t:ty ) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// main function

fn main() {
    let mut sc : Scanner = Scanner::new();
    let t = 1;
    // rin!( from sc, usize : t, );
    for _ in 0..t { solve(&mut sc); }
}

fn solve(sc: &mut Scanner) {
    let out = stdout();
    let mut out = BufWriter::new(out.lock());

    rin! {
        from sc,
        i32 : a,
    }

    write!(out, "{}\n", a + a * a + a * a * a).ok();
}

Measured memory_bytes: 2148
#include<stdio.h>
#include<string.h>
int main()
{
	int n=0;
	long s,t;

	scanf("%ld",&s);

	t=s;
	while(s!=0){
		n+=s%10;
		s/=10;
	}
	if(t%n==0)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

int main() {
int H, W;
do{
std::cin >> H >> W;
if(!(H == 0 && W == 0)){
for(int i = 0; i < H; i++){
for(int j = 0; j < W; j++){
std::cout << '#';
}
std::cout << std::endl;
}
std::cout << std::endl;
}
} while(!(H == 0 && W == 0));
}

Measured memory_bytes: 3100
def rotN(ht)
    tmp=ht['T']
    ht['N']=ht['T']
    ht['T']=ht['S']
    ht['S']=7-tmp
    return ht
end

def rotS(ht)
    tmp=ht['T']
    ht['S']=ht['T']
    ht['T']=ht['N']
    ht['N']=7-tmp
    return ht
end

def rotE(ht)
    tmp=ht['T']
    ht['E']=ht['T']
    ht['T']=ht['W']
    ht['W']=7-tmp
    return ht
end

def rotW(ht)
    tmp=ht['T']
    ht['W']=ht['T']
    ht['T']=ht['E']
    ht['E']=7-tmp
    return ht
end

mp=gets.split(' ').map(&:to_i)
rs=gets
lbl=Hash.new
mp.each_with_index do |x,i|
   lbl.store(i+1,x)
end
ht={'T'=>1,'S'=>2,'N'=>5,'W'=>4,'E'=>3}
rs.length.times do |i|
   case rs[i]
   when 'N' then ht=rotN(ht)
   when 'S' then ht=rotS(ht)
   when 'E' then ht=rotE(ht)
   when 'W' then ht=rotW(ht)
   end
end
p lbl[ht['T']]

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

int main() {
    char S[200010],T[200010];
    int i = 0;
    
    scanf("%s",S);
    scanf("%s",T);
    
    for (int j = 0;j < strlen(S);j++)
    {
        if (S[j] != T[j]) i++;
    }
    
    printf("%d\n",i);
    
    return 0;
}


Measured memory_bytes: 2120
N, = map(int, input().split())
X = list(map(int, input().split()))
t = 0
for x in X:
    t = t^x
inf = float('inf')
d = dict()
def it(x, y, z):
    if (x, y, z) in d:
        return d[(x, y, z)]
    xm, ym, zm = x%2, y%2, z%2
    if xm ^ ym != zm:
        d[(x, y, z)] = inf
        return inf
    if x^y == z:
        d[(x, y, z)] = 0
        return 0
    Rz = 2*it(x>>1, y>>1, z>>1)
    Ro = inf
    if x:
        Ro = 2*it((x-1)>>1, (y+1)>>1, z>>1)+1
    Rz = min(Rz, Ro)
    d[(x, y, z)] = Rz
    return Rz

r = it(X[0], X[1], t^X[0]^X[1])
if 0 <= r < X[0]:
    print(r)
else:
    print(-1)


Measured memory_bytes: 62264
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
string S,T;
vector<ll> A;


ll N,K,M;
ll B[100005];
ll ans;

int main() {
    cin >> N >> K;
    for(ll i=0;i<N;i++){
        ll a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(),A.end());
    ll r = 1000000001;
    ll l = 0;
    ll s=0;
    ll k=0;
    while(r-l>0){
        s=(r+l+1)/2;
        k=0;
        for(ll i=0;i<N;i++){
            k += (A[i]-1)/s;
        }
        if(k<=K){
            r = s;
            if(r-l==1){
                break;
            }
        }else{
            l = s;
        }
    }
    cout << r<< endl;
    
}


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

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

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    a = []
    for i in range(5):
        a.append(I())

    ans = inf
    for arr in itertools.permutations(range(5)):
        t = 0
        for j, i in enumerate(arr):
            t += a[i]
            if t % 10 != 0 and j < 4:
                t = (t // 10 + 1) * 10
        ans = min(ans, t)
    print(ans)

main()



Measured memory_bytes: 83412
fn main() {
    const MOD: usize = 998244353;
    let mut line = String::new();
    std::io::stdin().read_line(&mut line);
    let ns: Vec<usize> = line.split_whitespace().map(|a| a.parse().unwrap()).collect();
    let s = (ns[1]);
    line = String::new();
    std::io::stdin().read_line(&mut line);
    let a: Vec<usize> = line.split_whitespace().map(|a| a.parse().unwrap()).collect();
    let n = a.len();
    let mut dp = vec![0; s + 1];
    dp[0] = 1;
    for &ai in &a {
        for j in (0 .. dp.len()).rev() {
            if j + ai < s {
                dp[j + ai] = (dp[j + ai] + dp[j]) % MOD;
            } else if j + ai == s {
                dp[j + ai] = (dp[j + ai] + dp[j] * (n - dp[0] + 1)) % MOD;
            }
        }
        dp[0] += 1;
    }
    println!("{}", dp[s]);
}


Measured memory_bytes: 4352
n, m, k = map(int, input().split())
a =  list(map(int, input().split()))
b = list(map(int, input().split()))
a_sum, b_sum = [0], [0]
for i in range(n):
  a_sum.append(a_sum[i]+a[i])
for i in range(m):
  b_sum.append(b_sum[i]+b[i])
ans, j = 0, m
for i in range(n+1):
  if a_sum[i] > k:
    break
  while b_sum[j] > k - a_sum[i]:
    j -= 1
  ans = max(ans, i+j)
print(ans)

Measured memory_bytes: 47476
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll INFl = 1e18;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
typedef map<int,int> mii;
typedef unordered_map<int,int> umii;
typedef queue<int> qi;

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	long double x;
	cin >> x;
	long double y = 2.00000 *  3.14159265359 * x;
	cout << fixed << setprecision(6) << y << '\n';
	
	return 0;
}


Measured memory_bytes: 3820
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

k = ni()
s = str(k)
n = len(s)
d = ni()

dp = [[[0] * 2 for _ in range(d + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1
for i in range(n):
    for j in range(d):
        for k in range(2):
            dmax = 9 if k else int(s[i])
            for D in range(dmax + 1):
                ni = i + 1
                nj = (j + D) % d
                nk = k | (D < dmax)
                dp[ni][nj][nk] += dp[i][j][k]
                dp[ni][nj][nk] %= mod

ans = dp[n][0][0] + dp[n][0][1] - 1
print(ans % mod)

Measured memory_bytes: 130396
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define ll long long int
#define fab(a,b,i) for(int i=a;i<b;i++)
#define pb push_back
#define db double
#define mp make_pair
#define endl "\n"
#define f first
#define se second
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
const ll INF=1e18+7;
ll dp[405][405];
//dp[i][j] denotes the minimum sum to combine interval i...j
// final answer will be dp[0][n-1]
ll rangesum(vector<ll> a,int l,int r)
{
	ll sum=0;
	fab(l,r+1,i)
	sum+=a[i];
	return sum;
}

int main()
{ quick;

	int n;
	cin>>n;
	vector<ll> a(n);
	//memset(dp,(ll)INF,sizeof(dp));
	fab(0,n,i)
	cin>>a[i];
	for(int i=n-1;i>=0;i--)
	{
		fab(i,n,j)
		{
			if(i==j)
			{
				dp[i][j]=0;
			}
			else
			

			{
				dp[i][j]=INF;
				fab(i,j,k)
				dp[i][j]=min(dp[i][k]+dp[k+1][j],dp[i][j]);
				dp[i][j]+=rangesum(a,i,j);
			}


		}
		
	}
	cout<<dp[0][n-1]<<endl;

	return 0;
}

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

string s;
string t = "YAKI";

int main() {
	cin >> s;
	if (s.length() < 4) {
		cout << "No\n";
		return 0;
	}

	for (int i = 0; i < 4; ++i) {
		if (s[i] != t[i]) {
			cout << "No\n";
			return 0;
		}
	}

	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const long long INF = LLONG_MAX / 2;
const int MAX = 10;

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

    vector<int> a(n);
    string op(n-1, ' ');
    for(int i=0; i<n; ++i){
        cin >> a[i];
        if(i < n - 1)
            cin >> op[i];
    }

    vector<vector<long long> > dp(n, vector<long long>(MAX, -INF));
    dp[0][0] = a[0];
    for(int i=1; i<n; ++i){
        for(int j=MAX-1; j>=0; --j){
            long long x = dp[i-1][j];
            if((j % 2 == 0) ^ (op[i-1] == '-'))
                x += a[i];
            else
                x -= a[i];

            dp[i][j] = max(dp[i][j], x);
            if(op[i-1] == '-' && j + 1 < MAX)
                dp[i][j+1] = max(dp[i][j+1], x);
        }
        for(int j=MAX-1; j>0; --j)
            dp[i][j-1] = max(dp[i][j-1], dp[i][j]);
    }
    cout << dp[n-1][0] << endl;

    return 0;
}


Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < n; ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define ll long long

#define MOD 1000000007
typedef pair<int, int> pii;
// typedef vector<int> vi;
// typedef vector<pii> vpi;
// typedef vector<vi> vvi;
// typedef long long i64;
// typedef vector<i64> vi64;
// typedef vector<vi64> vvi64;
// typedef pair<i64, i64> pi64;
// typedef double ld;
typedef  long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
// ui64 mx=1000*1000*1000+3;
// ui64 dp[mx];
int dp[1003][1003];
char arr[1000][1000];

int main()
{
	int h,w;
	cin>>h>>w;
	forn(i,h)
	{
		forn(j,w)
		{
			cin>>arr[i][j];
		}
	}
	dp[0][0]=1;
	for1(i,h)
	{
		if(arr[i-1][0]=='#')
		{
			for(int j=i;j<=h;j++)
			{
				dp[j][0]=0;
			}
			break;
		}
		else
		dp[i][0]=	(dp[i][0]+dp[i-1][0])%MOD;

	}
	for1(i,w)
	{
		if(arr[0][i-1]=='#')
		{
			for(int j=i;j<=w;j++)
			{
				dp[0][j]=0;
			}
			break;
		}
		else
		dp[0][i]=	(dp[0][i]+dp[0][i-1])%MOD;

	}
	forn(i,h+1)
	{
		forn(j,w+1)
		{
      if(i==0||j==0)
			continue;
			if(arr[i-1][j]!='#')
			dp[i][j]=(dp[i][j]+dp[i-1][j])%MOD;
			if(arr[i][j-1]!='#')
			dp[i][j]=(dp[i][j]+dp[i][j-1])%MOD;
}
}
cout<<dp[h-1][w-1];

return 0;}


Measured memory_bytes: 5120
/*================================================================
*
*   创 建 者： badcw
*   创建日期： 2020/5/23
*
================================================================*/
#include <bits/stdc++.h>

#define ll long long
using namespace std;

const int maxn = 15;
const int mod = 1e9+7;
ll qp(ll a, ll n, ll mod = ::mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

map<ll, ll> mp;

ll n, a, b, c, d;

ll dfs(ll now) {
    if (now < 0) return LONG_LONG_MAX;
    if (mp.count(now)) return mp[now];
    ll res = LONG_LONG_MAX;
    {
        ll ch2 = now % 2;
        ll ch = (now - ch2) / 2;
        if ((__int128)ch * d <= a) {
            res = min(res, dfs(now - ch - ch2) + (ch + ch2) * d);
        } else {
            res = min(res, dfs(now - ch - ch2) + a + ch2 * d);
        }
    }
    {
        ll ch2 = now % 3;
        ll ch = (now - ch2) / 3 * 2;
        if ((__int128)ch * d <= b) {
            res = min(res, dfs(now - ch - ch2) + (ch + ch2) * d);
        } else {
            res = min(res, dfs(now - ch - ch2) + b + ch2 * d);
        }
    }
    {
        ll ch2 = now % 5;
        ll ch = (now - ch2) / 5 * 4;
        if ((__int128)ch * d <= c) {
            res = min(res, dfs(now - ch - ch2) + (ch + ch2) * d);
        } else {
            res = min(res, dfs(now - ch - ch2) + c + ch2 * d);
        }
    }

    {
        ll ch2 = 2 - now % 2;
        ll ch = (now + ch2) / 2;
        if (ch > ch2) {
            if ((__int128) ch * d <= a) {
                res = min(res, dfs(now - ch + ch2) + (ch + ch2) * d);
            } else {
                res = min(res, dfs(now - ch + ch2) + a + ch2 * d);
            }
        }
    }
    {
        ll ch2 = 3 - now % 3;
        ll ch = (now + ch2) / 3 * 2;
        if (ch > ch2) {
            if ((__int128) ch * d <= b) {
                res = min(res, dfs(now - ch + ch2) + (ch + ch2) * d);
            } else {
                res = min(res, dfs(now - ch + ch2) + b + ch2 * d);
            }
        }
    }
    {
        ll ch2 = 5 - now % 5;
        ll ch = (now + ch2) / 5 * 4;
        if (ch > ch2) {
            if ((__int128) ch * d <= c) {
                res = min(res, dfs(now - ch + ch2) + (ch + ch2) * d);
            } else {
                res = min(res, dfs(now - ch + ch2) + c + ch2 * d);
            }
        }
    }
    return mp[now] = res;
}

int main(int argc, char* argv[]) {
    int T;
    scanf("%d", &T);
    for (int kase = 1; kase <= T; ++kase) {
        mp.clear();
        mp[0] = 0;
        scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);
        dfs(n);
//        for (auto i : mp) {
//            cout << i.first << " " << i.second << endl;
//        }
        printf("%lld\n", mp[n]);
    }
    return 0;
}

Measured memory_bytes: 4864
#pragma GCC optimize("trapv")
#include<bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using vi = vector<int>;
using ll = long long;
const int maxn = 2020, mod = 924844033;
int n, m, a[maxn][maxn], b[maxn][maxn], h[maxn], l[maxn], r[maxn];
int solve() {
	h[0] = h[m] = -1;
	{
		vi s {0};
		for(int i = 1; i < m; i++) {
			while(h[s.back()] >= h[i]) s.pop_back();
			l[i] = s.back();
			s.push_back(i);
		}
	}
	{
		vi s {m};
		for(int i = m-1; i; i--) {
			while(h[s.back()] >= h[i]) s.pop_back();
			r[i] = s.back();
			s.push_back(i);
		}
	}
	int ans = 0;
	for(int i = 1; i < m; i++)
		ans = max(ans, (r[i]-l[i])*h[i]);
	return ans;
}
int ans = 0;
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m;
	ans = max(n, m);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++) {
			char t; cin >> t;
			a[i][j] = t=='#';
		}
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j < m; j++) {
			b[i][j] = 1;
			if(i && (a[i][j]^a[i][j+1]) == (a[i-1][j]^a[i-1][j+1])) b[i][j] += b[i-1][j];
		}
		for(int j = 1; j <= m; j++) h[j] = b[i][j];
		ans = max(ans, solve());
	}
	cout << ans;
}


Measured memory_bytes: 32000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200010;
ll n,a[N],num[N];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i],num[a[i]]++;
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		ans+=(num[i]-1)*num[i]/2;
		//cout<<num[i]<<endl;
	}
//	cout<<ans<<endl;
	for(int i=0;i<n;i++)
		cout<<ans-num[a[i]]+1<<endl;
	return 0;
}

Measured memory_bytes: 4736
#include<iostream> 
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
#define ll long long
#define N 200010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
int n,a[N],ans;
map<int,int> cnt; 
int main()
{
	n=read();
	for (int i=1;i<=n;i++) cnt[a[i]=read()]++;
	sort(a+1,a+n+1);
	for (int i=n;i>=1;i--)
	if (cnt[a[i]])
	{
		int t=a[i];cnt[a[i]]--;
		while (t!=(t&-t)) t^=t&-t;
		if (cnt[(t<<1)-a[i]]) ans++,cnt[(t<<1)-a[i]]--;
		else cnt[a[i]]++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 19712
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  getline(cin,str);
  int i=0;
  for(i=0;i<str.size();i++){
    if(str[i]>='a'&&str[i]<='z') str[i]+='A'-'a';
  }
  cout << str << endl;
}



Measured memory_bytes: 2996
h,w = map(int,input().split())
a = [[int(i) for i in input().split()] for j in range(h)]
ans = []
for i in range(h):
    for j in range(w):
        if a[i][j]%2 != 0:
            if j+1 < w:
                a[i][j] -= 1
                a[i][j+1] += 1
                ans.append([i+1,j+1,i+1,j+2])
            elif i+1 < h:
                a[i][j] -= 1
                a[i+1][j] += 1
                ans.append([i+1,j+1,i+2,j+1])

print(len(ans))
for i in ans:
    print(' '.join(map(str,i)))

Measured memory_bytes: 29740
#include <stdio.h>          // printf(), fgets()
#include <string.h>         // strlen(), strncmp()

const int NUL = '\0';

int
main(int argc, char **argv)
{
	char line[1001];
	const char *apple = "apple";
	const char *peach = "peach";
	char *s;
	int i;

	fgets(line, sizeof(line), stdin);
	s = line + strlen(line) - 1;
	if (s >= line && *s == '\n')
		*s = NUL;

	for (s = line; *s != NUL; ++s)
	{
		if (*s == 'a' || *s == 'p')
		{
			if (strncmp(s, "apple", 5) == 0)
			{
				for (i = 0; i < 5; ++i)
					*s++ = peach[i];
			}

			else if (strncmp(s, "peach", 5) == 0)
			{
				for (i = 0; i < 5; ++i)
					*s++ = apple[i];
			}
		}
	}

	printf("%s\n", line);
	return 0;
}

Measured memory_bytes: 524
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9+7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;
int dx[8] = { -1,-1,-1,0,0,1,1,1, };
int dy[8] = { 1,0,-1,1,-1,1,0,-1 };


char A[101][101];

int H, W;
void calc(int x, int y) {
	int cnt = 0;
	REP(k, 8) {
		int nx = x + dx[k], ny = y + dy[k];
		if (nx < 0 || nx >= H || ny < 0 || ny >= W)continue;
		if (A[nx][ny] == '#')cnt++;
	}
	A[x][y] = (char)('0' + cnt);
}
void solve() {
	int N; cin >> N;
	vector<int>A(N);
	REP(i, N) {
		cin >> A[i];
	}
	ll all = 1;
	ll sb = 1;
	REP(i, N) {
		all *= 3;
		if (A[i] & 1)sb *= 1;
		else sb *= 2;
	}
	print(all - sb);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a*b, c*d) << endl;
}


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

int main() {
	int n, k; cin >> n >> k;
    vector<int> alturas(n);
    for(int i = 0; i < n; i++) cin >> alturas[i];
    vector<int> dp(n,1000000009); dp[0] = 0;
    int values[k];
    for(int i = 1; i <=k; i++) values[i-1] = i;
    for(int i =0; i < n; i++){
        for(int x: values){
            if(i+x >= n) break;
            dp[i+x] = min(dp[i+x], dp[i] + abs(alturas[i] - alturas[i+x]));
        }
    }
    cout << dp[n-1];
	return 0;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> L(m),R(m);
  for(int i=0;i<m;i++)
    cin >> L[i] >> R[i];
  bool p=false;
  for(int i=0;i<m-1;i++){
  	if(L[i+1]>R[i] || R[i+1]<L[i]){
    	p=true;
      	break;
    }else{
    L[i+1]=max(L[i],L[i+1]);
    R[i+1]=min(R[i],R[i+1]);
    }
  }
  if(p)
    cout << 0;
  else
    cout << R[m-1]-L[m-1]+1;
}

Measured memory_bytes: 1024
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
//using
using namespace std;
/*using vi = vector<int>;
using vs = vector<string>;
using vc = vector<char>;*/
//define
#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
//グローバル変数宣言
int a=0,b=0,c=0,d=0,n=0;

//int sa(int n,int p){if(n>=p)return n-p;else return p-n;}

signed main(){
    cin>>n>>a>>b;
    string s;
    cin>>s;
    rep(i,n)
    {
        if(s[i]=='a'){
            if (c<a+b){print("Yes");c++;}
            else print("No");}
        else if(s[i]=='b')
        {
            if (c<a+b&&d<b)
            {
                print("Yes");c++;d++;
            }else print("No");
        }else print("No");
    }
}

Measured memory_bytes: 3764
#include <stdio.h>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int n,m;
    scanf("%d %d",&n,&m);
    int arr[100][100]={{}};
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            arr[i][j]=0;
        }
    }
    for (int x=0;x<n;x++){
        for (int y=0;y<m;y++){
            scanf("%d",&arr[x][y]);
        }
    }
    int lis[m];
    for (int z=0;z<m;z++){
        scanf("%d",&lis[z]);
    }
    int cnt=0;
    for (int d=0;d<n;d++){
        for (int e=0;e<m;e++){
            cnt+=arr[d][e]*lis[e];
        }
        printf("%d\n",cnt);
        cnt=0;
    }
    return 0;
}



Measured memory_bytes: 2796
# ABC061b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]

ans = [0] * n

for r in a:
    ans[r[0]-1] += 1
    ans[r[1]-1] += 1

for a in ans:
    print(a)

Measured memory_bytes: 3064
using System;

namespace NTL_1_C_Least_Common_Multiple
{
	class Program
	{
		static void Main ( string[] args )
		{
			int inputCount = int.Parse (Console.ReadLine ());
			int[] numArray = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);

			int lcm = LeastCommonMultiple (numArray[0], numArray[1]);

			for (int lp = 2; lp < inputCount; lp++)
			{
				lcm = LeastCommonMultiple (lcm, numArray[lp]);
			}

			Console.WriteLine (lcm);
		}

		static int GreatestCommonDivisor ( int divided, int divisor )
		{
			int mod;

			while ((mod = divided % divisor) != 0)
			{
				divided = divisor;
				divisor = mod;
			}

			return divisor;
		}

		static int LeastCommonMultiple ( int num1, int num2 )
		{
			if (num1 < num2)
			{
				int tmp = num1;
				num1 = num2;
				num2 = tmp;
			}

			return num1 * num2 / GreatestCommonDivisor (num1, num2);
		}
	}
}



Measured memory_bytes: 9188
// ABC_169_A

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define forn(i, n) for(int i = 0; i < (int)n; ++i)

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

  cout << a * b << "\n";

  return 0;
}

Measured memory_bytes: 3636
fn c() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).expect("input error");
    let L = input.trim_right().parse::<f64>().expect("parse error");

    let L2 = L / 3f64;
    println!("{:6}", L2 * L2 * L2);
}

fn main() {
    c();
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        String str = "";

        while (sc.hasNextLine()) {
            str += sc.nextLine();
        }

        char x;
        char[] alpha = new char[26];
        int[] count = new int[26];

        int k = 0;
        for (x = 'a'; x <= 'z'; x++) {
            alpha[k] = x;
            k++;
        }

        char[] strArray = (str.toLowerCase()).toCharArray();

        for (int i = 0; i < strArray.length; i++) {
            for (int j = 0; j < alpha.length; j++) {
                if (strArray[i] == alpha[j]) {
                    count[j] += 1;
                }
            }
        }

        for (int i = 0; i < alpha.length; i++) {
            System.out.println(alpha[i] + " : " + count[i]);
        }

        sc.close();
    }
}


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

typedef long long ll;
typedef vector <bool> v_bool;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll N;
v_ll A;
int main(){
  cin >> N;
  cout << 3*N*N << endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x,t,m=0,a=1,b=0,c=0;
	cin>>n>>x>>t;
	if(x==1)
	m=t*n;
	else{
	if(n<=x)
	m=t;
	else {
		b=n/x;
		c=n%x;
		if(c!=0){
		m=t*(a+b);}
		else{
			m=t*b;
		}
	}
	}
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 3620
void main(){
	string s = readln().chomp();
	string outs;
	foreach(i; 0..s.length){
		outs ~= "x";
	}
	outs.writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2612
w = input()
dic = {}
flag = True

for wd in w:
  if wd not in dic:
    dic[wd] = 0
  dic[wd] += 1
  
for dicw in dic:
  if dic[dicw] % 2 == 1:
    flag = False
    break
    
if flag == True:
  print('Yes')
else:
  print('No')

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

def comb2(n):
    if n < 2:
        return 0
    return n*(n-1)//2

cntd = {}
for i in range(N):
    if A[i] in cntd:
        cntd[A[i]] += 1
    else:
        cntd[A[i]] = 1

sum_comb = 0
for k, v in cntd.items():
    sum_comb += comb2(v)

#print(cntd)
#print(sum_comb)
for i in range(N):
    k = A[i]
    ans = sum_comb - comb2(cntd[k]) + comb2(cntd[k]-1)
    print(ans)


Measured memory_bytes: 91980
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;

int main()
{
  string s;
  ll k;
  const ll c = 5000000000000000;
  cin >> s >> k;
  ll num = 0;

  for (ll i = 0; i < k; i++)
  {

    if (s[i] != '1')
    {
      cout << s[i] << endl;
      return 0;
    }
    else
    {
    }
  }

  cout << '1' << endl;
  return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 500010
int heap[MAX];
int heap_size;
int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

void maxHeapify(int i){
  int l,r,largest,tmp;
  l=left(i);
  r=right(i);
  if(l<=heap_size && heap[l]>heap[i]) largest=l;
  else largest=i;

  if(r<=heap_size && heap[r]>heap[largest])  largest=r;
  
  if(largest!=i){
    tmp=heap[i];
    heap[i]=heap[largest];
    heap[largest]=tmp;
    maxHeapify(largest);
  }
}

void builtMaxHeap(void){
  int i;
  for(i=heap_size/2;i>0;i--){
    maxHeapify(i);
  }
}


int main(){
  int i,n;
  scanf("%d",&n);
  heap_size=n;
  for(i=1;i<=n;i++){
    scanf("%d",&heap[i]);
  }

  builtMaxHeap();

  for(i=1;i<=n;i++){
    printf(" %d",heap[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 2552
#include<iostream>
#include<cstring>
using namespace std;
int t[505][505];
int nt[505][505];

int main(){
	int n,w,h;
	int i,j,k;
	int a,b,c;
	int x,y;
	while(cin>>n){
		if(!n)break;
		memset(t,0,sizeof(t));
		memset(nt,0,sizeof(nt));
		cin>>w>>h;
		for(i=0;i<n;i++){
			cin>>a>>b;
			a--,b--;
			t[a][b]++;
		}
		for(i=0;i<w;i++){
			for(j=0;j<h;j++){
				nt[i+1][j+1]=nt[i+1][j]+nt[i][j+1]-nt[i][j]+t[i][j];
			}
		}
		cin>>x>>y;
		b=0;
		for(i=0;i<=w-x;i++){
			for(j=0;j<=h-y;j++){
				a=nt[i+x][j+y]-nt[i][j+y]-nt[i+x][j]+nt[i][j];
				if(b<a)b=a;
			}
		}
		cout<<b<<endl;
	}
}
			



Measured memory_bytes: 5048
import java.util.*;

class Main{
  public static int minK(int K,int[] X,int idx){
    int minimum=X[idx];
    for(int i=idx+1;i<idx+K;i++){
      if(minimum>X[i]) minimum=X[i];
    }
    return minimum;
  }
  
  public static int abs(int a){
    if(a>=0) return a;
    return -a;
  }
  
  public static int min2(int a,int b){
    return (a<b)?a:b;
  }
  
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    int K=sc.nextInt();
    int[] H=new int[N];//jの高さ
    int[] H_C=new int[N];//jにいくコスト
    int[] H_K=new int[K];//jからiにいくコスト
    H_C[0]=0;
    K=min2(N,K);
    
    for(int i=0;i<N;i++){
      H[i]=sc.nextInt();
    }
   
    H_C[1]=abs(H[1]-H[0]);
    
    for(int i=2;i<K;i++){
      for(int j=0;j<i;j++){
        H_K[j]=H_C[j]+abs(H[j]-H[i]);
      }
      H_C[i]=minK(i,H_K,0);
    }
    for(int i=K;i<N;i++){
      for(int j=0;j<K;j++){
        H_K[j]=H_C[i-j-1]+abs(H[i-j-1]-H[i]);
      }
      H_C[i]=minK(K,H_K,0);
    }
    
    System.out.print(H_C[N-1]);
  }
}

Measured memory_bytes: 51124