akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
	int H, W;
	while(cin >> H >> W){
		if(H==0 && W==0) return 0;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(i%2==0){
					if(j%2==0) cout << "#";
					else cout << ".";
				}
				else if(i%2!=0){
					if(j%2==0) cout << ".";
					else cout << "#";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
}

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

int main(int argc, char *argv[]) {
	int A = 0;
	int B = 0;
	int C = 0;

	std::cin >> A;
	std::cin >> B;
	std::cin >> C;

	//
	//  演算子パネルは脇に置けないので、2枚+1枚 の組み合わせで
	//  最大のものを求めれば良い
	//
	//  たかがか以下の6通りである。
	//	
	//  AB + C
	//  AC + B
	//  BA + C
	//  BC + A
	//  CA + B
	//  CB + A
	//

	int max = 0;
	std::vector<int> candidates({
		(10 * A) + B + C,
		(10 * A) + C + B,
		(10 * B) + A + C,
		(10 * B) + C + A,
		(10 * C) + B + A
	});
	for (auto candidate: candidates) {
		if (candidate >= max) {
			max = candidate;
		}
	}

	std::cout << max << std::endl;
	return 0;
}


Measured memory_bytes: 256
#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
//#define int long long int
using namespace std;


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

  double ans = 0;
  double rev = 0;

  for(int i=0;i<N;i++){
      double x; cin>>x;

      rev += double(1.0)/x;

  }

  ans =  double(1)/rev;

  printf("%f",ans);
    return 0 ;
}

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

using namespace std;

typedef long long ll;

struct Node {
    ll sumw, sumv;
    Node(ll sumw = 0, ll sumv = 0):sumw(sumw), sumv(sumv){
    }
};


void process(vector<ll>& w, vector<ll>& v,  int l, int r, vector<Node>& result) {
    int size = r - l + 1;
    int bound = (1 << size) - 1;
          
    for (int i = 0; i <= bound; i++) {
        ll sumw = 0;
        ll sumv = 0;
        for (int k = 0; k < size; k++) {
            if ((i & (1 << k)) > 0) {
                sumw += w[l + k];
                sumv += v[l + k];
            }
        }
        result.push_back(Node(sumw, sumv));
    }
}

bool cmp1(const Node& a, const Node &b) {
    return a.sumw < b.sumw || (a.sumw == b.sumw && a.sumv > b.sumv);
}

bool cmp2(const Node& a, const Node &b) {
    return a.sumw < b.sumw;
}

//sort vector w in increasing order and by v in decreasing order and.
//Create a new list where if w1 > w2 then v1 > v2.
void createMonoQueue(vector<Node>& a, vector<Node>& mono) {
    sort(a.begin(), a.end(), cmp1);
    ll curv = -1;
    for (Node& node : a) {
        if (node.sumv > curv) {
            mono.push_back(node);
            curv = node.sumv;
        }
    }
}

int main() {
    int n;
    ll c; 
    cin >> n >> c;
    
    vector<ll> v(n);
    vector<ll> w(n);
    
    for (int i = 0; i < n; i++) {
        cin >> v[i] >> w[i];
    }
    
    vector<Node> result1, result2;
    
    int m = (n - 1)/2;
    
    process(w, v, 0, m, result1);
    process(w, v, m + 1, n - 1, result2);
    
//    for (Node& node : result1) {
//        cout << node.sumw << " " << node.sumv << endl;
//    }
//    
//    cout << "second" << endl;
//    
//    for (Node& node : result2) {
//        cout << node.sumw << " " << node.sumv << endl;
//    }
    
    vector<Node> mono;
    
    createMonoQueue(result2, mono);
    
    ll ans = 0;
    for (Node& node : result1) {
        //cout << node.sumv << " " << node.sumw << endl;
        auto it = upper_bound(mono.begin(), mono.end(), c - node.sumw, cmp2);
        if (it != mono.begin()) {
            it--;
            ans = max(ans, node.sumv + it->sumv);
        }
    }
    
    cout << ans << endl;
    
    
    return 0;    
}

Measured memory_bytes: 43756
n = gets.to_i
s = n.times.map{ gets.chop }.group_by{ _1 }
puts "AC x #{s['AC'] ? s['AC'].count : 0}"
puts "WA x #{s['WA'] ? s['WA'].count : 0}"
puts "TLE x #{s['TLE'] ? s['TLE'].count : 0}"
puts "RE x #{s['RE'] ? s['RE'].count : 0}"

Measured memory_bytes: 21756
#include <stdio.h>
#include <string.h>
 
#define WORD_SIZE_MAX 100
 
int dict_compare(const char *s1, const char *s2) {
    while (*s1 == *s2) {
        if (*s1 == '\0')
            return 0;
        s1++;
        s2++;
    }
    return *s1 - *s2;
}
 
int main(void) {
    int n;
    scanf("%d", &n);
 
    int score[2] = {0, 0};  // ?????????¨???±????????????.
    int i;
    for (i = 0; i < n; i++) {
        char words[2][WORD_SIZE_MAX];   // ?????????¨???±????????????.
        scanf("%s %s", words[0], words[1]);
         
        int result = dict_compare(words[0], words[1]);
        if (result == 0) {
            score[0] += 1;
            score[1] += 1;
        } else if (result > 0) {
            score[0] += 3;
        } else {
            score[1] += 3;
        }
    }
 
    printf("%d %d\n", score[0], score[1]);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n;
    cin >> n;
    vector<vector<ll>> sh(n, vector<ll>(10));
    vector<vector<ll>> pro(n, vector<ll>(11));
    for (ll i = 0; i < n; i++)
    {
        for (ll j = 0; j < 10; j++)
        {
            cin >> sh[i][j];
        }
    }
    for (ll i = 0; i < n; i++)
    {
        for (ll j = 0; j < 11; j++)
        {
            cin >> pro[i][j];
        }
    }
    ll ans = -10000000000000;
    for (ll bit = 0; bit < (1 << 10); bit++)
    {
        ll sum = 0;
        set<ll> st;
        for (ll i = 0; i < 10; i++)
        {
            if (bit & (1 << i))
                st.insert(i);
        }
        if(st.size() == 0)
        continue;
        vector<ll> open_or_not(n, 0);
        ll cnt = 0;
        for (ll i = 0; i < n; i++)
        {
            for (ll j = 0; j < 10; j++)
            {
                if (sh[i][j] == 1 && st.count(j))
                    open_or_not[i]++;
            }
            if (open_or_not[i] == 0)
                cnt++;
        }
       
            for (ll i = 0; i < n; i++)
            {
                sum += pro[i][open_or_not[i]];
            }
            ans = max(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define reps(i, n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define repi(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> h(100200);
    rep(i,n) cin>>h.at(i);
    
    vector<int> dp(100200,1000000000);
    dp.at(0)=0;
    rep(i,n){
        reps(j,k){
            dp.at(i+j)=min(dp.at(i+j),dp.at(i)+abs(h.at(i)-h.at(i+j)));
        }
    }
    
    cout<<dp.at(n-1)<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define reps(i, n , m) for(ll i = n; i <= m; i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
const int mod = 1000000007; 
long long inv[200000],fact[200000],ifact[200000];
long long comb(ll n, ll k){
	if(n<k)return 0;
	else if (n<0||k<0) return 0;
	else return fact[n] * ifact[k] % mod * ifact[n-k] % mod;
}
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}
 
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	/*inv[1] = fact[0] = fact[1] = ifact[0] = ifact[1] = 1; for (int i=2;i<200000;i++){ inv[i] = (mod - mod / i) * inv[mod % i] % mod; fact[i] = fact[i-1] * i % mod;ifact[i] = ifact[i-1] * inv[i] % mod;
	}*/ //nCr
	int N;
	cin>>N;
	vector <int> d(N);
	rep(i,N)cin>>d[i];
	
	int sum=0;
	rep(i,N){
	    rep(j,N){
	        if(i!=j)sum+=d[i]*d[j];
		}
	}
	sum/=2;
	cout<<sum<<endl;
}

Measured memory_bytes: 256
import math

X = int(input())

def isPrime(X):
  if X == 2:
    return True
  if X % 2 == 0:
    return False
  
  # nの平方根まで計算する
  m = math.floor(math.sqrt(X)) + 1
  for p in range(3, m, 2):
      if X % p == 0:
        return False
  return True

for i in range(1, 10**5):
    if isPrime(X) == True:
        print(X)
        exit()
    else:
        X = X + 1

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    string s;
    cin >> s;
    int n = s.size();
    string pre = s.substr(0,1);
    int pos = 1;
    int ans = 1;
    while(pos < n)
    {
        int next = 1;
        while(pos + next <= n && s.substr(pos, next) == pre)
        {
            next++;
        }
        if(pos + next > n) break;
        pre = s.substr(pos, next);
        ans++;
        pos += next;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
// https://atcoder.jp/contests/abc178/tasks/abc178_f

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
using ll = long long;
using ld = long double;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
template <typename T>
using VV = V<V<T>>;
using VVL = VV<ll>;
template <typename T>
using VVV = VV<V<T>>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
using asc_pq = priority_queue<T, V<T>, greater<T>>;

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

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N;
  cin >> N;

  VL as(N);
  rep(i, N) cin >> as[i];

  VL bs(N);
  rep(i, N) cin >> bs[i];

  {
    VL ct(N + 1);

    for (ll e : as) ct[e]++;
    for (ll e : bs) ct[e]++;

    rep(num, N + 1) {
      if (ct[num] > N) drop("No");
    }
  }

  auto print_and_exit = [&]() {
    cout << "Yes"
         << "\n";

    rep(i, N) {
      if (i > 0) cout << " ";
      cout << bs[i];
    }
    cout << "\n";
    throw exit_exception();
  };

  reverse(all(bs));

  // 逆順ソートすれば、被っている要素はたかだか一種類となり、範囲となる
  // [same_l, same_r) で被っているとする
  ll same_l = -1;
  ll same_r = -1;

  rep(i, N) {
    if (as[i] == bs[i] && same_l == -1) {
      same_l = i;
    }

    if (as[i] != bs[i] && same_l != -1) {
      same_r = i;
      break;
    }
  }

  if (same_l == -1) print_and_exit();

  ll dup = bs[same_l];
  ll ni = same_l;

  rep(i, N) {
    if (ni == same_r) break;
    if (same_l <= i && i < same_r) continue;

    if (as[i] != bs[ni] && bs[i] != as[ni]) {
      swap(bs[i], bs[ni++]);
    }
  }

  print_and_exit();
}


Measured memory_bytes: 7960
#include <iostream>
#include <algorithm>
#include <queue>

#define INF 1<<20
#define BLACK 0
#define GRAY 1
#define WHITE 2

using namespace std;

int dijkstra(int n, vector<vector<pair<int, int> > > &adj) {
  priority_queue<pair<int, int> > PQ;
  int *color = new int[n];
  int *d = new int[n];
  for (int i = 0; i < n; i++) {
    d[i] = INF;
    color[i] = WHITE;
  }

  d[0] = 0;
  PQ.push(make_pair(0, 0));
  color[0] = GRAY;

  while (!PQ.empty()) {
    pair<int, int> f = PQ.top();
    PQ.pop();
    int u = f.second;
    color[u] = BLACK;

    if (d[u] < f.first * (-1)) {
      continue;
    }

    for (int j = 0; j < adj[u].size(); j++) {
      int v = adj[u][j].first;
      if (color[v] == BLACK) {
        continue;
      }
      if (d[v] > d[u] + adj[u][j].second) {
        d[v] = d[u] + adj[u][j].second;
        PQ.push(make_pair(d[v] * (-1), v));
        color[v] = GRAY;
      }
    }
  }

  for (int i = 0; i < n; i++) {
    cout << i << " " << (d[i] == INF ? -1 : d[i]) << endl;
  }

  return 0;
}

int main() {
  int n, u, k, v, c;
  vector<vector<pair<int, int> > > adj;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> u;
    cin >> k;
    vector<pair<int, int> > vc;
    for (int j = 0; j < k; j++) {
      cin >> v;
      cin >> c;
      vc.push_back(make_pair(v, c));
    }
    adj.push_back(vc);
  }

  dijkstra(n, adj);

  return 0;
}


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

namespace _0031
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line)) return;

                int n = int.Parse(line);
                List<int> res = new List<int>();
                for (int i = 0 ; i < 10 ; i++)
                {
                    if ((n >> i & 1) == 1) res.Add((int)Math.Pow(2, i));
                }
                Console.WriteLine(WAr(res));
            }

        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



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

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

		for(int i=0;i<Q;i++){
			int c,a,n;
			cin>>c>>a>>n;
			int can=min(min(c,a),n);
			c-=can;
			a-=can;
			
			int cca=min(c/2,a);
			c-=cca*2;
			int ccc=c/3;

			cout<<can+cca+ccc<<endl;
		}

	return 0;
}

Measured memory_bytes: 3076
<?php
$numbers = fgets(STDIN);
$n = intval($numbers);
// print $n;

$numbers1 = preg_split("/[\s,]+/", rtrim(fgets(STDIN)));
// print_r($numbers);

$numbers2 = fgets(STDIN);
$n = intval($numbers);
// print $n;

$numbers2 = preg_split("/[\s,]+/", rtrim(fgets(STDIN)));
// print_r($numbers);
// print_r($numbers2);

$numbers_merge = array_intersect($numbers1, $numbers2);
sort($numbers_merge);

foreach ($numbers_merge as $nm){
    echo $nm;
    echo PHP_EOL;
}
// print_r($numbers_merge);


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

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            //問題160

            string s = Console.ReadLine();

            //Console.WriteLine(s[0]);

            if (s[2] == s[3] && s[4] == s[5])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }


        }

    }





    
}


Measured memory_bytes: 25668
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <ciso646>


int main()
{
    int num_d;
    std::cin >> num_d;

    int num_prob_1;
    std::cin >> num_prob_1;

    std::vector<int> scores_1;
    for (int i = 0; i < num_prob_1; ++i)
    {
        char answer;
        int score;
        std::cin >> answer >> score;
        if (answer == 'D')
            scores_1.push_back(score);
    }

    int num_prob_2;
    std::cin >> num_prob_2;
    
    std::vector<int> scores_2;
    for (int i = 0; i < num_prob_2; ++i)
    {
        std::string answer;
        int score;
        std::cin >> answer >> score;
        if (answer[0] == 'D' and answer[1] == 'D')
            scores_2.push_back(score);
    }

    std::sort(scores_1.begin(), scores_1.end(), std::greater<int>());
    std::sort(scores_2.begin(), scores_2.end(), std::greater<int>());

    int out(0);

    for (int n1 = 0; n1 <= std::min<int>(num_d, scores_1.size()); ++n1)
    {
        int n2(std::min<int>((num_d - n1) / 2, scores_2.size())), sum(0);
        for (int i = 0; i < n1; ++i) sum += scores_1[i];
        for (int i = 0; i < n2; ++i) sum += scores_2[i];

        if (sum > out) out = sum;
    }

    std::cout << out << std::endl;
    
    return 0;
}

Measured memory_bytes: 1228
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;

class Program
{
   

    static void Main(string[] args)
    {
        int ans = 0;
        int k = crI();
        int amari = 7 % k;
        if(amari == 0)
        {
            Console.WriteLine(1);
            return;
        }
        int kou = 2;
        while (true)
        { 
            amari = (amari * 10 + 7) % k;
            if (amari == 0)
            {
                Console.WriteLine(kou);
                return;
            }
            kou++;
            if (kou > k) break;
        }
        Console.WriteLine(-1);
        
    }

   
   

    //入力受け取り用
    static string crS() { return Console.ReadLine(); }
    static int crI() { return int.Parse(Console.ReadLine()); }
    static int[] arrInt(){return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();}
    static long[] arrLong(){ return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray(); }
    static string[] arrStr(){return Console.ReadLine().Split(' ').ToArray();}
    static List<int[]> mapInt(int h)
    {
        List<int[]> mapInt = new List<int[]>();
        for (int i = 0; i < h; i++)
        {
            mapInt.Add(arrInt());
        }
        return mapInt;
    }

    static List<string[]> mapStr(int h)
    {
        List<string[]> mapStr = new List<string[]>();
        for (int i = 0; i < h; i++)
        {
            mapStr.Add(arrStr());
        }
        return mapStr;
    }

    static List<char[]> mapChar(int h)
    {
        List<char[]> mapChar = new List<char[]>();
        for (int i = 0; i < h; i++)
        {
            string s = crS();
            mapChar.Add(s.ToCharArray());
        }
        return mapChar;
    }

    static List<char[]> mapCharCopy(List<char[]> map)
    {
        List<char[]> copyMap = new List<char[]>();
        foreach (var arr in map)
        {
            List<char> list = new List<char>();
            foreach (var ele in arr)
            {
                list.Add(ele);
            }
            copyMap.Add(list.ToArray());
        }
        return copyMap;
    }
}

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

int main() {
    int N;
    cin >> N;
    vector<int>vec(N-1);
    for(int i=0; i<N-1 ;i++){
        cin >> vec.at(i);
    }
    vector<int>kiroku(N);
    for(int j=0; j<N-1; j++){
        kiroku.at(vec.at(j)-1)++;
    }
    for(int i=0; i<N; i++){
        cout << kiroku.at(i) <<endl;
    }

    
}

Measured memory_bytes: 4776
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String result = "AC";
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            String one = s.substring(i, i + 1);
            if (i == 0) {
                if (!one.equals("A")) {
                    result = "WA";
                    break;
                } else {
                    continue;
                }
            }
            if ((i > 1) && (i < s.length() - 1)) {
                if (one.equals("C")) {
                    count++;
                    continue;
                }
            }
            if (Character.isUpperCase(one.toCharArray()[0])) {
                result = "WA";
                break;
            }
        }
        // 出力
        if (count != 1) {
            result = "WA";
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 23124
def Next(): return input()
def NextInt(): return int(Next())

X = NextInt()

if 400<= X <= 599:
	print(8)
elif 600<= X<= 799:
	print(7)
elif 800<= X<=999:
	print(6)
elif 1000 <= X<=1199:
	print(5)
elif 1200 <=X <=1399:
	print(4)
elif 1400 <=X<=1599:
	print(3)
elif 1600<=X<=1799:
	print(2)
else:
	print(1)

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {std::cout << x;}
void __print(unsigned x) {std::cout << x;}
void __print(unsigned long x) {std::cout << x;}
void __print(unsigned long long x) {std::cout << x;}
void __print(float x) {std::cout << x;}
void __print(double x) {std::cout << x;}
void __print(long double x) {std::cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
template <typename T> inline void inp(T &any) {cin >> any;} template <typename T, typename... U>inline void inp(T &a, U &...b) {cin >> a; inp(b...);}
#define rin(args...) ll args; inp(args);
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#define matdeb(mat,row,col) cout << #mat << "::" << endl; printmat(mat,row,col); printpartition;
#define debugv(v,n) cout << #v << ":" << endl; printv(v,0,n-1); printpartition;
#else
#define debug(x...)
#define matdeb(mat,row,col)
#define debugv(v,n)
#endif

const int maxm = 1000000000 + 7;

double startTime;
double getCurrentTime() {
	return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->


int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

   string s;
   cin>>s;

   cout<<s[0]<<s.length()-2<<s[s.length()-1]<<endl;

}


Measured memory_bytes: 3608
n = int(input())
lst = [int(v) for v in input().split()]

count = 0
for i, p in enumerate(lst):
    if i + 1 != p:
        count += 1
    if count > 2:
        break

if count == 0 or count == 2:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
#include<stdio.h>
#define N 102

int main(){
  int a[N][N];
  int n,i,j,u,k,v;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      a[i][j]=0;
    }
  }

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

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j!=1) printf(" ");
      printf("%d",a[i][j]);
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 2736
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<vector<pair<int64_t, bool>>> A(N);
  for (int64_t i = 0; i < N; ++i) {
    int64_t a;
    cin >> a;
    for (int64_t j = 0; j < a; ++j) {
      int64_t x, y;
      cin >> x >> y;
      A[i].emplace_back(x - 1, (y == 1));
    }
  }
  int64_t result = 0;
  for (int64_t b = 0; b < (1L << N); ++b) {
    bitset<15> bs(b);
    bool is_okay = true;
    for (int64_t i = 0; i < N; ++i) {
      // cerr << b << ", " << i << " " << __LINE__ << endl;
      if (bs[i]) {
        for (auto p : A[i]) {
          if (p.second) {
            if (!bs[p.first]) {
              is_okay = false;
            }
          } else {
            if (bs[p.first]) {
              is_okay = false;
            }
          }
        }
      }
    }
    if (is_okay) {
      result = max(result, static_cast<int64_t>(bs.count()));
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
    int ab, bc, ca; cin >> ab >> bc >> ca;
    cout << (ab * bc) / 2 << endl;
    return 0;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

const int column = 50;

struct Solution {
    int water, sugar;

    double rate() {
        return (double)(100 * sugar) / (double)(water + sugar);
    }
};

int main() {
    int w1, w2, s1, s2, mr, b;
    cin >> w1 >> w2 >> s1 >> s2 >> mr >> b;

    w1 *= 100;
    w2 *= 100;

    set<int> sugars;
    for (int s1i = 0; s1i * s1 <= b; s1i++) {
        for (int s2i = 0; (s1i * s1) + (s2i * s2) <= b; s2i++) {
            sugars.insert(s1 * s1i + s2 * s2i);
        }
    }

    auto check_rate = [&](int w) {
        int b = w * mr / 100;
        auto it = sugars.upper_bound(b);
        assert(it != sugars.begin());
        it--;
        int l = *it;
        assert((100 * l) / (w + l) <= mr);
        return l;
    };

    auto check_b = [&](int w) {
        int nokori = b - w;
        assert(nokori >= 0);
        auto it = sugars.upper_bound(nokori);
        if (it == sugars.begin()) return 0;
        it--;
        int l = *it;
        assert(w + l <= b);
        return l;
    };

    vector<Solution> solutions;

    for (int w1i = 0; w1i * w1 <= b; w1i++) {
        for (int w2i = 0; w1i * w1 + w2i * w2 <= b; w2i++) {
            if (w1i == 0 && w2i == 0) continue;
            int w = w1i * w1 + w2i * w2;
            int s_r = check_rate(w);
            int r_b = check_b(w);
            int now = min(s_r, r_b);
            solutions.push_back(Solution{w, now});
        }
    }


    sort(solutions.rbegin(), solutions.rend(), [](Solution &s, Solution &t) {
        return s.rate() < t.rate();
    });
    Solution s = solutions.front();
//    Solution s = *max_element(solutions.begin(), solutions.end(), [](Solution &s, Solution &t) {
//        return s.rate() < t.rate();
//    });

    assert(s.water + s.sugar <= b);
    assert(s.water * mr / 100 >= s.sugar);
    cout << s.water + s.sugar << ' ' << s.sugar << endl;

}



Measured memory_bytes: 384
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N,A,B = input_int()

temp_B = N%(A+B)
temp_A = N//(A+B)



print(temp_A * A + min(temp_B, A))

Measured memory_bytes: 3060
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] b = new int[n];
        int res = 0;
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
            res += Math.min(b[i], k-b[i])*2;
        }

        System.out.println(res);
        sc.close();
    }
}

class io {
    public static void br() {
        System.out.println("");
    }

    public static void YesNo(boolean f) {
        System.out.println(f ? "Yes" : "No");
    }

    public static void YESNO(boolean f) {
        System.out.println(f ? "YES" : "NO");
    }

}

class Algo {
    public static boolean isOdd(int n) {
        return n % 2 == 1;
    }

    public static boolean isEven(int n) {
        return n % 2 == 0;
    }


}



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

int main()
{
    map<int,int> mp;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        mp[x]++;
    }
    vector<pair<int,int>> vc;
    for(auto it=mp.begin();it!=mp.end();it++){
        int sidelen=it->first;
        int cnt=it->second;
        if(cnt>=2)
            vc.push_back(make_pair(sidelen,cnt));
    }
    sort(vc.rbegin(),vc.rend());
    if(vc.size()<2){
        cout<<0;
        return 0;
    }
    if(vc[0].second>=4){
        cout<<1LL*vc[0].first*vc[0].first;
        return 0;
    }
    cout<<1LL*vc[0].first*vc[1].first;
    return 0;
}


Measured memory_bytes: 4992
#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>;
 
 
int main() {
    int x,n;
    cin >> x >> n;
    vector<int> p(n);
    rep(i,n) cin >> p.at(i);
    rep(i,100){
        bool flag=true;
        rep(j,n){
            if(p.at(j)==x-i) flag=false;
        }
        if(flag){
            cout << x-i << endl;
            break;
        }
        bool flag2=true;
        rep(j,n){
            if(p.at(j)==x+i)flag2=false;
        }
        if(flag2){
            cout << x+i << endl;
            break;
        }
    }

}

Measured memory_bytes: 3628
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	b = zeros(Int,n)
	for i in 1:n
		b[a[i]] = i
	end
	ans = 0
	bs = BitSet()
	push!(bs,0)
	push!(bs,n+1)
	for i in 1:n
		l = Base._bits_findprev(bs.bits,b[i]-1)
		r = Base._bits_findnext(bs.bits,b[i]+1)
		ans += i*(b[i]-l)*(r-b[i])
		push!(bs,b[i])
	end
	println(ans)
end

main()

Measured memory_bytes: 197256
#!/usr/bin/ruby

gets.to_i.times do
  x, y = gets.split.map(&:to_f).partition.with_index{|x,i| i.even?}

  puts (y[1]-y[0]) / (x[1]-x[0]) == (y[3]-y[2]) / (x[3]-x[2]) ? "YES" : "NO"
	
end

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

int main(){
  int n,x;
  cin >> n >> x;
  vector<int> l(n);
  for (int i=0;i<n;i++){
    cin >> l[i];
  }
  int ans=1;
  int p=0;
  
  for (int i=0;i<n;i++){
    p += l[i];
    if(p<=x) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {

  var n int
  fmt.Scanln(&n)
  p := scanNums(n)
  
  count := 0
  for i:=1; i<n-1; i++ {
    
    a := p[i-1]
    b := p[i]
    c := p[i+1]
    
    if (a < b && b < c) || (a > b && b > c) {
      count += 1
    }
  }
  fmt.Print(count)
}

func scanNums(len int) (nums []int) {
    var num int
    for i := 0; i < len; i++ {
        fmt.Scan(&num)
        nums = append(nums, num)
    }
    return
}

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n, k; cin >> n >> k;
  cout << (k == 1 ? 0 : n - k) << endl;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb                 push_back
#define bug(x)             cerr<<#x<<" "<<x<<endl;
#define T int time;        scanf("%d", &time); while(time--)
    vector<ll>ar;
  bool check(ll i,ll n){
    if(abs(i-n)<=1)return true;
    for(ll ii=n-1; ii>i; ii--)if(ar[ii]<ar[ii-1])
      cout<<ar[ii]<<" ";
    cout<<endl;
    return true;
  }

   int main(){
         map<string ,ll>memo;
         ll n;
         string s;
         cin>>n;
         ll mx=0;
         for(ll i=0; i<n; i++){
            cin>>s;
            memo[s]++;
            mx=max(mx,memo[s]);
         }
         for(auto it: memo)
          if(it.second==mx)cout<<it.first<<endl;
         
     }
   

Measured memory_bytes: 19240
N, *ds = $<.read.split.map(&:to_i)

a = [0] * 13
ds.each { |d| a[d] += 1 }

left = true
a2 = [0]
0.upto(12) do |i|
  case a[i]
  when 0
    next
  when 1
    a2 << (left ? i : 24-i)
    left = !left
  when 2
    a2 << i << 24-i
  else
    p 0
    exit 0
  end
end

a,b=a2.sort.each_cons(2).min_by { |a,b| b-a }
p b-a

Measured memory_bytes: 1788
use std::str::FromStr;

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

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let hw : Vec<u64> = get_vec();
    if hw[0] == 1 || hw[1] == 1{
        println!("{}", 1);
    }
    else if hw[0] % 2 == 0 {
        println!("{}", hw[0] * hw[1] / 2);
    }
    else {
        println!("{}", (hw[0]/2) * hw[1] + (hw[1]+1)/2);
    }
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main(){
    int n;
    while(cin >> n, n){
        for(int i = 0; i < n; i++){
            int m,e,j;
            cin >> m >> e >> j;
            int sum = m + e + j;
            if(m == 100 || e == 100 || j == 100)cout << "A" << endl;
            else if(m+e >= 90*2 || sum >= 80*3)cout << "A" << endl;
            else if(sum >= 70*3)cout << "B" << endl;
            else if(sum >= 50*3 && (m >= 80 || e >= 80))cout << "B" << endl;
            else cout << "C" << endl;
        }
    }
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    ll N, M, K;
    cin >> N >> M >> K;
    
    vec<ll> A(N);
    rep(i, N) cin >> A[i];
    
    vec<ll> B(M);
    rep(i, M) cin >> B[i];

    rep(i,N-1) A[i+1]+=A[i];
    rep(i,M-1) B[i+1]+=B[i];
    A.insert(A.begin(),0);
    A.push_back(1e18);
    B.insert(B.begin(),0);
    B.push_back(1e18);

    ll ans = 0;
    rep(i,A.size()){
        if(A[i] > K) break;
        ll Z = K - A[i];
        int index = upper_bound(all(B),Z) - B.begin();
        --index;
        ans = max(ans,i+index);
    }
    cout << ans << endl;
}


Measured memory_bytes: 7988
n, m = map(int, input().split())
ps = [input().split() for i in range(m)]
ac, wa = [0] * n, [0] * n
wa_sum = 0
for i in ps:
    p, s = int(i[0]), i[1]
    if ac[p - 1] == 0 and s == "AC":
        ac[p - 1] += 1
        wa_sum += wa[p - 1]
    else:
        wa[p - 1] += 1
print(sum(ac), wa_sum)

Measured memory_bytes: 69592
#include <array>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

#define REP(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) REP(i, 0, n)

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }

constexpr int EMBLEM_SIZE = 2;
bool out(int x, int y, int w, int h) {
	return x < 0 || y < 0 || x >= w || y >= h;
}

bool check(int x, int y, const vector<string> &flag, const array<string, 2> &emblem) {
	rep(i, EMBLEM_SIZE) {
		rep(j, EMBLEM_SIZE) {
			if(flag[y + i][x + j] != emblem[i][j]) return false;
		}
	}
	return true;
}

int main() {
	constexpr int dx[] = {-1, 0, -1, 0};
	constexpr int dy[] = {-1, -1, 0, 0};
	const string JOI = "JOI";

	int h, w;
	cin >> h >> w;

	vector<string> flag(h);
	for(auto &e : flag) cin >> e;

	array<string, EMBLEM_SIZE> emblem;
	for(auto &e : emblem) cin >> e;

	vector<vector<bool>> match(h - 1, vector<bool>(w - 1, 0));
	int sum = 0;

	rep(y, h - 1) {
		rep(x, w - 1) {
			if(check(x, y, flag, emblem)) {
				match[y][x] = true;
				++sum;
			}
		}
	}

	int ans = sum;
	rep(y, h) {
		rep(x, w) {
			for(const auto &c : JOI) {
				const char tmp = flag[y][x];
				flag[y][x] = c;

				int num = sum;
				rep(d, 4) {
					const int nx = x + dx[d];
					const int ny = y + dy[d];
					if(out(nx, ny, w, h) || out(nx + 1, ny + 1, w, h)) continue;
					num += check(nx, ny, flag, emblem) - match[ny][nx];
				}

				chmax(ans, num);
				flag[y][x] = tmp;
			}
		}
	}

	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 2444
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] a = in.nextIntArray(n);

            Arrays.sort(a);
            int high = n;
            int low = -1;
            while (high - low > 1) {
                int mid = (high + low) / 2;
                if (isNeed(a, k, mid)) {
                    high = mid;
                } else {
                    low = mid;
                }
            }

            out.println(high);
        }

        boolean isNeed(int[] a, int k, int idx) {
            int n = a.length;
            boolean[] can = new boolean[k];
            can[0] = true;
            for (int i = 0; i < n; i++) {
                if (i == idx) continue;
                for (int j = k - 1; j >= 0; j--) {
                    if (j - a[i] >= 0 && j - a[i] < k && can[j - a[i]]) {
                        can[j] = true;
                    }
                }
            }

            for (int i = Math.max(0, k - a[idx]); i < k; i++) {
                if (can[i]) return true;
            }
            return false;
        }

    }

    static class InputReader {
        private BufferedReader in;
        private StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 24020
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

#define DIV 2019
int main(void) {
    int left, right;
    cin >> left >> right;
    int left_ceil = ((left/DIV) + 1)*DIV;
    int right_floor = (right/DIV)*DIV;
    vector<int> map(DIV);
    for(int val = left; val <= left_ceil; val++) {
        if(val > right) break;
        map[val%DIV]++;
    }
    for(int val = max(left_ceil+1, right_floor); val <= right; val++) {
        if(val < left) continue;
        map[val%DIV]++;
    }

    int ans = DIV;
    for(int i = 0; i < DIV; i++) {
        if(!map[i]) continue;
        for(int j = 0; j < DIV; j++) {
            if(!map[j]) continue;
            if(i == j && map[j]<2) continue;
            ans = min(ans, (i*j)%DIV);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0;i < (n);i++)
using namespace std;
typedef long long ll;

int main() {
   ll n;cin >> n;
   ll ans = 0;
   ll data[n];
   rep(i, n) {
      cin >> data[i];
   }
   for(ll i = 1;i < n;i++) {
      if(data[i] >= data[i-1]) {

      }else {
         ans += data[i-1] - data[i];
         data[i] = data[i-1];
         // cout << data[i] - data[i+1] ;
      }
   }

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


Measured memory_bytes: 5184
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        char alpha = br.readLine().charAt(0);

        if (alpha > 96) {
            bw.write("a\n");
        } else {
            bw.write("A\n");
        }

        bw.close();
        br.close();
    }
}


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

using namespace std;
typedef pair <int, int> pii;
#define pb push_back
#define mp make_pair
#define ll long long
#define PI acos(-1)

int main() {
    int r;
    cin >> r;
    cout << fixed << setprecision(2) << 2 * PI * r ;
    return 0;
}


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

typedef long long ll;
typedef tuple<ll, int, int> tlii;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
#define rep(i, a, b) for (ll i=(a); i<(b); i++)
#define rrep(i, a, b) for (ll i=(a); i>(b); i--)
#define all(obj) (obj).begin(), (obj).end()
#define pb push_back
#define str to_string
#define mkp make_pair
#define mkt make_tuple
#define print(out) cout << (out) << endl
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
void chmax(ll &a, ll b) { a = max(a, b); }
void chmin(ll &a, ll b) { a = min(a, b); }

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

    int N, Q;
    ll s, t, x, d;
    bool flag;
    map<ll, vector<pair<ll, bool>>> A;
    set<ll> D;
    set<ll> S;
    map<ll, ll> B;
    map<ll, ll> C;

    cin >> N >> Q;
    rep(i, 0, N) {
        cin >> s >> t >> x;
        // 全ての工事を同じ時系列に持ってくる
        S.insert(s-x);
        S.insert(t-x);
        A[s-x].pb(mkp(x, 0));
        A[t-x].pb(mkp(x, 1));
    }
    rep(i, 0, Q) {
        cin >> d;
        D.insert(d);
        S.insert(d);
    }
    // 人か工事のある箇所だけ見る
    for (ll key: S) {
        // 工事の状態に変化のある時
        if (A.find(key) != A.end()) {
            for (auto p: A[key]) {
                x = p.first;
                flag = p.second;
                // 工事の本来の開始時期毎に値を増減させる
                if (flag == false) {
                    C[x] ++;
                } else {
                    C[x] --;
                }
                if (C[x] == 0) {
                    C.erase(x);
                }
            }
        }
        // 人が出発する時
        if (D.find(key) != D.end()) {
            // この時点で存在する工事の最も早いものを使いたいので、先頭位置を取得
            auto itr = C.begin();
            if (itr != C.end()) {
                B[key] = itr->first;
            } else {
                // 工事が1つもなければその人は止まらない
                B[key] = -1;
            }
        }
    }
    for (ll x: D) {
        print(B[x]);
    }
    return 0;
}


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

#define all(s) s.begin(), s.end()
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second
#define bit(x, y) ((x >> y) & 1)
#define sz(s) ((int) (s).size())

int main() {
    ios::sync_with_stdio(false); cin.tie(0); 
    cout.tie(0);
    string s;
    cin >> s;
    if (s.size() % 2 == 1) return cout << "No", 0;
    bool flag = 1;
    for (int i = 0; i < sz(s); i += 2) if (s[i] != 'h') flag = 0;
    for (int i = 1; i < sz(s); i += 2) if (s[i] != 'i') flag = 0;
    cout << (flag == 1 ? "Yes" : "No"); 
    return 0;
}

Measured memory_bytes: 256
from sys import setrecursionlimit
setrecursionlimit(1000000) 
_ = input()
H = list(map(int, input().split()))
dp = {}
def jump(i):
    if i == 0:
        return 0
    if i - 1 in dp:    
        a = abs(H[i] - H[i - 1]) + dp[i - 1]
    else:
        pre = jump(i - 1)
        a = abs(H[i] - H[i - 1]) + pre
        dp[i - 1] = pre
    if i == 1:
        return a
    if i - 2 in dp:
        b = abs(H[i] - H[i - 2]) + dp[i - 2]
    else:
        pre = jump(i - 2)
        b = abs(H[i] - H[i - 2]) + pre
        dp[i - 2] = pre

    return min(a, b)

print(jump(len(H) - 1))

Measured memory_bytes: 102752