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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
int n = 4;
vector<vector<int>> p(4);
bool used[4] = {0};

int dfs(int i) {
  if (used[i])
    return 0;
  used[i] = true;
  int ret = 0;
  for (auto &j : p[i])
    ret = max(ret, dfs(j));
  return ret + 1;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  for (int i = 0; i < 3; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    p[a].push_back(b);
    p[b].push_back(a);
  }
  for (int i = 0; i < n; i++) {
    if (p[i].size() == 1) {
      if (dfs(i) == 4) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

int main(int argc, char const* argv[])
{
    char S[(int)2e5 + 1], T[(int)2e5 + 1];
    char c['z' - 'a' + 1] = { 0 }, r['z' - 'a' + 1] = { 0 };
    size_t len;

    gets(S);
    gets(T);

    len = strlen(S);

    for (size_t i = 0; i < len; i++) {
        if (c[S[i] - 'a'] != 0 || r[T[i] - 'a'] != 0) {
            if ((c[S[i] - 'a']) != T[i]) {
                puts("No");
                return 0;
            }
            if ((r[T[i] - 'a']) != S[i]) {
                puts("No");
                return 0;
            }
        } else {
            c[S[i] - 'a'] = T[i];
            r[T[i] - 'a'] = S[i];
        }
    }

    puts("Yes");
    return 0;
}


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

int main() {
    int n,x;
    
    while(true){
        int count = 0;
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                for(int k=j+1;k<=n;k++){
                    if(i+j+k==x){
                        count++;
                    }
                }
            }
        }
        cout << count << endl;
    }
    

}


Measured memory_bytes: 3080
#include <iostream>
#include<algorithm>

using namespace std;

int main()
{
  int fruits_n,select_n;
  cin >> fruits_n >> select_n;
  int fruit[fruits_n];
  for(int i=0; i<fruits_n; i++)
    cin >> fruit[i];

  sort(fruit,fruit+fruits_n);

  int min=0;
  for(int i=0; i<select_n; i++){
    min += fruit[i];
 //   cout << fruit[i] << endl;
  }
  cout << min << endl; 
}

Measured memory_bytes: 3616
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//直方体を塗り分け
//負とzeroを数える

int main(){
    vector <ll> v(3);
    REP(i,3)
    {
        cin >> v[i];
    }
    ll res;
    if(v[0] % 2 == 0 || v[1] % 2 == 0 || v[2] % 2 == 0)
    {
        res = 0;
    }
    else
    {
        sort(v.begin(),v.end(),greater<ll>());
        res = v[1] * v[2];
    }
    cout << res << endl;

    return 0;    
}



Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
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; }



#define rep(n) for(int i=0;i<n;i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
const int MOD = 1000000007;
const int INF = 1 << 29;


int main() {
	
	int n,a, b;
	char s[100001];
	cin >> n >> s;
	int cnt=0;
	rep(n) {
		if (s[i] != s[i + 1]) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 384
using System;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            String str = Console.ReadLine();
            bool bGood = true;

            if (str[0] == str[1]) {bGood = false;}
            if (str[1] == str[2]) {bGood = false;}
            if (str[2] == str[3]) {bGood = false;}

            if (bGood)
            {
                Console.WriteLine("Good");
            }
            else
            {
                Console.WriteLine("Bad");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vector<pair<int,int>> v;
	for (int i=0; i<n; ++i){
		int a,b;
		cin >> a >> b;
		v.emplace_back(b,a);
	}
	sort(v.begin(),v.end());
	int t=0;
	for (auto& i:v){
		t += i.second;
		if (t > i.first){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 6512
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"25
" => r"Christmas",

r"22
" => r"Christmas Eve Eve Eve"
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        x: i32
    }

    let ans = match x {
        7 | 5 | 3 => "YES",
        _ => "NO",
    };

    ans.to_string()
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(void){
  int h = 0,w = 0,i = 0,j = 0;
    scanf("%d %d",&h,&w);
    while(h != 0 && w != 0){
      //   scanf("%d %d",&h,&w);
    /*
    if( h == 0 && w == 0){
      puts("");
      break;
    }else {
    */
      for( i = 1;i <= h;i++){
        for( j = 1;j <= w; j++){
          printf("#");
        }
        puts("");
      }
      puts("");
      scanf("%d %d",&h,&w);
  }
  return 0;
}

Measured memory_bytes: 588
import java.util.*

fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(' ').map(String::toInt)
    val n = readLine()!!.toInt()
    val aQueue = ArrayDeque<Int>(readLine()!!.split(' ').map(String::toInt))

    val map = Array(h) { IntArray(w) { 0 } }
    var curNum = 1
    var count = aQueue.pollFirst()!!
    var reverse = false
    for (r in 0 until h) {
        for (tc in 0 until w) {
            if (reverse) {
                map[r][w - tc - 1] = curNum
            } else {
                map[r][tc] = curNum
            }
            count--
            if (count == 0) {
                curNum++
                count = aQueue.pollFirst()?:0
            }
        }
        reverse = !reverse
    }
    map.forEach { println(it.joinToString(" ")) }
}

Measured memory_bytes: 39632
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N, M;

int main() {
    cin >> N >> M;

    vvi A(0);
    for (int i = 0; i < N; i++) {
        vi a(2, 1);
        cin >> a[0];
        A.push_back(a);
    }
    for (int i = 0; i < M; i++) {
        vi a(2, 1);
        cin >> a[1] >> a[0];
        A.push_back(a);
    }
    sort(begin(A), end(A), [](vi l, vi r) {
        return l[0] > r[0];
    });

    ll i = 0, ans = 0;
    while (N > 0) {
        while (A[i][1] == 0) i++;
        ans += A[i][0];
        N--;
        A[i][1]--;
    }

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


Measured memory_bytes: 12464
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
typedef long long ll;
//
int main(){
   ll h,w,n;cin>>h>>w>>n;
   vector<pair<ll,ll>> vp,check;
   rep(i,n){
      ll a,b;cin>>a>>b;
      vp.push_back(pair<ll,ll>(a,b));
   }
   rep(i,n){
      ll x=vp[i].F,y=vp[i].S;
       rep(a,3){
            rep(b,3){
               if(x-a>0&&y-b>0&&x-a+2<=h&&y-b+2<=w){
                  check.push_back(pair<ll,ll>(x-a,y-b));
               }
            }
         }
      
   }
   map<pair<ll,ll>,ll> mp;
   for(auto e:check){
      mp[e]++;
   }
   sort(all(check));
   check.erase(unique(all(check)),check.end());
   vector<ll> count;
   FOR(i,1,9){
      ll a=0;
      for(auto e:check){
         if(mp[e]==i){
            a++;
         }
      }
      count.push_back(a);
   }
   ll aa=(h-2)*(w-2);
   rep(i,count.size()){
      aa-=count[i];
   }
   cout<<aa<<endl;
   for(auto e:count)cout<<e<<endl;

}


Measured memory_bytes: 74988
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
std::map<T, int> prime_factorize(T x) {
  std::map<T, int> primes;
  for (T factor = 2; factor * factor <= x; factor++) {
    if (x % factor == 0) {
      T count = 0;
      while (x % factor == 0) {
          count++;
          x /= factor;
      }
      primes[factor] = count;
    }
  }
  if (x != 1) primes[x] = 1;
  return primes;
}

int main() {
  int N; cin >> N;
  int cnt = 0;
  for (int i = 1; i <= N; i += 2) {
    auto m = prime_factorize(i);
    int num = 1;
    for (auto p : m) num *= (p.second + 1);
    if (num == 8) ++cnt;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  char b; cin >> b;
  map<char, char> mp = {{'A', 'T'}, {'C', 'G'}, {'T', 'A'}, {'G', 'C'}};
  cout << mp[b] << "\n";
  return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	static int cnt = 0;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[]A = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = scan.nextInt();
		}
		scan.close();
		selectionSort(A, N);
		disp(A, N);
		System.out.println(cnt);
	}
	static void selectionSort(int[]A, int n) {
		for(int i = 0; i < n - 1; i++) {
			int min_j = i;
			for(int j = i; j < n; j++) {
				if(A[j] < A[min_j]) {
					min_j = j;
				}
			}
			int t = A[i];
			A[i] = A[min_j];
			A[min_j] = t;
			if(i != min_j) {
				cnt++;
			}
		}
	}
	static void disp(int[]A, int n) {
		for(int i = 0; i < n; i++) {
			if(i == n - 1) {
				System.out.println(A[i]);
			}else {
				System.out.print(A[i] + " ");
			}
		}
	}
}


Measured memory_bytes: 26332
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a;
  int sum = 0;
  cin >> N;
  a = N;
  while (a > 0) {
    sum += a % 10;
    a /= 10;
  }
  
  if (N % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1000000001;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, m) cin >> a[i];

  int ans = 0;
  rep(i, m){
    ans += a[i];
  }

  if(n < ans){
    cout << -1 << endl;
  }
  else{
    cout << n - ans << endl;
  }

  return 0;
}


Measured memory_bytes: 7220
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  int N,M; cin >> N >> M;
  cout << N*(N-1)/2+M*(M-1)/2 << endl;
  return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;


int main(){
	ll N, x, ans=0;

	cin >> N >> x;
	ll mx = N * 2 - 1;
	if( 1 < x && x < mx ){
		cout << "Yes" << endl;
		for(ll i=0; i < mx; i++) cout << ((mx+i-N+x)%mx+1) << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    //全体の和と、a[i]の入力
    ll all_sum = 0;
    rep(i, n){
        cin >> a[i];
        all_sum += a[i];
    }
    vector<ll> sum(n+1);
    //累積和
    sum[0] = 0;
    for(int i = 1; i <= n; i++){
        sum[i] = sum[i-1] + a[i-1];
    }
    ll mn = pow(10, 10);
    for(int i = 1; i <= n-1; i++){
        ll x = sum[i];
        ll y = all_sum - sum[i];
        if(mn > fabs(x - y)) mn = fabs(x - y);
    }
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 6400
def main():
  N, M = map(int,input().split())
  fromOne = set()
  toM = set()
  for i in range(M):
    a, b = map(int,input().split())
    if a == 1:
      fromOne.add(b)
    elif b == N:
      toM.add(a)
  return 'POSSIBLE' if fromOne & toM else 'IMPOSSIBLE'
print(main())

Measured memory_bytes: 23964
use proconio::input;
use std::cmp::*;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};

const MAX_T: i32 = 200000 * 10 + 1;
#[allow(dead_code)]

type Iic = (i32,i32,char);

fn test180(vu: &Vec<Iic>, vd: &Vec<Iic>, flip_xy: bool) -> i32 {
    let mut v: Vec<Iic> = Vec::new();
    for i in vu {
        if flip_xy {
            v.push((i.1, i.0, 'U'));
        } else {
            v.push((i.0, i.1, 'U'));
        }
    }
    for i in vd {
        if flip_xy {
            v.push((i.1, i.0, 'D'));
        } else {
            v.push((i.0, i.1, 'D'));
        }
    }
    v.sort_by(|a, b| a.0.cmp(&b.0).then(a.1.cmp(&b.1)));
    let mut t = MAX_T;
    for i in 1..v.len() {
        let a = &v[i - 1];
        let b = &v[i];

        if a.0 == b.0 && a.2 == 'U' && b.2 == 'D' {
            t = min(t, (b.1 - a.1) * 5);
        }
    }
    t
}

fn test90(vu: &Vec<Iic>, vr: &Vec<Iic>, flip_x: bool, flip_y: bool) -> i32 {
    let mut v: Vec<Iic> = Vec::new();
    for i in vu {
        v.push((
            if flip_x { -i.0 } else { i.0 },
            if flip_y { -i.1 } else { i.1 },
            'U',
        ));
    }
    for i in vr {
        v.push((
            if flip_x { -i.0 } else { i.0 },
            if flip_y { -i.1 } else { i.1 },
            'R',
        ));
    }
    v.sort_by(|a, b| (a.0 + a.1).cmp(&(b.0 + b.1)).then(a.1.cmp(&b.1)));
    let mut t = MAX_T;
    for i in 1..v.len() {
        let a = &v[i - 1];
        let b = &v[i];

        if a.0 + a.1 == b.0 + b.1 && a.2 == 'U' && b.2 == 'R' {
            t = min(t, (b.1 - a.1) * 10);
        }
    }
    t
}

//#[proconio::fastout]
fn main() {
    input! {
        n:usize,
        v:[(i32,i32,char);n],
    }

    let mut vu: Vec<Iic> = Vec::new();
    let mut vd: Vec<Iic> = Vec::new();
    let mut vr: Vec<Iic> = Vec::new();
    let mut vl: Vec<Iic> = Vec::new();
    for i in 0..v.len() {
        match v[i].2 {
            'U' => vu.push(v[i]),
            'D' => vd.push(v[i]),
            'R' => vr.push(v[i]),
            'L' => vl.push(v[i]),
            _ => panic!(),
        }
    }
    let mut t = MAX_T;

    t = min(t, test180(&vu, &vd, false));
    t = min(t, test180(&vr, &vl, true));

    t = min(t, test90(&vu, &vr, false, false));
    t = min(t, test90(&vu, &vl, true, false));
    t = min(t, test90(&vd, &vr, false, true));
    t = min(t, test90(&vd, &vl, true, true));

    if t == MAX_T {
        println!("SAFE");
    } else {
        println!("{}", t);
    }
}


Measured memory_bytes: 13756
#include <iostream>
#include <queue>
#include <vector>

int main() {
    int n, q;
    std::cin >> n >> q;

    std::vector<std::priority_queue<int>> priority_queues{};
    priority_queues.resize(n);
    for (int i = 0; i < q; ++i) {
        int kind;
        std::cin >> kind;

        int t;
        switch (kind) {
            case 0:
                int x;
                std::cin >> t >> x;
                priority_queues[t].push(x);
                break;
            case 1:
                std::cin >> t;
                if (priority_queues[t].size() != 0)
                    std::cout << priority_queues[t].top() << std::endl;
                break;
            case 2:
                std::cin >> t;
                if (priority_queues[t].size() != 0) priority_queues[t].pop();
                break;
            default:
                std::cerr << "strange kind" << std::endl;
        }
    }
}


Measured memory_bytes: 4000
def answer(t, x, y)
  n = t.size - 1
  n.times.with_index(1) do |i|
    time = t[i + 1] - t[i]
    distance = x[i + 1] - x[i] + y[i + 1] - y[i]
    return 'No' unless distance <=  time && (distance - time).even?
  end
  'Yes'
end

n = gets.to_i
t, x, y = [0], [0], [0]
n.times do |i|
  t[i + 1], x[i + 1], y[i + 1] = gets.split.map(&:to_i)
end

puts answer(t, x, y)

Measured memory_bytes: 4312
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#include <numeric>

#include <map>

using namespace std;

typedef long long LL;

int cnt[323456], a[323456];

LL ans = 0;

int n;

int main() {

    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        cnt[a[i]]++;
    }

    for (int i = 1; i <= n; ++i) 
        ans += LL(cnt[i]-1) * cnt[i] / 2;
    
    for (int i = 1; i <= n; ++i) {

        LL tmp = ans - LL(cnt[a[i]] - 1) * cnt[a[i]] / 2;

        tmp += LL(cnt[a[i]] - 2) * (cnt[a[i]]-1) / 2;

        cout << tmp << endl;

    }


}

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

int main(){
  int n;
  cin>>n;
  int arr[n+2]={0};
  int ret = 0;
  for(int i=1; i<=n; i++) cin>>arr[i];
  for(int i=1; i<=n; i++){
    if(arr[i]==i){
      swap(arr[i],arr[i+1]);
      ret++;
    }
  }
  cout<<ret;
}

Measured memory_bytes: 4028
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int K;
int main(){
  int a, b, i, j;
  long long res=0;
  rd(N);
  rd(K);
  for(b=(K+1);b<(N+1);b++){
    i = N / b;
    j = N % b;
    if(K==0){
      res += (b-K) * i +max_L(0, j-K+1 -1);
    }
    else{
      res += (b-K) * i +max_L(0, j-K+1);
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// int N, K;
// {
//   int i, j, a, b;
//   ll res = 0;
//   rd(N,K);
//   rep(b,K+1,N+1){
//     i = N / b;
//     j = N % b;
//     res += (b-K) * i + max(0, j-K+1 if[K==0, -1]);
//   }
//   wt(res);
// }


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

int main() {
  int x, y;
  cin >> x >> y;
  if (y % 2 == 1){
    cout << "No" << endl;
  }
  else {
  	int min = (y / 4) + (y - 4 * (y / 4)) / 2;
    int max = y /2;
    if (min <= x && x <= max){
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}



Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                int[] temp = Array.ConvertAll(input.Split(','), int.Parse);

                var distTable = temp.Take(10).ToArray();
                int v1 = temp[10];
                int v2 = temp[11];

                double d = distTable.Sum();
                double p = v1 * d / (v1 + v2);

                for (int i = 0; i < 10; i++)
                {
                    p -= distTable[i];

                    if (p <= 0)
                    {
                        sb.AppendLine((i + 1).ToString());
                        break;
                    }
                }
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9388
#include<bits/stdc++.h>
using namespace std;
int main(){
  int K;
  cin >> K;
  vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << vec.at(K-1) << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			int a = scanner.nextInt();
			if ((n | m | a) == 0)
				break;
			int max = 0;
			int[][] map = new int[n+1][1001];
			for (int i = 0; i < m; i++) {
				int h = scanner.nextInt();
				int p = scanner.nextInt();
				int q = scanner.nextInt();
				max = Math.max(max, h);
				map[p][h] = q;
				map[q][h] = p;
			}
			for (int i = max ; i > 0; i--) {
				if (map[a][i] != 0)
					a = map[a][i];
			}
			System.out.println(a);
		}
	}
}

Measured memory_bytes: 67236
julia -En,s=`tr '
' ,`1";A=3n;f(b,n)=n<b?n:f(b,n÷b)+n%b;g(b)=b>1&&f(b,n)==s?min(A,b):A;A=g(n+1);for b=1:isqrt(n);A=g(b);A=g((n-s)÷b+1);end;A>2n?-1:A"

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

double get_distance(double x1, double y1, double x2, double y2)
{
	return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
}

int main()
{
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << fixed << setprecision(12) << get_distance(x1, y1, x2, y2) << endl;
}


Measured memory_bytes: 3292
#include <iostream>
#include <string>

int main() {
  int x;
  std::string out = "Christmas", eve = " Eve";
  
  std::cin >> x;
  for (int i = 25 - x; i > 0; i--) {
    out += eve;
  }
  
  std::cout << out << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s, t;
    int a, b;
    string u;
    cin >> s >> t >> a >> b >> u;
    if (s == u) {
        cout << a - 1 << " " << b << endl;
    } else {
        cout << a << " " << b - 1 << endl;
    }
}


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

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;
	vector<int> h( N );
	for( auto& v: h ) { cin >> v; }

	int l = 0;
	int r = 0;
	int result = 0;

	for( int i = 0; i < h.size(); ) {
		if( h[i] == 0 ) {
			++i;
			continue;
		}

		l = i;

		int hmin = INT_MAX;
		for( int j = i; j < h.size() && h[j] > 0; ++j ) {
			r = j;

			if( h[j] < hmin ) {
				hmin = h[j];
			}
		}

		if( hmin != INT_MAX ) {
			for( int j = l; j <= r; ++j ) {
				h[j] -= hmin;
			}

			result += hmin;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop

N,M = map(int,input().split())
jobs = sorted((tuple(map(int,input().split())) for _ in range(N)), reverse=True)

def it():
    q = []
    for d in range(1,M+1):
        while jobs and jobs[-1][0] <= d:
            a,b = jobs.pop()
            heappush(q, -b)
        if q:
            yield -heappop(q)

print(sum(it()))

Measured memory_bytes: 79064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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


int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  if (A >= B && A >= C)
    cout << (10*A + B + C) << endl;
  else if(B >= A && B >= C)
    cout << (10*B + A + C) << endl;
  else 
    cout << (10*C + A + B) << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*
#ifndef ONLINE_JUDGE
    #define cin f
    #define cout g
    ifstream cin("a.in");
    ofstream cout("a.out");
#endif
*/
int n,x,y,z,dp[4],ddp[4];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        cin>>x>>y>>z;
        ddp[1]=max(dp[2],dp[3])+x;
        ddp[2]=max(dp[1],dp[3])+y;
        ddp[3]=max(dp[2],dp[1])+z;
        for(int j=1;j<=3;++j) dp[j]=ddp[j];
    }
    cout<<max(max(dp[1],dp[2]),dp[3]);
    return 0;
}


Measured memory_bytes: 256
// Problem : B - Greedy Takahashi
// Contest : AtCoder - AtCoder Beginner Contest 149
// URL : https://atcoder.jp/contests/abc149/tasks/abc149_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int a,b,k;
    cin>>a>>b>>k;
    if(a > k) a -= k;
    else b -= k-a, a = 0;
    cout<<a<<' '<<max(b,0LL)<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3616
[n,m] = [int(i) for i in input().split()]
ls = [1]
mod = 10 ** 9 + 7
for i in range(1,10**5+1):
    ls.append((ls[-1]*i) % mod)

if abs(n-m) >= 2:
    print(0)
else:
    ans = (ls[n] * ls[m]) % mod
    if n == m:
        ans *= 2
        ans %= mod
    print(ans)


Measured memory_bytes: 7060
using System;
using System.Collections.Generic;


namespace aizu0510
{
    class Problem
    {

        public static List<string[]> getinputdata()
        {

            List<string[]> list_temp = new List<string[]>();
            string strdata = Console.ReadLine();

            while (strdata != null)
            {

                string[] s_temp = strdata.Split(' ');

                list_temp.Add(s_temp);

                strdata = Console.ReadLine();

            }

            return list_temp;
        }


        public static void Main(string[] args)
        {
            List<string[]> list_result = new List<string[]>();
            list_result = getinputdata();

            int mysum1 = 0;
            int mysum2 = 0;

            for(int i = 0; i < 4; i++)
            {

                mysum1 += int.Parse(list_result[0][i]);
                mysum2 += int.Parse(list_result[1][i]);

            }

            Console.WriteLine(Math.Max(mysum1, mysum2));





        }
    }
}

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

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

  int A[110];
  for(int i = 0; i < n; i++){
    cin >> A[i];
    if(i > 0) cout << " ";
    cout << A[i];
    if(i == n - 1) cout << endl;
  }

  

  for(int i = 1; i < n; i++){
    int v = A[i];
    int j = i - 1;
    while(j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    } 

      A[j + 1] = v;

    for(int j = 0; j < n; j++){
      if(j > 0) cout << " ";
      cout << A[j];
    }
    cout << endl;
  }  
  
 }


Measured memory_bytes: 3088
use std::collections::HashSet;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let k:usize = read();
    let mut ans: HashSet<usize> = HashSet::new();
    for _ in 0..k {
        let a:usize = read();
        for _ in 0..a {
            let i:usize = read();
            ans.insert(i);
        }
    }
    println!("{}", n - ans.len());
}


Measured memory_bytes: 2184
from math import ceil

N, H = map(int, input().split())
sword = [[int(x) for x in input().split()] for _ in range(N)]

max_swing = max(sword, key=lambda x:x[0])[0]

attack = 0
# 投げで攻撃
for i in sorted(sword, key=lambda x: x[1], reverse=True):
  if max_swing < i[1]:
    H -= i[1]
    attack += 1
    if H <= 0:
      break
# 残りを振りで攻撃      
if 0 < H:
  attack += ceil(H / max_swing)
print(attack)  


Measured memory_bytes: 23520
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)

bool isprime(int x){
	for(int i = 2;i*i<=x;i++){
		if(x%i == 0)return false;
	}
	return x!=1;
}
int gcd(int a, int b) 
{ 
    // Everything divides 0  
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    // base case 
    if (a == b) 
        return a; 
   
    // a is greater 
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
} 





void solve(){
	ins(morty);
	ins(morty1);
	set<char> MORTY[310];
	set<char> MORTY1[310];
	FOR(i,0,morty.size()){
		MORTY[morty[i]].insert(morty1[i]);
		MORTY1[morty1[i]].insert(morty[i]);
	}
	FOR(i,0,310){
		if(MORTY[i].size()>1){return out("No");}
		if(MORTY1[i].size()>1){return out("No");}
	}
	return out("Yes");
}

int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}

Measured memory_bytes: 916
#include <stdio.h>
#include <string.h>
#define LEN 1000005

typedef struct qq{
  char name[10];
  int t;
}queue;

queue Q[LEN];
int head, tail, n;

void enqueue(queue x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

queue dequeue(){
  queue x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b) {
  if(a<b) return a;
  else return b;
}

int main(){
  int costtime = 0, c;
  int i, q;
  queue box;

  scanf("%d %d", &n, &q);

  for(i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head = 1; tail = n + 1;

  while(head !=  tail){
    box = dequeue();
    c = min(q, box.t);
    box.t -= c;
    costtime += c;
    if(box.t > 0) enqueue(box);
    else{
      printf("%s %d\n", box.name, costtime);
    }
  }
  
  return 0;
}



Measured memory_bytes: 4756
#include<string.h>

int main(void){

	int i,j;
	int q;
	int x, y;

	char str[1000];
	char str2[10];
	char w[1000];
	char r;

	scanf("%s", str);
	scanf("%d", &q);

	for(i=0; i<q; i++){
		scanf("%s", str2);

		if(strcmp(str2, "replace")==0){
			scanf("%d %d %s", &x, &y, w);
				for(j=x; j<=y; j++){
				str[j]=w[j-x];
			}
		}

	else if(strcmp(str2, "reverse")==0){
		scanf("%d %d",&x, &y);
			while(x<y){
				r=str[x];
				str[x]=str[y];
				str[y]=r;
				x++;
				y--;
			}
		}

	else if(strcmp(str2, "print")==0){
		scanf("%d %d",&x,&y);
			for(j=x; j<=y; j++){
				printf("%c", str[j]);
			}
			printf("\n");
		}
	}

	return 0;
}

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

int main()
{
  int n, i, j;
  cin >> n;
  vector<vector<int>> ac(n, vector<int>(3));
  vector<vector<int>> dp(n, vector<int>(3));
  for (i=0; i<n; i++) {
    for (j=0; j<3; j++) {
      cin >> ac.at(i).at(j);
    }
  }
  
  for (j=0; j<3; j++) // 初期条件
    dp.at(0).at(j) = ac.at(0).at(j);
  
  for (i=1; i<n; i++) { // dpテーブル
    for (j=0; j<3; j++) {
      if (j==0)
      dp.at(i).at(j) = max(dp.at(i-1).at(1), dp.at(i-1).at(2)) + ac.at(i).at(j);
      else if (j==1)
      dp.at(i).at(j) = max(dp.at(i-1).at(2), dp.at(i-1).at(0)) + ac.at(i).at(j);
      else
      dp.at(i).at(j) = max(dp.at(i-1).at(0), dp.at(i-1).at(1)) + ac.at(i).at(j);
    }
  }
  
  int res = dp.at(n-1).at(0);
  if (dp.at(n-1).at(1) > res) res = dp.at(n-1).at(1);
  if (dp.at(n-1).at(2) > res) res = dp.at(n-1).at(2);
  
  cout << res << endl;
  
}

Measured memory_bytes: 11136
# (c) midandfeed
while(1):
	n, x = [int(x) for x in input().split()]
	c = 0
	if ( (n==0) and (x==0) ):
		break
	while(n > 0):
		for i in range(1, n):
			for j in range(i+1, n):
				if (i+j+n == x):
					c += 1
		n -= 1
	print(c)
		

Measured memory_bytes: 7772
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String t = sc.nextLine();
		int[][] dp = new int[s.length() + 1][t.length() + 1];
		for(int i = 1; i <= s.length(); i++){
		    for(int j = 1; j <= t.length(); j++){
		        if(s.charAt(i-1) == t.charAt(j-1)){
		            dp[i][j] = dp[i - 1][j - 1] + 1;
		        }else{
		            dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
		        }
		    }
		}
		int a = s.length();
		int b = t.length();
		StringBuilder ans = new StringBuilder();
		while(a > 0 && b > 0){
		    if(s.charAt(a - 1) == t.charAt(b - 1)){
		        ans.append(s.charAt(a - 1));
		        a--;
		        b--;
		    }else if(dp[a - 1][b] >= dp[a][b - 1]){
		        a--;
		    }else{
		        b--;
		    }
		}
		System.out.println(ans.reverse());
	}

}


Measured memory_bytes: 82260
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]
  member this.ScanMatrix n f  = [ for i in 1..n do yield stream.ReadLine().Split() |> Array.map f ]
  member this.ScanCharMatrix n = [| for i in 1..n -> stream.ReadLine().ToCharArray() |]
  member this.Close () = stream.Close()

let util = ABC(stdin)
let s = util.Scan1 (fun x -> x.Split([|'/'|]))
let y,m = (int s.[0]),(int s.[1])

match y, m with
| y, _ when y < 2019 -> "Heisei"
| y, _ when y > 2019 -> "TBD"
| _, m when m < 5 -> "Heisei"
| _ -> "TBD"
|> printfn "%s"


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





int main() {
  int n;
  cin>>n;
  
  int x=1;
  int answer=1;

  while ((x+1)*(x+1)<=n){
    x+=1;
    answer=x*x;
      
  }
  
  cout<<answer<<endl;
  
  
    
    
    
  
}

  













Measured memory_bytes: 256
N, K = map(int, input().split())
S = input()+"2"
L = []
cnt = 0
temp = int(S[0])

for x in S:
  if temp == int(x):
    cnt += 1
  else:
    L.append(cnt)
    cnt = 1
    temp = int(x)

if S[0] == "0":
  Lcs = [0, 0]
else:
  Lcs = [0]

for x in L:
  Lcs.append(Lcs[-1] + x)
 
ans = Lcs[1]
N = len(Lcs)
i = 2

if i + 2*(K-1) > N-1:
  print(Lcs[-1])
else:
  while i + 2*(K-1) <= N-1:
    if i + 2*(K-1) == N-1:
      ans = max(ans, Lcs[i + 2*(K-1)]-Lcs[i-2])
    else:
      ans = max(ans, Lcs[i + 2*(K-1) +1]-Lcs[i-2])
    i += 2
  print(ans)

Measured memory_bytes: 13696
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    srand((unsigned) time(NULL));
    int h, w;
    cin >> h >> w;
    string s[h+2];
    rep(i,h+2){
        if(i == 0 || i == h + 1){
            rep(j,w+2)s[i] += 'x';
        }else{
            string ss;
            cin >> ss;
            /*
            rep(j,w){
                int x = rand()%2;
                if(x == 0)ss += '.';
                else ss += '#';
            }
            */
            s[i] = 'x' + ss + 'x';
            // cout << ss << endl;
        }
    }

    int a[h+2][w+2];
    rep(i,h+2){
        rep(j,w+2){
            if(s[i][j] == 'x')a[i][j] = -1;
            else a[i][j] = 1001001001;
        }
    }

    int dx[2] = {0,1};
    int dy[2] = {1,0};

    priority_queue<pair<int,P>, vector<pair<int,P>>, greater<pair<int,P>>> que;
    pair<int,P> p;

    if(s[1][1] == '#')a[1][1] = 1;
    else a[1][1] = 0;
    p.first = a[1][1];
    p.second.first = 1;
    p.second.second = 1;
    que.push(p);

    while(que.size() > 0){
        p = que.top();
        que.pop();
        int t = p.first;
        int x = p.second.first;
        int y = p.second.second;
        if(t > a[x][y])continue;
        rep(i,2){
            if(s[x+dx[i]][y+dy[i]] == 'x')continue;
            if(s[x][y] == '.' && s[x+dx[i]][y+dy[i]] == '#'){
                if(a[x][y] + 1 < a[x+dx[i]][y+dy[i]]){
                    a[x+dx[i]][y+dy[i]] = a[x][y] + 1;
                    p.first = a[x][y] + 1;
                    p.second.first = x + dx[i];
                    p.second.second = y + dy[i];
                    que.push(p);
                }
            }else{
                if(a[x][y] < a[x+dx[i]][y+dy[i]]){
                    a[x+dx[i]][y+dy[i]] = a[x][y];
                    p.first = a[x][y];
                    p.second.first = x + dx[i];
                    p.second.second = y + dy[i];
                    que.push(p);
                }
            }
        }
    }
    /*
    srep(i,1,h+1){
        srep(j,1,w+1)cout << a[i][j];
        cout << endl;
    }
    */

    int ans = a[h][w];

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


Measured memory_bytes: 384
import Control.Monad
import Control.Applicative
import Data.Char
import Data.List

solve :: String -> String
solve s =
    let chunk = group $ sort [toLower c | c<-s, isAlpha c] in
    let sets = [(c,length s) | s@(c:_)<-chunk] in
    unlines $ map (showchr sets) ['a'..'z']
    where
    showchr :: [(Char,Int)] -> Char -> String
    showchr sets c =
        let n = maybe 0 id (lookup c sets) :: Int in
        [c] ++ " : " ++ (show n)

main =
    putStr =<< solve <$> getContents 


Measured memory_bytes: 4016
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeSearch(Node u, int k){
  while(u != NIL){
    if(u->key == k)return u;
    if( u->key > k)u = u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else x = x->right;
  }

  z->parent = y;
  if(y == NIL) {
    root = z;  
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else y->right = z;
}


void inorder(Node u){
  if(u->left != NIL){
    inorder(u->left);
  }
  printf(" %d",u->key);
  if(u->right != NIL){
    inorder(u->right);
  }

}
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left!= NIL){
    preorder(u->left);
  }
  if(u->right!= NIL){
    preorder(u->right);
  }
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }
  return 0;
}

Measured memory_bytes: 19364
/*
Author : Gaurav Singh
*/
#include<bits/stdc++.h>
using namespace std;
#define N 5005
#define MOD 1000000007
#define ll long long
#define ld long double
#define ull unsigned long long
#define li long int
#define str string
#define vll vector<ll>
#define pb push_back
#define frn(i,n) for(ll (i) = 0; (i) <(n) ; (i)=(i+1))
#define fr(i,n) for(ll (i) = 1; (i) <=(n) ; (i)=(i+1))
#define frev(i,n) for(ll (i) = n-1; (i) >=(0) ; (i)--)
#define fr1(j,a,b,c) for(ll (j) = a; (j) <c ; (i)=(i+b))
#define w(t) while(t--)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
void solve(){
    ld b,c;
    ll a,d;
    cin>>a>>b;
    c=a*b;
    d=c;
    cout<<d;
}
int main()
{   
   fast;
   int t=1;
   //cin>>t;
    w(t){
        solve();
    }
   return 0;
}   
            

Measured memory_bytes: 3744
#include <stdio.h>
#include <string.h>
#include <ctype.h>

void str_toupper(char *s){
	int i=0;
	while(s[i]!='\0'){
		s[i] = toupper(s[i]);
		i++;
	}
}

int main(void)
{	
	char s[1001], w[11];
	int cnt=0;

	scanf("%s", w);
	str_toupper(w);
	while(1){
		scanf("%s", s);
		if(!strcmp(s, "END_OF_TEXT"))
			break;
		str_toupper(s);
		if(!strcmp(s,w))
			cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 548
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  vector<char> s(19);
  for (int i = 0; i < 19; i++) {
    cin >> s.at(i);
  }
  for (int i=0; i < 19; i++) {
    if (i != 5) {
      if (i != 13){
      cout << s.at(i);
        continue;
    }
  }
  cout << " ";}
  }

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<functional>

using namespace std;
using ll = long long;
using pint = pair<int, int>;

ll INF = 1LL << 60;

vector<vector<ll>> dp(10, vector<ll>(10));
vector<vector<pint>> G(10);

int main() {
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			int c;
			cin >> c;
			G[i].push_back(make_pair(c, j));
		}
	}
	
	dp.assign(10, vector<ll>(10,INF));
	for (int i = 0; i < 10; i++) {
		dp[i][i] = 0;
		for (pint p : G[i]) {
			int w = p.first;
			int v = p.second;
			dp[i][v] = w;
		}
	}

	for (int k = 0; k < 10; k++) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
			}
		}
	}

	ll ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int a;
			cin >> a;
			if (a == -1 || a == 1) continue;
			ans += dp[a][1];
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3596
#include <iostream>

using namespace std;

main(){

    int A, B, C;

    //cout << "input three numbers here" << endl;
    cin >> A >> B >> C;

    //cout << A << " " << B << " " << C << endl;

    if((1 <= A && A <= 10) && (1 <= B && B <= 10) && (1 <= C && C <= 10)){

        if((A == 5 && B == 5 && C == 7) ||
            (A == 5 && B == 7 && C == 5) ||
            (A == 7 && B == 5 && C == 5)) cout << "YES" << endl;
            else cout << "NO" << endl;

    }else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
l = [int(i) for i in input().split()]
cnt = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if not (l[i] == l[j] or l[j] == l[k] or l[k] == l[i]) and l[i] + l[j] > l[k] and l[i] + l[k] > l[j] and l[k] + l[j] > l[i]:
                cnt += 1
print(cnt)

Measured memory_bytes: 9196