akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int day[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int main()
{
	int m,d;
	while(cin>>m>>d){
		if(!m)break;
		for(int i=1;i<m;i++)d+=day[i];
		if(d%7==0)cout<<"Wednesday"<<endl;
		else if(d%7==1)cout<<"Thursday"<<endl;
		else if(d%7==2)cout<<"Friday"<<endl;
		else if(d%7==3)cout<<"Saturday"<<endl;
		else if(d%7==4)cout<<"Sunday"<<endl;
		else if(d%7==5)cout<<"Monday"<<endl;
		else if(d%7==6)cout<<"Tuesday"<<endl;
	}
    return 0;
}

Measured memory_bytes: 1156
object Main extends App {
  val sc = new FastScanner(System.in)
  val n = sc.nextInt()
  val as = List.fill(n)(sc.nextInt())
  val x = as.reduceLeft(_ ^ _)
  val ans = as.map(x ^ _).mkString(" ")
  println(ans)
}

class FastScanner(source: java.io.InputStream) {
  val buf = new Array[Byte](1024)
  var now, end = 0

  def isPrintable(b: Byte): Boolean = 33 <= b && b <= 126
  def isNum(b: Byte): Boolean = 48 <= b && b <= 57

  def hasNextByte: Boolean = {
    if (now < end) {
      true
    } else {
      now = 0
      end = source.read(buf)
      end > 0
    }
  }

  def nextByte(): Byte = {
    if (hasNextByte) {
      val b = buf(now)
      now += 1
      b
    } else {
      -1
    }
  }

  def hasNext: Boolean = {
    while (hasNextByte && !isPrintable(buf(now))) {
      now += 1
    }
    hasNextByte
  }

  def next(): String = {
    if (hasNext) {
      val sb = new StringBuilder()
      var b = nextByte()
      while (isPrintable(b)) {
        sb += b.toChar
        b = nextByte()
      }
      sb.toString
    } else {
      throw new NoSuchElementException()
    }
  }

  def nextInt(): Int = {
    nextLong().toInt
  }

  def nextLong(): Long = {
    if (hasNext) {
      var b = nextByte()
      var sign = 1
      var n = 0L
      if (b == '-') {
        sign = -1
        b = nextByte()
      }
      while (isNum(b)) {
        n = n * 10 + (b - 48)
        b = nextByte()
      }
      sign * n
    } else {
      throw new NoSuchElementException()
    }
  }

  def nextDouble(): Double = next().toDouble
}


Measured memory_bytes: 80520
#[allow(unused)]
use std::cmp::{max, min};

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($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")
    };
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        n: i64,
        d: i64,
    }

    let ans: i64;

    if n % (d * 2 + 1) != 0 {
        ans = n / (d * 2 + 1) + 1;
    } else {
        ans = n / (d * 2 + 1);
    }
    println!("{}", ans);
}

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define repU(i,s,t) for(int i = (s); i <= (t); ++i)
#define repD(i,t,s) for(int i = (t); i >= (s); --i)
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1)/(d) + 1)
#define parity(a,b) (((a)^(b)) & 1 ^ 1)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = 1e9 + 7;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int k; cin>>k;
	deque<int> deq;
	int dist[100000];
	fill(all(dist),INF_32);
	deq.puf(1),dist[1] = 1;
	while(!deq.empty()){
		int t = deq.front();
		deq.pof();
		if(dist[t * 10 % k] > dist[t]) dist[t * 10 % k] = dist[t],deq.puf(t * 10 % k);
		if(dist[(t + 1) % k] > 1 + dist[t]) dist[(t + 1) % k] = dist[t] + 1,deq.pub((t + 1) % k);
	}
	cout<<dist[0]<<endl;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#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 SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	LL n;
	cin >> n;
	VVL a(2,VL(n,0));
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		LL tmp = 0;
		for (int j = 0; j < n; j++) {
			if (j < i) {
				tmp += a[0][j];
			}
			else if (j == i) {
				tmp += a[0][j] + a[1][j];
			}
			else {
				tmp += a[1][j];
			}
		}
		ans = max(tmp,ans);
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
#define ll long long int

ll n,ara[505],dp[505][505],cum[505];

ll func(ll st, ll en)
{
    if(st>=en) return 0;
    if(dp[st][en]!=-1) return dp[st][en];
    ll ans=1e18;
    for(ll i=st; i<en; i++)
    {
        ans=min(ans,cum[en]-cum[st-1]+func(st,i)+func(i+1,en));
    }
    return dp[st][en]=ans;
}

int main()
{
    ll i,j,a=0;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        cin>>ara[i];
        a+=ara[i];
        cum[i]=a;
    }
    memset(dp, -1, sizeof dp);
    ll ans=func(1,n);
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 2304
aa,bb,m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = min(a) + min(b)

for i in range(m):
    x,y,c = map(int, input().split())
    p = a[x-1] + b[y-1] - c
    if p < ans:
        ans = p

print(ans)

Measured memory_bytes: 18608
(n,m,k),A,B=$<.map{|s|s.split.map &:to_i}
S=[0]
T=[0]
A.map{|a|S<<S.last+a}
B.map{|b|T<<T.last+b}
z=[]
(n+1).times{|i|
s=S[i]
j=(T.bsearch_index{|t|s+t>k}||m+1)-1
z<<i+j if j!=-1
}
p z.max

Measured memory_bytes: 48412
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define fo(i,a) for(ll i=0;i<a;i++)
#define Fo(i,a,n) for(ll i=a; i<n; i++)
#define u_m unordered_map
#define u_s unordered_set
#define ff first
#define ss second
#define mp make_pair
using namespace std;
ll __pow(ll x, ll y) {ll res = 1;while(y>0){if(y&1) res*=x; y>>=1; x*=x;}return res;}
ll gcd(ll a , ll b){if(b==0) return a;a%=b;return gcd(b,a);}
bool isprime(ll n){for(ll i=2; i*i<=n; i++){if(n%i==0) return 0;}return 1;}
ll n,m,x,y,z,k;

int main(){
    ll t=1;
    //cin >> t;
    for(ll i=1; i<=t; i++){
        cin>>n;
    string s;
    ll r=0, w=0;
    cin>>s;
    fo(i,n){
        if(s[i]=='R') r++;
        else w++;
    }
    ll ans=0;
    fo(i,r){
        if(s[i]=='W') ans++;
    }
    cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3696
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let k: usize = input();
    let xy: Vec<(i64, i64)> = (0..n)
        .map(|_| {
            let x = input();
            let y = input();
            (x, y)
        })
        .collect();
    let (mut qx, mut qy): (Vec<i64>, Vec<i64>) = xy.iter().cloned().unzip::<i64, i64, _, _>();
    qx.sort();
    qy.sort();

    let mut ans = i64::max_value();
    for xi in 0..n {
        for xj in xi + 1..n {
            for yi in 0..n {
                for yj in yi + 1..n {
                    let mut cnt = 0;
                    for m in 0..n {
                        let (px, py) = xy[m];
                        if qx[xi] <= px && px <= qx[xj] && qy[yi] <= py && py <= qy[yj] {
                            cnt += 1;
                        }
                    }
                    if cnt >= k {
                        ans = std::cmp::min(ans, (qx[xi] - qx[xj]).abs() * (qy[yi] - qy[yj]).abs());
                    }
                }
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>

int main() {
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/b;
    printf("%d %d %f\n",d,r,f);
    
    return 0;
}

Measured memory_bytes: 1852
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9+7;
const int MOD = 1e9 + 7;

int N,A;
ll dp[52][2502];

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

	vint a(N);
	FOR(i, 0, N)cin >> a[i];

	dp[0][0] = 1;
	
	FOR(i, 0, N) {
		for (int j = N; j >= 1; j--) {
			for(int k=2500;k>=a[i];--k){
				dp[j][k] += dp[j - 1][k - a[i]];
			}
		}

	}

	ll ans = 0;
	FOR(i, 1, N + 1) {
		ans += dp[i][i*A];
	}
	ct(ans);

	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 1e3+7;
const int S = 2e4+7;

int s[N],w[N],v[N];
ll dp[S];


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);

    vector<pi> vec;
    int n;
    cin >> n;
    REP(i,1,n)
    {
        cin >> w[i] >> s[i] >> v[i];
        vec.PB({w[i]+s[i],i});
    }
    sort(vec.begin(),vec.end());
    ll ans = 0;

    REP(i,0,n-1)
    {
        int idx = vec[i].S;
        REPI(j,min(s[idx],S-w[idx]),0)
        {
            dp[j+w[idx]] = max(dp[j+w[idx]],dp[j]+v[idx]);
        }
    }

    REP(j,0,S-1) ans = max(ans,dp[j]);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
package main

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

type priorityQueue struct {
	queue []int
	size  int
}

var inf = math.MaxInt32

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func (pq *priorityQueue) maxHeapify(i int) {
	l := pq.left(i)
	r := pq.right(i)

	largest := i
	if l <= pq.size && pq.queue[i] < pq.queue[l] {
		largest = l
	}
	if r <= pq.size && pq.queue[largest] < pq.queue[r] {
		largest = r
	}

	if largest != i {
		pq.queue[largest], pq.queue[i] = pq.queue[i], pq.queue[largest]
		pq.maxHeapify(largest)
	}
}

func (pq *priorityQueue) left(i int) int {
	return i * 2
}

func (pq *priorityQueue) right(i int) int {
	return i*2 + 1
}

func (pq *priorityQueue) parent(i int) int {
	return i / 2
}

func (pq *priorityQueue) extract() int {
	if pq.size < 1 {
		return -inf
	}

	// rootキーが優先度max
	maxv := pq.queue[1]

	// 最後の値をrootに移しsizeを1つ減らす
	pq.queue[1] = pq.queue[pq.size]
	pq.size--

	// maxheapを保つためrootからheapifyする
	pq.maxHeapify(1)

	return maxv
}

func (pq *priorityQueue) insert(key int) {
	pq.size++
	pq.queue[pq.size] = -inf
	pq.heapIncreaseKey(pq.size, key)
}

func (pq *priorityQueue) heapIncreaseKey(i, key int) {
	if key < pq.queue[i] {
		return
	}

	pq.queue[i] = key

	for i > 1 && pq.queue[pq.parent(i)] < pq.queue[i] {
		pq.queue[pq.parent(i)], pq.queue[i] = pq.queue[i], pq.queue[pq.parent(i)]
		i = pq.parent(i)
	}
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	var command string
	var key int

	pq := &priorityQueue{make([]int, 2000000), 0}

	for {
		command = nextString(sc)
		if command == "end" {
			break
		} else if command == "insert" {
			key = nextInt(sc)
			pq.insert(key)
		} else if command == "extract" {
			fmt.Println(pq.extract())
		}
	}
}



Measured memory_bytes: 25752
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    def d(C0,C1):
        return abs(C0[0]-C1[0])+abs(C0[1]-C1[1])
    N=int(input())
    t=[0]*(N+1)
    C=[[0,0] for _ in range(N+1)]
    for i in range(1,N+1):
        t[i],C[i][0],C[i][1]=map(int,input().split())
    for i in range(N):
        a=d(C[i],C[i+1])
        if a<=t[i+1]-t[i] and a%2==(t[i+1]-t[i])%2:
            continue
        else:
            print('No')
            exit()
    print('Yes')

if __name__ == '__main__':
    main()


Measured memory_bytes: 54512
#include "bits/stdc++.h"

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  int K;
  cin >> K;
  for (int i = 0; i < K; i++) {
    auto &eat = (i % 2 == 0 ? a : b);
    auto &other = (i % 2 == 0 ? b : a);
    if (eat % 2) eat--;
    auto tmp = eat / 2;
    other += tmp;
    eat -= tmp;
  }
  cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  long n,z,w;
  cin >> n >> z >> w;
  vector<long> a(n);
  rep(i,n) cin >> a.at(i);
  if(n == 1){
    long x = a.at(0);
    long y = w;
    cout << abs(x-y) << endl;
    return 0;
  }
  cout << max(abs(a.at(n-1) - w),abs(a.at(n-1)-a.at(n-2))) << endl;
}


Measured memory_bytes: 256
n=gets.to_i
a=gets.split.map(&:to_i)
s=[0]
n.times do |i|
  s[i+1]=s[i]+a[i]
end
c=0
s.sort!
l=-1
n.times do |i|
  if s[i+1]!=s[i]
    m=i-l
    c+=m*(m-1)/2
    l=i
  end
end
m=n-l
c+=m*(m-1)/2
puts c

Measured memory_bytes: 19660
from collections import Counter
input()
A = list(map(int, input().split()))
C = Counter([sum(a >= r for r in [400,800,1200,1600,2000,2400,2800,3200]) for a in A])
c8 = C[8] if 8 in C else 0
a1 = len(C) - (1 if c8 else 0)
a2 = a1+c8
if a1 == 0:
    a1 += 1
print(a1, a2)

Measured memory_bytes: 3316
// 
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


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

    int x;
    cin>>x;
    if(30<=x) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main() {
  string board[60];
  int dx[] = {1, 1, 0,-1,-1,-1, 0, 1,1};
  int dy[] = {0, 1, 1, 1, 0,-1,-1,-1,0};
  int h, w;
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    cin >> board[i];
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      // まわりの爆弾を数える
      if (board[i][j] == '.') {
        int count = 0;
        for (int k = 0; k < 8; k++) {
          int x = i + dx[k];
          int y = j + dy[k];
          if (x >= 0 && x < h && y >= 0 && y < w && board[x][y] == '#') {
            count++;
          }
        }
        board[i][j] = '0' + count;
      }

    }
  }

  // output
  for (int i = 0; i < h; i++) {
    cout << board[i] << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int scoring(int score , int choose, int day, vector<int> &c,vector<vector<int>> &s,vector<int> last){
    --choose;
    score += s[day][choose];
    int hiku = 0;
    ++day;
    rep(i,26){
        hiku += c[i]*(day - last[i]);
    }
    score -= hiku;
    return score;
}

//ミョ(-ω- ?)
int main() {
    int d;
    cin >> d;
    const int n = 26;
    vector<int> c(n,0);
    rep(i,n)cin >> c[i];
    vector<vector<int>> s(365,vector<int>(n,0));
    rep(i,d)rep(j,n)cin >> s[i][j];
    vector<int> last(n,0);
    int score = 0;
    rep(i,d){
        int res = 0;
        int max_score = 0;
        rep(j,n){
            int ch = scoring(score,j,i,c,s,last);
            if(max_score < ch){
                res = j;
                max_score = ch;
            }
        }
        cout << res + 1 << endl;
        last[res] = i+1;
    }
    return 0;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define INF 1001
int main(){
    int n,T,c,t,min_cost=INF;
    cin>>n>>T;
    for(int i=0;i<n;i++){
        cin>>c>>t;
        if(t<=T){
            if(c<min_cost) min_cost=c;
        }
    }
    if(min_cost==INF) cout<<"TLE";
    else cout<<min_cost;
}

Measured memory_bytes: 384
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map(String::toInt)
    var count = 0
    var sameFlag = true
    for (i in 0..(n - 2)) {
        if (aList[i] == aList[i + 1] && sameFlag) {
            count++
            sameFlag = !sameFlag
        } else {
            sameFlag = true
        }
    }
    println(count)
}

Measured memory_bytes: 38340
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        double N = sc.nextDouble();
        
        double ans = Math.ceil(N/1.08);
        
        if(Math.floor(ans*1.08)==N){
            System.out.println((int)ans);
        }else{
            System.out.println(":(");
        }
        
    }
}


Measured memory_bytes: 37380
n = gets
black_board = gets.split(' ').map(&:to_i)
count = 0

while true
  break unless black_board.all?{ |i| i % 2 == 0 }

  black_board = black_board.map do |s|
    s / 2
  end

  count += 1
  break unless black_board.all?{ |i| i % 2 == 0 }
end

puts count

Measured memory_bytes: 1788
//#include<iostream>
#include<cstring>
#include<cstdio>
//#include<time.h>
//#include<complex>
//#include<set>
#include<algorithm>
//#include<math.h>
#include<stdlib.h>
using namespace std;

int n,m;
char mp[15][15];

int a[15]; bool vis[15],ans=0;

bool v2[15];
bool check()
{
//	for (int i=1;i<=n;i++) cout<<a[i]<<' ';cout<<endl;
	memset(v2,0,sizeof(v2));
	bool used=(m&1);
	for (int i=1;i<=m;i++) if (!v2[i])
	{
		bool flag=0;
		for (int j=i+1;j<=m;j++) if (!v2[j])
		{
			bool ff=1;
			for (int k=1;k<=n;k++) if (mp[a[k]][i]!=mp[a[n-k+1]][j]) ff=0;
			if (ff) {v2[j]=1; flag=1; break;}
		}
		if (!flag)
		{
			if (used)
			{
				bool ff=1;
				for (int k=1;k<=n;k++) if (mp[a[k]][i]!=mp[a[n-k+1]][i]) ff=0;
				if (ff) used=0;
				else return 0;
			}
			else return 0;
		}
	}
	return 1;
}
			
void dfs(int cur,int pos,bool odd)
{
	if (ans) return;
	if (cur>n) {ans=check(); return;}
	if (vis[cur]) {dfs(cur+1,pos,odd); return;}
	
	for (int i=cur+1;i<=n;i++) if (!vis[i])
	{
		a[pos]=i; a[n-pos+1]=cur;
		vis[i]=1;
		dfs(cur+1,pos+1,odd);
		vis[i]=0;
	}
	if (odd)
	{
		a[(n>>1)+1]=cur;
		dfs(cur+1,pos,0);
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%s",mp[i]+1);
	dfs(1,1,n&1);
	puts(ans?"YES":"NO");
	return 0;
}

Measured memory_bytes: 128
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int H, W, N;

vector<int> colors;
int res[100][100];

int main() {
    cin >> H >> W >> N;
    for (int j = 0; j < N; ++j) {
        int A; cin >> A;
        for (int k = 0; k < A; ++k) {
            colors.push_back(j+1);
        }
    }

    int num = 0;
    for (int j = 0; j < H; ++j) {
        int base = ( j%2==0 ? 0 : (W-1) ), step = ( j%2==0 ? 1 : -1 );
        for (int k = 0; k < W; ++k) {
            int kk = base + step * k;
            res[j][kk] = colors[num++];
        }
    }

    for (int j = 0; j < H; ++j) {
        for (int k = 0; k < W; ++k) {
            if (k > 0) cout << " ";
            cout << res[j][k];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
	using namespace std;
	typedef long long ll;
	ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
	ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

	int main() {
		long long n, m;
		cin >> n >> m;
		long long res = m % n;
		if (res == 0)cout << m/n << endl;
		else {
			long long loop = m / n;
			long long ans = 1;
			for (long long i = 1;i <= loop;++i) {
				long long target = m - i * (n - 1);
				if (target % i == 0)ans = i;
			}
			cout << ans << endl;
		}
		return 0;
	}

Measured memory_bytes: 256
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    string s;
    cin>>s;
    if(s=="RRR"){
        cout<<3<<endl;
    }else if(s=="RRS"||s=="SRR"){
        cout<<2<<endl;
    }else if(s=="RSS"||s=="SRS"||s=="SSR"||s=="RSR"){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t n, x;
    cin >> n >> x;

    vector<int64_t> b(n), l(n), u(n);
    vector<pair<int64_t, int64_t>> p(n);
    int64_t score = 0;
    for (auto i : irange(0L, n)) {
        cin >> b[i] >> l[i] >> u[i];
        p[i] = make_pair(u[i] * x - (u[i] - l[i]) * b[i], i);
        score += l[i] * b[i];
    }

    sort(p.rbegin(), p.rend());

    cerr << score << endl;

    int64_t sum = 0;
    int64_t ans = 0;
    bool filled = false;
    vector<int64_t> sp;
    for (auto idx : irange(0L, n)) {
        const auto& pp = p[idx];
        // cerr << pp.second << " " << b[pp.second] << " " << l[pp.second] << " " << u[pp.second] << " " << l[pp.second] * b[pp.second] << " " << pp.first << endl;
        if (sum + pp.first > score) {
            if (!filled) {
                for (auto j = idx - 1; j >= 0; --j) {
                    auto r = score - (sum - p[j].first + pp.first);
                    auto i = p[j].second;
                    int64_t a = 0;
                    if (r < l[i] * b[i]) {
                        a = (r + l[i] - 1) / l[i];
                    } else {
                        a = b[i] + (r - l[i] * b[i] + u[i] - 1) / u[i];
                    }

                    // necessary??
                    if (a <= x) {
                        sp.push_back(a);
                    }
                }

            }

            filled = true;
            {
                auto r = score - sum;
                auto i = pp.second;
                int64_t a = 0;
                if (r < l[i] * b[i]) {
                    a = (r + l[i] - 1) / l[i];
                } else {
                    a = b[i] + (r - l[i] * b[i] + u[i] - 1) / u[i];
                }

                // necessary??
                if (a <= x) {
                    sp.push_back(a);
                }
            }
        } else if (filled) {
            break;
        } else {
            sum += pp.first;
            ans += x;

            if (sum == score) {
                break;
            }
        }
    }

    if (!sp.empty()) {
        ans += *min_element(sp.begin(), sp.end());
    }

    cout << ans << endl;
}

Measured memory_bytes: 5368
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#define N 210000
using namespace std;
int n,m,a[N],b[N],ans,num;
struct node{int l,r,c;}A[N];
int solve(int lim)
{
    for(int i=1;i<=m;i++) b[i]=(a[i]>=lim);
    num=0;
    int i=1;
    while(i<m)
    {
        if(b[i]!=b[i+1]) {i++;continue;}
        A[++num].l=i;A[num].c=b[i];
        while(i<m && b[i+1]==b[i]) i++;
        A[num].r=i;
    }
    if(num==0) return b[1];
    A[0].r=0;
    for(int i=1;i<=num;i++)
    {
        int l=A[i-1].r+1,r=A[i].l-1;
        if(l>r) continue;
        int mid=(l+r)/2;
        A[i-1].r=mid;A[i].l=mid+1;
    }
    int l=A[num].r+1,r=m,mid;
    if(l<=r) {mid=(l+r)/2;A[num].r=mid;}
    for(int i=1;i<=num;i++) if(A[i].l<=n && A[i].r>=n) return A[i].c;
}
int main()
{
    scanf("%d",&n);
    m=2*n-1;
    for(int i=1;i<=m;i++) scanf("%d",&a[i]);
    int l=1,r=m;
    while(l<=r)
    {
        int mid=(l+r)/2;
        if(solve(mid)) ans=mid,l=mid+1;
        else r=mid-1;
    }
    printf("%d\n",ans);
    return 0;
}

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

int main() {
  int a;
  cin>>a;
  vector<int> vec(a);
  
  for(int i=0;i<a;i++){
    cin>>vec.at(i);
  }
  int answer=1;
  int gg=0;
    for(int i=1;i<a;i++){
      for(int j=0;j<i;j++){
        if(vec.at(j)>vec.at(i)){
          gg++;
        }
      }
      if(gg==0){
      answer++;
      }
      gg=0;
    }
  cout<<answer<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vii=vector<vi>;
const int MAX = 510000;
const int MOD = 1000000007;
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


/*
* 素因数分解
* @param [in] n   自然数
* @param [in] out 素因数分解した数が入る
*/
template<typename T>
void PrimeFactors(T n, std::map<T,T> &out)
{
	while (n % 2 == 0)
	{
		++out[2];
		n = n / 2;
	}

	for (T i = 3; i <= sqrt(n); i = i + 2)
	{
		while (n%i == 0)
		{
			++out[i];
			n = n / i;
		}
	}

	if (n > 2)
		++out[n];
}



int main(void){ 
    ll a,b;
    cin>>a>>b;
    ll i=gcd(a,b);
    map<ll,ll> m;
    
    PrimeFactors(i, m);
    int j=0;
    for(const auto &a : m){
        j++;
    }
    cout <<j+1<< endl;
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,ans=0;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		if(x>=m)
		ans++;
	}
	cout<<ans;
}

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

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int A, B, C;
  cin >> A >> B >> C;
  if ((A == B && B != C) || (C == B && A != C) || (A == C && B != C))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int main(void){
    long long n;
    long long a[100000];

    long long result = 1;
    int i;
    cin >> n;

    for(i=0; i<n; i++){
        cin >> a[i];

        if(!a[i]){
            cout << 0 << endl;
            return 0;
        }
    }
    long long resultdiv = 1;
    long long resultdiv2 = 1;


    for(i=0; i<n; i++){


        result *= a[i];

        if(i>0){

            resultdiv /= 10000;
            resultdiv2 = a[i] /= 10000;
            if(resultdiv * resultdiv2 > 10000000000){
                cout << -1 << endl;
                return 0;
            }

        }

        resultdiv = result;
        if(result > 1000000000000000000){
            cout << -1 << endl;
            return 0;
        }
    }

    cout << result << endl;


}


Measured memory_bytes: 4400
#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;}

int solve(){
    int n,k;
    cin >>n >>k;

    map<int,int> m;
    rep(i,n){
        int a;
        cin >>a;
        ++m[a];
    }

    vector<int> v;
    for(const auto &p:m) v.pb(p.se);
    sort(all(v), greater<int>());

    if(v.size()<=k) return 0;
    int s = 0;
    rep(i,k) s += v[i];
    return n-s;
}

int main(){
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 10748
from itertools import count
# 素因数分解
def prime_factors(n):
    i = 2
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            yield i
    if n > 1:
        yield n


from collections import Counter

c = Counter(prime_factors(int(input())))
res = 0
for cnt in c.values():
    for i in count(1):
        if cnt < 0:
            break
        cnt -= i
        res += 1
    res -= 1

print(res)


Measured memory_bytes: 9464
#line 2 "/Users/kaage/Desktop/ProgrammingWorkspace/library/other/template.hpp"
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx2")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
typedef std::pair<lint, lint> LP;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, lint b) {
	T res(1);
	while(b){
		if(b&1)res*=a;
		a*=a;
		b>>=1;
	}
	return res;
}
lint modpow(lint a, lint b, lint m) {
	lint res(1);
	while(b){
		if(b&1){
			res*=a;res%=m;
		}
		a*=a;a%=m;
		b>>=1;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size()){
		std::cout << vec[i];
		std::cout<<(i==(int)vec.size()-1?"\n":" ");
	}
}
template<typename T>
void printArray(T l, T r) {
	T rprev = std::prev(r);
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
LP extGcd(lint a,lint b) {
	if(b==0)return {1,0};
	LP s=extGcd(b,a%b);
	std::swap(s.first,s.second);
	s.second-=a/b*s.first;
	return s;
}
LP ChineseRem(const lint& b1,const lint& m1,const lint& b2,const lint& m2) {
	lint p=extGcd(m1,m2).first;
	lint tmp=(b2-b1)*p%m2;
	lint r=(b1+m1*tmp+m1*m2)%(m1*m2);
	return std::make_pair(r,m1*m2);
}
/*template<typename F>
inline constexpr decltype(auto) lambda_fix(F&& f){
	return [f=std::forward<F>(f)](auto&&... args){
		return f(f,std::forward<decltype(args)>(args)...);
	};
}*/
#line 2 "main.cpp"
lint x,k,d;
int main(){
	std::cin>>x>>k>>d;
	if(std::abs(x)/d>=k){
		std::cout<<std::abs(x)-k*d<<std::endl;
		return 0;
	}
	else{
		if((k-std::abs(x)/d)%2)std::cout<<d-std::abs(x)%d<<std::endl;
		else std::cout<<std::abs(x)%d<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 3596
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CLamps {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N, K;
        cin >> N >> K;
        vector<int> A(N);
        REP(i, N) cin >> A[i];

        while (K--) {
            vector<int> V(N+1);
            REP(i, N) {
                int val = A[i];
                int l = max(0LL, i - val);
                int r = min(N, i + val + 1);
                V[l] += 1;
                V[r] -= 1;
            }
            FOR(i, 1, N) {
                V[i] += V[i-1];
            }
            swap(A, V);

            bool finish = true;
            REP(i, N) {
                if (A[i] < N) {
                    finish = false;
                    break;
                }
            }
            if (finish) break;
        }
        REP(i, N) cout << A[i] << " ";
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CLamps solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 6368
#include<iostream>
using namespace std;
int main(){
	while(1){
	int H,W;
    cin>>H>>W;
	if(H==0&&W==0){break;}

	for(int i=0;i<H;i++){
	for(int k=0;k<W;k++){
		if(k==0||k==W-1||i==0||i==H-1){
			cout<<"#";
		}
		else{
			cout<<".";
		}

	}
	cout<<endl;
	}

	cout<<endl;


	}
	return 0;
}


Measured memory_bytes: 3080
#include<stdio.h>
#include<math.h>
#define n 10000
int isprime(int);

int main(){
  int num,array[n],count=0,i;
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d",&array[i]);
    
    if(isprime(array[i])==1)count++;
  }
  printf("%d\n",count);
  
  return 0;
}

int isprime(int x){
  int i;
  if(x==2)return 1;
  
  if (x%2==0 || x<2)return 0;
  
  i = 3;
  while(i <= sqrt(x)){
    if(x % i==0)return 0;
      i = i + 2;
  }
  return 1;
}



Measured memory_bytes: 2144
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

ll lcm(ll a, ll b) { //最小公倍数
  return a * b / gcd(a, b);
}

ll digit_sum(ll a){ //10進桁和
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}



int main()
{
  ll n,a[110],max=0,min=1e15;
  cin>>n;
  rep(i,n){
    cin>>a[i];
    if(a[i]>max)max=a[i];
    if(a[i]<min)min=a[i];
  }

  cout<<max-min<<endl;
  return 0;
}


Measured memory_bytes: 3592
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(s:#));
    let a=s.chars().take(2).collect::<String>().parse::<i64>().unwrap();
    let b=s.chars().skip(2).take(2).collect::<String>().parse::<i64>().unwrap();
    let x=1<=a&&a<=12;
    let y=1<=b&&b<=12;
    match (x,y){
      (true,true)=>"AMBIGUOUS",
      (true,false)=>"MMYY",
      (false,true)=>"YYMM",
      (false,false)=>"NA",
    }.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "1905\n" => "YYMM\n",
    test2: "0112\n" => "AMBIGUOUS\n",
    test3: "1700\n" => "NA\n",
}

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

int main(){
    long long N,A,B,ans=0;
    cin >>N>>A>>B;
    ans+=(N/(A+B))*A;
    if(N%(A+B)<=A){
        ans+=N%(A+B);
    }
    if(N%(A+B)>A){
        ans+=A;
    }
    cout <<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(long long i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const double pi = acos(-1.0);
const ll mod = pow(10,9) + 7;
const ll INF = pow(2,31) - 1;

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
	ll n,cnt = 0;
	string s;
	cin >> n >> s;

	rep(i,n-2){
		if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')cnt++;
	} 

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int m,f,r;
	char grade;
	for(;;){
		cin >> m >> f >> r;
		if(m==-1 && f==-1 && r==-1)	break;
		if(m==-1 || f==-1)			grade='F';
		else if(m+f>=80)			grade='A';
		else if(m+f<80 && m+f>=65)	grade='B';
		else if(m+f<65 && m+f>=50)	grade='C';
		else if(m+f<50 && m+f>=30){
						if(r>=50)	grade='C';
							else	grade='D';}
		else if(m+f<30)				grade='F';
		cout<< grade << endl;
	}
	return 0;
}

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

int main(){
	int H,W;
	while(true){
    cin >> H >> W;
		if(H == 0 && W == 0) break;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if((i+j)%2 == 0){
          cout << "#";
        }
				else{
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
}




Measured memory_bytes: 3088
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forr(i,a,b) for (ll i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef vector<ll> vl;
typedef vector<ii> vii;

const ll MX = 300005;
const ll inf = 2e18;
#define ptr nodo*
#define tam 301000
ll vpos[tam];
int main () 
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    forr(i,0,n)
    {
        cin>>vpos[i];
    }
    ll minn=1e9;
    forr(i,1,101)
    {
        ll tot=0;
        forr(j,0,n)
        {
            tot+=(vpos[j]-i)*(vpos[j]-i);
        }
        minn=min(minn,tot);
    }
    cout<<minn<<endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	h := make([]int, n)
	
	for i := range h {
		fmt.Scan(&h[i])
	}
	
	max,cnt := 0, 0
	for i := 1; i < n; i++ {
		if h[i-1] >= h[i] {
			cnt++
			//fmt.Printf("i=%d, cnt=%d\n",i,cnt)
		} else {
			cnt = 0
		}
		if max < cnt {
			max = cnt
		}
	}
	fmt.Println(max)
}

Measured memory_bytes: 5504
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>

using namespace std;
const int dir[4][2] = {-1, 0, 0, 1, 1, 0, 0, -1};
int w, h, n;
int X1[1000 + 1], Y1[1000 + 1], X2[1000 + 1], Y2[1000 + 1];
int field[1000 + 1000][1000 + 1000];

int compree(int *X1, int *X2, int w) {
    vector<int> xs;
    for (int i = 0; i < n; i++) {
        if (X1[i] - 1 >= 0) xs.push_back(X1[i] - 1);
        xs.push_back(X1[i]);
        xs.push_back(X2[i] - 1);
        if (X2[i] < w) xs.push_back(X2[i]);
    }
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    for (int i = 0; i < n; i++) {
        X1[i] = find(xs.begin(), xs.end(), X1[i]) - xs.begin();
        X2[i] = find(xs.begin(), xs.end(), X2[i]) - xs.begin();
    }
    return xs.size();
}

int main() {
    //freopen("../input.in", "r", stdin);
    while (~scanf("%d %d", &w, &h) && (w || h)) {
        memset(field, 0, sizeof(field));
        scanf("%d", &n);
        for (int i = 0; i < n; i++)
            scanf("%d %d %d %d", X1 + i, Y1 + i, X2 + i, Y2 + i);
        w = compree(X1, X2, w);
        h = compree(Y1, Y2, h);
        for (int i = 0; i < n; i++) {
            for (int x = X1[i]; x < X2[i]; x++)
                for (int y = Y1[i]; y < Y2[i]; y++)
                    field[x][y] = 1;
        }
        int ans = 0;
        for (int i = 0; i < w; i++)
            for (int j = 0; j < h; j++) {
                if (field[i][j]) continue;
                ans++;
                field[i][j] = 1;
                queue<pair<int, int> > que;
                que.push(make_pair(i, j));
                while (!que.empty()) {
                    int x = que.front().first, y = que.front().second;
                    que.pop();
                    for (int d = 0; d < 4; d++) {
                        int tx = x + dir[d][0], ty = y + dir[d][1];
                        if (0 <= tx && tx < w && 0 <= ty && ty < h && !field[tx][ty]) {
                            que.push(make_pair(tx, ty));
                            field[tx][ty] = 1;
                        }
                    }
                }
            }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 18344