akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e+9;


int main() {
    int H,W;
    cin >> H >> W;
    
    vector<vector<int>> dp(10,vector<int>(10,INF));
    REP(i,10) REP(j,10){
        cin >> dp[i][j];
    }
    //REP(i,10) dp[i][i] = 0;
    
    vector<vector<int>> A(H,vector<int>(W));
    vector<int> num(10,0);
    REP(i,H) REP(j,W){
        cin >> A[i][j];
        
        if ( A[i][j] == -1 ) continue;
        num[A[i][j]] += 1;
    }
    
    REP(k,10) REP(i,10) REP(j,10) {
        dp[i][j] = min(dp[i][j],dp[i][k] + dp[k][j]);
    }
    
    ll ans = 0;
    
    for ( int i = 0; i <= 9; ++i){
        ans += ( num[i] * dp[i][1] );
    }
    
    cout << ans << endl;
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 3812
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}


fn main() {
  solve();
}

fn solve() {
    let (n, m) = read_touple::<usize>();
    let mut g = vec![vec![]; n];
    for _ in 0..m {
      let (a, b) = read_touple::<usize>();
      g[a-1].push(b-1);
      g[b-1].push(a-1);
    }

    let mut visited = vec![false; n];
    visited[0] = true;

    //let ans = dfs_rec(0, &g, &mut visited);
    let ans = dfs_loop(n, &g);

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

fn dfs_rec(v: usize, g: &Vec<Vec<usize>>,  visited: &mut Vec<bool>) -> usize {
  let mut all_visited = visited
                          .iter()
                          .fold(true, |acc, &x| acc && x);

  if all_visited {
     return 1;
  }

  let mut res = 0;

  for &e in &g[v] {
    if visited[e] {
       continue
    }

    visited[e] = true;
    res += dfs_rec(e, g, visited);
    visited[e] = false;
  }

  return res
}


// stack に訪問状況の情報も付随しないと解けない
fn dfs_loop(n: usize, g: &Vec<Vec<usize>>) -> usize {
  let mut res = 0;
  let mut stack = Vec::new();

  // init
  let now = 0;
  let visited = vec![false; n];
  stack.push((now, visited));


  while let Some(t) = stack.pop() {
    let (now, mut visited) = t;
    visited[now] = true;
    let all_visited = visited
                        .iter()
                        .fold(true, |acc, &x| acc && x);

    if all_visited {
       res += 1;
       continue
    }

    for &e in &g[now] {
      if visited[e] {
         continue
      }
      stack.push((e, visited.clone()));
    }
  }

  res
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,K;cin >> N >> K;
  vector<int> H(N);
  rep(i,N)cin >> H[i];
  sort(all(H),greater<int>());
  rep(i,min(K,N)) H[i] = 0;
  ll sum = 0;
  rep(i,N) sum += (ll) H[i];
  cout << sum << endl;
  return 0;
}


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

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    
    int ans = 1900 * M + 100 * (N - M);
    for(int i = 0; i < M; i++){
        ans *= 2;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define testing 0
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto i : v) cerr << i << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto i : v) cerr << "{"  << i.f << ',' << i.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9
#define oo (ll)1e18
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string lts(ll x) {stringstream s; s << x; return s.str(); }
ll stl(string x) {stringstream s(x); ll temp; s >> temp; return temp; }
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN (int)1e5 + 5
#if !testing
	#define cerr if(0)cout
#endif

vector <int> V[MAXN];
vector <int> d2;
int sz[MAXN];
bool visited[MAXN];
int k;
ll dfs(int x, int p) {
	ll pos = k-1;
	if (p!=-1)--pos;
	ll res = 1;
	for (auto v : V[x]) { //selecting the colours of the child 
		if (v==p) continue;
		res *= pos;
		--pos;
		res %= MOD;
	}
	for (auto v : V[x]) {
		if (v==p)continue;
		res *= dfs(v,x);
		res %= MOD;
	}
	return res;
	
}
	

int32_t main() {
	IAMSPEED
	// set testing to 0 when submitting to judge
	int n; cin >> n >> k;
	FOR(i,1,n-1) {
		int a,b; cin >> a >> b;
		V[a].pb(b);
		V[b].pb(a);
	}
	cout << (k*dfs(1,-1)) %MOD;
}


Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>

using namespace std;
typedef long long ll;


int main(){

    string S;
    cin >> S;

    bool b_flg = false;
    bool c_flg = false;

    S += "xxxx";

    ll ans = 0;
    ll a_count = 0;

    ll flg = 0;

    for(ll i = 0; i < S.length(); i++){
        //cout << S[i];
        if(S[i] == 'A'){
            a_count++;
            continue;
        }

        if(a_count > 0 && S[i] == 'B'){
            if(S[i + 1] == 'C'){
                ans += a_count;
                i += 1;
            }else
            {
                a_count = 0;
            }
            
        }else if(a_count > 0 && S[i] == 'C'){
            a_count = 0;
        }


        
    }

    cout << ans << endl;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,k;
    cin >> a >> b >> k;
    if(a-k>=0){
        cout << a-k << ' ' << b;
    }
    else if(k<a+b){
        cout << 0 << ' ' << b-k+a;
    }
    else{
      	cout << "0 0";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<string.h>
#include <iostream>
#include <algorithm>
#include <cstdlib>
//#include <vector.h>
//#include <malloc.h>

#include <math.h>
using namespace std;
#include<stdlib.h>
#include<stdio.h>
long long store[100009];

  
void fun(){
    for(int i=2;i<=100001;i++){
        store[i] = (i*(i-1))/2;
    }
}
int upperBound(int n,int key){
    int s =2,e=n;
    int ans = -1;

    while(s<=e){
        int mid = (s+e)/2;
        if(s==e){
            ans=s;
            break;
        }

        if(store[mid]==key){
            ans = mid+1;
            s = mid+1;
            break;
        }
        else if(store[mid]>key){
            e = mid - 1;
        }
        else{
            s = mid + 1;
        }
    }

    return ans;
}

int main(){
    long long  n,m;
    //int ar[101];
    cin>>n>>m;
    n=n%m;
    long long  d = abs(n-m);
    long long  dd= abs(d-m);
    if(d>dd){
        cout<<dd<<"\n";
    }
    else{
        cout<<d<<"\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

 
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
		String str=reader.readLine();
		String s[]=str.split(" ");
		int w=Integer.parseInt(s[0]);
		int h=Integer.parseInt(s[1]);
		String c=s[2];

		int x=(w/2);
		int y=(h/2);

		StringBuilder sb=new StringBuilder();

		for(int i=0;i<h;i++){
		    for(int j=0;j<w;j++){
			if(i==0||i==h-1){
			    if(j==0||j==w-1){
				sb.append("+");
			    }else {
				sb.append("-");
			    }
			}else{
			    if(j==0||j==w-1){
				sb.append("|");
			    }else if(i==y&&j==x){
				sb.append(c);
			    }else{
				sb.append(".");
			    }
			}
			if(j==w-1&&i!=h-1){
			    sb.append("\n");
			}
		    }
		}
		System.out.println(sb);
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    static int gcd (int a, int b){
	return b>0?gcd(b,a%b):a;
    }
    static int lcm (int a, int b) {
	return a*b/gcd(a,b);
    }
}



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

int main() {
  int n;
  cin >> n;
  
  if(n < 2) cout << 1 << endl;
  else if(n < 4) cout << 2 << endl;
  else if(n < 8) cout << 4 << endl;
  else if(n < 16) cout << 8 << endl;
  else if(n < 32) cout << 16 << endl;
  else if(n < 64) cout << 32 << endl;
  else cout << 64 << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
using namespace std;
int N, M;
vector<int> G[300005];
int d[300005];

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

  cin >> N >> M;
  int u, v;
  rep(i, M){
    cin >> u >> v;
    u--, v--;
    G[u].push_back(v+N);
    G[u+N].push_back(v+2*N);
    G[u+2*N].push_back(v);
  }
  int s,t;
  cin >> s >> t;
  s--, t--;

  queue<int> q;
  q.push(s);
  rep(i, 3*N) d[i] = -1;
  d[s] = 0;
  while(!q.empty()){
    int k = q.front(); q.pop();
    rep(i, G[k].size()){
      int n = G[k][i];
      if(d[n] < 0){
        q.push(n);
        d[n] = d[k]+1; 
      }
    }
  }

  if (d[t]==-1) cout << -1 << endl;
  else cout << d[t] / 3 << endl;
}

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

using u64 = std::uint64_t;
constexpr u64 inf = std::numeric_limits<u64>::max();

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

namespace io {
  constexpr int is = 1 << 17;
  char ib[is], *ip = ib + is, it;
  inline char getc() {
    if (ip == ib + is) { read(STDIN_FILENO, ib, is); ip = ib; }
    return *ip++;
  }
  inline u64 scan() {
    u64 r = 0;
    if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';
    else while ((it = *ip++) & 16) r = r * 10 + it - '0';
    return r;
  }
  constexpr int os = 1 << 17;
  char ob[os], *op = ob, ot;
  inline void putc(const char c) {
    *op++ = c;
    if (op == ob + os) { write(STDOUT_FILENO, ob, os); op = ob; }
  }
  /* x shoud be greater than or equal to zero */
  inline void print(u64 x) {
    char d[20];
    int i = 0;
    while (true) {
      d[i] = x % 10 + 48;
      x /= 10;
      ++i;
      if (x <= 0) break;
    }
    while (i--) {
      putc(d[i]);
    }
  }
  inline void flush() {
    write(STDOUT_FILENO, ob, op - ob);
  }
}

signed main() {
  u64 n = io::scan();
  auto G = vector<vector<u64>>(n);
  auto H = vector<u64>(n);
  REP(i, n - 1) {
    u64 a = io::scan() - 1;
    u64 b = io::scan() - 1;
    G[a].push_back(i);
    G[b].push_back(i);
    H[i] = a ^ b;
  }
  u64 m = io::scan();
  auto paths = vector<u64>(m);
  auto collect = [&G, &H](auto &collect, u64 u, u64 v, u64 p) -> u64 {
    if (u == v) return 0;
    for (auto e : G[u]) {
      u64 t = H[e] ^ u;
      if (t == p) continue;
      u64 s = collect(collect, t, v, u);
      if (s != inf) {
        return s | (1ULL << e);
      }
    }
    return inf;
  };
  REP(j, m) {
    u64 u = io::scan() - 1;
    u64 v = io::scan() - 1;
    paths[j] = collect(collect, u, v, -1);
  }
  auto search = [&paths](auto &search, u64 ans, u64 j, u64 m, u64 mask) -> u64 {
    if (j != m) {
      return (
        search(search, ans, j + 1, m, mask)
      - search(search, ans, j + 1, m, mask | paths[j])
      );
    } else {
      return ans >> __builtin_popcountll(mask);
    }
  };
  u64 ans = search(search, 1ULL << (n - 1), 0, m, 0);
  io::print(ans);
  io::flush();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;

int main(){
  int n,max_w;
  cin >>n>>max_w;
  vector<int> w(n+1);
  vector<int> v(n+1);
  int max_v = 0;
  rep1(i,n){
    cin >>w[i]>>v[i];
    max_v += v[i];
  }
  const int INF = pow(10,9)+7;
  vector<vector<ll>> dp(n+1, vector<ll>(max_v+1,INF));
  rep1(i,n){
    rep1(j,max_v){
      ll tmp;
      if(j <= v[i]) tmp = w[i];
      if(j > v[i]) tmp = dp[i-1][j-v[i]]+w[i];
      dp[i][j] = min(tmp, dp[i-1][j]);
    }
  }
  rep1(i,max_v){
    if(dp[n][i] > max_w){
      cout << i-1 << endl;
      break;
    }
    if(i == max_v) cout << i << endl;
  }
}

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

int abs( int a ) { return a < 0 ? -a : a; }

int main() {
	int n, m;
	cin >> n >> m;
	vector<uint64_t> a( n );
	typedef pair<uint64_t, uint64_t> pair_t; 
	vector<pair_t> x( m );
	for ( int i = 0; i < n; i++ ) cin >> a[i];
	uint64_t c = 0;
	for ( int i = 0; i < m; i++ ) {
		cin >> x[i].first >> x[i].second;
		c += x[i].first;
	}
	sort( a.begin(), a.end(), []( uint64_t a, uint64_t b ) { return a > b; } );
	sort( x.begin(), x.end(), []( pair_t a, pair_t b ) { return a.second > b.second; } );
	int p = 0, q = 0;
	uint64_t s = 0;
	for ( int i = 0; i < n; i++ ) {
		if ( m <= q || x[q].second <= a[p] ) {
			s += a[p++];
		}
		else {
			s += x[q].second;
			if ( !--x[q].first ) q++;
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 2560
x, k, d = map(int, input().split())
x = abs(x)
if x - k * d >= 0:
    print(x - k * d)
    exit()
n = (x - x % d) // d  # x>0で一番近づくところまでに費やす移動回数
k -= n
if k % 2 == 0:
    print(x % d)
else:
    print(d - x % d)


Measured memory_bytes: 9072
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
 
int main()
{
	string S;
	cin >> S;
	if (S == "Sunny") {
		cout << "Cloudy";
	}
	else if (S == "Cloudy") {
		cout << "Rainy";
	} else {
		cout << "Sunny";
	}
 
	return 0;
}



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

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int K = NextInt();
        int X = NextInt();
        for (int i = X - K + 1; i < X + K; i++) Console.Write(i+" ");
        Console.WriteLine() ;
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }

    public static long RepPow(long x, long p, long m = 1000000007)
    {
        if (p == 0) return 1;
        if (p == 1) return x % m;
        long b = RepPow(x, p / 2, m) % m;
        if (p % 2 == 0) { return (b * b) % m; }
        else { return (x * ((b * b) % m)) % m; }
    }
}
public class MinTree
{
    private List<int> table = new List<int>();
    private static int size = 1;
    private static int high = 1;
    public MinTree(int n, int k = 0)
    {
        while (size < n) size *= 2;
        high = (int)Math.Log(size, 2);
        for (int i = 0; i < 2 * size - 1; i++) table.Add(k);
    }
    public void Add(int x, int v)
    {
        x += size - 1;
        table[x] += v;
        table[x] = Math.Max(0, table[x]);
        while (x != 0)
        {
            x = (x % 2 == 0 ? x / 2 - 1 : x / 2);
            table[x] = table[x * 2 + 1] + table[x * 2 + 2];
        }
    }
    public int MLS(int k)
    {
        if (table.First() == 0) return -1;
        int index = 0;
        for (int y = 0; y < high; y++)
        {
            int left = index * 2 + 1;
            int right = index * 2 + 2;
            if (table[left] >= k) index = left;
            else { k -= table[left]; index = right; }
        }
        return index - size + 1;
    }
}
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


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

const int64_t MOD = 1e9 + 7;
struct mint
{
    int64_t x;
    mint(int64_t x = 0) : x((x % MOD + MOD) % MOD) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += MOD - a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(int64_t n) const
    {
        if (n == 0)
            return 1;
        mint t = pow(n >> 1);
        t *= t;
        if (n & 1)
            t *= *this;
        return t;
    }
    mint inv() const { return pow(MOD - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};

void solve(string S)
{
    reverse(S.begin(), S.end());
    vector<vector<mint>> dp(S.size() + 1, vector<mint>(13));
    dp.at(0).at(0) = 1;
    vector<int> r(10);
    for (int i = 0; i < 10; i++)
    {
        r.at(i) = i;
    }

    for (int i = 0; i < S.size(); i++)
    {
        if (S.at(i) != '?')
        {
            int c = S.at(i) - '0';
            for (int j = 0; j < 13; j++)
            {
                int j_next = (j + r.at(c)) % 13;
                dp.at(i + 1).at(j_next) += dp.at(i).at(j);
            }
        }
        else
        {
            for (int c = 0; c < 10; c++)
            {
                for (int j = 0; j < 13; j++)
                {
                    int j_next = (j + r.at(c)) % 13;
                    dp.at(i + 1).at(j_next) += dp.at(i).at(j);
                }
            }
        }
        for (int i = 0; i < 10; i++)
        {
            r.at(i) = 10 * r.at(i) % 13;
        }
    }
    cout << dp.at(S.size()).at(5).x << endl;
}

int main()
{
    string S;
    cin >> S;
    solve(move(S));
    return 0;
}


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

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

const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    int d;
    cin >> d;
    if(d == 25) cout << "Christmas" << endl;
    else if(d == 24) cout << "Christmas Eve" << endl;
    else if(d == 23) cout << "Christmas Eve Eve" << endl;
    else if(d == 22) cout << "Christmas Eve Eve Eve" << endl;
    
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
 
/*
// ordered_set 
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
# define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
 
using namespace std;
 
typedef long long                                        ll;
typedef long double                                      ld;
typedef pair <int, int>                                  pii;
typedef pair <pii, int>                                  ppi;
typedef pair <int, pii>                                  pip;
typedef pair <pii, pii>                                  ppp;
typedef pair <ll, ll>                                    pll;
 
# define A                                               first
# define B                                               second
# define endl                                            '\n'
# define sep                                             ' '
# define all(x)                                          x.begin(), x.end()
# define kill(x)                                         return cout << x << endl, 0
# define SZ(x)                                           int(x.size())
# define Sort(x)                                         sort(all(x))
# define InTheNameOfGod                                  ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
 
ll power(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));}
 
const int xn = 5e3 + 10;
const int xm = - 20 + 10;
const int SQ = 320;
const int sq = 320 + 10;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const int mod = 1e9 + 7;
const int TM = 3;
const int base = 257;

ll n, p[xn], x, y, part[xn][xn], dp[xn][xn], a[xn][xn], b[xn];

int main(){
    InTheNameOfGod;
    
	cin >> n >> x >> y;
	for (int i = 1; i <= n; ++ i){
		cin >> p[i];
		b[p[i]] = i;
	}
	for (int i = 1; i <= n; ++ i) for (int j = 1; j <= n; ++ j) part[i][j] = part[i][j - 1] + (p[j] < i);
	for (int i = 1; i <= n; ++ i){
		for (int j = 1; j < i; ++ j) a[i][j] = a[i - 1][j];
		for (int j = i; j >= 1; -- j){
			if (a[i][j - 1] > p[i]) a[i][j] = a[i][j - 1];
			else{
				a[i][j] = p[i];
				break;
			}
		}
	}
	for (int i = 1; i <= n; ++ i){
		for (int j = 1; j <= i; ++ j){
			dp[i][j] = dp[i][j - 1] + x;
			int ind = b[a[i][j]];
			int ted = part[a[i][j]][i] - part[a[i][j]][ind];
			dp[i][j] = min(dp[i][j], dp[ind - 1][j - ted - 1] + ted * y);
		}
	}
	cout << dp[n][n] << endl;

    return 0;
}


Measured memory_bytes: 432752
#import bisect,collections,copy,heapq,itertools,math,numpy,string
#from operator import itemgetter
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
X = I()
print(X//500*1000+(X%500)//5*5)

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

struct edge{int to, cost;};

vector<edge> G[100000];
int color[100000];



void dfs(int v, int c) {
  color[v] = c;
  for (int i = 0; i < G[v].size(); i++) {
    if (color[G[v][i].to] == 0 && 
        G[v][i].cost % 2 == 1) {
      dfs(G[v][i].to, -c);
    }
    if (color[G[v][i].to] == 0 && 
        G[v][i].cost % 2 == 0) {
      dfs(G[v][i].to, c);
    }
    if (color[G[v][i].to] != 0) {
      continue;
    }
  }
}
  

int main() {
  memset(color, 0, 100000);
  int N;
  cin >> N;
  for (int i = 0; i < N-1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    
    G[u].push_back({v, w});
    G[v].push_back({u, w});
  }
  
  dfs(0,1);
  
  for (int i = 0; i < N; i++) {
    cout << (color[i]+1)/2 << endl;
  }

  
}

Measured memory_bytes: 9088
W,H,N = [int(x) for x in input().split()]
xya = [[int(x) for x in input().split()]for _ in range(N)]
rectangle = [[1 for _ in range(W)]for _ in range(H)]
cnt = 0
for i in xya:
    if(i[2]==1):
        for y,li in enumerate(rectangle):
            for x in range(i[0]):
                rectangle[y][x] = 0
    elif(i[2]==2):
        for y,li in enumerate(rectangle):
            for x in range(i[0],W):
                rectangle[y][x] = 0
    elif(i[2]==3):
        for y in range(i[1]):
            rectangle[y] = [0]*W
    else:
        for y in range(i[1],H):
            rectangle[y] = [0]*W
for i in rectangle:
    cnt += sum(i)
print(cnt)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main (void) {
    string w;

    cin >> w;

    int cnt[26] = {0};
    for (int i = 0; i < w.length(); i++) {
        cnt[w[i] - 'a']++;
    }

    bool beautiful = true;
    for (int i = 0; i < 26; i++) {
        if (cnt[i] % 2 != 0) beautiful = false;
    }

    if (beautiful) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
sp = []

for i in range(n):
    spi = list(map(str, input().split()))
    spi[1] = int(spi[1])
    spi.append(i+1)
    sp.append(spi)

sp.sort()
shop = sp[0][0]
sameshop = [sp[0][2]]
ten = []

for i in range(1,n):
    if sp[i][0] == shop:
        sameshop.append(sp[i][2])
    else:
        ten = ten+sameshop[::-1]
        sameshop = []
        sameshop.append(sp[i][2])
        shop = sp[i][0]

ten = ten+sameshop[::-1]

for i in ten:
    print(i)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int N=2e5+5;
int a[N]; 
int n,m;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int g(int n)
{
	if (n <= 2)	return n;
	for (int i = n - 1; i >= 2; i--) {
		n *= i;
	}
	return n;
}
int min(int n, vector<int> a)
{
	int t = a[n];
	vector<int> b(a.size() - n);
	for (int i = n; i < a.size(); i++) {
		b[i - n] = a[i];
	}
	sort(b.begin(), b.end());
	for (int i = 0; i < b.size(); i++) {
		if (t == b[i])	return i;
	}
}
int main()
{
  int n, pc, qc, z;
	cin >> n;
	vector<int> p(n);
	vector<int> q(n);
	for (int i = 0; i < n; i++)	cin >> p[i];
	for (int i = 0; i < n; i++)	cin >> q[i];
	pc = qc = 1;
	for (int i = 0; i < n - 1; i++) {
		z = n - i;
		pc += min(i, p)*g(z) / z;
		qc += min(i, q)*g(z) / z;
	}
	cout << abs(pc - qc) << endl;
 	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
string s1;
string s2;
long long st(int i,char prev)
{
	if(i==s1.size())
	{
		return 1;
	}
    int n=s1.size();
	if(i<n && s1[i]==s1[i+1])
	{
		if(prev=='Y')
		{
			return (3*st(i+2,'Y'))%mod;
		}
		else if(prev=='X')
		{
			return (2*st(i+2,'Y'))%mod;
		}
	}
	else
	{
		if(prev=='Y')
		{
			return (1*st(i+1,'X'))%mod;
		}
		else if(prev=='X')
		{
			return (2*st(i+1,'X'))%mod;
		}
	}
}
main()
{  long long n;
	cin>>n;
	cin>>s1;
	cin>>s2;

	if(n>=2 && s1[0]==s1[1])
	{
		cout<<(6*st(2,'Y'))%mod;
	}
	else
	{
		cout<<(3*st(1,'X'))%mod;
	}
}

Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))

ans1 = max(a)
sa = sorted(a)

if n == 2:
    ans1 = a[0]
    ans2 = a[1]
else:
    idx = n // 2
    flag = True
    if sa[idx] == ans1 // 2:
        ans2 = ans1 // 2
    elif sa[idx] < ans1 // 2:
        while True:
            idx += 1
            if ans1 // 2 <= sa[idx]:
                if abs(sa[idx] - ans1 / 2) < abs(sa[idx - 1] - ans1 / 2):
                    ans2 = sa[idx]
                else:
                    ans2 = sa[idx - 1]
                break
    else:
        while True:
            idx -= 1
            if sa[idx] <= ans1 // 2:
                if abs(sa[idx] - ans1 / 2) < abs(sa[idx + 1] - ans1 / 2):
                    ans2 = sa[idx]
                else:
                    ans2 = sa[idx + 1]
                break

print(ans1, ans2)


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

int main() 
{
    string ac="AC", tle="TLE", wa="WA", re="RE",s;
    int acc=0, tlec=0, wac=0,rec=0;
    int n;
    cin>>n;
    while(n--)
    {
        cin>>s;
        if(s==ac) acc++;
        else if (s==tle) tlec++;
        else if (s==wa) wac++;
        else rec++;
    }
    cout<<"AC x "<<acc<<endl;
    cout<<"WA x "<<wac<<endl;
    cout<<"TLE x "<<tlec<<endl;
    cout<<"RE x "<<rec<<endl;
    return 0;
}

Measured memory_bytes: 3612
from itertools import combinations
import numpy as np
import math
X = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

divisors = make_divisors(X)

for d in divisors:
    f = lambda x: (x + d) ** 5 - x ** 5
    if f(d / -2) <= X and f(10 ** 3) > X:
        ok = d / -2
        ng = 10 ** 3
        for _ in range(100):
            c = (ok + ng) / 2
            if f(c) <= X:
                ok = c
            else:
                ng = c
        if math.isclose(ok, round(ok)):
            print(round(ok) + d, round(ok))
            exit()
    if f(d / -2) <= X and f(-10 ** 3) > X:
        ok = d / -2
        ng = -10 ** 3
        for _ in range(100):
            c = (ok + ng) / 2
            if f(c) <= X:
                ok = c
            else:
                ng = c
        if math.isclose(ok, round(ok)):
            print(round(ok) + d, round(ok))
            exit()

Measured memory_bytes: 27232
#include <iostream>
#include <vector>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    ll c = 0;
    c = n / (a + b);
    ll ans = 0;
    ans += c * a;
    ll d = 0;
    d = n % (a + b);
    if(d > a){
        cout << ans + a << endl;
    }
    else {
        cout << ans + d << endl;
    }
    return 0;
}


Measured memory_bytes: 888
a,b,c,d = [int(i) for i in input().split()]
ct = 0
while True:
    if ct%2:
        a -= d
    else:
        c -= b
    if a <= 0 or c <= 0:
        break
    ct += 1
    
    
print('Yes' if a > 0 else 'No')





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


int main(){
  int h,w,k;
  cin >>h >> w>>k;
  char a[h][w];
  int ans=0;
  rep(i,h){
    rep(r,w)cin >> a[i][r];
  }
  for (int tmp = 0; tmp < (1 << h); tmp++) {
    bitset<7> s(tmp);//これで0101010といった数列を2^n個生成してくれる
    for (int tmp = 0; tmp < (1 << w); tmp++) {
      bitset<7> s2(tmp);//これで0101010といった数列を2^n個生成してくれる
      int e[h][w]={};
      rep(i,h){
        if(s[i])rep(d,w)e[i][d]=1;
      }
      rep(i,w){
        if(s2[i])rep(d,h)e[d][i]=1;
      }

      int gg=0;
      rep(i,h){
        rep(r,w)if(e[i][r]==0 && a[i][r]=='#')gg++;
      }
      if(gg==k)ans++;
    }
  }
  cout << ans << endl;
}

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

void combmod(vector<vector<ll> > &v) {
  for(int i=0; i<v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(int i=2; i<v.size(); i++){
    for(int j=1; j<i; j++){
      v[i][j] = (v[i-1][j-1]+v[i-1][j])%mod;
    }
  }
}

int main() {
  ll s;
  cin >> s;
  
  vector<vector<ll> > v(2001,vector<ll>(2001,0));
  combmod(v);
  
  
  
  ll nmax = s/3;
  ll result=0;
  for (int i=1; i<=nmax; i++) {
    result += v[s-2*i-1][i-1];
    result %= mod;
  }
  
  cout << result << endl;
}


Measured memory_bytes: 34620
n= int(input())
a = input().split()
cost = [0]*n
c1 = 0
c2 =0
for i in range(n):
    a[i] = int(a[i])
i = 0
for i in range(1,n):
    if(i==1):
        cost[i] = abs(a[i] - a[i-1])
    else:
        c1 = abs(a[i] - a[i-1]) + cost[i-1]
        c2 = abs(a[i] - a[i-2]) + cost[i-2]
        cost[i] = min(c1,c2)

print(cost[n-1])

Measured memory_bytes: 11608
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >>h2 >> m2 >> k;

	int ans = (h2 * 60 + m2) - (h1 * 60 + m1) - k;
	if (ans < 0) {
		ans = 0;
	}

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


Measured memory_bytes: 3192
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {
	
	static Queue<State> queue=new LinkedList<>();
	static Set<String> set=new HashSet<>();
	
	static class State{
		String str1;
		int minstep;
		State(String str1, int minstep){
			this.str1=str1;
			this.minstep=minstep;
		}
	}
	
	static char change(char a, char b) {
		if(a=='b'||b=='b') {
			if(a=='r'||b=='r') {
				return 'g';
			}
			else if(a=='g'||b=='g') {
				return 'r';
			}
		}
		return 'b';
	}
	
	static String bfs() {
		while(! queue.isEmpty()) {
			State state=queue.remove();
			String s=state.str1;
			int step=state.minstep;
			set.add(s);
			String s1="", s2="";
			int count=0;
			for(int i=0; i<s.length()-1; i++) {
				if(s.charAt(i)!=s.charAt(i+1)) {
					s1=s.substring(0, i);
					s2=s.substring(i+2, s.length());
					char c=change(s.charAt(i), s.charAt(i+1));
					String sa=s1+String.valueOf(c)+String.valueOf(c)+s2;
					if(! set.contains(sa)) {
						set.add(sa);
						queue.add(new State(sa, step+1));
					}
				}
				else if(s.charAt(0)==s.charAt(i+1)) {
					count++;
				}
			}
			if(count==s.length()-1) {
				queue.clear();
				set.clear();
				return String.valueOf(step);
			}
		}
		set.clear();
		return "NA";		
		
	}
	public static void main(String args[]){
		try(Scanner sc=new Scanner(System.in)){
			while(sc.hasNext()) {
				String str=sc.next();
				if(str.equals("0")) {
					break;
				}
				queue.add(new State(str, 0));
				set.add(str);
				System.out.println(bfs());
			}
			
		}
	}
}


Measured memory_bytes: 96412
package main

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

func main() {
	sc.Split(bufio.ScanWords)

	x, y, z := nextInt(), nextInt(), nextInt()
	n := x / (y + z)
	if x%(y+z) < z {
		n = n - 1
	}
	fmt.Println(n)
}

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	if i, err := strconv.Atoi(sc.Text()); err != nil {
		panic(err)
	} else {
		return i
	}
}

func atoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(err)
	} else {
		return i
	}
}

func split(s, seq string) []string {
	return strings.Split(s, seq)
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cfloat>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

llong C[55][55];
void comb_table(int N){
    for(int i=0;i<=N;++i){
        for(int j=0;j<=i;++j){
            if(j==0 || j==i){
                C[i][j]=1LL;
            }else{
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}

llong n, a, b;
llong v[55];
llong sum[55];

int main() {
    comb_table(50);
    
    cin >> n >> a >> b;
    for (llong i = 1; i <= n; i++) {
        cin >> v[i];
    }
    sort(v + 1, v + n + 1, greater<>());

    for (llong i = 1; i <= n; i++) {
        sum[i] = sum[i - 1] + v[i];
    }

    __float128 maxv = 0;
    for (llong i = a; i <= b; i++) {
        __float128 avg = (sum[i]) / ((__float128)i);
        maxv = max(avg, maxv);
    }
    
    llong ans = 0;
    for (llong i = a; i <= b; i++) {
        __float128 avg = (__float128)sum[i] / (__float128)i;

        if (maxv == avg) {
            llong t = v[i];
            llong N = 0;
            llong K = 0;
            
            for (llong j = 1; j <= n; j++) {
                if (v[j] == t) N++;
            }
            for (llong j = i; j > 0; j--) {
                if (v[j] == t) K++;
            }

            ans += C[N][K];
        }
    }

    printf("%.*lf\n", DBL_DIG, (double)maxv);
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 384
main :: IO ()
main = do
  [n,l] <- map read . words <$> getLine :: IO [Int]
  let wa = n * l + (n * (n+1)) `div` 2 - n
      sa = map ((wa - ) . (wa - ) . aji l) [1..n]
  print $ snd . minimum . map (\(x,y) -> (abs x,wa - y)) $ zip sa sa
  

aji :: Int -> Int -> Int
aji l' i = l' + i - 1


Measured memory_bytes: 508
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<map>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];
map<int,int>maps;
map<int,int>::iterator it;
int n,m;
int ac = 0,wa = 0;
int main(void) {
    void solve();
    cin >> n >> m;
    ac = wa = 0;
    solve();
    return 0;
}
void solve() {
    if(m == 0) {
        cout << 0 << " " << 0 << endl;
        return ;
    }
    int num;
    string vis;
    for(int i = 1; i <= m; i ++) {
        cin >> num >> vis;
        if(maps[num] == -1) continue;
        if(vis == "AC") {
            wa += maps[num];
            ac += 1;
            maps[num] = -1;
            continue;
        }
        maps[num] ++;
    }
    maps.clear();
    cout << ac << " " << wa << endl;
    return ;
}

Measured memory_bytes: 4992
A,B,C = map(int,input().split())
K = int(input())
if B<=A:
    while B<=A:
        B *= 2
        K -= 1
if C<=B:
    while C<=B:
        C *= 2
        K -= 1
if K>=0:
    print("Yes")
else :
    print("No")
    


Measured memory_bytes: 9176
#include <stdio.h>
 
int main(){
  int h,w;
 
  while(1){
    scanf("%d %d",&h,&w);
    if(h == 0 && w == 0)
      return 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        putchar('#');
      }
      putchar('\n');
    }
    putchar('\n');
  }
  return 0;
}


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

int main() {
    stack<char> Sa,Sb,Sc;
    string S1; cin>>S1;
    for(int i=S1.size()-1;i>=0;i--){
        Sa.push(S1[i]);
    }
    string S2; cin>>S2;
    for(int i=S2.size()-1;i>=0;i--){
        Sb.push(S2[i]);
    }
    string S3; cin>>S3;
    for(int i=S3.size()-1;i>=0;i--){
        Sc.push(S3[i]);
    }
    char now=Sa.top(); Sa.pop();
    while(true){
        if(now=='a'){
            if(Sa.empty()){
                cout<<'A';
                return 0;
            }
            now=Sa.top(); Sa.pop();
        }
        else if(now=='b'){
            if(Sb.empty()){
                cout<<'B';
                return 0;
            }
            now=Sb.top(); Sb.pop();
        }
        else{
            if(Sc.empty()){
                cout<<'C';
                return 0;
            }
            now=Sc.top(); Sc.pop();
        }
    }

    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//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())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const double INF = 1e9;



int main(){
	long double a,b;
	while(cin>>a>>b){
		long double l=-1.0,r=10001.0;
		REP(i,1000){
			long double md=(l+r)/2.0;
			if(md*3.305785>a*b){
				r=md;
			}else{
				l=md;
			}
		}
		cout<<fixed<<setprecision(8)<<r<<endl;
	}
	return 0;
}

Measured memory_bytes: 1284
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const ll inf=1e17;
int main(){
	int n;
	cin>>n;
	vp in(n);
	rep(i,n){
		int a;
		cin>>a;
		in[i]=pii(a,i+1);
	}
	sort(all(in));
	vi out;
	bool h=true;
	rep(i,n)rep(j,in[i].second-1)out.pb(in[i].second);
	rep(i,n)rep(j,n-in[i].second)out.pb(in[i].second);
	rep(i,n){
		if(out.size()<in[i].first-1){
			cout<<"No"<<endl;
			return 0;
		}
		out.insert(out.begin()+in[i].first-1,in[i].second);
	}
//	rep(i,out.size())cout<<" "<<out[i];cout<<endl;
	vi co(n);
	rep(i,out.size()){
		co[out[i]-1]++;
		rep(j,n)if(in[j].first==i+1){
			if(in[j].second!=co[in[j].second-1])h=false;
		}
	}
	if(h){
		cout<<"Yes"<<endl;
		rep(i,out.size())cout<<(i?" ":"")<<out[i];cout<<endl;
	}else cout<<"No"<<endl;
	
}










Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a>b){
    for(int i=1;i<=a;i++)
      cout<<b;
  }
  else if(a<=b){
    for(int i=1;i<=b;i++)
      cout<<a;
  }
  
}


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

int main() {
  int N,A,B;
  cin >> N;
  int sum = 0;
  for(int i = 0; i < N; i++){
    cin >> A >> B;
    sum += B - A + 1;
  }
	cout << sum << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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

	string S;
	int K;
	cin >> S >> K;
	int i = 0;
	while (K>0) {
		int a=26-(S[i]-'a');
		//cout << a <<" "<<K<< endl;

		if (i == S.size()-1 ) {
			K %= 26;
			while (K>0) {
				if (S[i] == 'z') {
					S[i] = 'a';
					K--;
				}
				else {
					S[i]++;
					K--;
				}				
			}
			break;
			
		}
		else if (S[i] == 'a') {
			i++;
			continue;
		}
		else if (K - a < 0) {
			i++;			
		}
		else {
			S[i] = 'a';
			K -= a;
			i++;
		}
	
	}
	cout << S << endl;
	return 0;
}



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

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var infoList = new List<Info>(N);
        for (int i = 0; i < N; i++)
        {
            var inputs = Console.ReadLine().Split(' ');
            var S = inputs[0];
            var P = int.Parse(inputs[1]);
            var inf = new Info(i + 1, S, P);
            infoList.Add(inf);
        }

        infoList = infoList.OrderBy(inf => inf.S).ThenByDescending(inf => inf.P).ToList();
        foreach (var inf in infoList)
        {
            Console.WriteLine(inf.shopNo);
        }

    }

    struct Info
    {
        internal int shopNo;
        internal string S;
        internal int P;
        internal Info(int shopNo, string S, int P)
        {
            this.shopNo = shopNo;
            this.S = S;
            this.P = P;
        }
    }
}



Measured memory_bytes: 13652
def dist(a, b):
  return ( (a[0]-b[0])**2 + (a[1]-b[1])**2 )**0.5

N = int(input())
xy = []

for _ in range(N):
  x, y = map(int, input().split())
  xy.append([x,y])

di2 = 0.0
for i in range(N):
  for j in range(N):
    if i >= j:
      continue
    else:
      di2 += dist(xy[i], xy[j])

print(2.0*di2/N)

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
using namespace std;

//ユークリッドの互除法
ll gcd(ll a,ll b)
{
  if(a<b) swap(a,b);
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}


int main(){
  ll N; cin>>N;
  vector <ll> A;A.resize(N);
  for(int i=0;i<N;i++) cin>>A[i];
  vector <ll> g1; g1.resize(N,0);
  vector <ll> g2; g2.resize(N,0);// first0
  vector <ll> g3;g3.resize(N,0);// first1
//  vector <ll> gl;gl.resize(N,0);


g1[1] = gcd(A[0],A[1]);

g2[1] = A[0] ;
g3[1] = A[1];


//cout<<1<<endl;
//cout<<g1[1]<<"   "<<gl[1]<<endl;

  for(int i=2;i<N;i++){
    
    g1[i] = gcd(g1[i-1],A[i]);// OK
    g2[i] = gcd(g2[i-1],A[i]);
    g3[i] = gcd(g3[i-1],A[i]);
    g2[i] = max(g1[i-1],g2[i]);
    g3[i] = max(g1[i-1],g3[i]);


    //cout<<i<<endl;

  // cout<<g1[i]<<"   "<<gl[i]<<endl;
  
  } 
ll ans = 0;
  //cout<<max(g1[N-1],g2[N-1])<<endl;
  ans = max(g2[N-1],g3[N-1]);
  ans = max(ans , g1[N-1]);
  cout<<ans<<endl;

 return 0;
}

Measured memory_bytes: 3328