akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

ll cutter[]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384};

bool cut(int in, ll index){
    if(in/cutter[index]%2==0) return false;
    else return true;
}



int main(void){
    ll N, M, X, A[14][14], C[14];
    cin>>N>>M>>X;
    ll bit=pow(2, N);
    ll count=0;
    ll Minim=10000000;
    ll skill[15];
    rep(i, N){
        cin>>C[i];
        rep(j, M){
            cin>>A[i][j];
        }
    }
    rep(i, bit){
        MEMSET(skill, 0);
        count=0;
        rep(j, N){
            if(cut(i, j)){
                count+=C[j];
                rep(k, M){
                    skill[k]+=A[j][k];
                }
            }
        }
        bool ok=true;
        rep(j, M){
            //cout<<skill[j]<<sp;
            if(skill[j]<X) ok=false;
        }
        //cout<<count<<sp<<ok<<endl;
        if(ok) Minim=min(Minim, count);
        //cout<<Minim<<endl;
    }
    cout<<(Minim==10000000 ? -1 : Minim)<<endl;
    return 0;
}


Measured memory_bytes: 4096
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
template<typename T>vector<T> make_v(size_t a){ return vector<T>(a); }
template<typename T,typename... Ts>auto make_v(size_t a, Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T &t, const V &v){ t = v; }
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

string s;

int main(){
    INIT;
    cin >> s;
    int cnt = 0;
    REP(i, 4){
        if(s[i] == '2')cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b;
	char op;
		
	while(true){
		scanf("%d %c %d", &a, &op, &b);
		
		if(op == '?')
			break;
		
		if(op == '+'){
			printf("%d\n",a + b);
		}
		else if(op == '-'){
			printf("%d\n",a - b);
		}
		else if(op == '*'){
			printf("%d\n",a * b);
		}
		else 			{
			printf("%d\n",a / b);
		}
	}	
	return 0;
}

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

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

const long long INF = 1LL << 60;
long long dp[100010];
int main()
{
	int n;
	cin >> n;
	int h[n];
	for (int i = 0; i < n; i++) cin >> h[i];
	for (auto &x : dp) x = INF;
	dp[0] = 0;
	for (int i = 0; i < n; i++){
		chmin(dp[i+1], dp[i] + abs(h[i]-h[i+1]));
		chmin(dp[i+2], dp[i] + abs(h[i]-h[i+2]));
	}

	cout << dp[n-1] << endl;

}



Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
    ll n,ans=0;
    cin>>n;
    for(ll i=1;i<=n/2;i++){
        if(n-i>0){
            if(i!=n-i)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] s = new char[h + 2][w + 2];
		for (int i = 1; i <= h; i++) {
			char[] a = sc.next().toCharArray();
			System.arraycopy(a, 0, s[i], 1, a.length);
		}
		sc.close();

		Queue<Obj> que = new ArrayDeque<Obj>();
		Obj fst = new Obj();
		fst.x = 1;
		fst.y = 1;
		fst.v = 1;
		que.add(fst);

		int[] dx = {-1, 0, 0, 1};
		int[] dy = {0, -1, 1, 0};
		boolean[][] flg = new boolean[h + 2][w + 2];
		flg[1][1] = true;
		int val = 0;
		while (!que.isEmpty()) {
			Obj o = que.poll();
			if (o.x == h && o.y == w) {
				val = o.v;
				break;
			}
			for (int i = 0; i < 4; i++) {
				int nx = o.x + dx[i];
				int ny = o.y + dy[i];
				if (!flg[nx][ny] && s[nx][ny] == '.') {
					Obj next = new Obj();
					next.x = nx;
					next.y = ny;
					next.v = o.v + 1;
					que.add(next);
					flg[nx][ny] = true;
				}
			}
		}

		if (!flg[h][w]) {
			System.out.println(-1);
			return;
		}

		int blk = 0;
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				if (s[i][j] == '#') {
					blk++;
				}
			}
		}
		System.out.println(h * w - blk - val);
	}

	static class Obj {
		int x, y, v;
	}
}


Measured memory_bytes: 23764
N = int(input())
ab = [[int(i) for i in input().split()] for i in range(N)]
cd = [[int(i) for i in input().split()] for i in range(N)]
abm = [0]*N
ans = 0

ab.sort()
cd.sort()

for i in cd:
  temp = -1
  ind = 0
  for index,j in enumerate(ab):
    if i[0] > j[0] and i[1] > j[1] > temp and abm[index] == 0:
      temp = j[1]
      ind = index
  if temp > -1:
    ans += 1
    abm[ind] = 1

print(ans)

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

int main(){
    long long n;
    long long a,b,c,d,e;
    cin >> n;
    cin >> a >> b >> c >> d >> e;
    long long cost = min(a,min(b,min(c,min(d,e))));
    long long result = (n-1)/cost + 5;
    cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define f(i,x,n) for(ll i=x;i<n;i++)
#define fl(i,x,n) for(ll i=n;i>=x;i--)
#define print(x) cout<<x<<endl
#define vec vector<ll>
#define pai pair<ll, ll>
#define itr(it) :: iterator it
#define MAX (ll)1e16
#define MIN (ll)-1e16
using namespace std;
       ///////////   ///     ///   ///      ///   ////////////  ///      ///
       ///           ///     ///   ///      ///   ///      ///  ///      ///
       ///           ///     ///   ///      ///   ///      ///  ///      ///
       ///////////   ///////////   ///      ///   ////////////  ////////////
               ///   ///     ///   ///      ///   ///      ///  ///      ///
               ///   ///     ///   ///      ///   ///      ///  ///      ///
       ///////////   ///     ///   ////////////   ////////////  ///      ///
ll minn( ll a , ll b)
{
    if(a>b)
        return b;
    return a;
}
ll maxx( ll a , ll b)
{
    if(a>b)
        return a;
    return b;
}
ll gcdd(ll a, ll b)
{
    if(b==0)
        return a;
    else
        return gcdd(b,a%b);
}
signed main()
{
    ll n;
    cin>>n;
    f(i,n,1000)
    {
        if(i==111 || i==222 || i==333 || i==444 || i==555 || i==666 || i==777 || i==888 || i==999)
            {
                cout<<i<<endl;
                break;
                }    
}
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  string s; cin >> s;
  int w; cin >> w;
  string ans = "";
  for (int i = 0; i < s.size(); i += w)
    ans += s[i];
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

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

string a,b;

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

	cin>>a>>b;
	int flg=0;
	if(a.size()>b.size()) flg=1;
	else if(b.size()>a.size()) flg=2;
	else {
		REP(i,a.size()) {
			int x=a[i]-'0',y=b[i]-'0';
			if(x==y) continue;
			if(x>y) flg=1;
			else if(y>x) flg=2;
			break;
		}
	}
	cout<<(flg==0?"EQUAL":flg==1?"GREATER":"LESS")<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	double N, K;
	cin >> N >> K;
	int j = 0;
	vector<double>A(N);
	for (int i = 1; i <= N; i++) {
		while (i * pow(2, j) < K) {
			j++;
		}
		A[i - 1] = j;
		j = 0;
	}
	double ans = 0;
	rep(i, N) {
		ans += pow(0.5, A[i]);
	}
	cout <<setprecision(20)<< 1 / N * ans << endl;
}


Measured memory_bytes: 1024
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <map>
# include <stack>
using namespace std;
//# define M_PI 3.141592
# define INF ((int)(1<<30))
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,-1,1,0 }, dy[4] = { 1,0,0,-1 };


int main()
{
	long long n;
	cin >> n;
	int ans = 0;
	while (n != 1)
	{
		long long a, b, c;
		a = b = n / 3;
		if (n % 3 == 0)
		{
			a--;
			b--;
		}
		while (1)
		{
			if (max(n - a - b, a) > max(n - a - b - 2, a + 1))
			{
				a++;
				b++;
			}
			else
			{
				break;
			}
		}
		c = n - a - b;
		n = max({ a,b,c });
		ans++;
	}

	cout << ans << endl;

}

Measured memory_bytes: 3112
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <cstring>
#include <iomanip>
using namespace std;

#define double long double
#define int long long
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << '\n';
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; };
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; };

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << ' ' << b << ' ' << c;
  	return 0;
}

Measured memory_bytes: 256
import sys
import string
s=input()
if s[0]!='A':
  print('WA')
  sys.exit()
elif s[1] in string.ascii_uppercase or s[-1] in string.ascii_uppercase:
  print('WA')
  sys.exit()
else:
  c=0
  for i in s[2:-1]:
    if i in string.ascii_uppercase:c+=1
  if c!=1:
    print('WA')
    sys.exit()
  print('AC')
  


Measured memory_bytes: 4084
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    long long N;
    cin >> N;
    vector<int> cNum;
    while(N>0LL){
        int mod = N%26 + (N%26==0)*26;
        cNum.push_back(mod);
        N -= mod;
        N /= 26LL;
    }
    reverse(All(cNum));
    for(int& digit:cNum){
        cout << char(digit+'a'-1);
    }
    cout << nn;
    return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  string S,T;
  cin>>S>>T;
  int ans=0;
  rep(i,S.size()) ans+=(S[i]!=T[i]);
  cout<<ans<<endl;
}



Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
 
int n;
string s,a;
int main(){
  cin>>n>>s;
  if(n%2==1){
    cout<<"No"<<endl;
  }
  else{
     a=s.substr(0,n/2);
     a+=a;
     if(a==s){
       cout<<"Yes"<<endl;
     }
     else{
       cout<<"No"<<endl;
     }
  }
  }

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

int main(){
  string a = "Sunny", b = "Cloudy", c = "Rainy", today;
  cin >> today;
  
  if(today == a)
    cout << b << endl;
  else if(today == b)
    cout << c << endl;
  else 
    cout << a << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

a, b, c, x, y = inm()
first = a*x + b*y
second = min(x, y) * c * 2 + abs(x-y) * (a if x > y else b)
third = max(x, y) * c * 2
print(min(first, second, third))

Measured memory_bytes: 9152
from itertools import product

n = int(input())
k = int(input())

li = [0,1]

lin = list(product(li, repeat=n))
mi = 10**18

for i in lin:
    point = 1
    for j in i:
        if j == 0:
            point *= 2
        else:
            point += k
    mi = min(point,mi)

print(mi)

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

using namespace std;

#define allof(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    int R, C;
    cin >> R >> C;

    cout << R * C - R - C + 1;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
int n,l,ans;
  scanf("%d%d",&n,&l);
    if(l>=0)
        ans=((n*(n-1+2*l))/2 - l);
    else if(l<=0 && l>-n)
        ans=(n*(n-1+2*l))/2 ;
    else if(l<=-n)
        ans = (n*(n-1+2*l))/2 -(n+l-1);

printf("%d\n",ans);

return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n,m,x;
  cin >> n >> m >> x;

  vll station(n, 0);
  ll a;
  REP(i, m){
    cin >> a;
    station[a-1] = 1;
  }

  ll sum,ans;
  ans = sum = 0;
  REP(i, x)
    sum += station[i];
  ans = sum;
  sum = 0;


  FOR(i, x, n)
    sum += station[i];
  ans = min(ans, sum);


  cout << ans << endl;
  
}


Measured memory_bytes: 256
N = int(input())						# 5

A=[]
for _ in range(N):
	a = int(input())						# 5
	A.append(a)

max_a = max(A)

B=list(A)
B.sort(reverse=True)

if B[0]==B[1]:
	for a in A:
		print(max_a)

else:

	b=max_a
	for i in B:
		if i!=max_a:
			b=i
			break


	for a in A:
		if a==max_a:
			print(b)
		else:
			print(max_a)




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

const int MAX_N = 220000;

vector<int> Dis(MAX_N, 0);
vector<int> C(MAX_N);
vector<ll> ANS(MAX_N, 0);
vector<int> Edge[MAX_N];

int dfs(int parent, int node, int cnt_p){
    int c = C[node];
    int past_dis = Dis[c];
    Dis[c] = 0;
    int present_cnt = cnt_p;
    for(int child : Edge[node]){
        if(child==parent) continue;
        Dis[c] = 0; 
        int next_cnt = dfs(node, child, present_cnt+1);
        int children_number = next_cnt - present_cnt - Dis[c];
        present_cnt = next_cnt;
        ANS[c] += (ll(children_number)*ll(children_number+1)) / 2ll;
    }
    Dis[c] = past_dis + present_cnt - cnt_p + 1;
    return present_cnt;
}

int main(void)
{
    int N;
    cin >> N;
    for(int i=0;i<N;i++) {
        int c;
        cin >> c;
        C[i] = c-1;
    }
    for(int i=0;i<N-1;i++){
        int a, b;
        cin >> a >> b;
        a--;b--;
        Edge[a].push_back(b);
        Edge[b].push_back(a);
    }
    int cnt = dfs(-1, 0, 0);
    for(int c=0;c<N;c++){
        if(c == C[0]) continue;
        int children_number = cnt + 1 - Dis[c];
        ANS[c] += (ll(children_number)*ll(children_number+1)) / 2ll;
    }
    ll total = (ll(N)*ll(N+1)) / 2ll;
    for(int c=0;c<N;c++){
        cout << total - ANS[c] << endl;
    }

    return 0;
}


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

int a, b;

int main()
{
	cin >> a >> b;
	if (a + b == 15)
		printf("+\n");
	else if (a * b == 15)
		printf("*\n");
	else printf("x\n");
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int R, G, B, N, ans = 0;

	cin >> R >> G >> B >> N;

	repc(r, 0, N) repc(g, 0, N) {
		if (r * R + g * G > N) continue;

		int rem = N - (r * R + g * G);
		if (rem % B == 0) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
try {
    long sum =0;
    int min =1000000;
    int max =-1000000;
	
	BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));

	String input1 = buf.readLine();	
	int count = Integer.parseInt(input1);
	
	String input2 = buf.readLine();
	String[] strAry = input2.split(" ");
	
	for (int i = 0; i < count; i++) {
    int x = Integer.parseInt(strAry[i]);
    sum = sum + x;
    if(x < min){ min = x;}
    if(x > max){ max = x;}
	}
	System.out.println(min + " " + max + " " + sum);
} catch (Exception e) {

	System.out.println("????????????");
	
}
		 }
    }

Measured memory_bytes: 28508
use proconio::{fastout, input};
use std::cmp::max;
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        n: usize,
        h: [usize; n]
    }
    let mut res = 0;
    let mut tmp = 0;
    for i in 1..n {
        if h[i] <= h[i - 1] {
            tmp += 1;
        } else {
            res = max(res, tmp);
            tmp = 0;
        }
    }
    res = max(res, tmp);
    println!("{}", res);
}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  Int n=s.size();
  Int ans=0,dir=0;
  for(Int i=0;i<n;i++){
    if(s[i]=='L') dir--;
    else dir++;
    if(dir==4) ans++;
    dir%=4;
  }

  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3208
from collections import Counter
n, k = map(int, input().split())
A = list(map(int, input().split()))
d = Counter(A)
v = list(d.values())
v.sort()
ans = 0
if len(v) >= k:
    for i in range(len(v) - k):
        ans += v[i]
print(ans)

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

#define rep(i, n) for(int i=0; i<n; i++) 

int main() {
    int n;
    cin >> n;
    vector<double> v(n);
    rep(i, n) cin >> v[i];

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

    rep(i, n - 1){
        v[i + 1] = 0.5 * (v[i] + v[i + 1]);
    }

    printf("%.6lf\n", v[n - 1]);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int main(void){
  map<string,string> data;
  data["101"] = " ";
  data["000000"] = "'";
  data["000011"] = ",";
  data["10010001"] = "-";
  data["010001"] = ".";
  data["000001"] = "?";
  data["100101"] = "A";
  data["10011010"] = "B";
  data["0101"] = "C";
  data["0001"] = "D";
  data["110"] = "E";
  data["01001"] = "F";
  data["10011011"] = "G";
  data["010000"] = "H";
  data["0111"] = "I";
  data["10011000"] = "J";
  data["0110"] = "K";
  data["00100"] = "L";
  data["10011001"] = "M";
  data["10011110"] = "N";
  data["00101"] = "O";
  data["111"] = "P";
  data["10011111"] = "Q";
  data["1000"] = "R";
  data["00110"] = "S";
  data["00111"] = "T";
  data["10011100"] = "U";
  data["10011101"] = "V";
  data["000010"] = "W";
  data["10010010"] = "X";
  data["10010011"] = "Y";
  data["10010000"] = "Z";
  map<string,string> data2;
  data2["A"] = "00000";
  data2["B"] = "00001";
  data2["C"] = "00010";
  data2["D"] = "00011";
  data2["E"] = "00100";
  data2["F"] = "00101";
  data2["G"] = "00110";
  data2["H"] = "00111";
  data2["I"] = "01000";
  data2["J"] = "01001";
  data2["K"] = "01010";
  data2["L"] = "01011";
  data2["M"] = "01100";
  data2["N"] = "01101";
  data2["O"] = "01110";
  data2["P"] = "01111";
  data2["Q"] = "10000";
  data2["R"] = "10001";
  data2["S"] = "10010";
  data2["T"] = "10011";
  data2["U"] = "10100";
  data2["V"] = "10101";
  data2["W"] = "10110";
  data2["X"] = "10111";
  data2["Y"] = "11000";
  data2["Z"] = "11001";
  data2[" "] = "11010";
  data2["."] = "11011";
  data2[","] = "11100";
  data2["-"] = "11101";
  data2["'"] = "11110";
  data2["?"] = "11111";
  string line;
  while(getline(cin,line)){
    string code;
    string ans;
    REP(i,line.size()){
      string cha = string(1,line[i]);
      code += data2[cha];
    }
    while(!code.empty()){
      bool f = true;
      REP(i,code.size()){
        string sub = code.substr(0,i+1);
        if(data.find(sub)!=data.end()){
          ans += data[sub];
          code.erase(0,i+1);
          f = false;
          break;
        }
      }
      if(f) break;
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Array.Sort(A);
		bool chk = A[0] == A[1] && A[1] != A[2];
		chk |= A[2] == A[1] && A[0] != A[1];
		Console.WriteLine(chk ? "Yes" : "No");
	}
	int[] A;
	public Sol(){
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int main(){
  int n;
  cin>>n;
  vector<string>s(n);
  for(int i=0;i<n;i++){
    cin>>s.at(i);
  }
  vector<long long int>count(6);
  for(int i=0;i<n;i++){
    if(s.at(i).at(0)=='M')
      count.at(1)++;
    if(s.at(i).at(0)=='A')
      count.at(2)++;
    if(s.at(i).at(0)=='R')
      count.at(3)++;
    if(s.at(i).at(0)=='C')
      count.at(4)++;
    if(s.at(i).at(0)=='H')
      count.at(5)++;
  }
  for(int i=1;i<6;i++){
    count.at(0)+=count.at(i);
  }
  long long int num=0,ans=0;
  for(int i=1;i<6;i++){
    num+=(count.at(i)*(count.at(i)-1)/2)*(count.at(0)-count.at(i))+
         (count.at(i)*(count.at(i)-1)*(count.at(i)-2)/6);
  }
  ans+=(count.at(0)*(count.at(0)-1)*(count.at(0)-2)/6)-num;
  cout<<ans<<endl;
        }


Measured memory_bytes: 6144
from bisect import bisect_right,bisect_left
import sys
N,H = map(int,input().split())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
B =sorted(B,reverse=True)
ama=max(A)

ans =0
for i in range(N):
    if H<=0:
        print(ans)
        sys.exit()
    elif B[i]>=ama:
        H-=B[i]
        ans +=1
    else:
        break
if H>0:
    ans += H//ama
    if H%ama!=0:
        ans +=1
print(ans)

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

 int main()
{
  char a[230];
  scanf("%s",&a);
  int y=strlen(a);
  for(int i=y-2;i>=1;i--)
  {
    int flag=0;
    if(i%2!=0)
    {
        for(int j=0;j<=(i+1)/2-1;j++)
        {
            if(a[j]!=a[j+(i+1)/2])
            {
                flag=1;
                break;
            }
        }
        if(flag==0)
        {
            printf("%d\n",i+1);
            break;
        }
    }
  }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// #define debug(a) cout << "["; rep(i,a.size()) cout << a[i] << ", "; cout<<"]"<< endl;

const ll mod = 1000000007;

int main() {
    int n; cin >> n;
    cout << 1000 * ((n + 999) / 1000) - n << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}


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

    for(int i = 1; i< 1000 ; i++){
        if(i*1000 >= N){
            cout << abs(N -i*1000) << endl;
            return 0;
        }
    }

}

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

void maxHeapify(vector<ll> &arr,int i,int n){
    int left_index = 2 * i ;
    int right_index = 2 * i + 1;
    int large_index = i;
    //printf("%d %d %d\n",left_index,right_index,large_index);
    if(left_index <= n && arr.at(left_index) > arr.at(i)){
        large_index = left_index;
    }
    if(right_index <= n && arr.at(right_index) > arr.at(large_index)){
        large_index = right_index;
    }

    if(large_index != i){
        swap(arr.at(i),arr.at(large_index));
        maxHeapify(arr,large_index,n);
    }    

}

void build(vector<ll> &arr,int n){
    for(int i=n/2;i>=1;i--){
        maxHeapify(arr,i,n);
    }
}

int main(){
    int n;
    cin >> n;
    vector<ll> array(n+1);
    for(int i=1;i<=n;i++){
        cin >> array.at(i);
    }
    build(array,n);
    for(int i=1;i<=n;i++) cout << " " << array.at(i);
    cout << endl;
}


Measured memory_bytes: 6612
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int n = 1;
    int ans = 0;
    for(int i = 0; i < N; i++){
      int a = Integer.parseInt(sc.next());
      if(a == n){
        n++;
      }else{
        ans++;
      }
    }
    System.out.println(N == ans ? -1 : ans);
  }
}

Measured memory_bytes: 48844
import java.io.*;
import java.util.*;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long A;
        A = sc.nextLong();
        long B;
        B = sc.nextLong();
        long C;
        C = sc.nextLong();
        long D;
        D = sc.nextLong();

        final Solver solver = new Solver();
        solver.solve(A, B, C, D);
    }
}

class Solver {
    public void solve(long A, long B, long C, long D) {
        long top = num(B, C, D);
        long bottom = num(A - 1, C, D);
        long ans = top - bottom;

        System.out.println(ans);
    }

    private long num(long N, long C, long D) {
        long lcd = Math.abs(C * D) / gcd(C, D);
        return N - (N / C + N / D - N / lcd);
    }

    private long gcd(long a, long b) {
        return (b == 0) ? a : gcd(b, a % b);
    }
}


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

using namespace std;

int main()
{
    long long a, b, c, k, ans = 0;   cin >> a >> b >> c >> k;
    if (a >= k)
    {
        cout << k << "\n";
    }
    else
    {
        ans += a;
        k -= a;
        if (b >= k)
        {
            cout << ans << "\n";
        }
        else
        {
            k -= b;
            ans -= k;
            cout << ans << "\n";
        }
        
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define reg(i,a,b) for(int i=a;i<=b;++i)
#define reh(i,a,b) for(int i=b;i>=a;--i)
#define in(x) scanf("%d",&x)
#define fro freopen("D:\\testdata.in", "r", stdin)
#define il inline
using namespace std;
typedef long long ll;
const int mx=1e5+10;
ll ans;
int t;
int main(){
	int n;
	scanf("%d",&n);
	reg (i,1,n) {
	    int x;
	    in(x);
	    if (t<=x) {
	       t=max(t,x);
	       ++ans;
	    }

	}
	printf("%lld\n",ans);



	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

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

int main() {
	int A,B,C;
	cin>>A>>B>>C;
	string ans = "No";
	if(A==B&&B==C)ans = "Yes";
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
q = int(input())
Q = []
for i in range(q):
    tmp = list(map(int, input().split()))
    Q.append(tmp)
for query in Q:
    A[query[0]:query[1]] = reversed(A[query[0]:query[1]])
print(*A)


Measured memory_bytes: 5872
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
typedef long long int ll;
int main()
{
    ll n;cin>>n;
    
    ll sum =0, v=1;
    ll prev=0;
    vector<int>ans;
    while(n >0)
    {
        int k = n%26;
        if(k==0)
        {
            ans.push_back(26+'a');
            n = (n/26)-1;
            
        }
        else
        {
            ans.push_back(k+'a');
            n = n/26;
        }
    }
   
    reverse(ans.begin(),ans.end());
    
    for(auto i:ans)cout<<(char)(i-1);
    return 0;
}


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

int main() {
  int N, l, r, i, n;
  n = 0;
  cin >> N;
  for (i = 0; i < N; i++){
    cin >> l >> r;
    n += (r - l + 1);
  }
  cout << n <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
//ONLINE_JUDGE   LOCAL
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int 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  in_o(){
#ifndef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}
 


 
int main(){
	//in_o();
	int n,m;
	cin>>n>>m;
	string s[101];
	FOR(i,0,n){
		string x;
		cin>>x;
		s[i]='#'+x+"#";
	}
	FOR(i,0,m+2){
		cout<<'#';
	}
	cout<<endl;
	FOR(i,0,n){
		cout<<s[i]<<endl;
	}
	FOR(i,0,m+2){
		cout<<'#';
	}
	cout<<endl;
	return 0;
}


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

const int MOD = (int)1e9+7;

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

	int r=0;
	int b=0;
	for(int i=0;i<N;i++){
		if(s.at(i)=='R')	r++;
		else	b++;
	}

	if(r>b)	cout << "Yes" << endl;
	else	cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>


#define gc getchar
#define pc putchar
#define sp pc(' ')
#define lnn pc('\n')
template <class t>
inline void read(t &num) {
    register bool flag = 0;
    register char c = gc();
    while ((c < '0' || c > '9') && c != '-') c = gc();
    if (c == '-') flag = 1, c = gc();
    num = 0;
    while (c >= '0' && c <= '9') num = (num << 1) + (num << 3) + c - '0', c = gc();
    flag && (num = ~(num - 1));
}
template <class t>
inline void print(t num) {
    if (num < 0) pc('-'), num = ~(num - 1);
    if (num >= 10) print(num / 10);
    pc(num % 10 + '0');
}
int min(int a, int b) {
    return a > b ? b : a;
}

typedef long long ll;

int a, b, c;
int main() {
    read(a);
    read(b);
    read(c);
    int d = min(a - b, c);
    print(c - d);
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
	ll a, v;
	cin >> a >> v;
	ll b, w;
	cin >> b >> w;
	ll t;
	cin >> t;
	ll d = abs(a-b);
	if (t*v-t*w >= d) cout << "YES\n";
	else cout << "NO\n";
}


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

#define ii pair<int, int>
#define lli long long int
#define ll pair<lli, lli>
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

int square (int a) {
	return (a * a);
}

double dist(ii a, ii b) {
	return sqrt((double) (square(a.fi - b.fi) + square(a.se - b.se)));
}

int main() {
	int n, perm[10], cnt = 0;
	ii p[10];
	double total = 0.0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d %d", &p[i].fi, &p[i].se);
		perm[i] = i;
	}
	do {
		cnt++;
		for (int i = 1; i < n; i++)
			total += dist(p[perm[i]], p[perm[i - 1]]);
	} while (next_permutation(perm, perm + n));
	total /= (double) cnt;
	printf("%.10lf\n", total);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
typedef long long int ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<vint> vvint;
const ll LINF = 9000000000000000000ll;
const int INF = 2000000000;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint a1(n/2);
    vint a2(n/2);
    vint cnt1(100005, 0);
    vint cnt2(100005, 0);
    rep(i, n) {
        int a;
        cin >> a;
        if (i % 2 == 0) {
            a1[i / 2] = a;
            cnt1[a]++;
        } else {
            a2[i / 2] = a;
            cnt2[a]++;
        }
    }
    vint mx(4);//最頻値
    vint val(4);//最頻値の出現回数
    mx[0] = argmax(cnt1);
    mx[1] = argmax(cnt2);
    val[0] = cnt1[mx[0]];
    val[1] = cnt2[mx[1]];
    cnt1[mx[0]] = 0;
    cnt2[mx[1]] = 0;
    mx[2] = argmax(cnt1);
    mx[3] = argmax(cnt2);
    val[2] = cnt1[mx[2]];
    val[3] = cnt2[mx[3]];

    int ans = n;
    if (mx[0] != mx[1]) {
        ans -= val[0];
        ans -= val[1];
        cout << ans << endl;
        return 0;
    }
    ans -= max(val[0]+val[3], val[2]+val[1]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
/****************************************************************************
Is this the real life? Is this just fantasy?
Caught in a landslide, no escape from reality
Open your eyes, look up to the skies and see
I'm just a poor boy, I need no sympathy
Because I'm easy come, easy go, little high, little low
Any way the wind blows doesn't really matter to me, to me!!!
--------------------------------------------------
CP is quite cool.It becomes cooler when you enjoy learning new things
******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define endl "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define pi pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(a) a.size()
#define ff first
#define ss second
#define debug(x) cout<<#x<<" = "<<x<<endl;
const int mod=1e9+7;

void solve()
{
  int n,k;
  cin>>n>>k;
  vi a(n);
  rep(i,n)
    cin>>a[i];

  vll dp(n);
  dp[0]=0;
  for(int i=1;i<n;i++)
  {
    ll mn=INT64_MAX;
    for(int j=i-1;j>=0 && j>=i-k;j--)
    {
      mn=min(mn,dp[j]+abs(a[i]-a[j]));
    }
    dp[i]=mn;
  }

  cout<<dp[n-1]<<endl;
} 

int main()
{

  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

  ios::sync_with_stdio(false);
  cin.tie(0);

  int t=1;
  // cin>>t;
  while(t--)
  {
    solve();
  }

  return 0;
}


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

using namespace std;

int main()
{
    long long n,m,x,y,z,i,j,k=0;
    cin>>n;
    long long a[n];

    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=n-1;i>=0;i--)
    {
        if(a[i-1]>a[i])
        {
            a[i-1]=a[i-1]-1;
        }
    }
    
    for(i=0;i<n-1;i++)
    {
        if(a[i]>a[i+1])
        {
            k=1;
            break;
        }

    }
    if(k==1)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 1024
(defn inner-input []
  (->> (clojure.string/split (read-line) #"\s")
     (map #(Integer/parseInt %))))

(defn inputs [N]
  (if (zero? N)
    nil
    (cons (inner-input) (inputs (dec N)))))

(defn input []
  (let [[N X](->> (clojure.string/split (read-line) #"\s")
               (map #(Integer/parseInt %)))]
    (list N X (apply concat(inputs N)))))

(defn BitterAlchemy [[N X Ms]]
  (+ N (quot (- X (apply + Ms)) (apply min Ms))))

(-> (input)
  BitterAlchemy
  println)

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

int main()
{
   int N,K; cin>>N>>K;
   vector<int> a(N);
   for(int i=0;i<N;i++) cin>>a[i];

   vector<bool> win(K+1);
   win[0]=false;
   for(int i=1;i<=K;i++){
      win[i]=false;
      for(int j=0;j<N;j++) if(i-a[j]>=0 and !win[i-a[j]]) win[i]=true;
   }
   cout<<(win[K]? "First":"Second")<<endl;
   return 0;
}


Measured memory_bytes: 256