akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let m: usize = sc.cin();
    let q: usize = sc.cin();
    let qs: Vec<_> = (0..q).map(|_| {
        let a: usize = sc.cin::<usize>() - 1;
        let b: usize = sc.cin::<usize>() - 1;
        let c: usize = sc.cin();
        let d: i64 = sc.cin();
        (a, b, c, d)
    }).collect();

    let mut ans = 0;

    let mut v = vec![0; n];
    let mut stack = vec![];
    for x in 0..m { stack.push((0, x)); }
    while let Some((i, x)) = stack.pop() {
        if i < n {
            v[i] = x;
            if i < n - 1 {
                for z in x..m {
                    stack.push((i + 1, z));
                }
            } else {
                // trace!(&v);
                let mut r = 0;
                for &(a, b, c, d) in qs.iter() {
                    if v[b] - v[a] == c {
                        r += d;
                    }
                }
                ans = max!(ans, r);
            }
        }
    }
    put!(ans);

}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 2136
// B - Postal Code
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int A,B; cin>>A>>B;
	string S; cin>>S;

	if(A+B+1 != S.size()){
		puts("No");
		return 0;
	}

	if(S[A] != '-'){
		puts("No");
		return 0;
	}

	rpz(i, S.size()){
		if(i == A) continue;
		int a = S[i]-'0';
		if(0<=a && a<=9) continue;
		puts("No");
		return 0;
	}
	puts("Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, m;
  cin >> n >> m;
  vl a(n);
  rep(i, n) {
    cin >> a[i];
    a[i] /= 2;
  }
  ll lcm, k;
  rep(i, n) {
    ll nk = 0;
    ll b = a[i];
    while(b % 2 == 0) {
      b /= 2;
      nk++;
    }
    if(i == 0) {
      k = nk;
      lcm = a[i];
      continue;
    }
    if(k != nk) {
      cout << 0 << endl;
      return 0;
    }
    lcm = lcm / __gcd(lcm, a[i]) * a[i];
  }
  cout << (m / lcm + 1) / 2 << endl;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  ll x; scanf("%lld", &x);
  ll r = x % 11;
  ll ans = (x / 11) * 2;
  if (r > 6) { ++ans; }
  if (r > 0) { ++ans; }
  printf("%lld\n", ans);
  return 0;
}


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

using namespace std;

typedef long long ll;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define vi vector<ll>
#define vp vector<pair<int, int>>
#define graph vector< vector<int> >
#define vs vector<string>

graph g(10010);
/**  '' "\n" ^ */
int cou;int n;int u,v,x,sum;
string str;
int p[10010];
vector<int> ans;
void sieve()
{
    for(int i=0;i<10010;i++)
    {
        p[i]=0;
        g[i].clear();
    }
}
void dfs(int r)
{
    if(p[r])return;
    cou++;
    p[r]=1;
    for(auto e:g[r])
    {
        dfs(e);
    }
}
int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  sf(n);
  vector<int> a(n);
  in(i,n)
  {
      cin>>a[i];
  }
  int c=0;
  for(int i=1;i<n-1;i++)
  {
      if(a[i]<a[i-1]&&a[i]>a[i+1])c++;
      if(a[i]>a[i-1]&&a[i]<a[i+1])c++;
  }
  pf(c);
}


Measured memory_bytes: 512
# ABC141 D - Powerful Discount Tickets
from heapq import heappop,heappush,heapify

n,m = map(int, input().split())
a = list(map(float,input().split()))

a_minus = [-x for x in a]

heapify(a_minus)

for _ in range(m):
    heappush(a_minus,-((-heappop(a_minus))//2))
ans = -sum(a_minus)
print(int(ans))


Measured memory_bytes: 13384
// 10/06/20 // 00:25 PM //

#include <bits/stdc++.h>

using namespace std;

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

typedef vector<vector<int>> matrix;

const int MOD = (int)(1e9)+7;

matrix prod(matrix ma, matrix mb){
    matrix mc((int)ma.size(), vector<int>((int)mb[0].size()));

    for(int i=0; i<(int)ma.size(); i++)
        for(int j=0; j<(int)mb[0].size(); j++)
            for(int k=0; k<(int)mb.size(); k++){
                mc[i][j] += (ma[i][k]*mb[k][j])%MOD;
	    		mc[i][j] %=MOD;
	    	}
    return mc;
}

matrix expo(matrix ma, int n){
    if(n==1) return ma;

    if(n&1)
        return prod(expo(matrix(ma), n-1), ma);
    else
        return expo(prod(ma, ma), n/2);
}

void mprint(matrix ma){
    for(int i=0; i<(int)ma.size(); i++){
        for(int j=0; j<(int)ma[0].size(); j++){
            cout << ma[i][j] << " ";
        }
        cout << endl;
    }
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	

   	int n, k;
	cin >> n >> k;
    
	matrix ma(n, vector<int>(n));
	
	for(int i=0; i<n; i++)
		for(int j=0; j<n; j++)
			cin >> ma[i][j];	

	ma = expo(ma, k);

	int resp = 0;
	for(int i=0; i<n; i++)
		for(int j=0; j<n; j++){
			resp += ma[i][j];
			resp %= MOD;		
		}

	cout << resp << endl;

    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

  int h_max = std::max(h - 1, 0);
  
  for (int i = 1; i < n; ++i) {
    cin >> h;
    h_max = h > h_max ? h - 1 : h_max;
    if (h - h_max < 0) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            boolean[] FURUI = new boolean[100_000_000 + 1];
            for (int i = 2; i < FURUI.length; i++) {
                FURUI[i] = true;
            }
            for (int i = 2; i * i <= FURUI.length; i++) {
                if (FURUI[i] == false) {
                    continue;
                }
                for (int j = i + i; j < FURUI.length; j += i) {
                    FURUI[j] = false;
                }
            }
            int count = 0;
            while (N-- > 0) {
                count += FURUI[in.nextInt()] ? 1 : 0;
            }
            System.out.println(count);
        }
    }
}

Measured memory_bytes: 138380
n, k = map(int, input().split())
A = list(map(int, input().split()))
route = [1]
dest = A[0]
check = {i: False for i in range(n)}
while not check[dest - 1]:
    check[dest - 1] = True
    route.append(dest)
    dest = A[dest - 1]
ind = route.index(dest)
cycle = route[ind:]
if k >= ind:
    ans = (k - ind) % len(cycle)
    print(cycle[ans])
else:
    print(route[k])

Measured memory_bytes: 40704
#include<stdio.h>

int CheckPrime(int n){
	int i;
	if(n%2==0){
		return 0;
	}
	for(i=3;i<=n/i;i+=2){
		if(n%i==0){
			return 0;
		}
	}
	return 1;
}
int AddPrime(int n, int num, int* value, int* result){
	int i;
	for(i=0;i<num;i++){
		if(n<=value[i]) result[i]++;
	}
	return 0;
}
int main(){
	int n, num=0, max=0, value[30], result[30];
	int i;
	while(scanf("%d",&n)!=EOF){
		value[num] = n;
		result[num] = 0;
		if(max<n) max=n;
		num++;
	}

	AddPrime(2,num,value,result);
	AddPrime(3,num,value,result);
	for(i=6;i-1<=max;i+=6){
		if(CheckPrime(i-1)==1){
			AddPrime(i-1,num,value,result);
		}
		if(CheckPrime(i+1)==1){
			AddPrime(i+1,num,value,result);
		}
	}
	for(i=0;i<num;i++){
		printf("%d\n",result[i]);
	}
	return 0;
}

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

int main(){
	string s,t;
while(cin>>s>>t){
	static int ans[4002][4002]={0},big=0;
	for(int i=0;i<4002;i++)for(int j=0;j<4002;j++)ans[i][j]=0;
	big=0;
	int ss=s.size(),ts=t.size();
	for(int i=ss-1;i>=0;i--){
		for(int j=ts-1;j>=0;j--){
			if(s[i]==t[j]){
				ans[i][j]=ans[i+1][j+1]+1;
				if(big<ans[i][j])big=ans[i][j];
			}
		}
	}
	cout<<big<<endl;
}
}
			

Measured memory_bytes: 63768
from sys import stdin

N = int(stdin.readline().rstrip())
S = []
ans = 0
count = 0

for i in range(N):
    line = sorted([x for x in stdin.readline().rstrip()])
    line = ("".join(line))
    S.append(line)

S.sort()
for i in range(N):
    if (i == 0) or (S[i] == S[i - 1]):
        count += 1
    else:
        ans += count*(count - 1)//2
        count = 1
ans += count*(count - 1)//2

print(ans)

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

int main(){
    int X, N, sub;
    cin >> X >> N;
    vector<int> a(N), b;
    map<int, int> m;
    if(N == 0) cout << X << endl;
    else{
        for(int i = 0; i < N; i++){
        cin >> a.at(i);
        }
        sort(a.begin(), a.end());
        bool finish = false;
        for(int i = 0; i < N; i++){
            if(a.at(i) == X){
                finish = true;
            }
        }
        if(!finish){
            cout << X << endl;
            return 0;
        }
        int sub;
        for(int i = 0; i <= 101; i++){
            bool judge = false;
            for(int j = 0; j < N; j++){
                if(i == a.at(j)){
                    judge = true;
                    break;
                }
            }
            if(!judge) b.push_back(i);
        }
        for(int i = 0; i < b.size(); i++){
            sub = b.at(i) - X;
            if(sub < 0) sub = -1 * sub;
            if(m.count(sub)) m[sub] = min(m[sub], b.at(i));
            else m[sub] = b.at(i);
        }
        for(auto p : m){
            auto k = p.first;
            auto v = p.second;
            cout << v << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3624
N,M,C = map(int,input().split())
B = input().split()
count = 0

for i in range(N):
  A = input().split()
  sum = C
  for k in range(M):
    sum += int(A[k]) * int(B[k])
  if sum > 0:
    count += 1

print(count)

Measured memory_bytes: 3060
N = int(input())

for i in range(11):
    if N <= 26 ** (i + 1):
        size = i + 1
        break
    N -= 26 ** (i + 1)

ans = [0] * size
N -= 1
for i in range(size):
    q = N // 26
    r = N % 26
    N = q
    ans[size - 1 - i] = r

ans_chr = ''
for i in range(size):
    ans_chr += chr(ans[i] + 97)

print(ans_chr)


Measured memory_bytes: 61932
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define int long long int
const int mod = 1000000007;
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;


signed main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string S, T;
    cin>>S>>T;
    int ans = T.length();
    for(int start=0; start<=S.length()-T.length(); start++){
        int dif = 0;
        for(int i=0; i<T.size(); i++){
            if(T[i] != S[i+start]){
                dif++;
            }
        }
        ans = min(ans, dif);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>

using namespace std;

int main(){
  int a;
  bool ok[31] = {};
  while(cin >> a) ok[a] = true;
  for(int i = 1 ; i < 31 ; i++ ){
    if(!ok[i]) cout << i << endl;
  }
}

Measured memory_bytes: 1160
n = int(input())
al = list(map(int, input().split()))

flg = True
for a in al:
    if a%2 == 0:
        if a%3 == 0 or a%5 == 0:
            continue
        else:
            flg = False
            break

if flg:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 9104
s = input()

for b in range(1<<(len(s)-1)):
    f = s[0]
    for i in range(len(s)-1):
        if b & (1<<i):
            f += '+' + s[i+1]
        else:
            f += '-' + s[i+1]
    if eval(f) == 7:
        print(f+'=7')
        exit(0)


Measured memory_bytes: 38384
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (; sc.hasNextInt();) {
			int n = sc.nextInt();
			System.out.printf("3C%02d\n", ((n-1)%39 + 1));
		}
	}

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
}

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

using namespace std;

int main(){
    string S;
    long long int K,i=0;
    cin >> S;
    cin >> K;
    while(1){
        if(S[i]!='1'){
            cout << S[i] << endl;
            break;
        }else{
            if(i==(K-1)){
                cout << "1" << endl;
                break;
            }else{
                i++;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int n,r;
    scanf("%d%d",&n,&r);
    int ans=0;
    if(n>=10)
    {
        ans=r;
    }
    else
    {
        ans=r+100*(10-n);
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 128
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
*p, = map(int, input().split())

*p, = map(lambda x:(x+1)/2, p)

# r, l = 0, 0
# su = 0
# ans = 0
# while r < n:
#     if r - l >= k-1:
#         su -= p[r]
#         r += 1
#         ans = max(ans, su)
#     else:
#         l += 1
#         su += p[l]
su = sum(p[:k])
ans = su
for i in range(k, n):
    su += p[i]
    su -= p[i-k]
    ans = max(su, ans)

print(ans)

Measured memory_bytes: 25188
#include <iostream>
#include <string>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

 long long int gcd(int a,int b){
  if(a%b == 0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
int main(){
  int k;
  int a,b,c;
  cin >> k;
  long long sum = 0;
  for(a=1;a<=k;a++){
    for(b=1;b<=k;b++){
      for(c=1;c<=k;c++){
        sum += gcd(gcd(a,b),c);
      }
    }
  }
  cout << sum << endl;

}


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

int main ()
{
  int N;
  cin >> N;
  vector<int> A(N);
  vector<long long> B(N+1, 0);
  int mod = 1000000007;
  for (int i = 0; i < N; ++i) {
      cin >> A[i];
      B[i+1] = B[i] + A[i];
  }
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    long long sum = (B[N] - B[i+1]) % mod;
    ans += A[i] * sum;
    ans = ans % mod;
  }
  cout << ans << endl;
  return 0;
}


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

vector<int64_t> v,vp;

int64_t countP(int L, int64_t x){
  if(L==0){
    return 1;
  }
  if(x<=1){
    return 0;
  }else if(x<=1+v.at(L-1)){
    return countP(L-1, x-1);
  }else if(x<=2+v.at(L-1)){
    return vp.at(L)/2+1;
  }else if(x<=2+v.at(L-1)*2){
    return vp.at(L)/2+1+countP(L-1, x-(2+v.at(L-1)));
  }else{
    return vp.at(L);
  }
}

int main(){
  int N;
  int64_t X;
  cin >> N >> X;
  v.resize(N+1);
  vp.resize(N+1);
  v.at(0)=1;
  vp.at(0)=1;
  for(int i=1;i<=N;i++){
    v.at(i)=v.at(i-1)*2+3;
    vp.at(i)=vp.at(i-1)*2+1;
  }
  cout << countP(N, X) << endl;
  return 0;
}


Measured memory_bytes: 3644
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int n;
	cin >> n;
	set<int> s;
	REP(i, n){
		cin >> tmp;
		s.insert(tmp);
	}
	cout << s.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef unsigned long long ll;
// vector<pair<uint, uint>> d;
vector<pair<ll, ll>> d;
 
int main(int, char**)
{
	unsigned int n;
	ll t = 0, s = 0;
	cin >> n;
	d.resize(n);
 
	for (unsigned int i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		d[i].first = a + b;
		d[i].second = a;
	}
 
	sort(d.begin(), d.end(), greater<>());
 
	for (unsigned int i = 0; i < n; i++) {
		if (i % 2 == 0) t += d[i].second;
		else s += (d[i].first - d[i].second);
	}
 
    cout << (long long)t - (long long)s << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    REP(i, N) cin >> A[i];
    long long sm = 0;
    REP(i, N) sm += A[i];
    long long cur = 0;
    long long ans = 1LL<<60;
    REP(i, N) {
        cur += A[i];
        long long rem = sm - cur;
        ans = min(ans, abs(cur-rem));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
a, b, c, k = map(int, input().split())
s, f = 0, 0
while k > 0:
    s += min(a, k)
    k -= s
    if k > 0:
        f = min(b, k)
        k -= f
    if k > 0:
        s -= min(c, k)
        k -= s
    break
print(s)


Measured memory_bytes: 9176
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
typedef long long ll;

int main(int argc, char *argv[])
{
	ll n;

	cin >> n;
	ll s =ceil(sqrt(double(n)));
	ll i;
	for (i=s;i>0;i--) if ((n%i)==0) break;

	ll x=i+(n/i)-2;

	cout << x  << endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  char a[1000000];
  for(int i = 0;i < 1000000;i++){
	a[i] =  'a';
  }
  int l;
  
  scanf("%s", a);
  
  for(int j = 0;j < 1000000;j++){
	if(a[j] == 'a'){
	  l = j + 1;
	  break;
	}else{
	  continue;
	}
  }
  
  int r = 0; 
  char t;
  
  if(a[0] == '1'){
	t = '0';
  }else if(a[0] == '0'){
	t = '1';
  }
  
  for(int k = 1;k < l;k++){
	
	if(a[k] != t){
	  r++;
	}
	
	if(t == '0'){
	  t = '1';
	}else if(t == '1'){
	  t = '0';
	}
	
  }
  printf("%d\n", r - 2);
}


Measured memory_bytes: 1152
while True:
    n=input()
    if n==0:break
    s=raw_input()
    for i in range(n):
        t=""
        r=0
        a=s[0]
        for c in s:
            if c==a:
                r+=1
            else:
                t+=str(r)+a
                r=1
                a=c
        t+=str(r)+a
        s=t
    print t

Measured memory_bytes: 4284
#include<stdio.h>

#define MAX 101
#define NIL -1

int main()
{
  int n,A[MAX][MAX],i,j,k,v,id;

  scanf("%d",&n);

  for(i = 1 ; i <= n ; i++)
    {
      for(j = 1 ; j <= n ; j++)
	{
	  A[i][j] = NIL;
	}
    }

  for(i = 1 ; i <= n ; i++)
    {
      scanf("%d",&id);
      scanf("%d",&k);
      for(j = 1 ; j <= k ; j++)
	{
	  scanf("%d",&v);
	  A[id][v] = v;
	}
    }

  for(i = 1 ; i <= n ; i++)
    {
      for(j = 1 ; j <= n ; j++)
	{
	  if(A[i][j] != NIL)
	    {
	      printf("1");
	    }
	  else printf("0");
	  if(j != n) printf(" ");
	}
      printf("\n");
    }
  
  return 0;
}




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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 200100;

int n, m;
int a[maxn + 5];
int num[maxn + 5];

int vis[maxn + 5];

int ans;

inline void add(int x)
{
	if (x - num[x] >= 0 && !(vis[x - num[x]]++)) --ans;
	++num[x];
}

inline void del(int x)
{
	--num[x];
	if (x - num[x] >= 0 && !--vis[x - num[x]]) ++ans;
}

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d%d", &n, &m);
	ans = n;
	REP(i, 0, n) scanf("%d", a + i), --a[i], add(a[i]);
	REP(i, 0, m)
	{
		int x, y;
		scanf("%d%d", &x, &y), --x, --y;
		del(a[x]);
		a[x] = y;
		add(a[x]);
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 3840
#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(int 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
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;

ll N;
ll A[100000];
ll HUSOKU;
ll TARIRU[100000];
ll ans;
int main(void) {
	cin >> N;
	int T = 0;
	FOR(i, 0, N) {
		cin >> A[i];
	}
	FOR(i, 0, N) {
		ll a;
		cin >> a;
		if (a > A[i]) {
			HUSOKU += a - A[i];
			ans++;
		}
		else if (A[i] > 0) {
			TARIRU[T] = A[i] - a;
			T++;
		}
	}
	sort(TARIRU, TARIRU + T);
	reverse(TARIRU, TARIRU + T);
	FOR(i, 0, T) {
		if (HUSOKU > 0) {
			HUSOKU -= TARIRU[i];
			ans++;
		}
		if (i == T - 1 && HUSOKU > 0) {
			ct(-1); return 0;
		}
	}

	ct(ans);
	return 0;
}

Measured memory_bytes: 1664
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, h, m float64
	fmt.Scan(&a, &b, &h, &m)

	var x1, x2, y1, y2 float64

	x1 = a * math.Cos(math.Pi*(3-h-(m/60))/6)
	y1 = a * math.Sin(math.Pi*(3-h-(m/60))/6)
	x2 = b * math.Cos(math.Pi*(15-m)/30)
	y2 = b * math.Sin(math.Pi*(15-m)/30)

	fmt.Println(math.Sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)))

}


Measured memory_bytes: 1824
#include<cstdio>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
long long n,h,d,p,y,x,z;
deque<pair<long long,long long> > w;
int main(){
  scanf("%lld%lld",&n,&p);
  y=p;
  for(;--n;){
    scanf("%lld%lld", &d, &h);
    while(!w.empty() && w.back().first < h){
      w.pop_back();
    }
    w.push_back(make_pair(h, x));
    x += d;
    while(p <= x){
      long long int tmpp = p ;
      while(!w.empty() && tmpp + w.front().first - w.front().second > y){
	p = max(p, w.front().second + y);
	w.pop_front();
      }
      if(!w.empty()){
	p = max(p, tmpp + w.front().first);
	int tmp = max(0ll, min((x - p) / w.front().first, (w.front().second + y - p) / w.front().first));
	z += tmp;
	p += tmp * w.front().first;
      }
      z++;
    }
  }
  printf("%lld\n", z);
  return 0;
}

Measured memory_bytes: 1056
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <map>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline bool Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+" ";
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
constexpr const ll INF = 1e15;
constexpr const ll MOD = 1000000007;
constexpr int nx[4] = {1,0,-1,0};
constexpr int ny[4] = {0,1,0,-1};
typedef pair<ll,ll> P;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    PRINT((x/500)*1000+((x-(x/500)*500)/5)*5);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;



int main(){
    int n; cin >> n;
    vector<vector<int>> e(n);


    rep(i,n){
        int s; cin >> s;
        int tmp; cin >> tmp;
        rep(j,tmp){
            int to; cin >> to;
            e[i].push_back(to-1);
        }
    }

    vi ans(n,-1);
    rep(i,n){
        //if(i != 3) continue;
        queue<pair<int,int>> bfs;
        bfs.emplace(0,0);
        vector<bool> visit(n,false);
        while(!bfs.empty()){
            auto tmp = bfs.front();
            if(tmp.first == i) {
                ans[i] = tmp.second;
                break;
            }
            visit[tmp.first] = true;
            bfs.pop();

            rep(j,e[tmp.first].size()){
                if(!visit[e[tmp.first][j]]) {
                    //cout << j << endl;
                    bfs.emplace(e[tmp.first][j],tmp.second+1);
                }
            }
        }

    }

    rep(i,n){
        cout << i+1 << " " << ans[i] << endl;
    }
}



Measured memory_bytes: 3416
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 
  string S; cin >> S;
  int sum = 700;
  for(int i = 0; i < 3; i++){
    if( S[i] == 'o'){ sum += 100;}
  }
  
  cout << sum << endl;
  
  return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k, temp, ans = 0;
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        cin >> temp;
        ans += 2*min(abs(k-temp), temp);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

int cnts[100005];

struct mint {
    ll x;
    mint(ll x=0):x(x%mod){}

    mint& operator+=(const mint a) {
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator-=(const mint a) {
        if (x < a.x) {
          x += mod;
        }
        x -= a.x;
        return *this;
    }

    mint& operator*=(const mint a) {
        x = (x * a.x) % mod;
        return *this;
    }

    mint& operator/=(const mint a) {
        *this *= a.inv();
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    mint pow(ll n) const {
        mint a(*this);
        mint res = 1;
        while (n > 0) {
            if (n & 1) res *= a;
            a *= a;
            n >>= 1;
        }
        return res;
    }

    mint inv() const {
        return pow(mod - 2);
    }
};

const int MAX_V = 100005;

mint fac[MAX_V];
mint inv[MAX_V]; 

void initFact() {
  fac[0] = 1;
  inv[0] = 1;
  for (int i = 1; i <= MAX_V; i++) {
    fac[i] = (fac[i - 1] * i);
    inv[i] = fac[i].inv();
  }
}

mint combi(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * inv[k] * inv[n - k];
}

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

  long n;
  cin >> n;

  string s;
  cin >> s;

  bool isOk = true;
  if (n%2) {
    isOk = false;
  }

  rep(i, n/2) {
    if (s[i] != s[n/2+i]) isOk = false;
  }

  cout << (isOk?"Yes":"No") << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename x>
using ordered_set = tree<x,null_type,less<x>,rb_tree_tag,tree_order_statistics_node_update>;
#define sorta(a,n) sort(a,a+n)
#define sortad(a,n) sort(a,a+n,greater<__typeof(a[0])>())
#define all(x) (x).begin(),(x).end()
#define ms0(x) memset((x),0,sizeof((x)))
#define ms1(x) memset((x),-1,sizeof((x)))
typedef pair<long long,long long> pi;
#define inarr(arr,n) for(long long i=0;i<n;i++)cin>>arr[i];
#define prinarr(arr) {for(long long x:arr)cout<<x<<" ";} cout<<"\n";
#define cout1(a) cout<<a<<"\n";
#define cout2(a,b) cout<<a<<" "<<b<<"\n";
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define setpre(n) cout<<fixed<<setprecision(8)<<n<<"\n";
#define filldp(arr,n,m,k) for(long long i=0;i<n;i++){for(long long j=0;j<m;j++) arr[i][j]=k;}

#define mod 1000000007
#define mod1 998244353


vector<vector<long long>> adj;
vector<long long> dis;
vector<long long> parent;
vector<bool> visited;

void newgr(long long n){
    n+=10;
    adj=vector<vector<long long>>(n);
    dis=vector<long long>(n,0);
    //parent=vector<long long>(n,-1);
    visited=vector<bool>(n,false);
}

void dfs(long long s){
    visited[s]=true;
    for(auto u:adj[s]){
        if(!visited[u]){
            //parent[u]=s;
            dis[u]=dis[s]+1;
            dfs(u);
        }
    }
}

void bfs(long long s){
    queue<long long> q;
    q.push(s);
    visited[s]=true;
    dis[s]=0;
    while(!q.empty()){
        auto u=q.front();
        q.pop();
        for(auto x:adj[u]){
            if(!visited[x]){
                //parent[x]=u;
                visited[x]=true;
                dis[x]=dis[u]+1;
                q.push(x);
            }
        }
    }
}

long long power(long long x,long long y){  
    long long ans=1;
    x%=mod;
    while(y>0){
        if(y&1) ans=(ans*x)%mod;
        y>>=1;
        x=(x*x)%mod;
    }
    return ans;
}

long long modinv(long long b){ 
    return power(b,mod-2);
}

long long dp[3004][3004][2];
long long arr[3004];
long long solve(long long l, long long r, long long flag, long long su){
    if(l>r)return 0;
    if(flag==0){
        if(dp[l][r][0]){
            return dp[l][r][0];
        }
        dp[l][r][0]=max(arr[l]+su-arr[l]-solve(l+1,r,0,su-arr[l]),arr[r]+su-arr[r]-solve(l,r-1,0,su-arr[r]));
        return dp[l][r][0];
    }
    else{
        if(dp[l][r][0]){
            return dp[l][r][0];
        }
        dp[l][r][0]=max(arr[l]+su-arr[l]-solve(l+1,r,0,su-arr[l]),arr[r]+su-arr[r]-solve(l,r-1,0,su-arr[r]));
        return dp[l][r][0];
    }
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    long long n;
    cin>>n;
    for(long long i=0;i<n+2;i++){
        for(long long j=0;j<n+2;j++){
            dp[i][j][0]=dp[i][j][1]=0;
        }
    }
    long long su=0;
    for(long long i=0;i<n;i++){
        cin>>arr[i];
        su+=arr[i];
    }
    long long p=solve(0,n-1,0,su);
    cout1(p-(su-p));
    //cout2(su,p);
    return 0;
}

Measured memory_bytes: 144740
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
 int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a=1,b=0,n,ans=0;
    cin>>n;
    ans=sqrt(n);
    while (a != 0) {
        a = n % ans;
        b = n / ans;
        ans--;
  }
     cout << ans + b - 1 << endl;
	return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

int kai(int n) {
  int res = 1;
  for (int i = 1; i <= n; i++) {
    res *= i;
  }
  return res;
}

// ====================================================================

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }

  double ans = 0;
  vector<int> v(n);
  iota(v.begin(), v.end(), 0);
  do {
    for (int i = 0; i < n - 1; i++) {
      ans += sqrt((x[v[i]] - x[v[i + 1]]) * (x[v[i]] - x[v[i + 1]]) + (y[v[i]] - y[v[i + 1]]) * (y[v[i]] - y[v[i + 1]]));
    }
  } while (next_permutation(v.begin(), v.end()));

  ans /= kai(n);
  cout << fixed << setprecision(10) << ans << endl;
}


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

int main(){
  int n; cin >> n;
  vector<int> a(n);
  
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  sort(a.begin(), a.end());
  int bi = *(a.end()-1);
  auto it1 = lower_bound(a.begin(), a.end(), bi/2);
  auto it2 = it1;
  it2--;
  int ans;
  if(bi % 2 == 0){
    if(*it1 - bi/2 > bi/2 - *it2) ans = *it2;
    else ans = *it1;
  }else {
    if(*it1 - bi/2 - 1 > bi/2 - *it2) ans = *it2;
    else ans = *it1;
  }
  if(n == 2){
    ans = a[0], bi = a[1];
  }
  
  cout << bi << ' ' << ans << endl;
}

Measured memory_bytes: 640
import java.io.*;

class Main {

    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        try {
            String[] line = reader.readLine().split(" ");
            int a = Integer.parseInt(line[0]);
            int b = Integer.parseInt(line[1]);

            int d = a / b;
            int r = a % b;
            double f = (double) a / b;

            System.out.printf("%d %d %f", d, r, f);
        } catch (NumberFormatException e) {
            System.out.println(e);
        } catch (IOException e) {
            System.out.println(e);
        }
    }

}

Measured memory_bytes: 24748
#include <cassert>

#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>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// 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>
#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>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){ 
    int a,b;
    cin>>a>>b;
    cout<<abs(a-b)<<endl;
    
}


/*
abcde

/root
a.txt
bunp.html
/desktop
r.txt
fsharp.cs
dp.cpp
/users
bison.txt

root r.txt
users r.txt
users a.txt

desktop/r.txt
../r.txt
../../a.txt
*/



Measured memory_bytes: 3076
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn permutations(aa: Vec<usize>) -> Vec<Vec<usize>> {
    let n = aa.len();
    if n == 1 {
        return vec![aa]
    }

    (0..n).flat_map(|i| {
        let mut tmp = aa.clone();
        let pick = tmp.swap_remove(i);
        permutations(tmp).into_iter().map(|mut p| {
            p.push(pick);
            p
        }).collect::<Vec<Vec<usize>>>()
    }).collect()
}


fn _solve(rs: Vec<usize>, mut abc: Vec<Vec<usize>>) -> usize {
    use std::cmp::min;

    let n = abc.len();

    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                if abc[i][k] == std::usize::MAX ||
                    abc[j][k] == std::usize::MAX {
                        continue
                    }

                abc[i][j] = min(abc[i][j], abc[i][k] + abc[j][k])
            }
        }
    }

    let mut dist = std::usize::MAX;

    for r in permutations(rs) {
        let mut d = 0;
        for i in 1..r.len() {
            d += abc[r[i-1]][r[i]];
        }
        if d < dist {
            dist = d;
        }
    }

    dist
}

fn solve(rs: Vec<usize>, abc: Vec<(usize, usize, usize)>) -> usize {
    let mut table = vec![vec![std::usize::MAX; 201]; 201];

    for (a,b,c) in abc {
        table[a][b] = c;
        table[b][a] = c;
    }

    _solve(rs, table)
}

fn main() {
    let (n,m,r) = parse_line!(usize, usize, usize);

    let rs = parse_vec!(usize);

    let abc = (0..m).map(|_| parse_line!(usize, usize, usize)).collect();

    println!("{}", solve(rs, abc));
}

#[test]
fn solve_test() {
    assert_eq!(solve(vec![1,2,3],
                     vec![(1,2,1),
                          (2,3,1),
                          (3,1,4)]), 2);

    assert_eq!(solve(vec![1,3],
                     vec![(2,3,2),
                          (1,3,6),
                          (1,2,2)]), 4);
}


Measured memory_bytes: 8444
l,r = map(int,input().split())
mod = 2019

if r - l >= 2019:
    print(0)
    exit()

for i in range(l,r+1):
    for j in range(i+1,r+1):

        mod = min(mod,(i*j)%2019)
        if mod == 0:
            break

print(mod)


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

int main() {
    int A, B, M;

    cin >> A >> B >> M;
    vector<int> a(A);
    vector<int> b(B);
    for (int i = 0; i < A; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < B; i++) {
        cin >> b[i];
    }

    int amin = *min_element(a.begin(), a.end());
    int bmin = *min_element(b.begin(), b.end());

    int ans = amin + bmin;
    for (int i = 0; i < M; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        ans = min(ans, a[x - 1] + b[y - 1] - c);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>

using namespace std;

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

    vector<int> p(n);
    for(int i=0;i<n;i++)cin >> p.at(i);

    int max = 0;
    int sum = 0;
    for(int i=0;i<n;i++){
        sum += p.at(i);
        if(max < p.at(i))max = p.at(i);
    }

    cout << sum - max/2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <memory.h>

#define MIN_N 1;
#define MAX_N 36

struct card {
  char picture;
  int number;
} typedef card_t;

card_t new_card(char picture, int number) {
  card_t card;
  card.picture = picture;
  card.number = number;
  return card;
}

void dump_cards(card_t cards[], int n) {
  for(int i=0; i<n; i++) {
    printf("%c%d", cards[i].picture, cards[i].number);
    if(i < n-1) {
      printf(" ");
    }
  }
}

void bubble_sort(card_t cards[], int n) {
  for(int i=0; i<n; i++) {
    for(int j=n-1; j>i; j--) {
      if(cards[j].number < cards[j-1].number) {
        card_t tmp = cards[j];
        cards[j] = cards[j-1];
        cards[j-1] = tmp;
      }
    }
  }
}

// 0 -> stable, 1 -> not stable
int selection_sort(card_t cards[], int n) {
  int not_stable = 0;
  for(int i=0; i<n; i++) {
    int minj = i;
    for(int j=i; j<n; j++) {
      if(cards[j].number < cards[minj].number) {
        minj = j;
      }
    }
    if(minj != i) {
      if(cards[i].picture == cards[minj].picture) {
        not_stable = 1;
      }
      card_t tmp = cards[i];
      cards[i] = cards[minj];
      cards[minj] = tmp;
    }
  }
  return not_stable;
}


int main() {
  int n;
  card_t cards[MAX_N];
  scanf("%d\n", &n);
  for(int i=0; i<n; i++) {
    char picture;
    int number;
    scanf("%c%d ", &picture, &number);
    cards[i].picture = picture;
    cards[i].number = number;
  }

  card_t cards_bubble[MAX_N];
  card_t cards_selection[MAX_N];
  memcpy(cards_bubble, cards, sizeof(card_t)*MAX_N);
  memcpy(cards_selection, cards, sizeof(card_t)*MAX_N);

  bubble_sort(cards_bubble, n);
  int not_stable = selection_sort(cards_selection, n);

  dump_cards(cards_bubble, n);
  printf("\nStable\n");
  dump_cards(cards_selection, n);
  if(not_stable == 0) {
    printf("\nStable\n");
  } else {
    printf("\nNot stable\n");
  }

}

Measured memory_bytes: 2768
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define sz size()
#define en end()
#define ro return 0
#define br break
#define con continue;
#define um unordered_map<ll,ll>
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define forr(i,a,b) for(ll i=a;i<b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace2(a,b) cerr <<"a is " << a << " b is " << b << el;
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;
char c[12][12];
int main()
{
    ios;
    ll row , col ;
    cin >> row >> col ;
    forn(i , 1 , row)
    {
        forn(j, 1 , col ) {
            cin >> c[i][j]  ;
        }
    }
    ll flag  = -1 ;
    ll cr = 1 , cc = 1;
    while(1){
        if(cr == row and cc == col ) break ;
         ll tr = 0 ,  tb= 0 ;
         forn(i , cc +1 , col){
            if(c[cr][i] == '#') {
                tr ++ ;
            }
         }
         forn(i , cr +1 , row){
             if(c[i][cc] == '#') {
                ++tb;
             }
         }
         if(tr > 0 and tb> 0 ) {
            flag = 0 ;
            br ;
         }
         else if(tr > 0 and tb== 0 ) {
             cr = cr ;
             cc = cc+1 ;
         }
         else if(tr == 0 and tb > 0 ){
            cr = cr +  1;
            cc = cc ;
         }
    }
    if(flag == -1){
        cout <<"Possible\n";
        ro ;
    }
    else cout << "Impossible\n" ;
    ro ;
}


























Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
    #define M_PI 3.14159265358979323846
    int main()
    {
     //clock_t begin = clock();
     //#ifndef ONLINE_JUDGE
     //freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);
     //#endif
   tani_nachi_ke
    
    int n;
    cin>>n;
    int arr[n+10]={0};
    for(int i=1; i<=n; i++)cin>>arr[i];
    int dp[n+10]={0};
    dp[2]=abs(arr[2]-arr[1]);
    for(int i=3; i<=n; i++)dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    cout<<dp[n]<<endl;
  
   // #ifndef ONLINE_JUDGE 
    //clock_t end = clock();
    //cout<<endl<<double(end - begin) / CLOCKS_PER_SEC*1000<<" ms";
    //#endif 
    return 0;
}






Measured memory_bytes: 1024