akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>

typedef long long ll;
using namespace std;

int main()
{
	double cv;
	while(~scanf("%lf",&cv)){
		//v=9.8t
		//y=4.9t^2

		int lb=1;
		int ub=100000000;
		
		for(int i=0;i<100;i++){
			int md = (lb+ub)/2;
			if(sqrt((5*md-5)/4.9) * 9.8 > cv) ub = md;
			else if(sqrt((5*md-5)/4.9) * 9.8 < cv) lb = md;			
		}

		cout << ub << endl;

	}
}

Measured memory_bytes: 0
/*
ID: varunra2
LANG: C++
TASK: nondec
*/
 
#include<bits/stdc++.h>
using namespace std;
 
#ifdef DEBUG
#include "lib/debug.h"
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#pragma GCC diagnostic ignored "-Wsign-compare"
//#pragma GCC diagnostic ignored "-Wunused-parameter"
//#pragma GCC diagnostic ignored "-Wunused-variable"
#else
#define debug(...) 42
#endif
 
#define EPS 1e-9
#define IN(A, B, C) assert(B <= A && A <= C)
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
#define MOD 1000000007
#define MP make_pair
#define PB push_back
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define x first
#define y second
 
const double PI = acos(-1.0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef map<int, int> MPII;
typedef multiset<int> MSETI;
typedef set<int> SETI;
typedef set<string> SETS;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<string> VS;
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef pair<int, int> pii;
typedef vector<int> vi;
#pragma GCC diagnostic ignored "-Wsign-compare"
// util functions
 
 
int main() {
  cin.sync_with_stdio(0); cin.tie(0);
 
 string s;
  cin >> s;
  
  int ret = 0;
  int cnt = 0;
  for(int i = 0; i < (int)s.size(); i++) {
  	if(s[i] == 'R') {
    	cnt++;
      	ret = max(ret, cnt);
    }
    else cnt = 0;
  }
  
  cout << ret << endl;
 
  return 0;
}

Measured memory_bytes: 3628
import sys
input = sys.stdin.readline

# B - Battle
def win_takahashi(A, B, C, D):

	for i in range(300):
		if i % 2 == 0:
			C -= B
			
			if C <= 0:
				return True
		else:
			A -= D
			
			if A <= 0:
				return False
			

A, B, C, D = map(int, input().split())

if win_takahashi(A, B, C, D):
	print('Yes')
else:
	print('No')

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

int main() {
  int H, W;
  cin >> H >> W;
  
 
  
  
  // print first row
  for(int i = 0; i < W + 2; i++){
    cout << "#";
  }
  cout << endl;
  
  for(int i = 0; i < H; i++){
    cout << "#";
    string A;
    cin >> A;
    for (int j = 0; j < W; j++){
      cout << A.at(j);
    }  
    cout << "#";
    cout << endl;
  }
  
  
  // print last row
  for(int i = 0; i < W + 2; i++){
    cout << "#";
  }
  cout << endl;
  

  
    
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;
    static CF_Reader in;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        in = new CF_Reader();

        int k = in.intNext();
        String s = in.next();

        if (s.length() <= k) out.println(s);
        else out.printf("%s...", s.substring(0, k));

        out.close();
    }

    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

        int intNext() throws IOException {
            return Integer.parseInt(next());
        }

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

        public int[] nextIntArray(final int n) throws IOException {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = intNext();
            return a;
        }

        public long[] nextLongArray(final int n) throws IOException {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = longNext();
            return a;
        }

        String line() throws IOException {
            return br.readLine().trim();
        }
    }
}


Measured memory_bytes: 34108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    ll a[n];
    rep(i, 0, n){
        cin >> a[i];
    }

    if(a[0] != 0){
        cout << -1 << endl;
        return 0;
    }

    ll count = 0;
    rep(i, 1, n){
        if(a[i] > a[i - 1] + 1){
            cout << -1 << endl;
            return 0;
        }else{
            if(a[i] == a[i - 1] + 1){
                count++;
            }else{
                count += a[i];
            }
        }
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(LL i=0; i<(n); i++)
#define FOR(i, m, n) for(LL i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back
#define INF INT_MAX

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {

	string s;
	int k,size;
	cin >> s >> k;
	size = SZ(s);

	VS u;
	//長さ
	for (int i = 1; i <= min(k, size); i++) {

		for (int j = 0; j <= size - i; j++) {
			string t;
			for (int k = j; k < j + i; k++)t += s[k];
			u.PB(t);
		}
	}
	SORT(u);
	u.erase(unique(u.begin(), u.end()), u.end());

	//for (auto q : u)cout << q << endl;

	cout << u[k-1] << endl;
}

Measured memory_bytes: 1660
#include<cstdio>
#include<iostream>
using namespace std;
int odd(int x){
    if(x % 2 == 0)return 0;
    else return 1;
}
int main()
{
    int a, b, k;
    cin>>a>>b>>k;
    for(int i = 1; i <= k; i++){
        if(i % 2 != 0){
            if(odd(a))a--;
            a /= 2;
            b += a;
        }

        if(i % 2 == 0){
            if(odd(b))b--;
            b /= 2;
            a += b;
        }

    }
    printf("%d %d", a, b);


    return 0;
}


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

int main()
{
    int n, k, x = 1;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        if (2 * x >= x + k)
        {
            x += k;
        }
        else
        {
            x *= 2;
        }
    }
    cout << x << endl;
}

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

void doc(){
    freopen("OB.inp","r",stdin);
    freopen("OB.out","w",stdout);
}

struct List{
    int val;
    struct List *left, *right;
    List(int x){
        val = x;
        left = NULL;
        right = NULL;
    }
};

typedef List *node;
map<int,int> M;

node Add(node head, int x){
    M[x] = 1;
    node temp = new List(x);


    if (head == NULL){
        head = temp;
        return head;
    }
    node p = head;
    node last = NULL;
    while(p != NULL){
        last = p;
        if (x < p->val) p = p->left;
        else p = p->right;
    }
    if (x < last->val) {
        last->left = temp;
    }
    else
        last->right = temp;
    return head;
}

void Inorder(node head){
    if (head == NULL) return;
    Inorder(head->left);
    cout << " " << head->val;
    Inorder(head->right);
}

void Preorder(node head){
    if (head == NULL) return;
    cout << " " << head->val;
    Preorder(head->left);
    Preorder(head->right);
}

void Print(node head){
    Inorder(head);
    cout << '\n';
    Preorder(head);
    cout << '\n';
}

void solve(){

    node head = NULL;
    //if (head != NULL) cout << head->val << '\n';
    int n;
    cin >> n;
    while(n--){
        string s;
        cin >> s;
        if (s == "print") Print(head);
        else{
            int x;
            cin >> x;
            if (s == "insert"){
                head = Add(head, x);
               // if (head != NULL) cout << head->val;
            }
            else{
                if (M[x] == 1) cout << "yes" << '\n';
                else cout << "no" << '\n';
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //doc();


    solve();
}



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

struct ind {
    string key;
    int cnt;
};

int main() {
    cin >> n;
    vector<string> s(n);
    vector<ind> insd;
    for(int i = 0; i < n; ++i) {
        cin >> s.at(i);
    }

    sort(s.begin(), s.end());
    s.push_back("################");

    ind indata;
    indata.key = s.at(0);
    int count = 0;
    for(int i = 0; i <= n; ++i) {
        if(s.at(i) == indata.key) {
            count++;
        }else {
            indata.cnt = count;
            insd.push_back(indata);
            indata.key = s.at(i);
            count = 1;
        }
    }

    int insdlen = insd.size();
    int maxv = 0;
    for(int i = 0; i < insdlen; ++i) {
        maxv = max(maxv, insd.at(i).cnt);
    }

    for(int i = 0; i < insdlen; ++i) {
        if(insd.at(i).cnt == maxv) {
            cout << insd.at(i).key << endl;
        }
    }
}

Measured memory_bytes: 20580
#include<stdio.h>
int main(void){
  int i,sum=0;
  int v[5];
  for(i=0;i<5;i++){
    scanf("%d",&v[i]);
  }
  for(i=0;i<5;i++){
    if(v[i]<40){
      v[i]=40;
    }
    sum=sum+v[i];
  }
  printf("%d\n",sum/5);
  return(0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int N, A, B, C;
vector<int> l;

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

ll rec(int i, int a, int b, int c)
{
  if (i == N)
  {
    if (!a || !b || !c)
      return INF;
    return abs(a - A) + abs(b - B) + abs(c - C);
  }

  ll res = rec(i + 1, a, b, c); // 今ある竹を使用しない場合

  // A, B, Cに使う場合
  // (a ? 10 : 0)とかは最初の1本目は合体コストなし，2本目から10かかることを意味する
  chmin(res, rec(i + 1, a + l[i], b, c) + (a ? 10 : 0)); // 各場合についてresと比較していく
  chmin(res, rec(i + 1, a, b + l[i], c) + (b ? 10 : 0));
  chmin(res, rec(i + 1, a, b, c + l[i]) + (c ? 10 : 0));
  return res;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N >> A >> B >> C;
  l.resize(N);
  for (auto &it : l)
    cin >> it;
  cout << rec(0, 0, 0, 0) << endl;
  return 0;
}

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

using namespace std;

int main() {
  int r, D, x;
  scanf("%d %d %d", &r, &D, &x);
  for (int i = 0; i < 10; ++i) {
    x = r * x - D;
    cout << x << endl;
  }
  return 0;
}



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


int main(){
    ll N ,L;
    cin >> N >> L;
    vector<ll> a(N);
    ll len = 0;
    rep(i,N){
        cin >> a[i];
    }
    bool ok = false;
    int l = 0,r = 0;
    rep(i,N-1){
        len = a[i] + a[i+1];
        if(len >= L){
            ok = true;
            l = i;
            r = i + 1;
            break;
        }
    }
   
    if(ok){
        cout << "Possible" << endl;
        for(int i = 1; i <= l; i++)cout << i << endl;
        for(int i = N-1; i >= r; i--)cout << i << endl;
    }else{
        cout << "Impossible" << endl;
    }   
    return 0;
}

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

int main() {
    int N; cin >> N;
    vector<ll> v(N + 1);
    for (int i = 1; i <= N; ++i) {
        for (int j = i; j <= N; j += i) {
            v[j]++;
        }
    }
    ll ans = 0;
    for (int i = 1; i <= N; ++i) {
        ans += i * (v[i]);
    }
    cout << ans << endl;
}



Measured memory_bytes: 81396
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll> 
#define pic pair<ll,char>
#define vi vector< ll > 
#define vvi vector< vi > 
#define vpi vector< pii > 
#define vvpi vector< vpi > 
#define st  set <ll, greater <ll> >
#define mst  multiset <ll, greater <ll> >
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mapp  unordered_map <ll, ll>
#define ppii pair< pii, pii > 
#define test(t) ll t;cin>>t;while(t--)
#define inarr(n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i];
#define ingra(m) vvi arr(100005);for(ll i=0;i<m;i++){ll u,v;cin>>u>>v;arr[u].pb(v);arr[v].pb(u);}
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
signed main()
{
    fast;
    ll n,k;
    cin>>n>>k;
    ll dp[k+1];
    ll i;
    ll arr[n];
    for(i=0;i<n;i++)
        cin>>arr[i];
    for(i=0;i<=k;i++)
        dp[i] = false;
    for(i=0;i<=k;i++)
    {
        ll j;
        for(j=0;j<n;j++)
        {
            if(i>=arr[j] and dp[i-arr[j]]==false)
                dp[i] = true;
        }
    }
    if(dp[k])
        cout<<"First";
    else
        cout<<"Second";
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

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

		String s  = sc.next();
		String t = sc.next();
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		String u = sc.next();
		
		if(s.equals(u)) {
			a--;
		}else {
			b--;
		}
		
		System.out.println(a + " " + b);
	}




}



Measured memory_bytes: 22612
# coding: utf-8

num = int(input())
str1 = input().split()
str2 = input().split()
str3 = []
for i in range(num):
    str3.append(int(str1[i]) - int(str2[i]))

total = 0
count = 0
for i in range(num):
    if str3[i] > 0:
        total += str3[i]
        count += 1
if count == 0:
    print(0)
else:
    print(total)


Measured memory_bytes: 9120
#include <iostream>
using namespace std;
typedef long long ll;
ll n, res;
string str[310];
int main(void){
    // Your code here!
    cin >> n;
    for (ll i = 0; i < n; i++) {
        cin >> str[i];
    }
    for (ll k = 0; k < n; k++) {
        ll ans = 0;
        for (ll i = 0; i < n; i++) {
            for (ll j = i + 1; j < n; j++) {
                if (str[(i + k) % n][j] != str[(j + k) % n][i]) ans++;
            }
        }
        if (ans == 0) res += n;
    }
    cout << res << endl;
}


Measured memory_bytes: 512
N = int(input())
lst = [0] * 9

for x in [int(x) for x in input().split()]:
    if x <= 399:
        lst[0] = 1
    elif x <= 799:
        lst[1] = 1
    elif x <= 1199:
        lst[2] = 1
    elif x <= 1599:
        lst[3] = 1
    elif x <= 1999:
        lst[4] = 1
    elif x <= 2399:
        lst[5] = 1
    elif x <= 2799:
        lst[6] = 1
    elif x <= 3199:
        lst[7] = 1
    else:
        lst[8] += 1

a = sum(lst[:-1])
b = lst[8]
if a == 0 and b > 0:
    print("1 {0}".format(b))
else:
    print("{0} {1}".format(a, a + b))


Measured memory_bytes: 3064
s[50],j,p,q;main(i){for(;p=atoi(gets(s));printf("%d\n",i)){for(i=0;i<p;s[i++]=strlen(gets(s+i)));for(i=j=0;j<7;)for(p=i++,j=q=1;q>0;)for(q=j++>5?0:j-2&&j-4?8:6;q>1;q-=s[p++]);}}

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

int main(){
  int N;
  cin >> N;
  int a;
  vector<int> s(101,0);
  for(int i=0; i<N; i++){
    cin >> a;
    for(int j=1; j<=a; j++){
      s.at(j)++;
    }
  }
  int ans;
  for(int i=1; i<=N; i++){
    if(s.at(i) >= i){
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define rep(i, l, r, a) for(int i = l; i <= r; i += a)
#define rrep(i, r, l, a) for(int i = r; i >= l; i -= a)
#define repn(i, n) for(int i = 0; i < n; i++)
#define iter(i, a) for(auto i = (a).begin(); i != (a).end(); i++)
#define trav(i, x) for(auto &i : x) 
#define ins insert
#define mp make_pair
#define pb push_back
#define f first
#define s second

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int mod = 1e9 + 7;
const long double pi = acos((long double)(-1));
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	set<int> col;
	repn(i, 3){
		int val;
		cin >> val;
		col.ins(val);
	}
	cout << col.size() << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define ld long douroote
#define pb push_back
#define sz size
#define ll long long
#define ull unsigned long long
#define INF 0x7f7f7f7f
#define sc(a) scanf("%d",&a)
#define scll(a) scanf("%lld",&a)
#define scd(a) scanf("%lf",&a)
#define scc(a) scanf(" %c",&a)
#define scs(a) scanf(" %s",a)
#define me(a,b) memset(a,b,sizeof a)
#define all(a) a.begin(),a.end()
#define allr(a,n) a,a+n
#define loop(a,s,e) for(ll a=s;a<=e;a++)
#define read_arr(a,s,n) for(int i=s;i<n+s;i++){sc(a[i]);}
#define read_arr_ll(a,s,n) for(int i=s;i<n+s;i++){scll(a[i]);}
#define err(a,s) cerr<<a<<s;
#define err_arr(a,s,n) for(int i=s;i<n+s;i++){cerr<<a[i]<<" ";}cerr<<endl;
#define prtll(x) printf("%lld",x);
#define prt(x) printf("%d",x);
using namespace std;
const int N=1e4+10;
int n,m;
bool vis[N][N];
double mem[N][N],a[N];
double dp(int i,int co){
if((co>((n)/2))){return 0.0;}
if(i==n){return (co<=((n)/2));}
if(vis[i][co]){return mem[i][co];}
double &ret=mem[i][co];
ret=0.0;
ret+=1.0*a[i]*(dp(i+1,co));
ret+=1.0*(1.0-a[i])*(dp(i+1,co+1));
vis[i][co]=1;
return ret;
}
int main(){
cin>>n;
loop(i,0,n-1){cin>>a[i];}
double ans=dp(0,0);
printf("%.9lf\n",ans);
return 0;
}
/**
**/


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

int main() {
    int D,G;
    cin >> D >> G;
    int P[D],C[D];
    rep(i,D){
        cin >> P[i] >> C[i];
    }
    int res=INT_MAX;
    for(int bit=0;bit<(1<<D);bit++){
        int point = 0;
        int count =0;
        for(int i=0;i<D;i++){
            if(bit & (1<<i)){
                point += (i+1) * 100 * P[i] + C[i];
                count += P[i];
                //cout <<  i+1 << "*" << 100 << "*" << P[i] << "+" << C[i] << " ";
            }
        }
        //cout << "=" << point << endl;
        if(point < G){
            //cout << "   ";
            for(int j=D-1;0<=j;j--){
                if(!(bit & (1<<j))){
                    int c = ceil((double)(G-point) / ((j+1)*100));
                    //cout << "c=" << c << " ";
                    if(c >= P[j]){ 
                        point += (j+1) * 100 * P[j] + C[j];
                        count += P[j];
                        //cout <<  j+1 << "*" << 100 << "*" << P[j] << "+" << C[j] << " ";
                    }else{
                        point += (j+1) * 100 * c;
                        count += c;
                        //cout <<  j+1 << "*" << 100 << "*" << c << " ";
                    }
                    if(point >= G){
                        break;
                    }
                }
            }
            //cout << "=" << point << endl;
        }
        res = min(res,count);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	boolean[][] map;
	boolean[][] visited;
	int w,h,cnt;
	boolean flag;
	
	void Land(int i, int j){
		if(i<0||j<0||i>=h||j>=w||map[i][j]==false||visited[i][j]==true){
			return;
		}
		visited[i][j] = true;
		flag = true;
		Land(i+1,j);
		Land(i,j+1);
		Land(i-1,j);
		Land(i,j-1);
		Land(i+1,j+1);
		Land(i+1,j-1);
		Land(i-1,j+1);
		Land(i-1,j-1);
	}
	
	void Search(){
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				flag = false;
				Land(i,j);
				if(flag){
					cnt++;
				}
			}
		}
	}
	
	void run(){
		Scanner stdIn = new Scanner(System.in);
		while(true){
			w = stdIn.nextInt();
			h = stdIn.nextInt();
			if((w|h)==0){
				return;
			}
			map = new boolean[h][w];
			visited = new boolean[h][w];
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					int tmp = stdIn.nextInt();
					if(tmp==1){
						map[i][j] = true;
					}
				}
			}
			cnt = 0;
			Search();
			System.out.println(cnt);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x1 = scan.nextInt();
		int y1 = scan.nextInt();
		int x2 = scan.nextInt();
		int y2 = scan.nextInt();
		scan.close();
		int x = x2-x1;
		int y = y2-y1;
		System.out.println((x2-y)+" "+(y2+x) +" "+(x1-y)+" "+(y1+x));
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    int n; cin >> n;
    vector<int> a(101);
    rep(i,n) cin >> a[i];
    sort(a.rbegin(), a.rend());
    int alice=0;
    int bob=0;
    for(int i=0; i < n; i+=2){
        alice += a[i];
        bob += a[i+1];
    }
    cout << alice-bob << endl;
    return 0;
}


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

int main() {
	float n, m; cin >> n >> m;
	vector<float> v(n);
	float t = 0;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		t += v[i];
	}
	float c = 0;
	for (int i = 0; i < n; i++) {
		if (v[i] >= t/(4*m)) c++;
	}
	if (c >= m) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

string op(int x) {
	return x > 0 ? "+" : "-";
}

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


	string s;
	cin >> s;
	int a = s[0] - '0', b = s[1] - '0', c = s[2] - '0', d = s[3] - '0';

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < 2; k++) {
				int bb = i ? b : -b;
				int cc = j ? c : -c;
				int dd = k ? d : -d;

				if (a + bb + cc + dd == 7) {
					cout << a << op(bb) << abs(bb) << op(cc) << abs(cc) << op(dd) << abs(dd) << "=" << 7 << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(input()) for i in range(n)]

memo = {}
for i in range(n):
    memo[a[i]] = i
ans = 0
pos = -1
cnt = 0
for i in range(n):
    if pos < memo[i+1]:
        cnt += 1
        pos = memo[i+1]
    else:
        ans = max(ans, cnt)
        cnt = 1
        pos = memo[i+1]
print(n - max(ans, cnt))


Measured memory_bytes: 35076
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(long long *)a>*(long long *)b)return 1;
    return -1;
}
int main()
{   int a,b,k,x,n,m,i,y,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b&&b==c)
    printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N, A, B;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>A>>B;
    if(N<A+B-1||N>1LL*A*B){
        cout1(-1); return 0;
    }
    
    vector<int> T;
    int S=N-A;
    int cur=N;
    rep(i,A){
        int num=min(B-1,S)+1;
        S-=num-1;
        rep(j,num) T.push_back(cur-num+1+j);
        cur-=num;
    }
    reverse(all(T));
    for(auto v:T) cout<<v<<" ";
    cout<<endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LLong_MAX // long long INF
#define inf INT_MAX // int inf
 
typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;
 
int main(){
    string s;
    cin >> s;
    int n =s.length();
    rep(i,n) {
        cout << "x";
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int r = sc.nextInt();
		int D = sc.nextInt();
		int x = sc.nextInt();

		for (int i = 0; i < 10; i++) {
			x = r*x - D;
			System.out.println(x);
		}
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq  priority_queue<double, std::vector<double>, std::greater<double>>

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

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




int main(){
    int N;
    cin >> N;
    vector<int> P(N);
    int small = 2200000;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> P[i];
    }
    for (int i = 0; i < N;i++)
    {
        if(small >= P[i]){
            ans++;
            small = P[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
// need
#include <iostream>
#include <algorithm>
// data structure
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <queue>
//#include <deque>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <array>
// etc
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
// utility
#define all(i) (i).begin(), (i).end()
#define rep(i, n) for(int i=0;i<int(n);++i)
#define rrep(i, n) for(int i=int(n)-1;i>=0;--i)
#define in(a, x, b) (a<=x && x<b)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

template<typename S, typename T>
std::ostream& operator<<(std::ostream& os, std::pair<S, T> p) {
  os << "(" << p.first << ", " << p.second << ")"; return os;
}

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using PAIR = std::pair<int, int>;
using PAIRLL = std::pair<ll, ll>;
constexpr int MOD = 1000000007;


signed main() {
  int H, W;
  std::cin >> H >> W;

  std::vector<std::string> a(H);

  rep(i, H){
    std::cin >> a.at(i);
    a.at(i) = '#'+a.at(i)+'#';
  }

  rep(i, W+2) std::cout << '#';
  std::cout << std::endl;
  rep(i, H) std::cout << a.at(i) << std::endl;    
  rep(i, W+2) std::cout << '#';
  std::cout << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <functional>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <algorithm>
#define ll long long
#define PI acos(-1)
#define mes(x,y) memset(x,y,sizeof(x))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
ll GCD(ll a, ll b) {//最大公约数
	return b == 0 ? a : GCD(b, a % b);
}
ll Power(ll a, ll b, ll p) { //计算(a^b)%p;
	ll ans = 1;
	while (b) {
		if (b & 1) //等价于b%2，判断b的奇偶性
			ans = ans * a % p; //如果为奇数，证明该位为1，需要乘上a
		a = a * a % p; //计算a^(2^i)
		b >>= 1; //等价于b/=2;
	}
	return ans;
}
bool isprime(ll num)
{
	if (num == 2 || num == 3)
		return true;
	if (num % 6 != 1 && num % 6 != 5)
		return false;
	ll t = sqrt((double)num);
	for (ll i = 5; i <= t; i += 6)
		if (num % i == 0 || num % (i + 2) == 0)
			return false;
	return true;
}
string sum(string s1, string s2)
{
	if (s1.length() < s2.length())
	{
		string temp = s1;
		s1 = s2;
		s2 = temp;
	}
	int i, j;
	for (i = s1.length() - 1, j = s2.length() - 1; i >= 0; i--, j--)
	{
		s1[i] = char(s1[i] + (j >= 0 ? s2[j] - '0' : 0));   //注意细节
		if (s1[i] - '0' >= 10)
		{
			s1[i] = char((s1[i] - '0') % 10 + '0');
			if (i) s1[i - 1]++;
			else s1 = '1' + s1;
		}
	}
	return s1;
}
bool isRunyear(int year)
{
	if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
	{
		return true;
	}
	else {
		return false;
	}
}
ll n, m, i, j, k, t;
const ll INF = 1e9 + 10;

int main() {
	FAST_IO;
	double r;
	while (cin >> n) {
		map<ll, ll>mm;
		for (i = 1; i < n; i++) {
			cin >> k;
			mm[k]++;
		}
		for (i = 1; i <= n; i++) {
			cout << mm[i] << endl;
		}
	}
}

Measured memory_bytes: 15700
def c():
    W, H, x, y = map(int, input().split())

    # a = (y-H/2.0)/(W/2.0-x)
    # b = y-a*x
    if 2*x == W and 2*y == H:
        print(W*H/2.0, 1)
    else:
        print(W*H/2.0, 0)

c()

Measured memory_bytes: 38256
n,m,l=map(int,input().split())
A=[]
B=[]
for i in range(n): A.append(list(map(int,input().split())))
for j in range(m): B.append(list(map(int,input().split())))
for A_r in A:
	print(" ".join(map(str,[sum([x*y for x,y in zip(A_r,[B_r[k] for B_r in B])]) for k in range(l)])))


Measured memory_bytes: 6316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}
 
 
int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, string>> a(m);
    set<int> ac;
    vector<int> wa(n);
    for(auto &p : a ) cin >> p.first >> p.second;
    for(auto p : a) {
        if(p.second == "AC") ac.insert(p.first);
        else if (!ac.count(p.first)) wa[p.first - 1]++;
        else continue;
    }
    int pena = 0;
    rep(i, n) {
        if(ac.count(i + 1)) pena += wa[i];
    }
    cout << ac.size() << ' ' << pena << endl;
}

Measured memory_bytes: 12156
n = int(input())
a = list(map(int, input().split()))

d = {}
for ai in a:
  if ai in d:
    d[ai] = d[ai] + 1
  else:
    d[ai] = 1

cnt = 0
for key, value in d.items():
  if key > value:
    cnt = cnt + value
  elif key < value:
    cnt = cnt + value - key

print(cnt)

Measured memory_bytes: 18172
import numpy as np

N = int(input())
A = []
B = []
for i in range(N):
    a,b=map(int, input().split())
    A.append(a)
    B.append(b)
    
Aarray = np.array(A)
Barray = np.array(B)

medA = np.median(Aarray)
medB = np.median(Barray)

if N%2 == 1:
    ans = medB-medA+1
else:
    ans = 2*(medB-medA)+1
    

print(str(int(ans)))

Measured memory_bytes: 47488
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include "math.h"

using namespace std;

int main() {
    
    long k, a, b;
    
    cin >> k >> a >> b;
    
    if (b - a < 3) {
        cout << k+1 <<endl;
    } else {
        long l = k-(a-1);
        long hl = l/2;
        if (l % 2 == 0) {
            cout << (hl * (b-a)) + a <<endl;
        } else {
            cout << (hl * (b-a)) + a + 1 <<endl;
        }
    }

    return 0;
    
}

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

s = sum(A)
B = [0]
for i in range(N):
    B.append(B[i] + A[i])

ans = float('inf')
for i in range(1, N):
    ans = min(ans, abs(s-(2*B[i])))

print(ans)


Measured memory_bytes: 101072
N = int(input())
a = [int(s) for s in input().split()]
b = int(1)
flag = int(0)
flag2 = int(0)

#0がないか確認する
for i in range(N):
  if a[i] == 0:
    flag = 1
    break
  else:
    pass

for i in range(N):
  b = b * a[i]
  if b > 1000000000000000000:
    flag2 = 1
    break
  else:
    pass

if flag == 1:
  print("0")
elif flag2 == 1:
  print("-1")
else:
  print(int(b))


Measured memory_bytes: 21576
#include<bits/stdc++.h>
using namespace std;
int a[101];
int main(){
	int n,s=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		int f=0;
		cin>>a[i];
		if(i==1){
			++s;
			continue;
		}
		for(int j=1;j<i;j++){
			if(a[j]>a[i]){
				f=1;
				break;
			}
		}
		if(f==0)++s;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
//https://blog.csdn.net/hesorchen
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define endl "\n"
#define lowbit(a) (a & (-a))
#define INF 0x3f3f3f3f
#define MAX 1010
#define mod 1000000007
#define PI 3.1415926

struct node
{
    int a, b, w;
} p[500000];
int ct = 1;
int ans;

int pre[500000];
int find(int x)
{
    if (pre[x] != x)
        return pre[x] = find(pre[x]);
    return x;
}
int mix(int a, int b)
{
    pre[a] = b;
}
int n, m;
void intt()
{
    for (int i = 0; i <= n; i++)
        pre[i] = i;
}

int check(int x)
{
    int res = 0;
    for (int i = 1; i < ct; i++)
    {
        if (i == x)
            continue;
        if (find(p[i].a) != find(p[i].b))
        {
            pre[find(p[i].a)] = find(p[i].b);
            res++;
        }
        if (res == n - 1)
            break;
    }
    if (res == n - 1)
        return 0;
    return 1;
}
int main()
{

    cin >> n >> m;
    while (m--)
    {
        cin >> p[ct].a;
        cin >> p[ct++].b;
    }

    // for(int i=1;i<=m;i++)
    for (int i = 1; i < ct; i++)
    {
        intt();
        if (check(i))
            ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#数字 1, 2, ..., 9 からなる文字列 S があります。 
#ダックスフンドのルンルンは、Sから連続する 3 個の数字を取り出し、
#1 つの整数 X としてご主人様の元に持っていきます。
#（数字の順番を変えることはできません。）
#ご主人様が大好きな数は 753 で、これに近い数ほど好きです。 
#X と 753 の差（の絶対値）は最小でいくつになるでしょうか？

S = input()
num = 753
ans = 999
for i in range(len(S)-1):
    n = abs(num - int(S[i:i+3]))
    if n<ans:
        ans = n
    else:
        ans == ans
print(ans)

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

using namespace std;
typedef long long ll;

#define  input freopen("in.txt","r",stdin)
#define  output freopen("out.txt","w",stdout)

const int mxn = 1e5+5;
ll dp[mxn];
ll arr[mxn];
ll n;

int main()
{
	//input;
	//output;

	cin >> n;

	for(int i = 0; i < n; i++) cin >> arr[i], dp[i] = 1e18;
	dp[0] = 0;

	for(int i = 0; i < n; i++) 
	{
		dp[i+1] = min(dp[i+1], dp[i]+abs(arr[i]-arr[i+1]));
		dp[i+2] = min(dp[i+2], dp[i]+abs(arr[i]-arr[i+2]));
	}
	cout << dp[n-1] << '\n';
	return 0;
}

Measured memory_bytes: 1920
// inputに入力データ全体が入る
function Main(input) {
  var ans
  if (input % 2 !== 0) {
    ans = 2 * input
  } else {
    ans = input
  }

  console.log(ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	
	scanf("%d", &a);
	scanf("%d", &b);
	
	if (a > b){
		printf("a > b\n");
	}
	else if (a < b){
		printf("a < b\n");
	}
	else if (a == b){
		printf("a == b\n");
	}
	
	return (0);
}

Measured memory_bytes: 580
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<stw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;

int main(void){
    int N,M;cin>>N>>M;
    vector<int> digit(N+1,-1);
    int s = 0;
    int alt = 0;
    int ans = 0;
    int end = 0;
    for(int i=0;i<M;i++){
        cin >> s;
        alt = digit[s];
        cin >> digit[s];
        if(alt!=-1&&alt!=digit[s]){
            end = 1;
        }
        if(digit[1]==0&&N!=1){
            end = 1;
        }else if(digit[1]==0&&N==1){
            end = 2;
        }
    }
    if(end==1){
        cout << -1 << endl;
    }else if(end==2){
        cout << 0 << endl;
    }else{
        for(int i=1;i<=N;i++){
            if(digit[i]==-1){
                if(i==1){
                    digit[i] = 1;
                }else{
                    digit[i] = 0;
                }
            }
        }
        for(int i=1;i<=N;i++){
            ans += digit[i]*pow(10,N-i);
        }
        if(M!=0){
            cout << ans << endl;
        }else if(M==0){
            if(N==1){
                cout << 0 << endl;
            }else{
                cout << pow(10,N-1);
            }
        }
    }
}


Measured memory_bytes: 256
<?php
list($n) = ints();
for ($i = 0; $i < $n; $i++) {
    list($c[], $s[], $f[]) = ints();
}
for ($i = 0; $i < $n; $i++) {
    $t = 0;
    for ($j = $i; $j < $n - 1; $j++) {
        if ($t < $s[$j]) {
            $t = $s[$j] + $c[$j];
        } else {
            $t = $f[$j] * intval(ceil($t / $f[$j])) + $c[$j];
        }
    }
    $ans[] = $t;
}
echo implode(PHP_EOL, $ans);

function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

using namespace std;

int main(){
  string s, sub;
  int k;
  vector<string> v;
  unordered_map<string, int> m;

  cin >> s >> k;

  int size = s.size();
  for(int i = 0; i < size; ++i){
    for(int j = 1; j <= k && (i + j) <= size; ++j){
      sub = s.substr(i, j);
      if(m[sub] == 0){
        m[sub] = 1;
        v.push_back(sub);
      }
    }
  }

  sort(v.begin(), v.end());

  printf("%s\n", v[k - 1].c_str());

  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N; cin >> N;
    vector<int> d(N);
    for (int i=0;i<N;i++) cin >> d[i];
    sort(d.begin(),d.end());
    cout << (d[N/2]-d[N/2-1]) << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(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; }
typedef long long ll;
using namespace std;
int main(void){
    vector<int> a(3);cin>>a[0]>>a[1]>>a[2];
    sort(a.begin(),a.end());
    cout<<a[2]-a[0]<<endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(int argc, char const *argv[]) {
	unsigned int n, d, x, sum=0;
	cin >> n >> d >> x;

	for(int i = 0; i<n; i++) {
		int a;
		cin >> a;

		sum += (d-1)/a;
	}

	cout << sum + x + n;

	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <vector> // vector
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
  int N, M, H, A, B;
  cin >> N >> M;
  vector<vector<int>> data(N+1);
  int cnt = 0;
  for (int i = 1; i <= N; i++){
    cin >> H;
    data[i].push_back(H);
  }
  for (int i = 0; i < M; i++){
    cin >> A >> B;
    data[A].push_back(data[B][0]);
    data[B].push_back(data[A][0]);
    }
  for (int i = 1; i < data.size(); i++){
     if (data[i].size() == 1) {
         cnt++;
         continue;
       }
      bool judge = true;
    for (int j = 1; j < data[i].size(); j++){
       if(data[i][0] <= data[i].at(j)){
       judge = false;
       break;
       }
    }
    if (judge) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 9240
#include <iostream>
#include <string>
using namespace std;
int get(int scount, string *s, int &now, int deep = 0) {
	char c = s[now++][deep++];
	int temp = c == '+' ? 0 : 1;
	while (now < scount) {
		if (s[now].size() <= deep) return temp;
		else if ('0' <= s[now][deep] && s[now][deep] <= '9') {
			if (c == '+') temp += s[now++][deep] - '0';
			else temp *= s[now++][deep] - '0';
		}
		else {
			if (c == '+') temp += get(scount, s, now, deep);
			else temp *= get(scount, s, now, deep);
		}
	}
	return temp;
}
int main() {
	int i;
	while(cin >> i && i != 0) {
		string *s = new string[i];
		for (int j = 0; j < i; j++) cin >> s[j];
		int t = 0;
		if (i != 1) cout << get(i, s, t) << endl;
		else cout << s[0][0] << endl;
	}
}


Measured memory_bytes: 3288
N = int(input())
A = tuple(map(int, input().split(' ')))

if A[0] == 0:
    cs = 1
    ans1 = 1
else:
    cs = A[0]
    ans1 = 0

for na in A[1:]:
    if cs >= 0:
        cs += na
        if cs < 0:
            continue

        ans1 += abs(cs) + 1
        cs = -1
    else:
        cs += na
        if cs > 0:
            continue

        ans1 += abs(cs) + 1
        cs = 1

if A[0] == 0:
    cs = -1
    ans2 = 1
elif A[0] > 0:
    cs = -1
    ans2 = abs(A[0]) + 1
else:
    cs = 1
    ans2 = abs(A[0]) + 1

for na in A[1:]:
    if cs >= 0:
        cs += na
        if cs < 0:
            continue

        ans2 += abs(cs) + 1
        cs = -1
    else:
        cs += na
        if cs > 0:
            continue

        ans2 += abs(cs) + 1
        cs = 1

print(min(ans1, ans2))


Measured memory_bytes: 21108
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#define get aaa

using namespace std;

typedef long long ll;

mt19937 rnd(228);

const int N = 600 + 1;

char c[N][N];
char d[N][N];
bitset <N> good[N];
bitset <N> get[N][N];

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cin >> c[i][j];
            get[j][c[i][j] - 'a'][i] = 1;
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int t = 0; t < n; t++)
        {
            good[i][t + n] = 1;
        }
    }
    ll ans = 0;
    vector <int> cnt(n);
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++)
    {
        cnt[(i - j + n) % n]++;
    }
    for (int x = 0; x < n; x++)
    {
        bool good = true;
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                if (c[i][j] != c[(j - x + n) % n][(i + x) % n])
                {
                    good = false;
                }
            }
        }
        if (good) 
        {
            ans += cnt[x];
        }
    }
    /*
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            for (int x = 0; x < n; x++)
            {
                int a = (x - i + n) % n;
                bitset <N> kek = get[x][c[i][j] - 'a'];
                kek <<= n;
                kek >>= j;
                good[a] &= kek;
            }
        }
    }
    ll ans = 0;
    */
    //for (int i = 0; i < n; i++) ans += good[i].count();
    cout << ans << '\n';
}


Measured memory_bytes: 14976
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define for1(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define endl '\n'
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            if (k == i * (m - j) + j * (n - i)) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
	return 0;
}

Measured memory_bytes: 256
/*https://atcoder.jp/contests/s8pc-4/tasks/s8pc_4_b*/

#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 next_combination(int sub) {
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}


int main(){
    int n,k;
    cin >> n >> k;
    k--;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    if(k==0) {
        cout << 0 << endl;
        return 0;
    }
    n--;
    int bit = (1<<k)-1;
    //cout << bitset<16>(bit) << endl; 
    ll res = 1001001001001;
    for(; bit < (1<<n); bit = next_combination(bit)){
        ll high = a[0];
        ll temp = 0;
        //cout << bitset<16>(bit) << endl; 
        rep(i,n){
            //cout << "i:" << i+1 <<" ";
            if(bit>>i & 1){
                //cout << "yes " << "h: " << high << "a: " << a[i+1] << endl;
                if(high>=a[i+1]){
                    temp+=(high-a[i+1]+1);
                    high++;
                }
                else{
                    high=a[i+1];
                }
            }
            else{
                if(high<a[i+1]) high = a[i+1];
                //cout << "no " << high << endl;
            }

        }
        res = min(temp,res);
    }
    cout << res << endl;
}

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

int main()
{
	ll i,j,n,m,k;
	scanf("%lld%lld",&n,&k);
	m=n%k;
	if (m>k-m) printf("%lld\n",k-m);
	else printf("%lld\n",m);
	return 0;
}

Measured memory_bytes: 256