akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

//右下左上
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

int eve(int x)
{
    if (x % 400 == 0)
        return 1;
    if (x % 100 == 0)
        return 0;
    if (x % 4 == 0)
        return 1;
    return 0;
}

ll h, w;
vllll pass(50, vll(50));
vs s(50);
struct P
{
    int y, x, c;
} p;
queue<P> q;

ll bfs()
{
    if (q.empty())
        return -1;
    p = q.front();
    q.pop();
    if (p.y == h - 1 && p.x == w - 1)
        return p.c;
    rep(i, 0, 4)
    {
        int ny = p.y + dy[i], nx = p.x + dx[i];
        if (0 > ny || ny >= h || 0 > nx || nx >= w)
            continue;
        if (s[ny][nx] == '.' && (!pass[ny][nx]))
        {
            q.push({ny, nx, p.c + 1});
            pass[ny][nx] = 1;
        }
    }
    return bfs();
}

int main(void)
{
    cin >> h >> w;
    rep(i, 0, h) cin >> s[i];

    ll ans = 0;
    rep(i, 0, h) rep(j, 0, w) if (s[i][j] == '.') ans++;
    q.push({0, 0, 1});
    pass[0][0] = 1;
    ll num = bfs();

    cout << (num == -1 ? -1 : ans - num) << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 5000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(){
    string s; cin>>s;
    int ans=0;
    rep(i,s.size()-1){
        if(s.at(i)!=s.at(i+1))ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int A[N];
  int num = 0;
  
  for(int i =0 ; i<N ;i++){
    cin >> A[i];
  }
  
  bool flg = true;
  
  while (flg){  
    for(int i=0; i<N ;i++){
      if(A[i]%2 == 1){
        flg = false;
        break;
      }
    }
    if(flg){
       for(int i=0; i<N ;i++){
         A[i] /= 2;
      }
      num ++;
    } 
  
  }

  cout << num <<endl;
}
  

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

namespace BeginnerContest133
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int N = int.Parse(str[0]);
            int D = int.Parse(str[1]);
            List<double[]> points = new List<double[]>();
            for(int i = 0; i < N; i++)
            {
                double[] X = new double[D];
                string[] str2 = Console.ReadLine().Split(' ');
                for(int j = 0; j < D; j++)
                {
                    X[j] = double.Parse(str2[j]);
                }
                points.Add(X);
            }

            int counter = 0;
            for(int i = 0; i < N; i++)
            {
                for(int j = i + 1; j < N; j++)
                {
                    double distance = 0;
                    for(int k = 0; k < D; k++)
                    {
                        distance += (points[i][k] - points[j][k]) * (points[i][k] - points[j][k]);
                    }
                    distance = Math.Sqrt(distance);

                    if (Math.Round(distance) - distance == 0)
                    {
                        counter++;
                    }
                }
            }

            Console.Write(counter);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it!= v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

random_device seed_gen; mt19937_64 mtrand(seed_gen());
#define MOD 1000000007
//////////////////////////////////////////

int main(){
  ins(S);
  string T = "EWSN";
  vi a(4 , 0);
  rep(i,sz(S)){
    rep(j,4){
      if(S[i]==T[j]) a[j]++;
    }
  }
  if(a[0]*a[1]==0 && a[0]!=a[1]) die("No");
  if(a[2]*a[3]==0 && a[2]!=a[3]) die("No");
  out("Yes");
}

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

int main() {
	int n;
  cin >> n;
  int c = n;
  if (n % 1000 == 0){
    cout << "0";
  }
  else {
    n/=1000;
    n += 1;
    int k = n * 1000;
    cout << k - c;
  }
	return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<stdio.h>
#include<string>

using namespace std;
 
int main(){
	string x;
	int sum;
	while(1){
		sum=0;
		cin>> x;
		if(x=="0")break;
		for(int i=0;i<x.size();i++){
			sum+=x[i]-'0';
		}
		cout<< sum<< endl;
	}
	return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<stdio.h>
using namespace std;
int n,a[20];
int f(int i,int m){
    int s;
    if(m==0){
        return true;
    }
    if(i>=n){
        return false;
    }
    s= f(i+1,m) || f(i+1,m-a[i]);
    return s;
}

int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        cin >>a[i];
    }
    int q,i=0,m;
    cin >> q;
    while(q--){
        cin >> m;
        if(f(i,m)){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
}


Measured memory_bytes: 3100
#include <stdio.h>
#include <string.h>

int main(){
    char S[100000];
    scanf("%s", S);
    long N = strlen(S);
    long len0=0, len1=0;
    long i;
    for(i = 0; i < N;i++){
        if(S[i] == '0') len0++;
        else{
            len1++;
        }
    }
    if(len0 > len1){
        printf("%ld\n", len1 * 2);
    }else{
        printf("%ld\n", len0 * 2);
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//C++17以上
template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main() {
    int w,h,x,y;cin >> w >> h >> x >> y;
    printf("%f %d\n",double(w)*double(h)/2.0,(x+x==w && y+y==h));
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	char[] ms;
	char[] msg;

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while (n != 0) {
			ms = sc.next().toCharArray();
			msg = sc.next().toCharArray();
			solve();
			n--;
		}
	}

	void solve() {
		for (int k = ms.length - 1; k >= 0; k--) {
			StringBuilder sb = new StringBuilder();
			switch (ms[k]) {
			case 'A':
				msg = sb.append(msg).reverse().toString().toCharArray();
				break;
			case 'J':
				sb.append(msg[msg.length - 1]);
				for (int i = 0; i < msg.length - 1; i++)
					sb.append(msg[i]);
				msg = sb.toString().toCharArray();
				break;
			case 'C':
				for (int i = 1; i < msg.length; i++)
					sb.append(msg[i]);
				sb.append(msg[0]);
				msg = sb.toString().toCharArray();
				break;
			case 'P':
				for (int i = 0; i < msg.length; i++) {
					if (msg[i] - '0' >= 0 && msg[i] - '0' <= 9) {
						if (msg[i] == '0') {
							msg[i] = '9';
						} else {
							msg[i]--;
						}
					}
				}
				break;
			case 'M':
				for (int i = 0; i < msg.length; i++) {
					if (msg[i] - '0' >= 0 && msg[i] - '0' <= 9) {
						if (msg[i] == '9') {
							msg[i] = '0';
						} else {
							msg[i]++;
						}
					}
				}
				break;

			case 'E':
				if (msg.length % 2 == 0) {
					for (int i = msg.length / 2; i < msg.length; i++) {
						sb.append(msg[i]);
					}
					for (int i = 0; i < msg.length / 2; i++) {
						sb.append(msg[i]);
					}
				} else {
					for (int i = msg.length / 2 + 1; i < msg.length; i++) {
						sb.append(msg[i]);
					}
					sb.append(msg[msg.length / 2]);
					for (int i = 0; i < msg.length / 2; i++) {
						sb.append(msg[i]);
					}
				}
				msg = sb.toString().toCharArray();
				break;
			}
		}
		System.out.println(new StringBuilder().append(msg).toString());
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}
}

Measured memory_bytes: 11000
import math
A, B, C, D, E, F = map(int, input().split())

n_sugar = set()
max_sugar = math.ceil(E*F/100)
for i in range(max_sugar//C + 1):
    for j in range(max_sugar//D + 1):
        if C*i + D*j <= max_sugar:
            n_sugar.add(C*i + D*j)
            
n_water = set()
for i in range(F//(100*A) + 1):
    for j in range(F//(100*B) +1):
        if 100*A*i + 100*B*j <= F:
            n_water.add(100*A*i + 100*B*j)
            
n_sugar = list(n_sugar)
n_water.remove(0)
n_water = list(n_water)

ans_list = []
for sugar in n_sugar:
    for water in n_water:
        if sugar + water <= F and sugar <= E*water/100:
            ans_list.append([sugar+water, sugar, sugar/(sugar+water)])
            
ans_list = sorted(ans_list, key = lambda x: x[2], reverse = True)

print(ans_list[0][0], ans_list[0][1])

Measured memory_bytes: 4532
import java.util.*;
public class Main {
	
	static int MOD = 1_000_000_007;
	static int N, K;
	static long ans;
	static List<Integer>[] edge;
	
	static void dfs(int now, int from) {
		int color = from == -1 ? K-1 : K-2;
		for(int i : edge[now]) {
			if(i != from) {
				ans = ans * color % MOD;				
				color--;
			}
		}
		for(int i : edge[now])
			if(i != from)
				dfs(i, now);
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		K = sc.nextInt();
		ans = K;
		edge = new ArrayList[N];
		for(int i = 0; i < N; i++)
			edge[i] = new ArrayList<>();
		for (int i = 0; i < N-1; i++) {
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            edge[a].add(b);
            edge[b].add(a);
        }
		dfs(0, -1);
		System.out.println(ans);

	}

}

Measured memory_bytes: 111996
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define FOR(i,a,n) for(int i = a; i < n; i++)
using namespace std;
 
const int N = 1e5+123;
ll a[N];
const long double PI = 3.14159265358979323846;

int main()
{
    int n;
    cin >> n;
    if(n <1200)
        puts("ABC");
    else if(n >= 1200&&n<2800)
        puts("ARC");
    else
        puts("AGC");
    return 0;  
}


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

typedef long long ll;

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    vector<int> h(N);
    ll lo = 0, hi = 0;
    rep(i, N) {
        cin >> h[i];
        hi += (h[i] + A - 1) / A;
    }
    while (lo + 1 < hi) {
        ll mi = (lo + hi) / 2, c = 0;
        //cout << mi << endl;
        rep(i, N) {
            ll d = (h[i] - B * mi + A - B - 1) /(A - B);
            if (d > 0) c += d;
        }
        if (c > mi) lo = mi;
        else hi = mi;
    }
    cout << hi << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> v(100000, 0);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        v[a]++;
    }

    int ans = 0;
    for (int x = 1; x <= 100000; x++) {
        ans = max(ans, v[x - 1] + v[x] + v[x + 1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
n, k = [int(x) for x in input().split()]

if n > 2 * k or k > 2 * n:
    n = n % k + k

_set = set()
_set_add = _set.add
_set_add(n)

while True:
    new_n = abs(n - k)
    _set_add(new_n)
    if new_n > n:
        # Looped:
        break
    else:
        n = new_n

print(min(_set))


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

using namespace std;

const int MAXN = 305;

long double dp[305][305][305];
int n;


long double solve(int s1, int s2, int s3)
{
    if (!s1 && !s2 && !s3)
        return 0;
    auto &cur = dp[s1][s2][s3];
    if (cur)
        return cur;
    cur = 1;
    if (s1)
        cur += s1/(long double)n * solve(s1-1, s2, s3);
    if (s2)
        cur += s2/(long double)n * solve(s1+1, s2-1, s3);
    if (s3)
        cur += s3/(long double)n * solve(s1, s2+1, s3-1);
    cur /= 1 - (n-s1-s2-s3)/(long double)n;
    return cur;
}

int main()
{
    int s[3] = {0, 0, 0};
    scanf("%i", &n);
    for (int x = 0; x < n; x++)
    {
        int a;
        scanf("%i", &a);
        s[a-1]++;
    }
    printf("%.30Lf\n", solve(s[0], s[1], s[2]));
}


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

int main(){
    int n,m;
    cin>>n>>m;
    int r[n]={0};
    for(int i=0;i<2*m;i++){int tmp;cin>>tmp;r[tmp-1]++;}
    for(int i=0;i<n;i++)cout<<r[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ans = 0
while True:
    i = 0
    while i <= n -1:
        if a[i]%2:
            print(ans)
            exit()
        else:
            a[i] = a[i]//2
        i += 1
    ans += 1

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;

const int MAXN = 2000;
bitset<MAXN + 1> f[MAXN + 1];
bool g[MAXN + 1][MAXN + 1], temp[MAXN + 1][MAXN + 1];
int w, h, ans = 1, now[MAXN + 1];

void solve() {
    ans = max(w, h);
    for(int i = 2; i <= h; i++) {
        for(int j = 1; j <= w; j++)
            g[i - 1][j] = f[i - 1][j] ^ f[i][j];
    }
    for(int i = 1; i <= h - 1; i++)
        now[i] = 1;
    for(int j = 2; j <= w; j++) {
        for(int i = 1; i <= h - 1; i++) {
            if(g[i][j] != g[i][j - 1]) {
                now[i] = 1;
            } else {
                now[i]++;
            }
        }
        vector<int> cur, left(h), right(h);
        for(int i = 1; i <= h - 1; i++) {
            while(!cur.empty() && now[cur.back()] >= now[i])
                cur.pop_back();
            if(cur.empty())
                left[i] = 1;
            else
                left[i] = cur.back() + 1;
            cur.push_back(i);
        }
        cur.clear();
        for(int i = h - 1; i >= 1; i--) {
            while(!cur.empty() && now[cur.back()] >= now[i])
                cur.pop_back();
            if(cur.empty())
                right[i] = h - 1;
            else
                right[i] = cur.back() - 1;
            cur.push_back(i);
        }
        for(int i = 1; i <= h - 1; i++) {
            ans = max(ans, (right[i] - left[i] + 1 + 1) * now[i]);
        }
    }
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin >> h >> w;
    for(int i = 1; i <= h; i++) {
        string s;
        cin >> s;
        for(int j = 1; j <= w; j++) {
            f[i][j] = (s[j - 1] == '#' ? 1 : 0);
        }
    }
    solve();
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++)
            temp[j][i] = f[i][j];
    }
    swap(h, w);
    for(int i = 1; i <= h; i++)
        for(int j = 1; j <= w; j++)
            f[i][j] = temp[i][j];
    solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 8576
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int32_t main(){_
    //freopen("input","r",stdin);
   	string s;
   	cin >> s;
   	if(s[0] == s[1] && s[1] == s[2]) rc("Yes"); 
   	if(s[1] == s[2] && s[3] == s[2]) rc("Yes"); 
   	rc("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    int A,B;
    cin >> A>>B;
    
    int sum= 0;

    if(A>B) sum=2*A-1;
    else if(A==B) sum=2*A;
    else sum=2*B-1;

   cout << sum << endl;

   return 0;
}

Measured memory_bytes: 256
x, n = list(map(int, input().split(" ")))
if n != 0:

    p = list(map(int, input().split(" ")))

    p_ = [abs(x - n) for n in p]

    m_p_ = p_.index(min(p_))

    start = p[m_p_]

    for v in range(100):
        a = start - v - 1
        b = start + v + 1
        if (a not in p) and (b in p):
            ans = a
            break

        elif (a in p) and (b not in p):
            ans = b
            break
            
        elif (a not in p) and (b not in p):
            if a > b:
                ans = b
                break
            else:
                ans = a
                break
                
else:
    ans = x
    
print(ans)

Measured memory_bytes: 9100
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <string>

using namespace std;

int main() {
    int h,w; cin >> h >> w;
    char map[h][w];
    for(int i = 0; i < h; i++) {
        string s;
        cin >> s;
        for(int j = 0; j < w; j++) {
            map[i][j] = s[j];
        }
    }
    vector<vector<int> > l(h, vector<int>(w,0));
    vector<vector<int> > r(h, vector<int>(w,0));
    vector<vector<int> > u(h, vector<int>(w,0));
    vector<vector<int> > d(h, vector<int>(w,0));
    for(int i = 0; i < h; i++) {
        l[i][0] = (map[i][0] == '.') ? 1 : 0;
        for(int j = 1; j < w; j++) {
            l[i][j] = (map[i][j] == '.') ? l[i][j-1] +1: 0;
        }
    }
    for(int i = 0; i < h; i++) {
        r[i][w-1] = (map[i][w-1] == '.') ? 1 : 0;
        for(int j = w-2; j >= 0; j--) {
            r[i][j] = (map[i][j] == '.') ? r[i][j+1] +1: 0;
        }
    }
    for(int j = 0; j < w; j++) {
        u[0][j] = (map[0][j] == '.') ? 1 : 0;
        for(int i = 1; i < h; i++) {
            u[i][j] = (map[i][j] == '.') ? u[i-1][j] +1: 0;
        }
    }
    for(int j = 0; j < w; j++) {
        d[h-1][j] = (map[h-1][j] == '.') ? 1 : 0;
        for(int i = h-2; i >= 0; i--) {
            d[i][j] = (map[i][j] == '.') ? d[i+1][j] +1: 0;
        }
    }

    int max = 0;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            int tmp = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3;
            if(max < tmp)
                max = tmp;
        }
    }
    cout << max << endl;
}


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

int main() {
  vector<string> xy(2);
  cin >> xy.at(0) >> xy.at(1);
  vector<int> vec(2);
  for (int i = 0; i < 2; i++) {
    if (xy.at(i) == "A") vec.at(i) = 1;
    else if (xy.at(i) == "B") vec.at(i) = 2;
    else if (xy.at(i) == "C") vec.at(i) = 3;
    else if (xy.at(i) == "D") vec.at(i) = 4;
    else if (xy.at(i) == "E") vec.at(i) = 5;
    else vec.at(i) = 6;
  }
  if (vec.at(0) < vec.at(1)) cout << "<" << endl;
  else if (vec.at(0) == vec.at(1)) cout << "=" << endl;
  else cout << ">" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    long long x[n],y[n];
    long long p=1000000000;
    for(int i=0;i<n;i++){
        scanf("%lld%lld",&x[i],&y[i]);
    }
    int o=0;
    for(int i=0;i<n-1;i++){
        if(((x[i]+y[i]+2*p)%2)!=((x[i+1]+y[i+1]+2*p)%2))o=1;
    }
    if(o){
        printf("-1\n");
        return 0;
    }
    if((x[0]+y[0]+2*p)%2==0){
        o=1;
    }
    printf("%d\n",o+31);
    if(o)printf("1 ");
    long long bi[35];
    bi[0]=1;
    for(int i=0;i<33;i++){
        bi[i+1]=bi[i]*2;
    }
    for(int i=30;i>0;i--){
        printf("%lld ",bi[i]);
    }
    printf("1\n");
    for(int i=0;i<n;i++){
        if(o){
            x[i]++;
            printf("L");
        }
        for(int j=30;j>0;j--){
            if(y[i]>x[i]&&y[i]>0-x[i]){
                printf("U");
                y[i]-=bi[j];
            }
            else if(y[i]<x[i]&&y[i]<0-x[i]){
                printf("D");
                y[i]+=bi[j];
            }
            else if(x[i]>y[i]&&x[i]>0-y[i]){
                printf("R");
                x[i]-=bi[j];
            }
            else if(x[i]<y[i]&&x[i]<0-y[i]){
                printf("L");
                x[i]+=bi[j];
            }
        }
        if(x[i]==1)printf("R\n");
        if(x[i]==-1)printf("L\n");
        if(y[i]==1)printf("U\n");
        if(y[i]==-1)printf("D\n");
    }
}

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


int main(){
    long double A,B,H,M;
    long double pi = 3.1415926535;
    cin >> A >> B >> H >> M;
    long double c = A*A + B*B - 2*A*B*cos((M*11/360 - H/6)*pi);
    c = sqrt(c);
    cout << fixed << setprecision(15);
    cout << c << endl;
}

Measured memory_bytes: 4168
from bisect import bisect, bisect_left 

A, B, Q = map(int, input().split())
S, T, X = [0]*(A+2), [0]*(B+2), [0]*Q

INF = 10**10
S[0], T[0] = -INF, -INF
S[-1], T[-1] = 2*INF, 2*INF

for i in range(A):
  S[i+1] = int(input())

for i in range(B):
  T[i+1] = int(input())

for i in range(Q):
  X[i] = int(input())

def dis(x):
  RS = bisect_left(S, x)
  LS = RS - 1
  RT = bisect_left(T, x)
  LT = RT - 1
  ans = [0]*4
  ans[0] = max(S[RS], T[RT]) - x
  ans[1] = x - min(S[LS], T[LT])
  ans[2] = S[RS] - T[LT] + min(S[RS] - x, x - T[LT])
  ans[3] = T[RT] - S[LS] + min(T[RT] - x, x - S[LS])
  return min(ans)

for x in X:
  print(dis(x))

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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


/*
--------------------------------------------

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;

/*
--------------------------------------------

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())

/*
--------------------------------------------

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

/*
--------------------------------------------

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))



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

	vector<int> a(N, 0);

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

	int next_val = 1;
	int broken_cnt = 0;
	for(int i = 0; i < N; i++) {
		if (next_val !=a[i]) {
			broken_cnt++;
		}
		else {
			next_val++;
		}
		//cout << a[i] << ' '  << broken_cnt << ' ' << next_val << endl;
	}

	if (broken_cnt == N) {
		cout << -1 << endl;
	}
	else {
		cout << broken_cnt;
	}

	
	return 0;
}


Measured memory_bytes: 1024
n = int(input())
P =[]
s = 0
for _ in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for j in range(n):s -= P[j][1]*P[j+1][0] -  P[j][0] * P[j+1][1]
print(s*0.5)

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

public class AtCoderA
{
    static void Main()
    {
        int n;
        int a;
        int b;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            n = int.Parse(words[0]);
            a = int.Parse(words[1]);
            b = int.Parse(words[2]);
        }

        int answer = 0;
        for (int i = 1; i <= n; i++)
        {
            int num = i;
            int sum = 0;
            while (num != 0)
            {
                sum += num % 10;
                num = num / 10;
            }
            if (a <= sum && sum <= b)
            {
                answer += i;
            }
        }

        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

/*
    SegmentTree<int> seg(f, def) のように宣言する
    RMQ の場合 : 
    auto f = [](int a, int b){return min(a, b);};
    int def = INF;
*/
template <typename Monoid>
struct SegmentTree{
    using F = function<Monoid(Monoid, Monoid)>;
    int n;
    vector<Monoid> dat;
    F f;
    Monoid def;

    SegmentTree(F f, Monoid def) : f(f), def(def) {}

    void build(const vector<Monoid> & vec){
        int siz = vec.size();
        n = 1;
        while(n < siz) n *= 2;
        dat.assign(2 * n - 1, def);
        for(int i = 0; i < siz; i++) dat[n - 1 + i] = vec[i];
        for(int i = n - 2; i >= 0; i--) dat[i] = f(dat[2 * i + 1], dat[2 * i + 2]);
    }

    void update(int k, Monoid x){
        k += (n - 1);
        dat[k] = x;
        while(k > 0){
            k = (k - 1) / 2;
            dat[k] = f(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }

    Monoid query(int a, int b){
        return query(a, b, 0, 0, n);
    }

private:
    Monoid query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return def;
        if(a <= l && r <= b) return dat[k];
        Monoid vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        Monoid vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return f(vl, vr);
    }
};

signed main(){
    int n;
    cin >> n;
    int h[n];
    ll a[n];
    REP(i,n){
        cin >> h[i];
    }
    REP(i,n){
        cin >> a[i];
    }
    auto f = [](ll a, ll b){return max(a, b);};
    SegmentTree<ll> dp(f, 0);
    dp.build(vector<ll>(n + 1, 0));
    for(int i = 0; i < n; i++){
        dp.update(h[i], dp.query(0, h[i] + 1) + a[i]);
    }
    cout << dp.query(0, n + 1) << endl;
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define MAX 1000005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define vll vector<ll>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
 
ll gcd(ll n1,ll n2){
	if(n2==0)
		return n1;
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent)
{
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
int arr[MAX];
int main()
{
	int n;
	cin>>n;
	bool flag=true;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	sort(arr,arr+n);
	if(arr[n-1]-arr[0]>1)
		flag=false;
	else if(arr[n-1]==arr[0])
	{
		if(arr[0]==n-1)
			flag=true;
		else
		{int x=arr[0]*2;
		if(n<x)
			flag=false;
	}}
	//assert(arr[1]==arr[0]);
	else
	{
		int cnt=0;
		for(int i=0;i<n;i++)
		if(arr[i]==arr[0])
		{
			cnt++;
		}
		//cout<<arr[n-1]<<endl;
		int min=cnt+(arr[n-1]-cnt)*2;
		if(n<min)
			flag=false;
		if(arr[n-1]<cnt)
			flag=false;
		if(arr[0]<cnt)
			flag=false;
	}
	if(flag)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    abc082c()
}

fun abc082c() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map { it.toLong() }

    val answer = aList.groupBy { it }.map { entry ->
        val (value, values) = entry
        if (value > values.size) values.size.toLong() else values.size - value
    }.sum()

    println(answer)
}


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

int main()
{
    int N, C, K;
    cin >> N >> C >> K;
    vector<int> T(N);
    rep(i, N) cin >> T[i];
    sort(T.begin(), T.end());
    int bus = 0;
    for (int i = 0; i < N;)
    {
        int j = i;
        int p = 0;
        while (T[j] <= T[i] + K && p < C)
        {
            j++;
            p++;
        }
        i += p;
        bus++;
    }
    cout << bus << endl;
    return 0;
}

Measured memory_bytes: 3796
#include<stdio.h>
void swap(int *a, int *b){
	int c;
	c=*a;
	*a=*b;
	*b=c;
}
int main(void){
	int N,i,a[101],j,k=0;
	scanf("%d",&N);
	for(i=0;i<N-1;i++){
		scanf("%d ",&a[i]);
	}
	scanf("%d",&a[N-1]);
	for(i=0;i<N;i++){
		for(j=N-1;j>=i+1;j--){
			if(a[j]<a[j-1]){
				swap(&a[j],&a[j-1]);
				k++;
			}
		}
	}
	for(i=0;i<N-1;i++){
		printf("%d ",a[i]);
	}
	printf("%d\n",a[N-1]);
	printf("%d\n",k);
}

Measured memory_bytes: 2736
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define mod 998244353
#define floop(i,a,b) for (int i=(a);i<(b);i++)
#define rloop(i,a,b) for (int i=(a);i>=(b);i--)
#define floopeq(i,a,b) for (int i=(a);i<(b);i++)
#define pa pair<int,int>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  
    {if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;  }  return res;  
}

void solve()
{
	int x,n;
	cin>>x>>n;
	vector<int>p(n);unordered_map<int,int>mp;
	for(int i=0;i<n;i++)
	{
		cin>>p[i];
		mp[p[i]]++;
	}

	int mini = 1000000;vector<int>ans;int k;
	for(int i=0;i<=1001;i++)
	{
		if(abs(i-x)<mini && mp.find(i)==mp.end())
		{
			k = i;
			mini = abs(i-x);
		}
	}
	cout<<k;
	return;

}
int main() 
{ 
    
    int t;
    t=1;
    while(t--){
    	solve();
    }
    return 0; 

} 


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
	int n;
	cin >> n;
	vector<int> divisor_cnt(n + 2, 0);

	ll ans = 0;
	for(int i = 1; i <= n; ++i)
	{
		for(int j = i; j <= n; j += i)
		{
			ans += j;
		}
	}
	cout << ans;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 42252
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<numeric>
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    int h,w;
    cin >> h >> w;
    vector<string> Map(h);

    rep(i,h)cin >> Map[i];

    rep(i,h)
    {
        rep(j,w)
        {
            if(Map[i][j]=='#')
            {
                cout << '#';
                continue;
            }
            Map[i][j]='0';
            if(i != h-1 && j!= w-1 && Map[i+1][j+1]=='#')++Map[i][j];
            if(j != w-1 && Map[i][j+1]=='#')++Map[i][j];
            if(i != 0 && j != w-1 && Map[i-1][j+1]=='#')++Map[i][j];
            if( i != h-1 && Map[i+1][j]=='#')++Map[i][j];
            if(i != 0 && Map[i-1][j]=='#')++Map[i][j];
            if(i != h-1 && j != 0 && Map[i+1][j-1]=='#')++Map[i][j];
            if(j != 0 && Map[i][j-1]=='#')++Map[i][j];
            if(i != 0 && j!= 0 && Map[i-1][j-1]=='#')++Map[i][j];
            cout << Map[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() { 
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int x,t;
  cin>>x>>t;
  if(x==t||x<t) cout<<"0"<<endl;
  else cout<<x-t<<endl;



  return 0;
}


Measured memory_bytes: 3568
S = input()
N = len(S)
for i in range(1,N+1):
    if i % 2 == 0:
        if S[i-1] not in ['L','U','D']:
            print('No')
            exit()
    else:
        if S[i-1] not in ['R', 'U', 'D' ]:
            print('No')
            exit()

print('Yes')

Measured memory_bytes: 3060
// vim: tabstop=2 softtabstop=2 shiftwidth=2
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

#define PRINT(e) cout << #e ": " << (e) << endl

void solve()
{
  ll n, k;
  cin >> n >> k;
  auto x = n / k;
  cout << min(n - x * k, (x + 1) * k - n) << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll gcd(ll a, ll b) {
  ll v0 = a, v1 = b, v2 = v0%v1;
  while(v2>0) {
    v0 = v1;
    v1 = v2;
    v2 = v0%v1;
  }
  return v1;
}

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

int main() {
  ll A, B, C, D;
  cin>>A>>B>>C>>D;
  ll AA, BB;
  ll ans = B-A+1;
  AA = A+(C-A%C)%C;
  BB = B-(B%C);
  ans -= (BB-AA)/C+1;
  AA = A+(D-A%D)%D;
  BB = B-(B%D);
  ans -= (BB-AA)/D+1;
  ll E = lcm(C, D);
  AA = A+(E-A%E)%E;
  BB = B-(B%E);
  ans += (BB-AA)/E+1;
  cout<<ans<<endl;
}



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

int main(){
	int n;
	cin >> n;
	bool flag = false;
	for(int i=1;i*i<=n;i++) {
		if(n%i==0) {
			if(1<=i and i <= 9 and 1<=(n/i) and (n/i)<=9) flag = true;
		}
	}
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
K,N,*as=$<.read.split.map(&:to_i)

as = as + [K+as[0]]
max = 0
i = 0
while i < as.length - 1
  t = as[i+1] - as[i]
  max = [t,max].max
  i += 1
end

p (K-max)


Measured memory_bytes: 24468
/*------------------------- Bism Allah Alruhmin Alrahim -------------------------------*/
#include <bits/stdc++.h>
using namespace std;

#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                    \
    sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
    {
sim > struct rge
{
    c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
    ~debug()
    {
        cerr << endl;
    }
    eni(!=) cerr << boolalpha << i;
    ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c &)
    {
        ris;
    }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);

#define forn(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i > -1; i--)
#define forl(i, l, r) for (int i = l; i <= r; i++)
#define vc vector
#define f first
#define s second
#define pb(i) push_back(i)
#define mx(ar, n) (*max_element(ar, ar + n))
#define mn(ar, n) (*min_element(ar, ar + n))

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

ll LCM(ll x, ll y)
{
    return (x * y) / __gcd(x, y);
}

bool even(ll n){
  return n%2 == 0;
}

bool odd(ll n){
  return n%2 == 1;
}

int main()
{
    fastio
    clock_t tStart = clock();
    /* --------- My Solution -------- */

    
    double n ;
    cin >> n ; 
    cout << pow(n,3) << endl ;
    // printf("\nTime taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
using namespace std;
string s;
vector <pair<string,string> > v[40][40];
map <string,int> m;
long long int cnt=0;
void rek(int index,int n,string str1,string str2,int b1,int b2) {
	if(index==n) {
		string str="";
		for(int i=str2.size()-1;i>=0;i--) str+=str2[i];
		string s1="";
		s1+=str1;
		s1+=' ';
		s1+=str;
		m[s1]+=1;
		v[b1][b2].push_back(make_pair(str1,str));
		return;
	}
	rek(index+1,n,str1+s[index],str2,b1+1,b2);
	rek(index+1,n,str1,str2+s[index],b1,b2+1);
}
void rek2(int index,int n,string str1,string str2,int b1,int b2) {
	if(index==n) {
		string str="";
		//cout <<"a"<<endl;
		for(int i=str2.size()-1;i>=0;i--) str+=str2[i];
		string s1="";
		s1+=str;
		s1+=' ';
		s1+=str1;
		cnt+=m[s1];
		//cout <<str1<<" "<<str2<<" "<<str<<endl;
		/*for(int i=0;i<v[b2][b1].size();i++) {
			//cout <<v[b2][b1][i].first<<" "<<v[b2][b1][i].second<<endl;
			if(str1+v[b2][b1][i].first==v[b2][b1][i].second+str) cnt+=1;
		}*/
		//cout <<endl;
		return;
	}
	rek2(index+1,n,str1+s[index],str2,b1+1,b2);
	rek2(index+1,n,str1,str2+s[index],b1,b2+1);
}
int main()
{
	int n;
	cin >> n >> s;
	rek(0,n,"","",0,0);
	rek2(n,n*2,"","",0,0);
	cout <<cnt;
	return 0;
}

Measured memory_bytes: 101328
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    a = list(map(int, readline().split()))
    a.sort()

    print(a[-1] - a[0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 61752
A,B,C,D=map(int, list(input()))
L=["+","-"]

for a in L:
  for b in L:
    for c in L:
      now=A
      if a=="+":
        now+=B
      else:
        now-=B
      if b=="+":
        now+=C
      else:
        now-=C
      if c=="+":
        now+=D
      else:
        now-=D
      #print(now)
      if now==7:
        print(str(A)+a+str(B)+b+str(C)+c+str(D)+"=7")
        exit()


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

int main() {

    long long n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e ;
    long long m = min(min(min(a, b), c), min(d, e));
    long long flag=0;
    if(n % m == 0) {
        cout << n / m + 4;
        exit(0);
    }
    else {
        cout << n / m + 5 - flag << endl;
    }

}

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

int sum_f(int n,int count)
{
  int i;
  int sum=0;
  
  for(i=count;i>=1;i--)
  {
    sum+=(n/(int)pow(10,i-1))%10;
  }
  
  return sum;
}

int main()
{
  int n;
  scanf("%d",&n);
  
  int tmp;
  int cnt=0;
  
  tmp=n;
  
  while(tmp>0)
  {
    tmp/=10;
    cnt++;
  }
  
  int sum=0;
  
  sum=sum_f(n,cnt);
  
 if(n%sum==0)
  {
    printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }
  
  return 0;
}
  

Measured memory_bytes: 128
s = input()
i = 0
while True:
	if i == len(s):
		print('YES')
		break
	if len(s) - i < 5:
		print('NO')
		break
	if s[i] == 'd':
		if s[i:i+5] != 'dream':
			print('NO')
			break
		if len(s) - i < 7:
			i += 5
			continue
		if s[i:i+7] != 'dreamer':
			i += 5
			continue
		if len(s) - i == 7 or s[i+7] != 'a':
			i += 7
			continue
		i += 5
		continue
	if s[i] == 'e':
		if s[i:i+5] != 'erase':
			print('NO')
			break
		if len(s) - i < 6:
			i += 5
			continue
		if s[i:i+6] != 'eraser':
			i += 5
			continue
		if len(s) - i == 6 or s[i+6] != 'a':
			i += 6
			continue
		i += 5
		continue
	print('NO')
	break

Measured memory_bytes: 3188
S=input()

i=1
K=1
lastword=[]
lastword.append(S[0])
while i<= (len(S)-1):
  if i==len(S)-1:
    if len(lastword[-1])==1 and S[i]!=S[i-1] or len(lastword[-1])==2:
      K+=1
      break
    elif len(lastword[-1])==1 and S[i]==S[i-1]:
      if lastword[-3]==lastword[-1] or lastword[-1]!=lastword[-2]:
        break
      else:
        K+=1
        break
  
  if len(lastword[-1])==1:
    if S[i]!=S[i-1]:
      lastword.append(S[i])
      i+=1
      K+=1
    else:
      lastword.append(S[i:i+2])  
      i+=2
      K+=1
  else:     # len(lastword)==2:
    lastword.append(S[i])
    i+=1
    K+=1
#  print(i,K,lastword)

print(K)

Measured memory_bytes: 8296
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

bool flags[100100];
void Sieve() {
  flags[0] = true;
  flags[1] = true;
  const int sqrt_x = ceil(sqrt(100100) + 0.1);
  FOR(p,2,sqrt_x){
    if (flags[p])continue;
    for (int mult = p * p; mult < 100100; mult += p)
      flags[mult] = true;
  }
}

ll N;
ll bit[1000010];

void bit_init(vector<ll> v){
  if(!v.empty()){
    N=v.size();
    for(ll x=1; x <= N; ++x) bit[x] = v[x];
    for(ll x=1; x < N; ++x) bit[x+(x&-x)] += bit[x];
  }
}
void bit_add(ll a, ll w){
    for(ll x=a; x <= N; x+=x&-x)bit[x]+=w;
}
ll bit_sum(ll a){
  ll ret=0;
  for(ll x=a;x>0;x-=x&-x) ret+=bit[x];
  return ret;
}

int main(){
  Sieve();
  bit_init(vector<ll>(100010,0));
  rep(i,100010){
    if(flags[i]==false){
      if(i%2){
        if(flags[ll((i+1)/2)]==false){
          bit_add(i,1);
        }
      }
    }
  }

  ll q;cin>>q;
  ll l,r;
  rep(i,q){
    cin>>l>>r;
    cout<<bit_sum(r)-bit_sum(l-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1920