akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
int N;
ll A, B;
ll x[100000];

int main() {
	cin >> N >> A >> B;
	rep(i, N) cin >> x[i];

	ll ret = 0;
	rep(i, N-1){
		ll d = x[i+1] - x[i];
		ret += min(d * A, B);
	}
	cout << ret << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> shop(n);
    for (auto &e: shop) cin >> e.first >> e.second;
    sort(shop.begin(), shop.end());

    ll c = m;
    ll ans = 0;
    for (auto &&e: shop) {
        ll b = min(e.second, c);
        ans += b * e.first;
        c -= b;
        if (c == 0) break;
    }

    cout << ans << endl;

    return 0;
}


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

int		main(void)
{
	int a, b, c, d;

	cin >> a >> b >> c >> d;
	if (a * b > c * d)
		cout << a * b << endl;
	else
		cout << c * d << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

        int N = Integer.parseInt(scanner.nextLine());
        String[] a = scanner.nextLine().split(" ");
        int[] array = new int[N];

        for (int i = 0; i < N; ++i) {
            array[i] = Integer.parseInt(a[i]) - (i + 1);
        }
        Arrays.sort(array);

        int c = array[N / 2];
        long sum = 0;
        for (int i = 0; i < N; ++i) {
            sum += Math.abs(array[i] - c);
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 55100
#include <stdio.h>

int main(){
	int A,B;
	
	scanf("%d%d",&A,&B);
	if (A == 1 && B == 2 || A == 2 && B == 1){
		printf("3");
	}
	if (A == 2 && B ==3 || A ==3 && B==2){
		printf("1");
	}
	if (A ==3 && B==1 || A ==1 && B==3 ){
		printf("2");
	}
	return 0;
}

Measured memory_bytes: 2024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 200011

struct Ball {
    ll x, y;
};

int n, i, p1, p2;
Ball B[maxN];
ll maxi, mini, ans;

vector< pair<ll, int> > ord;
vector<ll> pos;

ll same(vector<int> alrdn) {
    int i, pp;
    ll limit;
    ll act, ans;

    ord.clear();
    act = 0;
    limit = 1LL << 30;

    for (i = 1; i <= n; i++) {
        if (i == p1 || i == p2) continue;

        limit = min(limit, B[i].y);

        ord.pb(mp(B[i].x, i));
        act = max(act, B[i].x);

        pos.pb(B[i].x);
        pos.pb(B[i].y);
    }

    sort(ord.begin(), ord.end());
    sort(pos.begin(), pos.end());
    pos.resize(unique(pos.begin(), pos.end()) - pos.begin());

    pp = 0; ans = 1LL << 30;
    for (auto e : pos) {
        if (e > limit) continue;

        while (pp < ord.size()) {
            if (ord[pp].first >= e) break;
            act = max(act, B[ord[pp].second].y);
            pp++;
        }

        ll aux_max = act;
        for (auto e : alrdn) aux_max = max(aux_max, 1LL * e);
        ll aux_min = e;
        for (auto e : alrdn) aux_min = min(aux_min, 1LL * e);

        ans = min(ans, (aux_max - aux_min));
    }

    return ans;
}

ll diff() {
    ll min1, min2;
    ll max1, max2;
    int i;

    min1 = mini; max1 = B[p2].x;
    max2 = maxi; min2 = B[p1].y;

    for (i = 1; i <= n; i++) {
        if (i == p1 || i == p2) continue;

        max1 = max(max1, B[i].x);
        min2 = min(min2, B[i].y);
    }

    return (max1 - min1) * (max2 - min2);
}

int main()
{
   // freopen("test.in","r",stdin);

    maxi = 0;
    mini = 1LL << 50;

    scanf("%d", &n);
    for (i = 1; i <= n; i++) {
        scanf("%lld%lld", &B[i].x, &B[i].y);
        if (B[i].x > B[i].y) swap(B[i].x, B[i].y);

        mini = min(mini, B[i].x);
        maxi = max(maxi, B[i].y);
    }

    for (p1 = 1; B[p1].x != mini; p1++);
    for (p2 = 1; B[p2].y != maxi; p2++);

    if (p1 == p2) {
        ans = (maxi - mini) * same({});
    } else {
        ans = (maxi - mini) * same({B[p1].y, B[p2].x});
        ans = min(ans, diff());
    }

    printf("%lld", ans);

    return 0;
}


Measured memory_bytes: 13664
package main

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

var s = bufio.NewScanner(os.Stdin)
var w = bytes.Buffer{}

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

	s.Scan()
	n, _ := strconv.Atoi(s.Text())

	T := make(map[string]int)
	for i := 0; s.Scan() && i < n; i++ {
		cmd := s.Text()
		if cmd[0] == 'f' {
			s.Scan()
			if _, ok := T[s.Text()]; ok {
				w.WriteString("yes\n")
				continue
			}
			w.WriteString("no\n")
			continue
		}
		s.Scan()
		T[s.Text()] = 0
	}
	fmt.Println(strings.TrimRight(w.String(), "\n"))
}



Measured memory_bytes: 36884
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
#define int long long
const int MOD = 1000000007;
signed main(void){
    int n; cin>>n;
    string s,t; cin>>s>>t;
    vector <int> data(100); 
    int x = 0;
    rep(i,n){
        if(s[i] == t[i]) data[x++] = 1;
        else {
            data[x++] = 2;
            i++;
        }
    }
    
    int ans = 0;
    x =0;
    while(data[x]!= 0){
        if(x == 0){
            if(data[x] == 1) ans = 3;
            else ans = 6;
            x++; continue;
        }else{
            if(data[x] == 1){
                if(data[x-1] == 1) ans *= 2;
                else ans *= 1;
            }else{
                if(data[x-1] == 1) ans *= 2;
                else ans *= 3;
            }
            x++;
        }
        ans %= MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	int S;
	int h, m, s;

	std::cin >> S;

	h = S / 3600;
	S %= 3600;

	m = S / 60;
	S %= 60;

	s = S;

	std::cout << h << ":" << m << ":" << s << std::endl;

	return 0;
}

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int MAX = 1e6 + 10;
int d[MAX];
void pre() {
	for(int i = 1; i < MAX; i ++) {
		for(int j = i; j < MAX; j += i) d[j] ++;
	}
}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	pre();
	int n; cin >> n;
	ll ans = 0;
	for(int c = 1; c <= n; c ++) {
		ans += d[n - c];
	}
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 7532
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#define RG register
#define LL long long
using namespace std;
const int N=1e5+10;
const LL mod=1e9+7;
int n,fi[N];
LL ans=1,t[N],a[N],ri[N],maxx;
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
template<typename I>inline I mi(const I&a,const I&b){return a<b ? a : b;}
inline void endd(){printf("0\n"); exit(0);}
int main()
{
	//freopen("Two Alpinists.in","r",stdin);
	//freopen(".out","w",stdout);
	read(n);
	for(int i=1;i<=n;i++) read(t[i]);
	for(int i=1;i<=n;i++) read(a[i]);
	
	for(int i=1;i<=n;i++)
	{
		if(t[i]!=t[i-1])
		{
			ri[i]=t[i]; fi[i]=1; maxx=t[i];
		}
		else {
			ri[i]=maxx;
		}
	}
	
	for(int i=n;i;i--)
	{
		if(a[i]!=a[i+1])
		{
			if(fi[i])
			{
				if(a[i]!=t[i]) endd();
			}
			if(a[i]>ri[i]) endd();
			ri[i]=a[i]; fi[i]=1; maxx=a[i];
		}
		else {
			ri[i]=mi(ri[i],maxx);
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(fi[i]) continue ;
		(ans*=ri[i])%=mod;
	}
	printf("%lld\n",ans);
	//fclose(stdin); fclose(stdout);
	return 0;
}


Measured memory_bytes: 2944
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx - sx, ty - sy
print('U'*dy + 'R'*dx + 'D'*dy + 'L'*(dx+1) + 'U'*(dy+1) + 'R'*(dx+1) + 'D' + 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
main()
{
    long long int n,k;
    while(cin>>n>>k){

        long long int c = floor(n/k);
        long long int ans = c*c*c;
        if(k%2==0){

            long long int p = n+ floor(k/2);
             p = floor(p/k);
             ans  = ans + p*p*p;



        }

        cout<<ans<<endl;
    }
}


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

int main() {
  string s;
  cin >> s;
  vector<int> v(3);
  rep(i,s.size()) v[s[i]-'a']++;
  sort(v.begin(),v.end());
  cout << (v[2]-v[0]<2? "YES" : "NO") << endl;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>

using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

typedef long long ll;
typedef vector<vector<int> > Graph;

const int Mod = static_cast<int>(1e9 + 7);

int a[51], b[51], c[51], d[51];
int dp[51][11];

int main()
{
	ll a, b, n;
	cin >> a >> b >> n;
	if (n >= b - 1) {
		cout << floor(a * (b - 1) / b) << endl;
	}
	else {
		cout << floor(a * n / b) - a * floor(n / b) << endl;
	}
}


Measured memory_bytes: 3784
let rec f hs =
    let (_, l) = Array.fold_left (fun (st, cnt) h ->
        h > 0, if h > 0 && not st then cnt + 1 else cnt)
        (false, 0)
        hs in
    if l > 0
    then l + f (Array.map (fun n -> n - 1) hs)
    else l

let id x = x

let () = Scanf.scanf "%d\n" @@ fun n ->
    Array.init n (fun _ -> Scanf.scanf " %d" id)
    |> f |> Printf.printf "%d\n"


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
  static String S;

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

    S = sc.next();

    StringBuilder sb = new StringBuilder();
    sb.append(S.charAt(0));
    for(int i = 1; i < S.length(); i++){
      if(S.charAt(i - 1) != S.charAt(i)){
        sb.append(S.charAt(i));
      }
    }

    int ans = Math.max(0, sb.length() - 1);

    System.out.println(ans);
  }
}


Measured memory_bytes: 14016
#include <iostream>

#define INF 1e9 + 7;

int main(){
    int a, b, c, x, y;
    std::cin >> a >> b >> c >> x >> y;

//    1
//    x * a + y * b;
//
//    2
//    int z = std::min(x, y);
//    (x - z) * a + (y - z) * b + z * c;
//
//    3
//    std::max(x, y) * c;

    int ans = (int)INF; 
    for(int i = 0; i <= std::max(x, y) * 2; i += 2){
        ans = std::min(ans, std::max(0, x - i / 2) * a + std::max(0, y - i / 2) * b + i * c);
    }

    std::cout << ans << std::endl;

    return 0;
}

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

using namespace std;

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

  int sum = 0;
  int m = 0;
  for (int i = 0; i < N; i++) {
    sum += L + i;
    if (abs(L + i) < abs(L + m)) {
      m = i;
    }
  }

  cout << sum - (L + m) << endl;

  return 0;
}


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

int linersearch(int a[], int n, int x);
void insetrtionsort(int a[], int n);
void printarray(int n, int a[]);
void babblesort(int n, int a[]);
void selectionsort(int n, int a[]);

int linersearch(int a[], int n, int x)
{
    int ret = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] == x)
        {
            ret = 1;
            break;
        }
    }
    return ret;
}

void insetrtionsort(int a[], int n)
{
    int j, v;
    for (int i = 1; i < n; i++)
    {
        v = a[i];
        j = i - 1;
        while (j >= 0 && a[j] > v)
        {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        for (int i = 0; i < n; i++)
        {
            cout << a[i] << " ";
        }
        cout << endl;
    }
}

void babblesort(int n, int a[])
{
    int flag = 1;
    int counter = 0;
    int tmp;
    while (flag)
    {
        flag = 0;
        for (int j = n - 1; j > 0; j--)
        {
            if (a[j] < a[j - 1])
            {
                swap(a[j], a[j - 1]);
                counter++;
                flag = 1;
            }
        }
    }
    printarray(n, a);
    cout << counter << endl;
}

void selectionsort(int n, int a[])
{
    int minj;
    int counter = 0;
    for (int i = 0; i < n; i++)
    {
        minj = i;
        for (int j = i; j < n; j++)
        {
            if (a[j] < a[minj])
                minj = j;
        }
        if (i != minj)
        {
            swap(a[minj], a[i]);
            counter++;
        }
    }
    printarray(n, a);
    cout << counter << endl;
}

void printarray(int n, int a[])
{
    for (int i = 0; i < n; i++)
    {
        cout << a[i];
        if (i != n - 1)
            cout << " ";
    }
    cout << endl;
}

int gcd(int a, int b)
{
    if (a < b)
    {
        int t = a;
        a = b;
        b = t;
    }
    cout << a << " " << b << endl;
    if (b == 0)
        return a;
    else
        return gcd(b, b % a);
}

int main()
{
    int n, m, ans;
    ans = 0;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    cin >> m;
    int x;
    for (int i = 0; i < m; i++)
    {
        cin >> x;
    	ans += linersearch(a, n, x);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3136
n = int(input())

ans = 99999999999999999999
for i in range(1, n) :
    j = n-i

    a = str(i)
    b = str(j)

    sum = int(0)
    for k in a : 
        sum += int(k)
    for k in b :
        sum += int(k)

    ans = min(ans, sum)

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using namespace std;

int main() {
  ll n;
  cin >> n;
  ll ans = 0, Min = INF;
  bool f = 0;
  REP(i, n) {
    ll a, b;
    cin >> a >> b;
    f |= (a != b);
    Min = a > b ? min(Min, b) : Min;
    ans += a;
  }
  if (!f)
    return !printf("%d\n", 0);
  cout << ans - Min << endl;
}


Measured memory_bytes: 256
use std::cmp;
use std::io;
use std::io::prelude::*;

fn main() {
    let mut stdin = io::stdin();
    let mut buf = String::new();

    stdin.read_to_string(&mut buf).unwrap();

    let mut lines = buf.lines();
    let n: usize = lines.next().unwrap().parse().unwrap();
    let a: Vec<&str> = lines.next().unwrap().split_whitespace().collect();
    let a: Vec<i64> = a.iter().map(|x| x.parse().unwrap()).collect();
    
    let mut snuke: i64 = a[0];
    let mut arai: i64 = a[1..].iter().sum();

    let mut ans: i64 = (snuke - arai).abs();
    
    for val in a[1..n-1].iter() {
        snuke += *val;
        arai -= *val;
        ans = cmp::min(ans, (snuke - arai).abs());
    }
    println!("{}", ans);
}


Measured memory_bytes: 13040
#include<bits/stdc++.h>
using namespace std;
int n,m,q,a[55],b[55],c[55],d[55],slot[20],has,flag[15];
void f(int k,int las)
{
	if(k>n)
	{
		int now=0;
		//for(int i=1;i<=n;i++) cout<<slot[i]<<" ";
		for(int i=1;i<=q;i++)
		{
			if(slot[b[i]]-slot[a[i]]==c[i]) now+=d[i];
		}
		//cout<<" , now= "<<now<<endl<<"========"<<endl;
		has=max(has,now);
		return;
	}
	for(int i=las;i<=m;i++)
	{
		slot[k]=i;
		f(k+1,i);	
	}
}
int main()
{
	cin>>n>>m>>q;
	for(int i=1;i<=q;i++) cin>>a[i]>>b[i]>>c[i]>>d[i];
	f(1,1);
	cout<<has<<endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define retunr return
#define pb push_back
#define mp make_pair
#define null NULL
#define sc(x) scanf("%d", &x)
#define sc64(x) scanf("%I64d", &x)
#define pr(x) printf("%d", (x))
#define sp putchar(' ')
#define ln putchar('\n')
#define pr64(x) printf("%I64d", (x))
#define rep(i,l,r) for (int i = l, lim = r;i <= lim; ++i)
#define repr(i,l,r) for (int i = r, lim = l;i >= lim; --i)
#define fi first
#define se second
#define SET(__set, val) memset(__set, val, sizeof __set)
#define prf(x) printf("%.20f", x)
typedef unsigned int uint;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define N 100010
#define M 1024
#define MOD 1000000007
void _add(int &a, int b){a = (a+b)%MOD;}
void _sub(int &a, int b){a = (a+MOD-b)%MOD;}
void _mul(int &a, int b){a = (ll)a*b%MOD;}
void _max(int &a, int b){a = max(a,b);}
void _min(int &a, int b){a = min(a,b);}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b,a%b);}
ll pw(ll a, ll b){ll res(1);while(b){if(b&1)res=res*a%MOD;a=a*a%MOD;b>>=1;}return res;}
ll pwM(ll a, ll b, ll mod){ll res(1);while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

const int infi = 2147483647;
const ll infl = 9223372036854775807ll;
const db PI = 3.14159265358979323846;
struct hh
{
    int a,b;
    bool operator < (const hh &x)const{
        return b < x.b || b == x.b && a > x.a;
    }
}a[N];
int n,m;
int main(){
//	freopen("1","r",stdin);
    sc(n),sc(m);
    int res = 0;
    rep(i,1,m){
    	sc(a[i].a),sc(a[i].b);
    	a[i].b--;
    }
    sort(a+1,a+1+m);
    int r = -1;
    rep(i,1,m){
        if(r < a[i].a){
            r = a[i].b;
            res++;
        }
    }
    pr(res),ln;
	return 0;
}

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

int main(){
    vector<int> vec(5);
    for(int i = 0; i < vec.size(); i++){
        cin >> vec[i];
        if(vec[i]==0){
            cout << i+1 << endl;
        }
    }

}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t X, K, D;
  cin >> X >> K >> D;
  X = abs(X);
  int64_t dis = X / D;
  int64_t ans;
  if (dis > K) {
    ans = X - K*D;
  }
  else {
    if ((dis % 2) == (K % 2)) {
      ans = X % D;
    }
    else {
      ans = (X % D) - D;
    }
  }
  cout << abs(ans) << endl;
  
  return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
//#define rep(i, n) for(int (i) = 0, TmP = (n); (i) < (int)TmP ; ++(i))
//rep(i, v.size()) v[i]=i;
//#define int long long
#define asort(v, n) sort((v), (v + n)) //Using array
#define vsort(v) sort((v).begin(), (v).end()) // Using vector
#define vint vector<int>

using namespace std;

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

  int AC = 0, WA = 0;
  vector<bool> flag(N, false);
  vector<int> wa(105000);
  rep(i, M){
    int p;
    string S;
    cin >> p >> S;
    if(flag[p])continue;//Go to the end of rep;
    if(S == "AC"){
      flag[p] = true;
      AC++;
      WA += wa[p];
    }else if(S == "WA"){
      wa[p]++;
    }
    //if(S == "AC" && flag[p - 1] == false){
    //  flag[p - 1] = true;
    //  ac++;
    //}
    //if(S == "WA" && flag[p - 1] == false)wa++;
  }


  //rep(i, N){
    //if(flag[i] == true)ac++;
    //if(flag[i] == false)wa++;
  //}

  cout << AC << " " << WA << endl;
}


Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main() {
	string str;
	int count = 0;
	cin >> str;
	for (int i = 0; i < 3; i++) {
		if (str[i] == '1') {
			count++;
		}
	}
	printf("%d", count);

	return 0;
}

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

int main()
{
	ll n;cin>>n;
	ll x,y;
	ll d;cin>>d;
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		cin>>x>>y;
		if(x*x+y*y<=d*d)
		ans++;
	}
cout<<ans<<"\n";
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

class longint
{
// friend
	friend ostream& operator<< (ostream&, const longint&);
	friend istream& operator>> (istream&, longint&);

// variable
private:
	string m_data;

// structor

public:
	longint(const string& data = "0") :
		m_data(data)
	{

	}

// operator
public:
	longint operator+(const longint& rhs) const
	{
		string data1 = m_data;
		string data2 = rhs.m_data;
		reverse(data1.begin(), data1.end());
		reverse(data2.begin(), data2.end());

		string result;
		int carry = 0;
		for(unsigned int i = 0; i < data1.length() || i < data2.length(); i++)
		{
			int num1 = 0;
			int num2 = 0;
			if(i < data1.length())
				num1 = ctoi( data1[i] );
			if(i < data2.length())
				num2 = ctoi( data2[i] );

			int sum = num1 + num2 + carry;
			result.push_back( itoc( sum % 10) );
			carry = sum / 10;
		}

		if(carry > 0)
			result.push_back( itoc(carry) );

		reverse(result.begin(), result.end());
		return longint(result);
	}

// method
private:
	inline static int ctoi(char c)
	{
		if(c < '0' || '9' < c)
			throw exception();

		return c - '0';
	}

	inline static char itoc(int i)
	{
		if(i < 0 || 9 < i)
			throw exception();

		return '0' + i;
	}

public:
	inline unsigned int length() const
	{
		return m_data.length();
	}
};

ostream& operator<< (ostream& stream, const longint& rhs)
{
	stream << rhs.m_data;
	return stream;
}

istream& operator>> (istream& stream, longint& rhs)
{
	stream >> rhs.m_data;
	return stream;
}

int main()
{
	int n;
	cin >> n;
	while(n-- > 0)
	{
		longint a, b;
		cin >> a >> b;

		longint result = a + b;
		if(result.length() > 80)
			cout << "overflow" << endl;
		else
			cout << a + b << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
N = int(input())
#A = list(map(int, input().split()))

ans = [0 for _ in range(N)]
for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      k = (x+y)**2+(y+z)**2+(z+x)**2
      if k % 2 == 0 and k <= 2*N:
        ans[((x+y)**2+(y+z)**2+(z+x)**2)//2-1] += 1

for i in range(N):
  print(ans[i])

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

using namespace std;

main(){
  vector<int> vec(3);
  for(int i=0; i < 3;i++){
    cin>> vec[i];
  }
  sort(vec.begin(), vec.end());
  cout<<vec[0]+vec[1]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int *NOD = new int[10000000+50];
void numDiv(int x)
    {
    for(long i=1; i<= x ; i++)
        {
        for(long j=i; j<=x; j+=i)
            NOD[j] += 1;
        }
    }
int main()
    {
    long long  n;
    long long sum=0;;
    cin>>n;
    numDiv(n);
    for(long long i=1; i<=n; i++)
        {
        sum += i * NOD[i];
        }
    cout << sum << "\n";
    return 0;
    }


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


int main() {

  int sx;
  int sy;
  int INF = 999999;

  vector<vector<int>> count(21, vector<int>(21));
  vector<vector<int>> count_(21, vector<int>(21));

  deque<pair<int,int>> que;

  vector<int> dx = {0, 1, 0, -1};
  vector<int> dy = {1, 0, -1, 0};

  int H, W;
  cin >> H >> W;

  vector<string> S;
  S.resize(H);
  
  for (int i = 0; i < H; i++) {
    cin >> S[i];
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      count_[i][j] = INF;
    }
  }

  count = count_;

  int answer = 0;

  for (int j = 0; j < H; j++) {
    for (int k = 0; k < W; k++) {

      if (S[j][k] == '.') {

        sx = k;
        sy = j;
       
        que.clear();
        que.push_back(make_pair(sy, sx));
		
        count = count_;
        count[sy][sx] = 0;

        while (!que.empty()) {
          
          pair<int,int> p = que.front();
          que.pop_front();

          for (int i = 0; i < 4; i++) {
            
            int dx_ = p.second + dx[i];
            int dy_ = p.first + dy[i];
            
            if (0 <= dy_ && dy_ < H && 0 <= dx_ && dx_ < W && count[dy_][dx_] == INF && S[dy_][dx_] == '.'){
              count[dy_][dx_] = count[p.first][p.second] + 1;
              answer = max(answer, count[dy_][dx_]);
              que.push_back(make_pair(dy_, dx_));
            }
            
          }
          
        }
        
      }
      
    }
  }

  cout << answer << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<map>
#include <algorithm>
#include<cstdlib>
#include<cmath>
#include<deque>
#include <numeric>
typedef unsigned long long ull;
typedef  long long ll;

int main() {
	ll n;
	std::string X, U;

	std::cin >> n;
	double numS = 0.0;
	for(int i = 0; i < n; ++i)
	{
		std::cin >> X>> U;
		if (U[0] == 'J') {
			ll tmpx = std::stol(X);
			numS += (double)tmpx;
		}
		else {
			double tmpx = std::stod(X);
			numS += tmpx * 380000.0;
		}
	}
	std::cout << numS << std::endl;

	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
X = list(map(int, input().split()))

distance = float('inf')
for i in range(N-K+1):
    tmp_distance = abs(X[i]) + abs(X[i+K-1]-X[i])
    distance = min(distance, tmp_distance)
    tmp_distance = abs(X[i+K-1]) + abs(X[i+K-1]-X[i])
    distance = min(distance, tmp_distance)
print(distance)


Measured memory_bytes: 14224
#include <iostream>

using namespace std;

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

  double ret = 0;
  for (int i = 1; i <= n; i++) {
    double tmp = 1.0 / n;
    int now = i;
    while(now < k) {
      now *= 2;
      tmp /= 2;
    }
    ret += tmp;
  }

  printf("%.12f\n", ret);
}

Measured memory_bytes: 256
import itertools
import math
import statistics
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]


def cal(list, n):
    ret = 0
    for i in range(n-1):
        ret += math.sqrt(((list[i][0]-list[i+1][0])**2)+((list[i][1]-list[i+1][1])**2))
    return(ret)


ans = []
for l in list(itertools.permutations(xy)):
    ans.append(cal(l, N))
print(statistics.mean(ans))


Measured memory_bytes: 11788
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(ll a=0;a<b;++a)
#define REP(a,b,c,d) for(ll a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	int A,B; cin >> A >> B;
	
	if (B%A)cout << B - A << endl;
	else cout << A + B << endl;
}

Measured memory_bytes: 256
fn main() {
    let (n, m) = read_tuple::<usize>();
    let mut bulbs: Vec<Vec<usize>> = Vec::new();
    for _ in 0..m {
        let mut temp = read_vec();
        temp.remove(0);
        bulbs.push(temp);
    }
    let pm: Vec<i32> = read_vec();

    let mut switches = vec![vec![]; n];
    for (i, bulb) in bulbs.iter().enumerate() {
        for s in bulb.iter() {
            switches[s - 1].push(i);
        }
    }


    let mut ans = 0;
    for i in 0..(1<<n) {
        let mut counter = vec![0; m];
        for j in 0..n {
            if i & (1 << j) == (1 << j) {
                for &s in switches[j].iter() {
                    counter[s] = (counter[s] + 1) % 2;
                }
            }
        }

        if pm == counter {
            ans += 1;
        }
    }

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

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

fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let temp = read_vec();
    (temp[0], temp[1])
}


Measured memory_bytes: 4352
/*
sonu_verma1
*/
#include <bits/stdc++.h>
// For policy based data structure
/*#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> */
using namespace std;
/*using namespace __gnu_pbds; 
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set;*/
 
#define MD 1000000007
#define X first
#define Y second
#define pb push_back
#define debug(val, ch) cout <<val <<ch
#define FOR(i, st, en, ch) for(register int i = (st); i <= (en) ; i += (ch))
#define RFOR(i, st, en, ch) for(register int i = (st); i >= (en) ; i -= (ch))
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
 
typedef long long int ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<int, bool> pib;
typedef pair<bool, int> pbi;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
/*********************************************************************/
void test(int r)
{
	int k,a,b;
	cin>>k>>a>>b;
	if((b/k)*k>=a)
		cout<<"OK";
	else
		cout<<"NG";

}
/***********************************************************************/
int main()
{
	fast();
    int t=1,r;
    // cin>>t;
    for(r=1;r<=t;r++)
        test(r);
    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <map>

using namespace std;

int main(int argc, char* argv[])
{
  int N; cin >> N;

  map<string, int> blue;
  for (int i = 0; i < N; i++) {
    string s; cin >> s;
    if (blue.find(s) == blue.end()) {
      blue[s] = 1;
    } else {
      blue[s]++;
    }
  }

  int M; cin >> M;

  for (int i = 0; i < M; i++) {
    string s; cin >> s;
    if (blue.find(s) != blue.end()) {
      blue[s]--;
    }
  }

  int cnt = 0;
  for (auto it = blue.begin(); it != blue.end(); it++) {
    cnt = max(cnt, it->second);
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 764
while True:
    n, x = map(int, raw_input().split())
    if (n+x) == 0:
        break

    comb = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            c = i + j
            tmp = x - c
            if (tmp <= n) & (tmp > j):
                comb += 1

    print comb

Measured memory_bytes: 6408
fun main(args: Array<String>) {

    /**
     * 累乗の計算
     * a^n mod を計算する
     */
    fun pow(a: Long, b: Long, mod: Int): Long {
        var at = a
        var bt = b
        var ret: Long = 1
        while (bt > 0) {
            if (bt and 1 == 1L) {
                ret = ret * at % mod
            }
            at = at * at % mod
            bt = bt shr 1
        }
        return ret
    }


    /**
     * 組み合わせ
     */
    fun nCk(n: Int, k: Int, mod: Int): Int {
        var ret: Long = 1
        val min = Math.min(k, n - k)
        for (i in 1..min) {
            ret = ret * pow(i.toLong(), (mod - 2).toLong(), mod) % mod
        }
        for (i in n - min + 1..n) {
            ret = ret * i % mod
        }
        return ret.toInt()
    }

    val MOD = 1000000007

    val (x, y) = readLine()!!.split(" ").map(String::toInt)

    val totalMove = (x + y) / 3
    val xCount = x - totalMove
    val yCount = y - totalMove

    if ((x + y) % 3 != 0 || xCount < 0 || yCount < 0) {
        println(0)
        return
    }


    println(nCk(totalMove, xCount, MOD) % MOD)

}




Measured memory_bytes: 37896
using System;
using System.Linq;
class MainClass {
  public static void Main (string[] args) {
    long[] inputs = Console.ReadLine().Split(' ').Select<string,long>(long.Parse).ToArray();
    long N = inputs[0];
    long X = inputs[1];
    long T = inputs[2];
    long M = 0;
    while(N > 0){
      N-= X;
      M+= T;
    }

    Console.WriteLine(M);
  }
}

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

int main() {
    int N, M; cin >> N >> M;
    vector<vector<long>> AB(N, vector<long>(2));
    long long ans = 0;
    int num = 0;

    for (int i = 0; i < N; ++i) {
        cin >> AB[i][0] >> AB[i][1];
    }

    sort(AB.begin(), AB.end());
    for (int j = 0; num!=M ; ++j) {
        if(num+AB[j][1]>M){
            ans += AB[j][0]*(M-num);
            num += M-num;
        } else {
            num += AB[j][1];
            ans += AB[j][0]*AB[j][1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int a,b,n;
cin >> n >> a >> b;
if(a>b || (n==1 && a!=b)) puts("0");
else if(n==1 && a==b) puts("1");
else {
int div = b-a+1;
   cout << (n-2)*(b-a)+1 << endl;
}

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using tiii = tuple<int,int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const ll DIV =1e9+7;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
#define chmax(a,b) a=max(a,b)

/*Coding Space*/
int main(){
  int m,k; cin >> m >> k;
  if(k == 1 && m == 1){cout << -1 << endl; return 0;}
  if(k == 0 && m == 0){cout << "0 0" << endl; return 0;}
  if(k == 0 && m == 1){cout << "0 0 1 1" << endl; return 0;}
  int tar = 1; tar <<= m;
  cerr << k << ' ' << tar<< endl;
  if(k >= tar){cout << -1 << endl; return 0;}
  
  vector<int> ans;

  if(k == 0){
    rep(i,tar) cout << i << ' ';
    rep(i,tar) cout << tar - i - 1 << (tar-i-1 == 0? '\n': ' ');
    return 0;
  }

  ans.pb(0);
  ans.pb(k);
  ans.pb(0);
  rep(i,tar-1) if(i+1!=k)ans.pb(i+1);
  ans.pb(k);
  rep(i,tar-1) if(tar-i-1!=k)ans.pb(tar - i - 1);
  rep(i, ans.size()) cout << ans[i] << (i == int(ans.size()-1)?'\n':' ');
}


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

int main(int argc, char *argv[])
{
  int i, num, i_max, i_min;
  double i_sum;
  int *pdata;

  scanf("%d", &num);

  pdata = (int *)malloc(sizeof(int) * num);

  for (i = 0; i < num; i++) {
    scanf ("%d", &pdata[i]);
  }

  for (i = 0, i_max = i_min = pdata[0], i_sum = 0; i < num; i++) {
    i_max = i_max > pdata[i] ? i_max : pdata[i];
    i_min = i_min < pdata[i] ? i_min : pdata[i];
    i_sum += pdata[i];
  }
  
  printf("%d %d %0.0f\n", i_min, i_max, i_sum);

  free(pdata);

  return 0;
}

Measured memory_bytes: 668
#include<bits/stdc++.h>
#define rep(i, x, n) for(int i = x; i < n; i++)
#define repr(i, x, n) for(int i = x; i > n; i--)
#define pii pair<int,int>
#define ll long long
const long long iinf = 1e18;
const int inf = 1e9;
const int MOD = (1e6+3);
int dir4[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};
int knight[8][2] = {{2,1},{2,-1},{-2,1},{-2,-1},{1,2},{-1,2},{1,-2},{-1,-2}};

using namespace std;

void solve()
{
    int n; cin >> n;
    long long cnt[100010] = {0};
    long long a[n+1];
    long long sum = 0;
    for(int i = 0; i < n; i++){cin >> a[i]; sum += a[i]; cnt[a[i]]++;}
    int q; cin >> q;
    for(int i = 1; i <= q; i++){
        long long b, c;
        cin >> b >> c;
        sum -= (b*cnt[b]);
        sum += (cnt[b]*c);
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << "\n";
    }
    
    
}
//new line is printed in main()

int main()
{
    int t = 1;
        // cin >> t; // comment out if no test case is required
    int i = 1;
    while(t--){
        //cout << "Case " << i++ << ": ";
        solve();
        // printf("\n");
    }
    return 0;
}


Measured memory_bytes: 5200
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = int(input())
S = input()
ans = -1
for i in range(1,N):
    a = S[:i]
    b = S[i:]
    seta = set(list(a))
    tmp = 0
    for sa in seta:
        if sa in b:
            tmp += 1
    ans = max(tmp,ans)
print(ans)


Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int func(int x,int d){
  int cnt=0,w=1;
  while(w<=d){
    w=w+x;
    cnt++;
  }
  return cnt;
}
int main(){
  int n,d,x;
  cin>>n>>d>>x;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  int ans=0;
  rep(i,n)ans=ans+func(a[i],d);
  cout<<ans+x<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
 
int main(void)
{
    int n, k;
    cin >> n >> k;
    
    if(n % k == 0){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
n, h, *A = map(int, open(0).read().split())
a = max(A[::2])
b = sorted(A[1::2])[::-1]
for i in range(n):
    if h <= 0:
        n = i
        h = 0
        break
    if b[i] < a:
        n = i
        break
    h -= b[i]
print(n - (-h // a))


Measured memory_bytes: 31784
import sys
from math import floor, sqrt, log

x = int(sys.stdin.readline().rstrip())

def main():
    res = [1]
    for b in range(2, x+1):
        p = 2
        while b ** p <= x:
            res.append(b ** p)
            p += 1
    return max(res)

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3060
import java.io.IOException;
import java.io.InputStream;
import java.text.DecimalFormat;
import java.util.NoSuchElementException;

public class Main {
	static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int q = sc.nextInt();
		
		StringBuilder ans = new StringBuilder();
		for(int i=0; i<q; i++) {
			double x0 = sc.nextDouble();
			double y0 = sc.nextDouble();
			double x1 = sc.nextDouble();
			double y1 = sc.nextDouble();
			double x2 = sc.nextDouble();
			double y2 = sc.nextDouble();
			double x3 = sc.nextDouble();
			double y3 = sc.nextDouble();
			
			double a1 = (y1 - y0) / (x1 - x0);
			double a2 = (y3 - y2) / (x3 - x2);
			double b1 = y0 - a1 * x0;
			double b2 = y2 - a2 * x2;
			
			double x;
			double y;
			if(x1 == x0) {
				x = x0;
				y = a2 * x + b2;
			} else if(x3 == x2) {
				x = x2;
				y = a1 * x + b1;
			} else {
				x = (b1 - b2)/(a2 - a1);
				y = a1 * x + b1;
			}
			DecimalFormat df = new DecimalFormat("0.00000000");
			ans.append(df.format(x));
			ans.append(" ");
			ans.append(df.format(y));
			ans.append("\n");
		}
		System.out.print(ans);
	}

	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 37636
#include <iostream>

using namespace std;

int x, y;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	while (true) {
		cin >> x >> y;
		if (x == 0 && y == 0)	break;
		if (x > y) {
			swap(x, y);
		}
		cout << x << " " << y << "\n";
	}

	return 0;
}

Measured memory_bytes: 3124
#include "bits/stdc++.h"
using namespace std;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
#define pii pair<int, int>
const int N = 25;
string s[N];
int vis[N][N], d[N][N];
int n, m;

int dx[]={-1,0,0,1};
int dy[]={0,-1,1,0};
int check(int x, int y) {
	return x>=0 && x<n && y>=0 && y<m;
}
void bfs(int sx, int sy) {
	queue<pii> q;
	q.push({sx, sy});
	vis[sx][sy]=1;
	d[sx][sy]=0;
	while(!q.empty()) {
		int a=q.front().first, b=q.front().second;
		q.pop();
		for(int i=0;i<4;++i) {
			int x=a+dx[i], y=b+dy[i];
			if(check(x, y) && !vis[x][y] && s[x][y]=='.') {
				vis[x][y]=1;
				d[x][y] = d[a][b] + 1;
				q.push({x, y});
			}
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	int a,b,T,cas=0;
	cin>>n>>m;
	for(int i=0;i<n;++i) cin>>s[i];

	int mx = 0;
	for(int i=0;i<n;++i) {
		for(int j=0;j<m;++j) {
			if(s[i][j]=='#') continue;
			for(int k=0;k<n;++k) {
				for(int t=0;t<m;++t) vis[k][t]=0, d[k][t]=-1;
			}
			bfs(i, j);
			for(int k=0;k<n;++k) {
				for(int t=0;t<m;++t) {
					if(d[k][t]!=-1) mx = max(mx, d[k][t]);
				}
			}
		}
	}
	cout<<mx;
	return 0;
}

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

using namespace std;

int main()
{
	int a, b, c, num_div = 0;
	vector<int> v;
	set<int> s;
	
	scanf("%d %d %d", &a, &b, &c);
	
	for(int i = a; i <= b; i++)
		v.push_back(i);
	
	for(int i = 1; i <= sqrt(c); i++)
	{
		if(c % i == 0)
		{
			if(c / i == i)
				s.insert(i);
			else
			{
				s.insert(i);
				s.insert(c/i);
			}
		}
	}
	
	vector<int>::iterator it;
	
	for(it = v.begin(); it != v.end(); it++)
		if(s.count(*it))
			num_div++;
	
	printf("%d\n", num_div);
	
	return 0;
}


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

using namespace std;

#define reps(i, n, m) for (int i = (int) (n); i < (int) (m); i++)
#define rep(i, n) reps(i, 0, (n))
#define all(v) (v).begin(), (v).end()

int main() {
    set<int> a, b, c;
    int n; cin >> n;
    while (n--) {
        int x; cin >> x; a.insert(x);
    }
    int m; cin >> m;
    while (m--) {
        int x; cin >> x; b.insert(x);
    }
    set_union(all(a), all(b), inserter(c, c.begin()));
    for (auto& x : c) {
        cout << x << endl;
    }
}


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

int rt[200000];

int main(){
	ios::sync_with_stdio(false);
	int n;
	int i , j;
	int max,min;
	cin>>n;
	max=0x80000000;
	for(i=0 ; i<n ; i++){
		cin>>rt[i];
	}
	min=rt[0];
	for(i=1 ; i<n ; i++){
		if((rt[i]-min)>max){
			max=rt[i]-min;
		}
		if((rt[i])<min){
			min=rt[i];
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 1976
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  int h,w; cin >> h >> w;
  char ans[h+2][w+2];
  for(int i = 0; i < h+2; i++){
    for(int j = 0; j < w+2; j++){
      ans[i][j] = '#';
    }
  }
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> ans[i+1][j+1];
    }
  }
  for(int i = 0; i < h+2; i++){
    for(int j = 0; j < w+2; j++){
      cout << ans[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#define ll long long 
#include <string>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
#define mod 1000000007
using namespace std;
int main()
{ 
	 #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    string s,t;
    cin>>s>>t;
    ll int m=1e9;
    ll int i,j;
    for(i=0;i<s.size()-t.size()+1;i++)
    {
    	ll int c=0;
    	string sb=s.substr(i,t.size());
    	for(j=0;j<t.size();j++)
    	{
    		if (s[i+j]!=t[j])
    			c++;
    	}
    	m=min(m,c);

    }
    cout<<m<<endl;



    	

}

	
		
	
	
	
	





Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int n , m;

void solve()
{
	string s;
	cin >> s;
	if(s[(int)s.length() - 1] != 's')s += 's';
	else s += 'e' , s += 's';

	cout << s;
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 3648