akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int to_int(char c) {
  if(isdigit(c)) { return c-'0'; }
  if(c == 'A') { return 11; }
  return 10;
}

bool test_ace17(int value, int ace11) {
  while(ace11) {
    if(value <= 17) { return true; }
    ace11 --;
    value -= 10;
  }
  return false;
}

int main() {

  int T; cin >> T;
  rep(_, T) {
    vector<int> in;
    rep(i, 10) {
      char c; cin >> c; in.push_back(to_int(c));
    }

    if(in[0] + in[1] == 21) { cout << "blackjack" << endl; continue; }
    if(in[0] + in[1] > 21) { in[0] -= 10; }

    REP(k, 1, 10) {
      int value = 0;
      int ace11 = 0;
      rep(i, k+1) {
        value += in[i];
        ace11 += in[i] == 11;
      }
      while(value > 21 && ace11) {
        ace11 --;
        value -= 10;
      }
      if(value > 21) {
        cout << "bust" << endl;
        break;
      }

      if(test_ace17(value, ace11)) { continue; }
      if(value <= 16) { continue; }
      cout << value << endl;
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    int n;
    cin>>n;
    map<string,int> mp;
    rep(i,n){
        string s;
        cin>>s;
        mp[s]++;
    }
    int mx=0;
    for(auto p:mp)mx=max(mx,p.second);
    for(auto p:mp){
        if(p.second!=mx)continue;
        cout<<p.first<<endl;
    }
    return 0;
}

Measured memory_bytes: 25216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
using namespace std;

int main() {
    int a,m,n,t;
    cin >> a >> m >> n >> t;
    if (abs(a - n) <= t || (abs(a - m) <= t && abs(m - n) <= t))cout << "Yes" << endl;
    else cout << "No" << endl;
         
}

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    string t; cin >> t;
    vector<char> c(10);
    for (int j = 0; j < 10; j++) {
      c.at(j) = t.at(j);
    }
    sort(c.begin(), c.end());
    char d[11];
    for (int j = 0; j < 10; j++) d[j] = c.at(j);
    d[10] = 0;
    s.at(i) = string(d);
  }
  sort(s.begin(), s.end());
  string prev = "";
  ll cnt = -1;
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    if (s.at(i) == prev) cnt++;
    else {
      if (cnt > 1) ans += cnt * (cnt - 1) / 2;
      cnt = 1;
      prev = s.at(i);
    }
  }
  if (cnt > 1) ans += cnt * (cnt - 1) / 2;
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 5760
package main

import (
	"fmt"
)

func main() {
	var n, t, c, d int
	fmt.Scanln(&n, &t)
	min := 1001
	for i := 0; i < n; i++ {
		fmt.Scanln(&c, &d)
		if d <= t && c < min {
			min = c
		}
	}
	if min == 1001 {
		fmt.Println("TLE")
	} else {
		fmt.Println(min)
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int m = 3, G[100];
int l=0;
unsigned long long int cnt = 0;
void isort(int a[], int n, int g){
  for(int i = g; i < n; i++){
    int v = a[i];
    int j = i - g;
    while(j >= 0 && a[j] > v){
      a[j + g] = a[j];
      j -= g;
      cnt++;
    }
    a[j + g] = v;
  }
}
void shellsort(int a[], int n){
  l=0;
  for(int i = 1; i <= n; i = i * m +1)G[l++] = i;
  for (int i = l; i >=0; i--) isort( a, n, G[i]);
}
int main(){
  int n, a[1000000];
  cin>>n;
  for(int i = 0; i < n; i++) cin>>a[i];
  shellsort(a,n);
  printf("%d\n",l);
  for(int i = l-1; i > 0; i--)printf("%d ", G[i]);
  printf("%d\n", G[0]);
  printf("%llu\n", cnt);
  for(int i = 0; i < n; i++)printf("%d\n", a[i]);
  return 0;
}



Measured memory_bytes: 7120
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main(){

  int N; cin >> N;
  vector <int> p(N);

  int cnt = 0;
  for (int i = 0; i < N; i++){
    cin >> p[i];
    if (p[i] != i + 1){
      cnt++;
    }
  }
  
  if (cnt <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  

  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
b = [-1] *N

for i in range((N+1)//2):
  b[i] = str(a[N-1-i*2])
for i in range(N //2):
  b[i+((N+1)//2)] = str(a[N%2 + 2*i])
print(" ".join(b))

Measured memory_bytes: 31940
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int H[] = new int[N];
        String result = "Yes";
        int count = 0;
        int min = 0;
        for (int i = 0; i< N; i++){
            H[i] = sc.nextInt();
            if (i == 0){
                min = H[0]-1;
            }else if (min <H[i]-1){

                min = H[i]-1;
            }
            if(H[i]<min){
                result = "No";
                break;
            }



//            if (i>0&&H[i-1] > H[i]){
//                if(count >0){
//                    result = "No";
//                    break;
//                }
//                count ++;
//            }
        }

        System.out.println(result);


    }
}


Measured memory_bytes: 50252
N = int(input())
 
A_list = [int(n) for n in input().split()]
 
import numpy as np
 
A_array = np.array(A_list)
sort_A = np.sort(A_array)

n_array = np.zeros(10**6)
  
for a in sort_A:
    
    if n_array[a - 1] >= 2:
        continue
        
    a_times = np.array(range(a, 10**6+1, a))
    
    n_array[(a_times -1).astype(int)] += 1

print((n_array[sort_A - 1] == 1).sum())

Measured memory_bytes: 99224
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    println(2 * Math.PI * n)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 34648
#include <stdio.h>
#include <math.h>

#define INF 10000000

int main(void)
{
    int n;
    int h[100010];
    int dp[100010] = {};
    int i;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        scanf("%d", &h[i]);
        dp[i] = INF; // 配列をINFで初期化(未探索にする)
    }

    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]); // absは絶対値を返す関数

    for (i = 2; i < n; i++) {
        int first = dp[i-1] + abs(h[i-1] - h[i]); //一つ前からの移動
        int second = dp[i-2] + abs(h[i-2] - h[i]); //2つ前からの移動
        if (first < second) { // コストの小さい方を採用する
            dp[i] = first;
        }
        else {
            dp[i] = second;
        }
    }

    printf("%d\n", dp[n-1]);

    return (0);
}

    


Measured memory_bytes: 896
import math
n = input()
for i in range(n):
  x1, y1, x2, y2, x3, y3 = map(float, raw_input().split())
  d1 = x1 * x1 + y1 * y1;
  d2 = x2 * x2 + y2 * y2;
  d3 = x3 * x3 + y3 * y3;
  u = 0.5 / ( x1 * y2 - x2 * y1 + x2 * y3 - x3 * y2 + x3 * y1 - x1 * y3)
  xp = u* (d1 * y2 - d2 * y1 + d2 * y3 - d3 * y2 + d3 * y1 - d1 * y3)
  yp = u * (x1 * d2 - x2 * d1 + x2 * d3 - x3 * d2 + x3 * d1 - x1 * d3)
  r = math.sqrt((xp - x1) * (xp - x1) + (yp - y1) * (yp - y1))
  print "%.3f %.3f %.3f" % (xp, yp, r)

Measured memory_bytes: 4412
import java.util.Scanner;

//Planning Rolling Blackouts
public class Main{

	int h, w, s, S;
	int[][] a, sum;
	int[][][][] group, rest;
	
	int get(int i, int j, int k, int l){
		return sum[k][l]-sum[i-1][l]-sum[k][j-1]+sum[i-1][j-1];
	}
	
	void dfs(int i, int j, int k, int l){
		if(group[i][j][k][l]!=-1)return;
		if(s<S-get(i, j, k, l))return;
//		if(group[i][j][k][l]<1){
			group[i][j][k][l] = 1;
			rest[i][j][k][l] = s-S+get(i, j, k, l);
//		}
//		else if(group[i][j][k][l]==1){
//			rest[i][j][k][l] = Math.max(rest[i][j][k][l], 0);
//		}
		for(int ni=i;ni<k;ni++){
			dfs(i, j, ni, l); dfs(ni+1, j, k, l);
			if(group[i][j][ni][l]==-1||group[ni+1][j][k][l]==-1)continue;
			if(group[i][j][k][l]<group[i][j][ni][l]+group[ni+1][j][k][l]){
				group[i][j][k][l] = group[i][j][ni][l]+group[ni+1][j][k][l];
				rest[i][j][k][l] = Math.min(rest[i][j][ni][l], rest[ni+1][j][k][l]);
			}
			else if(group[i][j][k][l]==group[i][j][ni][l]+group[ni+1][j][k][l])
				rest[i][j][k][l]=Math.max(rest[i][j][k][l], Math.min(rest[i][j][ni][l], rest[ni+1][j][k][l]));
		}
		for(int nj=j;nj<l;nj++){
			dfs(i, j, k, nj); dfs(i, nj+1, k, l);
			if(group[i][j][k][nj]==-1||group[i][nj+1][k][l]==-1)continue;
			if(group[i][j][k][l]<group[i][j][k][nj]+group[i][nj+1][k][l]){
				group[i][j][k][l] = group[i][j][k][nj]+group[i][nj+1][k][l];
				rest[i][j][k][l] = Math.min(rest[i][j][k][nj], rest[i][nj+1][k][l]);
			}
			else if(group[i][j][k][l]==group[i][j][k][nj]+group[i][nj+1][k][l])
				rest[i][j][k][l]=Math.max(rest[i][j][k][l], Math.min(rest[i][j][k][nj], rest[i][nj+1][k][l]));
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			h = sc.nextInt(); w = sc.nextInt(); s = sc.nextInt();
			if((h|w|s)==0)break;
			a = new int[h+1][w+1]; sum = new int[h+1][w+1];
			for(int i=1;i<=h;i++)for(int j=1;j<=w;j++){
				a[i][j] = sc.nextInt();
				sum[i][j] = sum[i-1][j] + sum[i][j-1] + a[i][j] - sum[i-1][j-1];
			}
			group = new int[h+1][w+1][h+1][w+1]; rest = new int[h+1][w+1][h+1][w+1];
			for(int i=0;i<=h;i++)for(int j=0;j<=w;j++)for(int k=0;k<=h;k++)for(int l=0;l<=w;l++)group[i][j][k][l]=rest[i][j][k][l]=-1;
			S = get(1, 1, h, w);
			dfs(1,1,h,w);
			System.out.println(group[1][1][h][w]+" "+rest[1][1][h][w]);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

using namespace std;

typedef long long ll;

const int maxn = 300100;
const int mod = 998244353;

int add(int a, int b) { return (a + b) % mod; }
int mult(int a, int b) { return ll(a) * b % mod; }
int exp(int b, int e) {
    if (!e) return 1;
    if (e & 1) return mult(b, exp(b, e-1));
    int res = exp(b, e >> 1);
    return mult(res, res);
}

int fact[maxn], invfact[maxn];

int C(int a, int b) {
    return mult(fact[a], mult(invfact[b], invfact[a-b]));
}

int n, a, b;
ll k;

int main() {
    cin >> n >> a >> b >> k;

    fact[0] = 1;
    for (int i = 1; i < maxn; i++) fact[i] = mult(fact[i-1], i);
    for (int i = 0; i < maxn; i++) invfact[i] = exp(fact[i], mod - 2);
    
    int ans = 0;
    for (int i = 0; i <= n; i++) { // num a
        ll tot = ll(a) * i;
        if ((k - tot) % b == 0) {
            ll j = (k - tot) / b;
            if (0 <= j && j <= n) ans = add(ans, mult(C(n, i), C(n, j)));
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <limits>
#include <map>
#include <set>
#include <vector>

using namespace std;

struct S
{
    int64_t x;
    int64_t y;
    int64_t h;

    S() {}

    S(int64_t x, int64_t y, int64_t h)
        : x(x)
        , y(y)
        , h(h)
    {
    }
};

bool validate(const vector<S>& ss, int64_t cy, int64_t cx, int64_t h)
{
    for (auto& s : ss)
    {
        int64_t expected_h = max<int64_t>(0, h - abs(cx - s.x) - abs(cy - s.y));
        if (expected_h != s.h)
        {
            return false;
        }
    }
    return true;
}

S solve(const vector<S>& ss)
{
    for (int64_t cx = 0; cx <= 100; cx++)
    {
        for (int64_t cy = 0; cy <= 100; cy++)
        {
            set<int64_t> height_set;
            for (auto& s : ss)
            {
                if (s.h > 0)
                {
                    const int64_t height = max<int64_t>(0, s.h + abs(cx - s.x) + abs(cy - s.y));
                    height_set.insert(height);
                }
            }

            if (height_set.size() == 1 && *height_set.begin() > 0 && validate(ss, cy, cx, *height_set.begin()))
            {
                return S(cx, cy, *height_set.begin());
            }
        }
    }
}

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

    vector<S> ss(n);
    for (auto& s : ss)
    {
        cin >> s.x >> s.y >> s.h;
    }

    auto s = solve(ss);
    cout << s.x << " " << s.y << " " << s.h << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

            var S = "ACABABAABABA";
            var cin = GetIntArray();
            var ans = YesNo(S[cin[0] - 1] == S[cin[1] - 1]);
            Console.WriteLine(ans);


            Console.Out.Flush();
            Console.ReadKey();
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public char GetChar() { return Console.ReadLine().Trim()[0]; }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public Double[] GetDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V,W>(out T a, out U b, out V c, out W d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
        }
        static void Multi<T, U, V, W,X>(out T a, out U b, out V c, out W d,out X e)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);e = cv<X>(ar[4]);
        }
    }
}

Measured memory_bytes: 11348
const main = (input) => {
  const inputs = input.trim();
  const match = inputs.match(/[ATCG]+/g);
  var ans = 0;
  for(var i=0;match&&i<match.length;i++){
    ans = Math.max(match[i].length, ans);
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


Measured memory_bytes: 7372
import sys
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
count = 0
for i in range(n):
  if x >= a[i]:
    x -= a[i]
    count += 1
    if i == n-1 and x > 0:
      print(count-1)
      sys.exit()
    elif i == n-1 and x == 0:
      print(count)
      sys.exit()
  else:
    print(count)
    sys.exit()

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

int main() {
    string s;cin>>s;
    int n = s.size();
    int cc = 0;
    rep(i,n){
        cc+=s[i]-'0';
    }
    if(cc%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,y,z;
	cin>>x>>y>>z;
	int s=0;x-=z;
	while((x-y-z)>=0)
	{
		s++;
		x=x-y-z;
	}
	cout<<s<<endl;
	return 0;
}

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

int main() {

    string s;

    cin >> s;

    vector<int> chCount(26, 0);
    int maxCount = 0;


    for(int i = s.size() - 1; i >= 0; --i) {
        chCount[s[i] - 'a']++;
    }
    string tempS = s;
    int answer = 999999999;
    for(int i = 0; i < 26; ++i) {

        if(chCount[i] == 0)
            continue;
        char ch = 'a' + i;

        int count = 0;
        s = tempS;
        while(1) {

            int index;
            for(index = 0; index < s.size() && s[index] == ch; ++index);

            if(index == s.size())
                break;

            string temp = "";
            for(int i = 0; i < s.size() - 1; ++i) {

                if(s[i] == ch || s[i + 1] == ch)
                    temp += ch;
                else
                    temp += s[i];

            }

            s = temp;

            count++;
        }

        answer = min(answer, count);

    }

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 3612
A, V = map(int,input().split())
B, W = map(int,input().split())
T = int(input())

if (A < B):
    D = B - A
    dv = T*V
    dw = T*W
    if(dv-dw >= D):
        print("YES")
    else:
        print("NO")
elif(A > B):
    D = A - B
    dv = T * V
    dw = T * W
    if (dv - dw >= D):
        print("YES")
    else:
        print("NO")
else:
    print("YES")


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

using namespace std;

int main () {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	//距離は不変
	const int dx = tx - sx, dy = ty - sy; 
	cout << string(dy, 'U') << string(dx, 'R'); 
	cout << string(dy, 'D') << string(dx, 'L');
	//2周目
	cout << string(1, 'L') << string(dy+1, 'U') << string(dx+1, 'R') << string(1, 'D');
	cout << string(1, 'R') << string(dy+1, 'D') << string(dx+1, 'L') << string(1, 'U') << endl;
	return 0;
}

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

bool f(string s){
    for(int i=0; i<s.size(); ++i){
        if(s[i]!='.'){return false;}
    }
    return true;
}

bool g(const vector<string> &s, int j){
    for(int i=0; i<s.size(); ++i){
        if(s[i][j]!='.'){return false;}
    }
    return true;
}

int main(){
    int h, w; cin >> h >> w;
    vector<string> s(h);
    vector<int> vi(h, 0), vj(w, 0);
    for(int i=0; i<h; ++i){cin >> s[i];}
    for(int i=0; i<h; ++i){
        string t = s[i]; //cout << t << "," << f(t) << endl;
        if(f(t)){vi[i]++;}
    }
    for(int i=0; i<w; ++i){
        if(g(s, i)){vj[i]++;}
    }
    for(int i=0; i<h; ++i){
      	if(vi[i]!=0){continue;}
        for(int j=0; j<w; ++j){
        	if(vj[j]!=0){continue;}
            cout << s[i][j];
        }
        cout << endl;
    }
    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int L = A + B;
  int R = C + D;
  
  if (L < R) {
    cout << "Right" <<endl;
  }
  
  else if (L>R) {
    cout << "Left" <<endl;
  }
  
  else if (L == R) {
    cout << "Balanced" <<endl;
  }
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
void plusle (int &a, int b) {
    if ((a += b) >= MOD ) a -= MOD;
}

void minun (int &a, int b) {
    if ((a -= b) < 0) a += MOD;
}
int add (int a, int b) {
    return ((a += b) >= MOD) ? a - MOD : a;
}
int sub (int a, int b) {
    return (( a -= b) < 0) ? a + MOD : a;
}
int mul (int a, int b) {
    return 1LL * a * b % MOD;
}
int power (int a, int b) {
    int res = 1;
    for (; b > 0 ; b >>= 1 , a = mul(a, a))
        if (b & 1) res = mul(res, a);
    return res ;
}


const int MX = 2e5 + 10;
int fac[MX], invf[MX] ;
void prefact () {
    fac[0] = 1 ;
    for (int i = 1 ; i < MX ; i ++) {
        fac[i] = mul(fac[i - 1], i);
    }
    invf[MX - 1] = power (fac[MX - 1], MOD - 2);
    for (int i = MX - 2 ; i >= 0 ; i --) {
        invf[i] = mul(invf[i + 1], i + 1);
    }
}

int ncr (int N, int R) {
    if (R > N) return 0;
    if (R == 0 || R == N) return 1;
    return mul (fac[N], mul(invf[N - R], invf[R]));
}



int s;

int main() {
    prefact();
    cin >> s;

    int ans = 0;

    for (int i = 1 ; i * 3 <= s ; ++ i) {
        int res = s - i * 3;
        ans = add(ans, ncr(res + i - 1, i - 1));
    }
    cout << ans << '\n';
}


Measured memory_bytes: 5192
from bisect import bisect_left
from bisect import bisect_right

n = int(input())
l = list(map(int,input().split()))

l.sort()

ll = []

for i in range(n):
    for j in range(i+1,n):
        ll.append(l[i]+l[j])

ll.sort()

ans = 0

for i in range(2,n):
    s = bisect_right(ll,l[i])
    ans += i*(i-1)//2 - s

print(ans)




Measured memory_bytes: 109068
'use strict'
function main(input) {
  input = input.trim().split('')
  let obj = {}
  for (let i = 0; i < 4; i++) {
    if (input[i] in obj) {
      obj[input[i]]++
    } else {
      obj[input[i]] = 1
    }
  }
  const ans = Object.keys(obj).length === 2 ? 'Yes' : 'No'
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 22076
#include <iostream>
#include <stack>

using namespace std;

static const int N = 100;
static const int White = 0;
static const int Gray = 1;
static const int Black = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

//按编号顺序获取与u相邻的v
int next(int u) {
    for (int v = nt[u]; v < n; v++) {
        nt[u] = v + 1;
        if (M[u][v]) return v;
    }
    return -1;
}

void dfs_visit (int r) {
    for (int i = 0; i < n; i++) {
        nt[i] = 0;
    }
    
    stack<int> S;
    S.push(r);
    color[r] = Gray;
    d[r] = ++tt;
    
    while(!S.empty()) {
        int u = S.top();
        int v = next(u);
        if (v != -1) {
            if (color[v] == White) {
                color[v] = Gray;
                d[v] = ++tt;
                S.push(v);
            }
        } else {
            S.pop();
            color[u] = Black;
            f[u] = ++tt;
        }
    }
    
}

void dfs() {
    for (int i = 0; i < n; i++) {
        color[i] = White;
        nt[i] = 0;
    }
    tt = 0;
    
    for (int u = 0; u < n; u++) {
        if (color[u] == White) dfs_visit(u);
    }
    for (int i = 0; i < n; i++) {
        cout <<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
    }
}

int main () {
    int u , k, v;
    cin >> n;
    for(int i = 0; i < n ; i++) {
        for (int j = 0; j < n; j++) {
            M[i][j] = 0;
        }
    }
    
    for (int i = 0; i < n; i++) {
        cin >> u>>k;
        u--;
        for(int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    
    dfs();
    
    return 0;
}
































Measured memory_bytes: 3116
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

Int A[200050], B[200050];

int main() {
  int N = in();
  Int K = lin();
  Int res = 0;
  for (int i = 0; i < N; ++i) {
    A[i] = lin();
    B[i] = lin();
    if ((A[i] | K) == K) {
      res += B[i];
    }
  }

  for (int b = 0; b <= 32; ++b) {
    Int s = 0;
    Int Ku = K & ~((1LL << b) - 1);
    if ((Ku & (1LL << b)) == 0) {
      continue;
    }
    Ku ^= (1LL << b);

    for (int i = 0; i < N; ++i) {
      if (A[i] == 0) {
        s += B[i];
        continue;
      }

      const Int Au = A[i] & ~((1LL << b) - 1);
      if ((Ku | Au) != Ku) {
        continue;
      }
      s += B[i];
    }
    chmax(res, s);
  }

  printf("%lld\n", res);

  return 0;
}


Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int dp[110][100010];

int main(){
  int n,W; cin >> n >> W;
  vector<int> w(n);
  vector<int> v(n);
  rep(i,n){
    cin >> v[i] >> w[i];
  }
  rep(i,n)rep(j,W+1){
    if(j+w[i]<=W) chmax(dp[i+1][j+w[i]],dp[i][j]+v[i]);
    chmax(dp[i+1][j],dp[i][j]);
  }
  int ans=0;
  rep(j,W+1){
    chmax(ans,dp[n][j]);
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 7440
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <vector>
using namespace std;

#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define FILLA(a, x) memset((a), (x), sizeof (a))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
#define COPYA(a, b) memcpy((b), (a), sizeof (a))

typedef unsigned long long lu;
typedef long long li;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;

inline int Add(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int Sub(int x) { return x < 0 ? x + mod : x; }
inline void Sub(int &x, int y) { x = Sub(x - y); }
inline int Mul(int x, int y) { return (int)((lu)x * y % mod); }
inline int Mul(int x, int y, int z) { return (int)((lu)x * y % mod * z % mod); }

int Pow(int x, int y) {
  int z = 1;
  for (; y; y >>= 1) {
    if (y & 1) z = Mul(z, x);
    x = Mul(x, x);
  }
  return z;
}

int Inv(int x) { return Pow(x, mod - 2); }
template <class T> inline void Max(T &x, T y) { if (y > x) x = y; }
template <class T> inline void Min(T &x, T y) { if (y < x) x = y; }

// ----------------------------------------

const int maxn = 3e5;
int n, p[maxn];

void Assert(bool x) {
  if (!x) {
    puts("No");
    exit(0);
  }
}

void Check(int l, int r) {
  Assert(r - l & 1);
  for (int i = l; i < r; ++i) {
    Assert((i - l & 1) == (i == p[i]));
  }
  vector<int> L, R;
  for (int i = l; i < r; ++i) {
    if (i < p[i]) L.push_back(p[i]);
    if (i > p[i]) R.push_back(p[i]);
  }
  for (int i = 1; i < L.size(); ++i) {
    Assert(L[i - 1] < L[i]);
  }
  for (int i = 1; i < R.size(); ++i) {
    Assert(R[i - 1] < R[i]);
  }

  int min_p = n, max_p = -1;
  for (int i = l; i < r; ++i) {
    Min(min_p, p[i]);
    Max(max_p, p[i]);
  }
  Assert(min_p == l && max_p == r - 1);
}

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", p + i);
    --p[i];
  }
  for (int i = 0; i < n; ) {
    if (i == p[i]) {
      ++i;
      continue;
    }
    int j = i + 1;
    while (j + 1 < n && (p[j] == j) && (p[j + 1] != j + 1)) {
      j += 2;
    }
    Check(i, j);
    i = j;
  }
  puts("Yes");
  return 0;
}


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

using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, ans;
ll cnt[1100000];
bool used[1100000];
int main() {
    cin >> n;
    vector<ll> s(n);
    REP(i, n){
        cin >> s[i];
        cnt[s[i]]++;
    }
    sort(ALL(s));
    REP(i, n){
        bool ok = true;
        if (cnt[s[i]] > 1) ok = false;
        else{
            for (ll j = 1; j <= sqrt(s[i]); j++) {
                if (s[i] % j == 0){
                    if(used[s[i] / j]) {
                        ok = false;
                        break;
                    }
                    if (used[j]) {
                        ok = false;
                        break;
                    }
                }
            }
        }
        used[s[i]] = true;
        if (ok) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 13592
#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>


using namespace std;


#define mod                1000000000000000007
#define pi                 3.1415926535897932384626433832795
#define ll                 long long
#define pb                 push_back
#define pii                pair < int , int >
#define vecsort(v)         sort(v.begin(),v.end())
#define lcm(x,y)           (x/__gcd(x,y))*y
#define forn(i,n)          for(i = 0 ; i < n ; i++)
#define deb(x)             cout << #x << " " << x << endl;
#define vecsum(v)          accumulate(v.begin(), v.end(), 0)
#define T(t)               cout << "Case " << t <<": ";
#define fast_cin           ios_base::sync_with_stdio(false);cin.tie(NULL)


bool seven( int n ){

      while( n ){

          if( n % 10 == 7 )return true;
          n/=10;
      }

      return false;
}

int main() {


    int n ;
    cin >> n ;
    if( seven( n ) == true ){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }





    return 0;
}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		for (int i = 0; i < n; i++) {
			int y = scan.nextInt();
			int m = scan.nextInt();
			int d = scan.nextInt();

			int days = 0;

			for (int j = y; j < 1000; j++) {
				if (j % 3 == 0) {
					days += 200;
				} else {
					days += 195;
				}
			}
			
			if(y%3==0){
				for(int j=1;j<m;j++){
					days -= 20;
				}
			}else{
				for(int j=1;j<m;j++){
					days -= 20;
					if(j%2==0)days += 1;
				}
			}
			days -= (d-1);
			System.out.println(days);
		}

		
		scan.close();
	}

}

Measured memory_bytes: 20732
#include <stdio.h>
#include <string.h>
int m[17][17];
int main()
{
  int a,b,n,i,j;
  for(;;){
    scanf("%d%d",&a,&b);
    if(a==0 && b == 0) break;
    memset(m,0,sizeof(m));
    scanf("%d",&n);
    while(n-->0){
      scanf("%d%d",&i,&j);
      m[i][j] = -1;
    }
    m[1][1] = 1;
    for(i=1;i<=a;i++){
      for(j=1;j<=b;j++){
	if(m[i][j] != -1){
	  if(m[i][j-1] != -1) m[i][j] += m[i][j-1];
	  if(m[i-1][j] != -1) m[i][j] += m[i-1][j];
	}
      }
    }
    printf("%d\n",m[a][b]);
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define int long long 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define ld long double
#define ub upper_bound
#define lb lower_bound
#define pii pair<int,int>
using namespace std;
signed main()
{
    fast;
    int h,w;
    cin>>h>>w;
    int cnt = 0;
    cin>>cnt;
    int ans = cnt/max(h,w) + (cnt%max(h,w)!=0);
    cout<<ans;
}   

Measured memory_bytes: 256
N = int(input())
Pi = list(map(int, input().split()))
count = 0
number_min = Pi[0]
for i in range(N):
    if i == 0:
        count += 1
    else:
        if Pi[i] <= number_min:
            count += 1
            number_min = Pi[i]
print(count)

Measured memory_bytes: 24744
(N, M, P), *ABCs = readlines.map{|l| l.split.map(&:to_i)}
INF = 1E10.to_i

g, to, from = [], Array.new(N + 1){[]}, Array.new(N + 1){[]}
ABCs.each do |a, b, c|
  g << [a, b, P - c]
  from[a] << b
  to[b] << a
end
f = ->(a, x){
  r = Array.new(N + 1, false); r[x] = true
  h = ->(y){a[y].reject{|z| r[z]}.each{|t| r[t] = true; h[t]}}
  h[x]; r
}
c = f[from, 1].zip(f[to, N]).map{|a, b| a && b}
g.select!{|a, b, _| c[a] && c[b]}
d = Array.new(N + 1, INF); d[1] = 0
c.count(true).times do
  f = false
  g.each do |a, b, e|
    if d[a] != INF && d[b] > (t = d[a] + e)
      d[b] = t
      f = true
    end
  end
  (puts [-d[N], 0].max; exit) unless f
end
puts -1

Measured memory_bytes: 14716
# from pprint import pprint
# import math
import collections

# n = int(input())
n, m = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = [None] * m
c = [None] * m
for i in range(m):
    _b, _c = map(int, input().split(' '))
    b[i] = _b
    c[i] = _c

# # リストに連結していって最後に大きい順に出力
# for j in range(m):
#     l = [c[j]] * b[j]
#     a.extend(l)


cnt = collections.Counter(a)

# カウンターのdictのみ更新
for j in range(m):
    cnt.update({c[j]: b[j]})

a_tup = cnt.items()

# print(a_tup)

# カウンターの結果を逆順にして合計n個になるまで取り出して加算
res = 0
num_cnt = 0
for _ in sorted(a_tup, reverse=True):
    res += _[0] * _[1]
    num_cnt += _[1]

    if num_cnt >= n:
        res -= _[0] * (num_cnt - n)
        break

print(res)


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

class UnionFind{
    vector<int> par;
    vector<int> rank;
    public:
    UnionFind(int n):par(n),rank(n){
        iota(par.begin(),par.end(),0);
    }
    int find(int x){
        if(par[x]==x) return x;
        else return par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x),y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]) par[x]=y;
        else{
            if(rank[x]==rank[y]) rank[x]++;
            par[y]=x;
        }
    }
};
using ll=long long;
const ll MOD=1e9+7;
ll powm(ll x,ll k){
    ll res=1;
    for(int i=0;i<k;i++) res=(res*x)%MOD;
    return res;
}
ll solve(int n,int m){
    UnionFind u(n);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        u.unite(a,b);
    }
    vector<int> cnt(n);
    for(int i=0;i<n;i++){
        cnt[u.find(i)]++;
    }
    int maxV=*max_element(cnt.begin(),cnt.end());
    if(maxV>=2){
        int rest=count(cnt.begin(),cnt.end(),1);
        int chunk=0;
        for(int i=0;i<n;i++) if(cnt[i]>1) chunk++;
        return (powm(2,rest)*powm(2,chunk)+1)%MOD;
    }
    else{
        return powm(2,n);
    }
}
int main(){
    int n,m;
    while(cin>>n>>m,n){
        cout<<solve(n,m)<<endl;
    }
}


Measured memory_bytes: 3996
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std; 
int a,b;
int main(){
    cin>>a>>b;
    int c=a*b-a-b+1;
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 998244353
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    if(s[0]>='A' && s[0]<='Z'){
    	cout<<"A";
	}
	else{
		cout<<"a";
	}
}

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

int main() {
    int A, B; cin >> A >> B;
    int ans = 0;
    for (int i = A; i <= B; i++)
    {
        string sa = to_string(i);
        string sa_rev = sa;
        reverse(sa_rev.begin(), sa_rev.end());
        if(sa == sa_rev) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    A = np.array(list(map(int, input().split())))
    B = np.array(list(map(int, input().split())))
    mod = 1
    ans = 0
    for bit in range(29):
        a_mod = A % (mod*2)
        b_mod = B % (mod*2)
        b_mod.sort()
        greater_or_equal_t = np.searchsorted(b_mod, mod-a_mod)
        less_2t = np.searchsorted(b_mod, 2*mod-a_mod)
        greater_or_equal_3t = np.searchsorted(b_mod, 3*mod-a_mod)
        less_4t = np.searchsorted(b_mod, 4*mod-a_mod)
        count = (less_2t - greater_or_equal_t + less_4t - greater_or_equal_3t).sum()
        if count % 2 == 1:
            ans += mod
        mod *= 2

    print(ans)


if __name__ == "__main__":
    main()

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    int n;
    cin >> n;
    set<int> st;
    int d;
    for (int i = 0; i < n; ++i) {
        cin >> d;
        st.insert(d);
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 256
N=int(input())
t,a=map(int,input().split())
for i in range(N-1):
    Ti,Ai=map(int,input().split())
    kt=(t+(Ti-1))//Ti;ka=(a+(Ai-1))//Ai
    k=max(kt,ka)
    t=k*Ti;a=k*Ai
print(t+a)

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

string a;
int x[100050], y[233333];

int main()
{
    cin >> a;
    int len = a.length();
    int ans1 = 0, ans2 = 0;
    for (int i = 1; i <= len; i++)
    {
        x[i] = i%2;
    }
    for (int i = 1; i <= len; i++)
    {
        y[i] = (i+1)%2;
    }
    for (int i = 0; i < len; i++)
    {
        if (a[i] - '0' != x[i+1])
            ans1++;
        if (a[i] - '0' != y[i+1])
            ans2++;
    }
    cout << min(ans1, ans2);
    system("pause");
    return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

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

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

int main() {
  int n;
  cin >> n;
  map<int,int> mp;
  vector<int> a(n);
  rep(i,n) {
    cin >> a[i];
    ++mp[a[i]];
  }
  int ans = 0;
  rep(i,1100000) {
    ans = max(ans,mp[i]+mp[i-1]+mp[i-2]);
    
  }
  cout << ans << endl;
  compute();
  return 0;
}


Measured memory_bytes: 52224
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner scan = new Scanner(System.in);

		double x1 = scan.nextDouble();
		double y1 = scan.nextDouble();
		double x2 = scan.nextDouble();
		double y2 = scan.nextDouble();
		scan.close();
		//Height????±???????
		double h = x1 - x2;
		//Width????±???????
		double w = y1 - y2;

		double result = Math.sqrt(Math.pow(h,2) + Math.pow(w,2));

		System.out.println( result);
	}

}

Measured memory_bytes: 18316
package main

import (
    "fmt"
    "sort"
)

func main() {
    var n int
    fmt.Scan(&n)

    cards := make([]int, n)
    for i := 0; i < n; i++ {
        fmt.Scan(&cards[i])
    }
    sort.Ints(cards)

    res := 0
    operator := 1
    for i := n - 1; i >= 0; i-- {
        res += cards[i] * operator
        operator *= -1
    }
    fmt.Println(res)
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  long result = 0;
  rep (i, N) {
    long l, r;
    cin >> l >> r;
    result += r - l + 1;
  }
  cout << result << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) {rep(i,x.size()) cout << x[i] << " "; cout << endl;}
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 2e5;

vector<int> z_algorithm(string &s) {
    vector<int> res(s.size());
    res[0] = s.size();
    int i = 1, j = 0;
    while (i < (int)s.size()) {
        while (i+j < (int)s.size() && s[j] == s[i+j]) j++;
        res[i] = j;

        if (j == 0) {
            i++;
            continue;
        }
        int k = 1;
        while (k < j && k + res[k] < j) {
            res[i+k] = res[k];
            k++;
        }
        i += k;
        j -= k;
    }
    return res;
}

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    rep(i,n) {
        string tmp = s.substr(i);
        vint x = z_algorithm(tmp);
        int mx = 0;
        rep(j,x.size()) {
            mx = max(mx,min(j,x[j]));
        }
        ans = max(ans,mx);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3688
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
       if(i%3==0){
           cout<<" "<<i;
       } 
       else if(i/1000==3){
           cout<<" "<<i;
       }
       else if((i%1000)/100==3){
           cout<<" "<<i;
       }
       else if((i%100)/10==3){
           cout<<" "<<i;
       }
       else if(i%10==3){
           cout<<" "<<i;
       }
    }
    cout<<endl;
}

Measured memory_bytes: 3100
// template {{{

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

#define loop(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) loop(i, 0, n)
#define rloop(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define rrep(i, n) rloop(i, 0, n)
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define all(c) std::begin(c), std::end(c)
#define mp std::make_pair
#define mt std::make_tuple
#define fi first
#define se second
#define popcnt __builtin_popcountll

using uint = std::uint32_t;
using ll = std::int64_t;
using ull = std::uint64_t;
using ld = long double;

template<typename T, size_t H, size_t W>
using matrix = std::array<std::array<T, W>, H>;

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

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

template<typename T>
inline T sq(T x){ return x * x; }

template<typename T, typename U>
inline bool chmax(T &x, U y){ if (x >= y) return false; x = y; return true; }

template<typename T, typename U>
inline void chmin(T &x, U y){ if (x <= y) return false; x = y; return true; }

template<typename T>
inline void sort(T &c){ std::sort(all(c)); }

template<typename T>
inline void reverse(T &c){ std::reverse(all(c)); }

template<typename T>
inline void unique(T &c){ sort(c); c.erase(std::unique(all(c)), std::end(c)); }

// }}}

int n, m;
int s[1000], d[1000];
vector<int> g[1000], rg[1000];
int cmp[1000];
bool used[1000];
vector<int> vs;
vector<int> h[1000];
int dp[1000];

void dfs(int v)
{
	used[v] = true;
	for (int to : g[v]){
		if (!used[to]) dfs(to);
	}
	vs.pb(v);
}

void rdfs(int v, int k)
{
	used[v] = true;
	cmp[v] = k;
	for (int to : rg[v]){
		if (!used[to]) rdfs(to, k);
	}
}

int scc()
{
	memset(used, 0, sizeof(used));
	rep(i, n){
		if (!used[i]) dfs(i);
	}

	memset(used, 0, sizeof(used));
	int k = 0;
	rrep(i, n){
		if (!used[vs[i]]) rdfs(vs[i], k++);
	}

	return k;
}

int main()
{
	cin >> n >> m;
	rep(i, m){
		cin >> s[i] >> d[i], s[i]--, d[i]--;
		g[s[i]].pb(d[i]);
		rg[d[i]].pb(s[i]);
	}
	
	int c = scc();
	
	rep(i, n){
		if (cmp[s[i]] == cmp[d[i]]) continue;
		assert(cmp[s[i]] < cmp[d[i]]);
		h[cmp[s[i]]].pb(cmp[d[i]]);
	}

	rep(i, c) unique(h[i]);
	
	int res = 1;
	rep(i, c) dp[i] = 1;
	rep(i, c){
		if (h[i].empty()){
			res = (ll)res * (1 + dp[i]) % MOD;
			continue;
		}
		for (int j : h[i]){
			dp[j] = (ll)dp[j] * (1 + dp[i]) % MOD;
		}
	}
	
	cout << res << endl;
}

Measured memory_bytes: 3308
#include<iostream>
#include<string>
using namespace std;
string A[80][80];
int cmp(string s,string d)
{
	if (s.length() > d.length())return 1;
	if (s.length() < d.length())return -1;

	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] > d[i])return 1;
		if (s[i] < d[i])return -1;
	}

	return 0;
}

bool isN(char ch)
{
	if (ch >= '0' && ch <= '9')return true;
	return false;
}
int main()
{
	int W, H;
	while (cin >> W >> H && W != 0 || H != 0)
	{
		char C[80][80];
		for (int i = 0; i < H; i++)
		{
			cin >> C[i];
		}
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				A[i][j] = C[i][j];
			}
		}
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				if (!isN(C[i][j]))continue;
				if (i - 1 >= 0 && isN(C[i - 1][j]))
				{
					string s = A[i - 1][j] + C[i][j];
					if (s[0] != '0' && cmp(s, A[i][j]) > 0)
					{
						A[i][j] = s;
					}
				}

				if (j - 1 >= 0 && isN(C[i][j - 1]))
				{
					string s = A[i][j - 1] + C[i][j];
					if (s[0] != '0' && cmp(s, A[i][j]) > 0)
					{
						A[i][j] = s;
					}
				}
			}
		}
		string max = "";
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				if (!isN(C[i][j]))continue;
				if (cmp(max, A[i][j]) < 0)
				{
					max = A[i][j];
				}
			}
		}
		cout << max << endl;
	}
	return 0;
}

Measured memory_bytes: 1392