akhauriyash/Code-Regression huggingface dataset:
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
      String[]s=line.split(" ",0);
      int n=s.length;
      int num[]=new int[n];
      for(int i=0;i<n;i++){
        num[i]=Integer.parseInt(s[i]);
      }
      Arrays.sort(num);
      int ans=0;
      for(int i=0;i<n-1;i++){
      	ans+=num[i+1]-num[i];
      }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] line = br.readLine().split(" ");
      int buf = 0;
      Stack stack = new Stack(line.length);

      for (String s : line) {
        switch(s) {
          case "+" :
            buf += stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "-" :
            buf -= stack.pop();
            buf += stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          case "*" :
            buf  = stack.pop();
            buf *= stack.pop();
            stack.push(buf);
            buf = 0;
            break;

          default :
            stack.push(Integer.parseInt(s));
            break;
        }
      }

      while(!stack.isEmpty())
        buf += stack.pop();
      
      System.out.println(buf);
    }
  }
}

class Stack {
  int[] stack;
  int ite;

  public Stack(int capacity) {
    stack = new int[capacity];
    ite = 0;
  }

  public void initialize() {
    ite = 0;
  }

  public int getIte() {
    return ite;
  }

  public boolean isEmpty() {
    return ite == 0;
  }

  public boolean isFull() {
    return ite >= stack.length-1;
  }

  public  boolean push(int x) {
    if(isFull()) return false;

    stack[++ite] = x;
    return true;
  }

  public int pop() {
    if(isEmpty()) return 0;

    return stack[ite--];

  }
}


Measured memory_bytes: 24312
#include<bits/stdc++.h>
using namespace std;
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    std::cout<<std::setprecision(10);
    std::cout<<std::fixed;
    int n;
    cin>>n;
    double dp[n+1][n+1];
  
         for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++)dp[i][j]=0;
            
    }

dp[0][0]=1;
    double p[n+1];
    for(int i=1; i<=n;i++)cin>>p[i];
        double t1,t2;

    for(int  i=1;i<=n;i++){
        dp[0][i]=dp[0][i-1]*(1-p[i]);
        for(int j=1;j<=i;j++){
            t1=dp[j-1][i-1]*p[i];
            t2=dp[j][i-1]*(1-p[i]);
            dp[j][i]=t1+t2;
        }       
    }

  double ans=0;
    for(int i=(n+1)/2;i<=n;i++)ans+=dp[i][n];
    cout<<ans;

    return 0;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int arr[n+10]={0};
	for(int i=1;i<n;i++)
	{
		int a;
		cin >> a;
		arr[a]++;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<arr[i]<<'\n';
	}
	return 0; 
} 

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

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

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin>>n;
    vl A(n);
    rep(i,n)cin>>A[i];
    ll res=0;
    rep(i,n-2){
        if(max({A[i],A[i+1],A[i+2]})!=A[i+1]&&min({A[i],A[i+1],A[i+2]})!=A[i+1])res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3640
import itertools

n = int(input())
ans = 0
for i in range(3,len(str(n))+1):
    for tuple357 in itertools.product([3,5,7], repeat=i):
        if len(set(tuple357)) < 3:
            continue
        number = int(''.join(map(str,tuple357)))
        if number <= n:
            ans += 1

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<char>> C(H, vector<char>(W));
    rep(0, i, H)
    {
        rep(0, j, W)
        {
            cin >> C.at(i).at(j);
        }
    }

    rep(0, i, 2 * H)
    {
        rep(0, j, W)
        {
            cout << C.at(i / 2).at(j);
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, m;
        cin >> n >> m;
        if(n == 0)
            return 0;

        vector<int> p(n);
        for(int i=0; i<n; ++i)
            cin >> p[i];
        sort(p.rbegin(), p.rend());

        for(int i=m-1; i<n; i+=m)
            p[i] = 0;
        cout << accumulate(p.begin(), p.end(), 0) << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

ll gcd(ll a,ll b){
	if (a%b==0) return(b);
	else return(gcd(b,a%b));
}

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

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

    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll ans=a[0];
    for(int i=1;i<n;i++){
        ans=gcd(ans,a[i]);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 4056
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

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

    int H,W;
    cin >> H >> W;
    char a[100][100];
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> a[i][j];
        }
    }

    bool h[100] = {};
    for(int i=0; i<H; i++){
        bool tmp = true;
        for(int j=0; j<W; j++){
            tmp = tmp && (a[i][j] == '.');
        }
        if(tmp) h[i] = true;
    }
    bool w[100] = {};
    for(int i=0; i<W; i++){
        bool tmp = true;
        for(int j=0; j<H; j++){
            tmp = tmp && (a[j][i] == '.');
        }
        if(tmp) w[i] = true;
    }

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(h[i] == false && w[j] == false) cout << a[i][j];
        }
        cout << endl;
    }
    
    return 0;
}


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

unsigned long long N, X, a, b, t, r, ans;

int main() {
	scanf("%llu %llu", &N, &X);
    ans += N;
    a = X, b = N - X;
    while (1) {
        t = 2 * (a / b);
        r = a%b;
        ans += b*t;
        if (r == 0) {
            ans -= b;
            break;
        }
        a = b;
        b = r;
    }
    printf("%llu\n",ans);
    return 0;
}

Measured memory_bytes: 128
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Tree = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n;
	cin >> n;
	Vec h(n);
	rep(i, n) cin >> h[i];

	Vec dp(n, LINF);
	dp[0] =0;
	repn(i, n-1){
		chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
		if(i >= 2) chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
	}
	co(dp[n-1]);

	return 0;
}


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

using namespace std;

const int MaxN = 1 << 18;
 
int n;  
int a[MaxN];
pair<int, int> f[MaxN];

void Update(int x, int Val)
{
    if (f[x].second <= Val)
    {
        f[x].second = Val;
    }
    if (f[x].first < f[x].second)
    {
        swap(f[x].first, f[x].second);
    }
}

int GetBit(int num, int pos)
{
    return (num >> pos) & 1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    int Pow2_n = (1 << n);
    for (int i = 0; i < Pow2_n; i++)
    {
        cin >> a[i];
        Update(i, a[i]);
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < Pow2_n; j++)
        {
            if (GetBit(j, i))
            {
                Update(j, f[j ^ (1 << i)].first);
                Update(j, f[j ^ (1 << i)].second);
            }
        }
    }
    int Ans = 0;
    for (int i = 1; i < Pow2_n; i++)
    {
        Ans = max(Ans, f[i].first + f[i].second);
        cout << Ans << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 6272
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;



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

int A = 0, B = 0, K = 0, T = 0, W = 0, N = 0, H = 0;
int n = 0;
double L = 0;
double S = 0;
double ar = 0, br = 0, cr = 0;
int answer = 0;

string C;
string sA, strB;
vector<vector<char>> map;
vector<double> num;
vector<string> str;

int sum = 0;

vector<int> value;
vector<int> weight;

int dp[110][10010];

int data_[210][2] = { -2 };

void input(void) {
	CI C;
	return;
}


int main(void) {
	input();
	reverse(C.begin(), C.end());
	
	CO C E


	return 0;
}

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

using namespace std;

int main(void){
    
    int n, q;
    cin >> n >> q;
    
    string s;
    cin >> s;
    
    vector<int> numberOfAC(n+1);
    
    for (int i = 1; i < n; i++){
        numberOfAC[i] = numberOfAC[i-1];
        if (s[i-1] == 'A' && s[i] == 'C') numberOfAC[i]++;
    }
    
    for (int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        l--,r--;
        cout << numberOfAC[r] - numberOfAC[l] << endl;
    }
    return 0;
}


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;


int main(){
  int N;
  cin >> N;
  vector<vector<int>> A(N, vector<int>(N-1));
  REP(i, N){
    REP(j, N-1){
      cin >> A[i][j];
      A[i][j]--;
    }
    reverse(A[i].begin(), A[i].end());
  }
  vector<pair<int, int>> que;
  auto check = [&](int i){
    if(A[i].size() == 0) return;
    int x = A[i].back();
    if(A[x].back() == i){
      pair<int, int> match = {i, x};
      if(match.second < match.first) swap(match.first, match.second);
      que.push_back(match);
    }
  };
  REP(i, N){
    check(i);
  }
  int day = 0;
  while(que.size()){
    day++;
    sort(que.begin(), que.end());
    que.erase(unique(que.begin(), que.end()), que.end());
    vector<pair<int, int>> pque;
    swap(pque, que);
    for (auto [x, y] : pque){
      A[x].pop_back();
      A[y].pop_back();
    }
    
    for(auto [x, y] : pque){
      check(x);
      check(y);
    }
  }
  REP(i, N){
    if(A[i].size()){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << day << endl;
  return 0;
}

Measured memory_bytes: 7568
#include"bits/stdc++.h"

using namespace std;

#define MAX 2020

int n;
int m;

vector<int> v[MAX];

vector<int> g[MAX];

vector<pair<int, int> > ed;

queue<tuple<int, int, int> > q;

set<pair<int, int> > s;

bitset<MAX> con[MAX];

bitset<MAX>  child[MAX];
bitset<MAX> par[MAX];

bitset<MAX> stk;

inline void dfs(int b, int pr = -1) {
	auto &c = child[b];
	c.set(b, 1);
	for (int go : v[b]) {
		if (go == pr)continue;
		dfs(go, b);
		c |= child[go];
	}
}

int pat[MAX][MAX];
int lca[MAX][MAX];

int dep[MAX];


inline void dfs2(int b, int pr = -1, int star = 0) {
	pat[star][b] = pr;
	lca[star][b] = b;
	if (pr != -1) {
		if (lca[star][pr] != -1) {
			if (dep[lca[star][pr]] < dep[b]) {
				lca[star][b] = lca[star][pr];
			}
		}
	}
	for (int go : v[b]) {
		if (go == pr)continue;
		dfs2(go, b, star);
	}
}
inline void dfs3(int b, int pr = -1, int d = 0) {
	stk.set(b, 1);
	par[b] = stk;
	dep[b] = d;
	for (int go : v[b]) {
		if (go == pr)continue;
		dfs3(go, b, d + 1);
	}
	stk.set(b, 0);
}
bitset<MAX> ff;
int main() {
	cin >> n >> m;
	for (int i = 1; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs3(0);
	dfs(0);
	for (int i = 0; i < n; i++) {
		dfs2(i, -1, i);
	}
	int edd = 0;
	for (int i = 0; i < m; i++) {
		int c, d;
		scanf("%d%d", &c, &d);
		c--;
		d--;
		g[c].push_back(d);
		g[d].push_back(c);
		ed.push_back(make_pair(c, d));
		con[c].set(d, 1);
		con[d].set(c, 1);
		q.push(make_tuple(0, c, d));
		edd++;
	}
	bitset<MAX> full;
	for (int i = 0; i < n; i++) {
		full.set(i);
	}
	while (!q.empty()) {
		int centre, lef, rig;
		tie(centre, lef, rig) = q.front();
		q.pop();
		int A = lef;
		int B = rig;
		ff.reset();
		if (lca[A][B] == B) {
			swap(A, B);
		}
		if (lca[A][B] == A) {
			ff = child[B] ^ full^child[pat[B][A]] ^ par[B] ^ par[A];
		}
		else {
			ff = child[B] ^ child[A] ^ par[A] ^ par[B];
			ff.set(lca[A][B]);
		}
		ff &= con[A] ^ con[B];
		//the node unconnected to node B
		//connected to A
		//the node is available at the pair(A,B)
		for (int i = (int)ff._Find_first(); i < n; i = (int)ff._Find_next(i)) {
			if (i == A || i == B)continue;
			if (con[B].test(i)) {
				swap(A, B);
			}
			q.push(make_tuple(A, i, B));
			con[i].set(B);
			con[B].set(i);
			edd++;
		}
	}
	cout << edd << endl;
	return 0;
}

Measured memory_bytes: 58164
console.log((args=>{
  const N = args.trim()|0;
  const s = N&1?[[N]]:[];
  for ( let i = N>>1; i > 0; i-- ) s.push([i,(N|1)-i]);
  const G = [];
  for ( let i = 1, l = s.length; i < l; i++ ) {
    for ( const a of s[i] ) {
      for ( const b of s[i-1] ) {
        G.push(`${a} ${b}`);
      }
    }
  }
  if ( s.length < 3 ) return G.length+'\n'+G.join`\n`;
  for ( const a of s[0] ) {
    for ( const b of s[s.length-1] ) {
      G.push(`${a} ${b}`);
    }
  }
  return G.length+'\n'+G.join`\n`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


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

typedef long long ll;
#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)

#define P pair<int, int >


const ll INF = 1e15 + 1;
const int MOD = 1e9 + 7;



//---functions---//
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}

bool firstCompare(const P& firstElof, const P& secondElof){
    return firstElof.first < secondElof.first;
}
bool secondCompare(const P& firstElof, const P& secondElof){
    return firstElof.second < secondElof.second;
}
//---------------//

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

    cin >> N;
    ll t[5];
    ll min_t = INF;
    LREP(i, 0, 5) {
	cin >> t[i];
	if(t[i] < min_t) min_t = t[i];
    }
    ll ans = 0;
    if(N % min_t == 0) ans = 5 + N / min_t - 1;
    else ans = 5 + N / min_t ;

    cout << ans << endl;

}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

ans = ''
diff_x = tx - sx
diff_y = ty - sy
ans += 'R' * diff_x
ans += 'U' * diff_y
ans += 'L' * diff_x
ans += 'D' * diff_y
ans += 'D'
ans += 'R' * (diff_x + 1)
ans += 'U' * (diff_y + 1)
ans += 'L'
ans += 'U'
ans += 'L' * (diff_x + 1)
ans += 'D' * (diff_y + 1)
ans += 'R'

print(ans)

Measured memory_bytes: 3064
sx,sy,tx,ty = map(int,input().split())
x = tx - sx
y = ty - sy
ans = ""
ans += "U"*y
ans += "R"*x
ans += "D"*y
ans += "L"*(x+1)
ans += "U"*(y+1)
ans += "R"*(x+1)
ans += "D"
ans += "R"
ans += "D"*(y+1)
ans += "L"*(x+1)
ans += "U"
print(ans)

Measured memory_bytes: 3064
#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 <math.h>
#include <cmath>
#include <ctime>
#include <stdlib.h>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define m_t make_tuple
#define rep(i,n)  for(int i=0; i<(int) (n); i++)


const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 1000000021;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	return lower_bound(all(vec), xx) - vec.begin();
}
template<typename T>void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>void vecin(vector<TT>& vec) {
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}
template<class tt> struct counter {
	map<tt, int>mp;
	bool add(tt t, int xx) {
		if (!mp.count(t)) {
			mp[t] = xx;
			return true;
		}
		mp[t] += xx;
		if (!mp[t]) {
			mp.erase(t);
		}
		return false;
	}
};

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
long long modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

bool chmax(int& xx, int yy) {
	if (xx < yy) {
		xx = yy;
		return true;
	}
	return false;
}
bool chmin(int& xx, int yy) {
	if (xx > yy) {
		xx = yy;
		return true;
	}
	return false;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx <= 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int x;
	cin >> x;
	if (x >= 30) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3676
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n;
string s[100];
map<string,ll>m;
int32_t main(){
CODE_START;
cin>>n;
for(ll i=0;i<n;i++)
{
    cin>>s[i];
    if(m[s[i]]==1){
        rc("No");
    }
    m[s[i]]=1;
}
for(ll i=1;i<n;i++)
if(s[i][0]!=s[i-1][s[i-1].size()-1])
rc("No");
cout<<"Yes";
return 0;}


Measured memory_bytes: 256
S_prime = input()
T = input()
ans = 'z'
matched = False

if len(S_prime) < len(T):
    print('UNRESTORABLE')
    exit()

for i in range(len(S_prime) - len(T) + 1):
    for k in range(len(T)):
        if S_prime[i + k] != T[k] and S_prime[i + k] != '?':
            break

    if k == len(T) - 1 and (S_prime[i + k] == T[k] or S_prime[i + k] == '?'):
        tmp = (S_prime[0:i] + T + S_prime[i + len(T):]).replace('?', 'a')
        if ans > tmp:
            ans = tmp
        matched = True

if matched:
    print(ans)
else:
    print('UNRESTORABLE')


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

int main() {
    int N, X;
    int L[110];
    int ans = 1;
    int d = 0;
    
    cin >> N >> X;
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    
    for (int i = 0; i < N; i++) {
        d += L[i];
        
        if (X >= d) {
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

int32_t main()
{
  int n;cin>>n;
  int arr[n];
  for (int i=0;i<n;i++)cin>>arr[i];

  int cou=0,check=1;
  for (int i=0;i<n;i++){
    if (arr[i]==check)cou++,check++;
  }

  if (cou==0){
    cout<<"-1\n";
    return 0;
  }
  cout<<n-cou<<'\n';

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
	int N, M, B;
	cin >> N >> M;
	vector<int> A(M);
	rep(i, M) cin >> A.at(i);
	vector<int> point(N);
	
	rep(i, M)
	{
		rep(j, N)
		{
			cin >> B;
			if(A.at(i)==B) point.at(j)++;
			else point.at(A.at(i)-1)++;
		}
	}
	rep(i, N) cout << point.at(i) << endl;
}



Measured memory_bytes: 3116
#include <stdio.h>
#include <string.h>
#include <math.h>
int main ()
{
    int n;
    scanf ("%d", &n);
    int a[n], a1[n];
    for (int i=0;i<n;i++) {
        scanf ("%d",&a[i]);
        a1[a[i]-1]=i+1;
    }
    for (int j=0;j<n;j++) {
        printf ("%d ", a1[j]);
    }
}


Measured memory_bytes: 2440
#include "bits/stdc++.h"
//PRAY :DOLPHINGARLIC: orz orz orz orz orz 
//PRAY :DORI: orz orz orz orz orz orz orz 
//PRAY :SAHIL KUCHLOUS: orz orz orz orz orz
#define GS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(0)
#define all(x) x.begin(), x.end()
#define el '\n'
#define Int long long
#define elif else if
#define test int t; cin>>t; while(t--)
using namespace std;


int main(){
	GS;
    // Int a,b,c,d;cin>>a>>b>>c>>d;
	bool a;cin>>a;cout << !a << endl;

    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int maxN = 1e5 + 10;
const int maxH = 1e4 + 10;

int f[maxN], a[maxN];

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

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

    f[1] = 0, f[2] = abs(a[2] - a[1]);

    for(int i = 3; i <= n; ++i)
        f[i] = min(f[i-1] + abs(a[i] - a[i - 1]), f[i - 2] + abs(a[i] - a[i - 2]));

    cout << f[n];
}


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

int main()
{
    string S;

    cin >> S;

    int count = 0;
    int countmax = 0;

    for (int i = 0; i < S.length(); i++)
    {
        if ((S[i] == 'A') || (S[i] == 'C') || (S[i] == 'G') || (S[i] == 'T'))
        {
            count++;
            if (count > countmax)
            {
                countmax = count;
            }
        }
        else
        {
            count = 0;
        }
    }

    cout << countmax << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S; cin >> S;
  int cnt = 0;
  for(int i = 0; i < S.size(); ++i){
    if(S.at(i) != S.at(S.size() - i - 1)) cnt++;
  }
  cout << cnt / 2 << endl;
}

Measured memory_bytes: 256
#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>;

int main() {
  int n; cin >> n;
  int tot = 0;
  vector<int> t(n);
  rep(i,n) {
    cin >> t[i];
    tot += t[i];
  }
  int m;
  cin >> m;
  rep(i,m) {
    int p, x;
    cin >> p >> x;
    cout << tot + x - t[p-1] << endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int n, k;
    cin >> n >> k;

    n = n % k;
    int ans;
    ans = n;
    ans = min(n, k - n);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
S = input()

memo = []
memo.append(S[0])
p = 1

while p<len(S):
    if len(memo[-1])==2:
        memo.append(S[p])
        p += 1
    elif memo[-1]!=S[p]:
        memo.append(S[p])
        p += 1
    elif p+1==len(S):
        break
    else:
        memo.append(S[p:p+2])
        p += 2
print(len(memo))

Measured memory_bytes: 8296
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <utility>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define DEBUG(x) // cerr << #x << " = " << x << endl

typedef pair<int, int> P;
ostream& operator<<(ostream& os, const P& p) {
    os << "(y,x) = " << '(' << p.first << ',' << p.second << ')';
    return os;
}

const int INF = (int)1e9;

int dist[11][11];
map<P, int> memo;

// current vertex, bitmask, number of vertex
int tsp(int v, int b, int N) {
    if(memo.count(P(v,b))) return memo[P(v,b)];
    if(b == (1 << N) - 1) return 0;
    int res = INF;
    for(int i = 0; i < N; i++) {
        if(b & (1 << i)) continue;
        res = min(res, dist[v][i] + tsp(i, b | (1 << i), N));
    }
    return memo[P(v,b)] = res;
}

int main() {
    while(true) {
        int W, H; cin >> W >> H;
        if(W + H == 0) break;
        vector<string> inp;
        REP(i,H) {
            string s; cin >> s;
            inp.push_back(s);
        }

        // y,x
        vector<P> dst;
        REP(y,H) REP(x,W) {
            if(inp[y][x] == 'o') {
                dst.push_back(P(y,x));
                inp[y][x] = '.';
            }
        }

        REP(y,H) REP(x,W) {
            if(inp[y][x] == '*') {
                dst.push_back(P(y,x));
                inp[y][x] = '.';
            }
        }

        REP(i,dst.size()) REP(j,dst.size()) dist[i][j] = INF;

        REP(i,dst.size()) {
            const int dy[4] = { 0, 1, 0, -1 };
            const int dx[4] = { 1, 0, -1, 0 };

            static bool vis[20][20];
            REP(y,H) REP(x,W) vis[y][x] = false;

            static int D[20][20];
            REP(y,H) REP(x,W) D[y][x] = INF;

            queue<P> Q;
            Q.push(dst[i]);

            vis[dst[i].first][dst[i].second] = true;
            D[dst[i].first][dst[i].second] = 0;

            while(!Q.empty()) {
                P p = Q.front(); Q.pop();
                REP(j,4) {
                    int ny = p.first + dy[j];
                    int nx = p.second + dx[j];
                    if(0 <= nx && nx < W && 0 <= ny && ny < H && inp[ny][nx] != 'x' && vis[ny][nx] == false) {
                        vis[ny][nx] = true;
                        D[ny][nx] = D[p.first][p.second] + 1;
                        Q.push(P(ny,nx));
                    }
                }
            }
            REP(j,dst.size()) {
                dist[i][j] = D[dst[j].first][dst[j].second];
            }
        }

        REP(i,dst.size()) REP(j,dst.size()) {
            DEBUG(dst[i]);
            DEBUG(dst[j]);
            DEBUG(dist[i][j]);
        }
        
        bool valid = true;
        for(int i = 1; i < dst.size(); i++) {
            if(dist[0][i] >= INF) {
                valid = false;
                break;
            }
        }
        if(valid == false) {
            cout << -1 << endl;
            continue;
        }

        memo.clear();
        int ans = tsp(0, 1, dst.size());
        cout << ans << endl;
    }
}

Measured memory_bytes: 1384
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    vector<int> a(n+1,0);
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)a[i]+=a[i-1];
    vector<int> v;
    for(int i=0;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            v.push_back(a[j]-a[i]);
        }
    }
    int res=0;
    for(int bit=60;bit>=0;bit--){
        int cnt=0;
        int now=(1ll<<bit);
        for(auto it:v){
            if(it&now)cnt++;
        }
        if(cnt>=k){
            res+=now;
            vector<int> vv;
            for(auto it:v)if(it&now)vv.push_back(it);
            v=vv;
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 6384
#include<bits/stdc++.h>
#define lli unsigned long long int
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

void solve(){
    lli n,tp; cin>>n;
	NA(i,0,n){
		cin>>tp; 
		if(tp%2) continue;
		if(tp%3==0 || tp%5==0) continue;
		else {cout<<"DENIED"; return;}
	}
	cout<<"APPROVED";
    return;
}
int main(){
    fastIO;
    solve();
    return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	ll n, y, ans = 0;
	cin >> n >> y;
	y /= 1000;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k <= n; k++) {
				if (i * 10 + 5 * j + k>y || i + j + k>n) break;
				if (10 * i + 5 * j + k ==y&& i + j + k == n) {
					cout << i << ' ' << j << ' ' << k;
					return 0;
				}
			}
		}
	}
	cout << "-1 -1 -1";
	return 0;
}


Measured memory_bytes: 256
use proconio::input;
use std::cmp::min;

fn main() {
    input! {
        n:usize,
        xyp:[(i64,i64,i64);n]
    };

    let mut dist_x = vec![vec![0;n];1<<n];
    for bit in 0..(1<<n) {
        for i in 0..n {
            dist_x[bit][i] = xyp[i].0.abs();
            for j in 0..n {
                if ((bit>>j)&1)==1 {
                    dist_x[bit][i] = min(dist_x[bit][i],(xyp[i].0-xyp[j].0).abs());
                }
            }
        }
    }

    let mut dist_y = vec![vec![0;n];1<<n];
    for bit in 0..(1<<n) {
        for i in 0..n {
            dist_y[bit][i] = xyp[i].1.abs();
            for j in 0..n {
                if ((bit>>j)&1)==1 {
                    dist_y[bit][i] = min(dist_y[bit][i],(xyp[i].1-xyp[j].1).abs());
                }
            }
        }
    }

    let mut pow3n = 1;
    for _ in 0..n {
        pow3n*=3;
    }
    let pow3n = pow3n;
    let mut ans = vec![1e15 as i64;n+1];
    for state in 0..pow3n {
        let mut x = state;
        let mut k = 0;

        let mut xbit = 0;
        let mut ybit = 0;
        for i in 0..n {
            if x%3>0 {
                k+=1;
                if x%3==1 {
                    xbit+= 1<<i;
                }
                else {
                    ybit+= 1<<i;
                }
            }
            x/=3;
        }   
        let mut sc = 0;
        for i in 0..n {
            sc += min(dist_x[xbit][i],dist_y[ybit][i])*xyp[i].2;
        }
        ans[k] = min(ans[k],sc);
    }

    for i in 0..=n {
        println!("{}",ans[i]);
    }
}



Measured memory_bytes: 11768
from collections import deque

s = deque(input())
q = int(input())
count = 0
for i in range(q):
    query = list(input().split())
    if query[0] == "1":
        count += 1
    else:
        if count % 2 == 0:
            if query[1] == "1":
                s.appendleft(query[2])
            else:
                s.append(query[2])
        else:
            if query[1] == "2":
                s.appendleft(query[2])
            else:
                s.append(query[2])

if count % 2 == 1:
    s.reverse()

for i in s:
    print(i, end="")


Measured memory_bytes: 9584
#include<bits/stdc++.h> 
using namespace std;
#define se second
#define fr first
#define int long long int
#define pb push_back
#define inf 1e18
#define all(v) v.begin(),v.end()
#define CHAL_BAAP_KO_MT_SIKHA ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
/*
    Damn Fast:TheFuckinMastermind
    while(How to solve the Question?){
                Read the Question Again!!
           }
        do
            Practise
    #Motivation::::0/0  
*/
const int N=4e3;
double dp[N+1][N+1];
double p[N+1];
signed main()
{
     
    CHAL_BAAP_KO_MT_SIKHA
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>p[i];
     memset(dp, 0.0, sizeof(dp));
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=i;j++){
            if(j==0){
                dp[i][j]=dp[i-1][j]*(1.0-p[i]);
            }
            else{
                dp[i][j]=dp[i-1][j]*(1.0-p[i])+dp[i-1][j-1]*p[i];
            }
        }
    }
    double ans=0.00;
    for(int i=(n+1)/2;i<=n;i++){
        ans+=dp[n][i];
    }
    cout<<setprecision(9)<<ans<<endl;
}

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

int main() {
	int n;
	cin >> n;
	getchar();
    string s1="",s2="";
    char x;
    for(int i = 0; i < n/2; i++){
    	scanf("%c",&x);
    	s1 += x;
	}
	for(int i = n/2; i < n; i++){
    	scanf("%c",&x);
    	s2 += x;
	}
	if(s1 == s2)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHEEM
                                                //ALLAH IS WATCHING ME

//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█


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

#define ull    unsigned long long
#define ll    long long
#define ios    ios::sync_with_stdio(0);cin.tie(0);
#define ses   "\n"

string digit="0123456789";
string small="abcdefghijklmnopqrstuvwxyz";

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; // 8-direction.......
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[]= {1,-1,0,0}; // 4-direction...........
int dy4[]= {0,0,1,-1};

/////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////

//main function is here.........

int main()
{
    //ios
ll n,cnt=0;
cin>>n;
ll arr[n];
for(ll i=0;i<n;i++)cin>>arr[i];
ll mn=1e18;
for(ll i=0;i<n;i++){
    if(mn>arr[i])cnt++;
    mn=min(mn,arr[i]);
}
cout<<cnt;
}




//Alhamdulillah


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner s = new Scanner(System.in);
          int number = Integer.parseInt(s.next());
        int min = Integer.parseInt(s.next());
        int max = Integer.parseInt(s.next());
          
          if (flag(max, min, number)) System.out.println("OK");
          else System.out.println("NG");
      	
    }

    public static boolean flag (int max, int min, int number) {
        if ((max - min) > number) return true;
        else {
            for (int i = min; i <= max; i++) {
                if (i%number == 0) {
                    return true;
                }
            }
            return false;
          }
    }
}

Measured memory_bytes: 35828
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
typedef unsigned long long ull;
const int inf=103974182;
using namespace std;

int main()
{
//	freopen("input.txt","r",stdin);
	ll n,k;
	ll ans=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		ll a=(int)((n+1)/i);
		ans+=a*max(0LL,i-k);
		ll tn=(n+1)-a*i;
//		cout<<i<<' '<<ans<<endl;
		ans+=max(0LL,tn-k);
		if(k==0) ans--;
	}
	cout<<ans<<endl;
	return 0;
}

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



int main()
{
    ll n,ans=0;
    cin>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    sort(a.begin(),a.end(),greater<ll>());
    ll j=0;
    if(n==2)
        ans=a[j];
    else{
            ans+=a[j];
    j++;
    ll temp=0;
    for(ll i=2;i<n;i++)
        {
          ans+=a[j];
          temp++;
          if(temp==2){
            temp=0;
            j++;
          }
        }
    }
    cout<<ans<<endl;


    	return 0;
}



Measured memory_bytes: 4840
main :: IO ()
main = do
  s <- getLine
  case solve s of
    YYMM      -> putStrLn "YYMM"
    MMYY      -> putStrLn "MMYY"
    Ambiguous -> putStrLn "AMBIGUOUS"
    NA        -> putStrLn "NA"

solve :: String -> Format
solve s = solve' yymm mmyy where
  a = read $ take 2 s
  b = read $ drop 2 s
  yymm = isYYMM a b
  mmyy = isMMYY a b

solve' :: Bool -> Bool -> Format
solve' False False = NA
solve' False True  = MMYY
solve' True False  = YYMM
solve' True True   = Ambiguous

isYYMM :: Int -> Int -> Bool
isYYMM _ b = isMM b

isMMYY :: Int -> Int -> Bool
isMMYY a _ = isMM a

isMM :: Int -> Bool
isMM a = 1 <= a && a <= 12

data Format = YYMM | MMYY | Ambiguous | NA


Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int N, M;
    cin >> N >> M;
    vector<int> X(M);
    for(int i = 0; i < M; ++i){
        cin >> X[i];
    }
    if(M <= N) {
        cout << 0;
        return 0;
    }
    int r = M - N;
    sort(X.begin(), X.end());
    vector<int> g(M-1);
    for(int i = 0; i < M - 1; ++i){
        g[i] = X[i + 1] - X[i];
    }
    sort(g.begin(), g.end());
    int sum = 0;
    for(int i = 0; i < r; ++i){
        sum += g[i];
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
#define X first
#define Y second
typedef long long ll; 
int main()
{
	// freopen("ARC094-E.in", "r", stdin);
	int n; 
	scanf("%d", &n); 
	ll ans = 0, mn = 2e9; 
	bool f = true; 
	for (int i = 0; i < n; i++)
	{
		int a, b; 
		scanf("%d%d", &a, &b); 
		if (a > b)
			mn = std::min(mn, (ll)b); 
		ans += a; 
		f &= a == b; 
	}
	if (f)
		puts("0"); 
	else
		printf("%lld\n", ans - mn);
	return 0; 
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#define MAXN 200009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
vector<int>adj[MAXN];
int lvl[MAXN],P[MAXN][20],n;
int LCA(int x,int y){
	if(lvl[x]<lvl[y])
		swap(x,y);
	for(int i=17;i>=0;i--)
		if(~P[x][i] and lvl[x]-(1<<i)>=lvl[y])
			x=P[x][i];
	if(x==y)
		return x;
	for(int i=17;i>=0;i--)
		if(~P[x][i] and P[x][i]!=P[y][i])
			x=P[x][i],y=P[y][i];
	return P[x][0];		
}
void build(){
	for(int j=1;j<=17;j++)
		for(int i=1;i<=n;i++)
			if(~P[i][j-1])
				P[i][j]=P[P[i][j-1]][j-1];
}
void dfs(int nd,int pr){
	lvl[nd]=(~pr?lvl[pr]+1:1);
	P[nd][0]=pr;
	for(int i=0;i<int(adj[nd].size());i++){
		int to=adj[nd][i];
		if(to==pr)
			continue;
		dfs(to,nd);	
	}
}
int dis(int x,int y){
	return lvl[x]+lvl[y]-2*lvl[LCA(x,y)];
}
int main(){
    //~ freopen("file.in", "r", stdin);
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		adj[u].pb(v);
		adj[v].pb(u);
	}dfs(1,-1);build();
	int a=0,b=0;
	for(int i=1;i<=n;i++){
		if(dis(1,i)<=dis(n,i))
			a++;
		else
			b++;
	}
	if(a<=b)
		puts("Snuke");
	else
		puts("Fennec");
	return 0;
}


Measured memory_bytes: 24576
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
template <class... T> void printArr(T&&...){ }
#endif

ll func(ll h, ll w){
    ll ans = MLL;
    for(int i = 1; i < h; i++){
        ll h2 = h - i;
        ll s1 = w * i;
        for(int j = max(1ll, h2 / 2 - 3); j < min(h2, h2 / 2 + 3); j++){
            ll s2 = w * j;
            ll s3 = w * (h2 - j);
            ans = min(ans, max({s1, s2, s3}) - min({s1, s2, s3}));
        }
        for(int j = max(1ll, w / 2 - 3); j < min(w, w / 2 + 3); j++){
            ll s2 = h2 * j;
            ll s3 = h2 * (w - j);
            ans = min(ans, max({s1, s2, s3}) - min({s1, s2, s3}));
        }
    }
    return ans;
}

int main(){
    ll h, w;
    cin >> h >> w;
    ll ans = MLL;
    ans = min(ans, func(h, w));
    ans = min(ans, func(w, h));
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x;
  cin>>x>>n;
  map<int,int> m;
  for(int i=0;i<n;i++){
    int ele;
    cin>>ele;
    m[ele]++;
  }
  int i;
  for(i=x;i>=1;i--){
    if(m[i]==0)break;
  }
  int min=i;
   for(i=x+1;i<=100;i++){
    if(m[i]==0)break;
   }
  int max=i;
  int ans=abs(min-x)<=abs(max-x)?min:max;
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 3724