akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < n;i++)
typedef long long ll;
using namespace std;

int main() {
  ll a, b, k; cin >> a >> b >> k;
  if(k <= a){
    cout << a - k << ' ' << b << endl;
  }else if(k <= a + b){
    cout << 0 << ' ' << b - (k - a) << endl;
  }else{
    cout << 0 << ' ' << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
const long long MOD = 1e18 ;
const long long INF = 1e18;
const int INT_INF   = 1e9 + 8;
int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD, long long tot = 1) {
    for(;exp > 0; exp >>= 1, base = base * base % mod) if((exp & 1) == 1) tot = tot * base % mod;
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD, long long tot = 0) {
    for(;exp > 0; exp >>= 1, base = base * 2 % mod) if((exp & 1) == 1) tot = (tot + base) % mod;
    return tot;
}
struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

const int MAXN = 100005;

vector<pair<int, int>> adj[MAXN];
vector<int> used[MAXN];
int deg[MAXN], ans[MAXN];
bitset<MAXN> cur;

void helper(int node, int prev = -1){

    cur.reset();
    for(auto i : used[node]) cur[i] = 1;
    int p = 1;
    for(auto nx : adj[node]){
        if(ans[nx.second] != 0) continue;
        while(cur[p]) ++p;
        ans[nx.second] = p;
        used[nx.first].push_back(p);
        ++p;
    }

    used[node].clear();

    for(auto nx : adj[node]){
        if(nx.first == prev) continue;
        helper(nx.first, node);
    }

}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

    int n, k = 0; cin >> n;

    for(int a, b, i = 1; i < n; ++i){
        cin >> a >> b;
        adj[a].push_back(make_pair(b, i));
        adj[b].push_back(make_pair(a, i));
        ++deg[a]; ++deg[b];
        k = max(k, max(deg[a], deg[b]));
    }

    cout << k << "\n";

    helper(1);

    for(int i = 1; i < n; ++i){
        cout << ans[i] << "\n";
    }

    return 0;

}


Measured memory_bytes: 14592
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long

signed main() {
  int n;
  cin >> n;
  int dp[90];
  dp[0] = 2;
  dp[1] = 1;
  for (int i = 2; i < 90; i++) {
    dp[i] = dp[i - 1] + dp[i - 2];
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 256
x1, x2, x3, x4, x5 = map(int, input().split())
if x1 == 0:
    print("1")
elif x2 == 0:
    print("2")
elif x3 == 0:
    print("3")
elif x4 == 0:
    print("4")
else:
    print("5")

Measured memory_bytes: 9168
def S(x1,y1,x2,y2,x3,y3):
    return ((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1))/2.0
import sys
for dataset in sys.stdin:
    x1,y1,x2,y2,x3,y3,xp,yp=map(float,dataset.split(" "))
    ABP=S(x1,y1,x2,y2,xp,yp)
    BCP=S(x2,y2,x3,y3,xp,yp)
    CAP=S(x3,y3,x1,y1,xp,yp)
    if ABP>0 and BCP>0 and CAP>0:
        print 'YES'
    elif ABP<0 and BCP<0 and CAP<0:
        print 'YES'
    else:
        print 'NO'

Measured memory_bytes: 6340
#include<stdio.h>
int main(void) {

int max, min, i, n, a;
long long int sum;

max = -1000000;
min = 1000000;
sum = 0;

scanf("%d\n",&n);
for(i=n;i>0;i--) {
  scanf("%d\n",&a);
  if(max < a) max = a;
  if(min > a) min = a;
  sum += a;
}

printf("%d %d %lld\n",min, max, sum);  
  return 0;
}


Measured memory_bytes: 2092
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
const int MAX_N=1<<20;
typedef long long ll;
typedef pair<int,int>P;
int N,A[200005],T,n,dat[2*MAX_N-1];

void init(int n_)
{
	n=1;
	while(n<n_)n*=2;
	for(int i=0;i<2*n-1;i++)dat[i]=-1;
}

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

int query(int a,int b,int k=0,int l=0,int r=n)
{
	if(r<=a||b<=l)return -1;
	if(a<=l&&r<=b)return dat[k];
	else
	{
		int vl=query(a,b,k*2+1,l,(l+r)/2);
		int vr=query(a,b,k*2+2,(l+r)/2,r);
		return max(vl,vr);
	}
}


int main()
{
	int mx=-1,cnt=0;
	scanf("%d%d",&N,&T);
	n=N;
	init(n);
	for(int i=0;i<N;i++)
	{
		scanf("%d",&A[i]);
		update(i,A[i]);
	}
	for(int i=0;i<N;i++)
	{
		int t=query(i,n,0,0,n)-A[i];
		if(t==mx)cnt++;
		else if(t>mx)
		{
			mx=t;
			cnt=1;
		}
	}
	printf("%d\n",cnt);
	return 0;
}




Measured memory_bytes: 1664
S = str(input())
T = str(input())
a = len(S)
b = len(T)
candidates =[]
if (a < b):
    B = "UNRESTORABLE"
else:
    m = a-b
    B = "UNRESTORABLE"
    i = m
    for i in range(m+1):
        for c1, c2 in zip(S[i:i+b], T):
            if c1 != '?' and c1 != c2:
                break   
        else:
            cand = S[:i] + T + S[i+len(T):]
            candidates.append(cand.replace('?','a'))

if candidates:
    print(min(candidates))
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
N = int(input())
A = input().split()

Ans = 0
Amax = 0

for i in range(len(A)):
    A[i] = int(A[i])
    if Amax < A[i]:
        Amax = A[i]
    Ans = Ans + (Amax - A[i])

print(Ans)

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

int main() {
  int d;
  cin >> d;
  cout << "Christmas";
  rep(i, 25-d) cout << " Eve";
  cout << endl;
  
  return 0;
}


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

#define ll long long
#define ull unsigned long long
#define ld long double
#define fo(i,start,end) for(int i=start;start<end?i<end:i>end;start<end?i+=1:i-=1)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vop vector<pll>
#define vov vector<vector<ll>>
#define endl "\n"
using namespace std;
const ld pi=3.14159265358979323;

const long long mod1=1e9+7;
const long long mod2=1e18;
const ll mod3=9e18;
const ll N=1e9+7;

long long power(ll  x, ll n){if(n==0)return 1;ll temp=power(x,n/2);if(n%2==0)return temp*temp;else return x*temp*temp;}

ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return (a*b)/(gcd(a,b));}
void swap(int* a, int* b){int t = *a;*a = *b;*b = t;}
bool f(ll x,ll y){return x>y;}
bool cmp(ll x ,ll y){
    return abs(x)<abs(y);
}
ll MAX(ll a,ll b){return a>b?a:b;}
ll MIN(ll x,ll  y){return x>y?y:x;}

ll pmod(ll a, ll b,ll mod)//a^b%mod
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b/=2;
        a=(a*a)%mod;
    }
    return ans;
}

vll adj[100001];

ll vis[100001];






void solve(){
ll x;
cin>>x;
if(x<30)cout<<"No";
else cout<<"Yes";



}






















int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin) ;
    freopen("output.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
#endif








    ll t;
    t=1;
    //  cin>>t;
    //  cin.ignore();
    while(t--){

        solve();
    }




    return 0;


}

////vll adj[100001];
////ll vis[100001];
////ll sssp[100001];

Measured memory_bytes: 5956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

int main(void) {
    string S;
    cin >> S;
    int red = 0, blue = 0;

    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '0') {
            red++;
        } else {  // S[i] == '1'
            blue++;
        }
    }
    int ans = min(red, blue) * 2;

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

Measured memory_bytes: 512
#ifdef _MSC_VER
#  define _CRT_SECURE_NO_WARNINGS
#  define _USE_MATH_DEFINES
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double;
using u32 = unsigned int; using u64 = unsigned long long int; using str = string;
template <typename T> using vec = vector<T>; void in() { }
template <typename T, typename...TS> void in(T &&x, TS &&...xs) { cin >> x; in(move(xs)...); }
template <typename T> void out(T &&x) { cout << x << "\n"; }
template <typename T, typename...TS> void out(T &&x, TS &&...xs) { cout << x << " "; out(move(xs)...); }
#define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
#define get(t) []{ t x; cin >> x; return x; }()
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define even(x) ((abs(x) & 1) == 0)
#define odd(x) ((abs(x) & 1) == 1)
#define bit(x, i) (((x) >> i) & 1)
#define append emplace_back
#define bisect_left lower_bound
#define bisect_right upper_bound
#define bound(a, x, b) (a <= x && x <= b)
const i64 MOD = 1000000007ll;
const f64 EPS = 1e-10;

i32 a[200000];

void solve() {
    indef(i32, n);
    i64 tol = 0;
    times(n, i){
        in(a[i]);
        tol += a[i];
    }
    i64 acc = 0;
    i64 ans = LLONG_MAX;
    times(n-1, i) {
        acc += a[i];
        ans = min(ans, abs(tol-acc-acc));
    }
    out(ans);
}

i32 main()
{
    ios::sync_with_stdio(false);

#ifdef _MSC_VER
    /**
    ifstream fin("input.txt"); cin.rdbuf(fin.rdbuf()); assert(fin);
    ofstream fout("output.txt"); cout.rdbuf(fout.rdbuf()); assert(fout);
    /**/
#endif

    //cout << fixed << setprecision(9);
    solve();
    return 0;
}

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

using ll = long long;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> num(N, 1);
    vector<bool> possible(N);
    possible[0] = true;
    for(int i = 0; i < M; ++i) {
        int x, y;
        cin >> x >> y;
        possible[y - 1] = possible[y - 1] | possible[x - 1];
        num[x - 1]--;
        num[y - 1]++;
        if(num[x - 1] == 0) {
            possible[x - 1] = false;
        }
    }
    cout << count(begin(possible), end(possible), true) << endl;
}



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

int n, k, a[5010], dp_pre[5010][5010], dp_suf[5010][5010], ans = 0;

int main() {
    memset(dp_pre, 0, sizeof(dp_pre));
    memset(dp_suf, 0, sizeof(dp_suf));
    scanf("%d%d", &n, &k);
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    sort(a+1, a + (n+1));
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < k; j++) {
            dp_pre[i][j] = dp_pre[i-1][j];
            if(j >= a[i]) dp_pre[i][j] = max(dp_pre[i][j], dp_pre[i-1][j-a[i]] + a[i]);
        }
    }
    for(int i = n; i > 0; i--) {
        for(int j = 0; j < k; j++) {
            dp_suf[i][j] = dp_suf[i+1][j];
            if(j >= a[i]) dp_suf[i][j] = max(dp_suf[i][j], dp_suf[i+1][j-a[i]] + a[i]);
        }
    }
    for(int i = 1; i <= n; i++) {
        int knap = 0;
        for(int j = 0; j < k; j++) knap = max(knap, dp_pre[i-1][j] + dp_suf[i+1][k-1-j]);
        ans += (a[i] + knap < k);
    }
    printf("%d", ans);
}


Measured memory_bytes: 196352
#include <algorithm>
#include <cmath>
#include <iostream>

auto main() -> int {
    int nInputs;
    std::cin >> nInputs;

    double lens[3];
    for (int i = 0; i < nInputs; i++) {
        std::cin >> lens[0] >> lens[1] >> lens[2];

        std::sort(std::begin(lens), std::end(lens));
        
        if (std::sqrt(std::pow(lens[0], 2) + std::pow(lens[1], 2)) == lens[2]) {
            std::cout << "YES" << std::endl;
        } else {
            std::cout << "NO" << std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3056
N= int(input())
N_length = len(str(N))
if(N_length == 1):
  print (int(N))
elif(N_length == 2):
  print (9)
elif(N_length == 3):
  print (9+N-100+1)
elif(N_length == 4):
  print (9 +900)
elif(N_length == 5 ):
  print (9+900 + N - 10000 + 1)
elif(N_length == 6):
  print (9+900 + 90000)

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

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

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;cin >> n;
    map<string,int> mp;
    rep(i,n){
        string s;cin >> s;
        if(mp[s] == 0)mp[s] = 1;
        else mp[s]++;
    }

    cout << mp.size() << endl;
    return 0;
}

Measured memory_bytes: 19188
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var N = int.Parse(ReadLine());

            int cnt = 0;
            for (int i = 0; i < N; i++)
            {
                var raw = ReadLine().Split().Select(int.Parse).ToArray();
                cnt = raw[0] == raw[1] ? cnt + 1 : 0;
                if(cnt >= 3)
                {
                    WriteLine("Yes");
                    return;
                }
            }

            WriteLine("No");
        }

    }
}


Measured memory_bytes: 28300
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;

int main() {
  string s;
  cin >> s;
  vector<bool> a(26);
  rep(i,26) a[i] = false;
  rep(i,s.size()) {
    a[s[i] - 'a'] = true;
  }
  rep(i,26) {
    if (a[i] == false) {
      cout << char('a' + i) << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 512
// Marcin Knapik
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< int , null_type,less< int >, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ll>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<vll>             vvll;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vii>             vvii;
#define pll pair<long long, long long>
#define vpll vector<pll>
#define ull unsigned long long

#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second

template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}

template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<class T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return abs(a); }

const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll BIG_INF = 1e18 + 7;
const ll N = 1e6+7;
const ll T = 1<<20;
const ld inf = 1e18;

ll n, m, q, k;
vvi G(N);
ll ans = 0;

void dfs(int x, int przodek = -1){
	if(przodek == -1){
		ans += n;
	}
	else{
		if(przodek < x)
			ans += 1ll * abs(x - przodek) * (n - x + 1);
		else
			ans += 1ll * abs(x - przodek) * x;
	}
	for(auto & u : G[x])
		if(u != przodek)
			dfs(u, x);
}

void solve(){
	cin >> n;

	for(int i = 1; i < n; i++){
		int a, b;
		cin >> a >> b;

		G[a].pb(b);
		G[b].pb(a);
	}

	dfs(1);
	cout << ans << '\n';
}


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

	q = 1;
	// cin >> q;

	while(q--)
		solve();
}	

Measured memory_bytes: 42152
import java.util.*;
public class Main {
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
		String X = sc.next();
		String Y = sc.next();
		int dec_x = Integer.parseInt(X,16);
		int dec_y = Integer.parseInt(Y,16);

		if(dec_x < dec_y) {
			System.out.print("<");
		}else if(dec_x > dec_y) {
			System.out.print(">");
		}else {
			System.out.print("=");
		}

	}
}


Measured memory_bytes: 21972
#include "iostream"

using namespace std;

int N;
int num[20000];
int a[20000];
int b[20000];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> num[i];
		a[i] = (i + 1)*N;
		b[i] += 2 * N*N - a[i];
		b[num[i]-1] += i+1;
	}
	for (int i = 0; i < N; i++)cout << a[i]<<" ";
	cout << "\n";
	for (int i = 0; i < N; i++)cout << b[i]<<" ";
	cout << "\n";
	return 0;
}

Measured memory_bytes: 896
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[100009]; bool cycle[100009], vis1[100009], vis2[100009];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) {
		vector<int> w;
		int p = i;
		while (!vis1[p]) {
			p = (p + a[p]) % n;
			if (vis2[p]) {
				int pos = find(w.begin(), w.end(), p) - w.begin();
				for (int j = pos; j < w.size(); j++) cycle[w[j]] = true;
				break;
			}
			w.push_back(p);
			vis2[p] = true;
		}
		for (int j : w) vis1[j] = true, vis2[j] = false;
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (cycle[i]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 4008
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <unordered_map>
#define lld long long int
#define DBG1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define DBG2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define DBG3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// freopen("input.txt", "r", stdin);  
	int n,k;
	cin >> n >> k;
	cout << (int)(k * pow(k-1,n-1));
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int N,A,B;
  cin >> N >> A >> B;

  int ans = 0;
  for(int i=1;i<=N;i++){
    int itmp = i;
    int sum = 0;
    while(itmp > 0){
      sum += itmp % 10;
      itmp /= 10;
    }

    if(A <= sum && sum <= B) ans += i;
  }

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <functional>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
using ll = unsigned long long;
const ll mod = 1000000007;
const int M_MAX = 10000;
string al = "abcdefghijklmnopqrstuvwxyz";
//bool less_sec(const pair<int, int>&a, const pair<int, int>&b) {
//	return a.second > b.second;
//}
int main() {
	
	cin.tie(0);
	ios::sync_with_stdio(false);
    int N, X; cin >> N >> X;
    vector<int> v;
    int minV=1000000;
    for(int i=0; i<N; ++i){
        int a; cin >> a;
        v.push_back(a);
        minV=min(minV, a);
    }
    int sum= accumulate(v.begin(), v.end(), 0);
    X-=sum;
    int cnt=N;
    while(X>0){
        X-=minV;
        if(X<0) break;
        cnt++;
    }
    cout << cnt << endl;
	return 0;
}

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

int gcd(int m, int n) {
  if(m < n) swap(m, n);
  if(n == 0) return abs(m);
  else return gcd(n, m % n);
}

int main() {
  int K; cin >> K;
  long long ans = 0;
  for(int a = 1; a <= K; a++) {
    for(int b = 1; b <= K; b++) {
      int ab = gcd(a, b);
      for(int c = 1; c <= K; c++) {
        int abc = gcd(ab, c);
        ans += abc;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<string>

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
using namespace std;

const int Yb = 0;
const int Mb = 1;
const int Db = 2;
const int Ye = 3;
const int Me = 4;
const int De = 5;

const int table[4][6] =
  {{1868, 9, 8 ,1912, 7,29},
   {1912, 7,30 ,1926,12,24},
   {1926,12,25 ,1989, 1, 7},
   {1989, 1, 8 ,3000,12,31}};

const string name[4] = {
  "meiji",
  "taisho",
  "showa",
  "heisei"
};

int main(void){
  int y,m,d;
  while(cin>>y>>m>>d){
    if(y<table[0][Yb] || 
       (y==table[0][Yb] && m<table[0][Mb]) || 
       (y==table[0][Yb] && m==table[0][Mb] && d<table[0][Db])){
      cout<<"pre-meiji"<<endl;
      continue;
    }
    bool find = false;
    loop(i,0,3){
      if(y<table[i][Ye] || 
	 (y==table[i][Ye] && m<table[i][Me]) || 
	 (y==table[i][Ye] && m==table[i][Me] && d<=table[i][De])){
	cout<<name[i]<<" "<<y-table[i][Yb]+1<<" "<<m<<" "<<d<<endl;
	find = true;
	break;
      }
    }	 
    if(find)continue;
    cout<<name[3]<<" "<<y-table[3][Yb]+1<<" "<<m<<" "<<d<<endl;
      
    
  }

}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
using namespace std;

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

const ll MOD = 1e9+7;

// Combinationの使い方
// vector<vector<ll>> v(N+1, vector<ll>(N+1, 0));
// comb(v);
void comb(vector<vector<ll>> &v){
    for(int i = 0; i < v.size(); i++){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(int k = 1; k < v.size(); k++){
        for(int j = 1; j < k; j++){
            v[k][j] = (v[k-1][j-1] + v[k-1][j]);
            //余りを求める問題は毎回計算ごとにやる
            // v[k][j] = (v[k-1][j-1] + v[k-1][j]) % MOD;
        }
    }
}

// Union Find
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

// 1 << 3 : int "3" change to bit "100"
// rep(pattern, 1 << N) if (pattern & (1 << x)) cnt++

int main(){
    int N, T, A;
    cin >> N >> T >> A;
    vector<int> H(1001, 0);
    rep(i,N) cin >> H[i];

    vector<double> t(1001,0);
    int pos;
    double min_dif = 10000000;
    rep(i,N){
        t[i] = T - H[i]*0.006;
        if(abs(t[i]-A)<min_dif){
            pos = i+1;
            min_dif = abs(t[i]-A);
        }   
    }

    cout << pos << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,x,sum[200005],sxor[200005];
long long l=1,ans=0;
int main(){
	cin>>n;
	sum[0]=0;sxor[0]=0;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(i==1)sum[i]=sxor[i]=x;
		else sxor[i]=sxor[i-1]^x,sum[i]=sum[i-1]+x;
	}
	for(int r=1;r<=n;r++){
		while((sum[r]-sum[l-1])!=(sxor[r]^sxor[l-1]))l++;
		ans+=r-l+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
string S;
/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>S;
//    int ans = S.size();
//    REP(i,0,S.size()-1){
//        if(S[i] != S[i+1]) {
//            ans = min(ans, max(i+1, (int)S.size()-(i+1)));
//        }
//    }
//    cout<<ans<<endl;


    int pos = ((int)S.size()) / 2;
    int offset = 0;

    if((int)S.size() % 2 == 0){
        while(true){
            if(pos - 1 - offset < 0 || S.size() <= pos+ offset) break;

            if(S[pos + offset] == S[pos] &&
               S[pos - 1 - offset] == S[pos] &&
               S[pos + offset] == S[pos - 1 - offset]){
                offset++;
            }else{
                break;
            }
        }
    }else{
        while(true){
            if(pos - offset < 0 || S.size() <= pos + offset) break;

            if(S[pos + offset] == S[pos] &&
               S[pos - offset] == S[pos] &&
               S[pos + offset] == S[pos - offset]){
                offset++;
            }else{
                break;
            }
        }
    }


    cout<<pos + offset<<endl;

    return 0;
}


Measured memory_bytes: 512
def choice(pos, num):
    global  ans
    if pos == n:
        if len(set(l)) != n:
            return
        check = sum(l)
        if check == s:
            if set(l) not in save:
                save.append(set(l))
                ans += 1
        return
    if num == 10:
        return
    l[pos] = num
    choice(pos + 1, num+1)
    choice(pos, num+1)


number = [0,1,2,3,4,5,6,7,8,9]
n, s = map(int, input().split())
while n != 0:
    l = [0] * n
    save = []
    ans = 0
    choice(0, 0)
    print(ans)
    n, s = map(int, input().split())


Measured memory_bytes: 5596
n = gets.to_i
as = gets.split.map(&:to_i)

state = 0
ans = 1
bef = nil
as.each do |a|
  if state == 1
    if bef < a
      ans += 1
      state = 0
    end
  elsif state == 2
    if bef > a
      ans += 1
      state = 0
    end
  elsif bef != nil
    state =
      if bef < a
        2
      elsif bef > a
        1
      end
  end

  bef = a
end
puts ans


Measured memory_bytes: 8452
#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() {
	ll a,b;
	cin>>a>>b;
	int c=1;
	string ans;
	if(b-a>1000000000)ans="Zero";

	else{
		for (ll i = a; i <= b; ++i){
			if(i<0)c*=-1;
			if(i==0)c*=0;
		}
		if(c>0)ans="Positive";
		if(c==0)ans="Zero";
		if(c<0)ans="Negative";
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define frr(i,s,n) for(int i=s;i<=n;i++)
#define fr(i,s,n) for(int i=s;i<n;i++)
#define lli long long int
#define llu unsigned long long int
#define vi vector <int>
#define vii vector <long long int>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define mk make_pair
#define mpp map<int,int>
#define ff first
#define ss second
#define mod 1000000007

using namespace std;

vector <double> v1;
int n;
long double a[3001];
long double dp[3001][3001];
int vis[3001][3001];
long double solve(int i,int t)
{
	if(i == 0)
	{
		if(t <= n/2)
			return 1;
		else
			return 0;
	}

	if(vis[i][t])
		return dp[i][t];

	vis[i][t] = 1;
	long double x = (1-a[i])*solve(i-1,t) + a[i] * solve(i-1,t-1);
	return dp[i][t] = x;
}
void loop()
{
	//memset(dp,-1,sizeof(dp));
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	cout<<fixed<<setprecision(10)<<solve(n,n);
}
int main()
{
	fast;
    int t=1;
    //cin>>t;
    while(t--)
    	loop();
}


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

ll n;
pii s[200005];

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x; cin >> x;
        s[i] = pii(x, i);
    }

    sort(s, s+n);
    int ans = 0;

    for (int i = 0; i < n; ++i)
        if (i%2 != s[i].second%2)
            ans++;
    cout << ans/2 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
int main() {
	long long a,b,c,k,ans;
	cin >>a>>b>>c>>k;
	if (k<=a){
		ans=k;
	}
	else if (k<=a+b){
		ans=a;
	}
	else{
		ans=a-(k-(a+b));
	}
	cout <<ans<<endl;
	return 0;
}


Measured memory_bytes: 3632
#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 FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<int> A;

void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N;
    REP(i,N){
        int a;
        cin >> a;
        A.push_back(a);
    }
    VSORT(A);
    reverse(ALL(A));
}

void solve(){
    input();
    int Alice,Bob;
    Alice=0;
    Bob=0;
    REP(i,N){
        if(i%2==0) Alice+=A[i];
        else Bob+=A[i];
    }
    cout << (Alice-Bob) << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 10000000
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
main(){
    FIO;
    //OJ;
    int n;
    cin>>n;
    int ch=1000;
    while(ch<n)
        ch+=1000;
    cout<<abs(ch-n);
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main(){
  ll N,H;cin>>N>>H;
  vl a(N);
  vl b(N);
  rep(i,N)cin>>a[i]>>b[i];

 
  sort(all(a));
  reverse(all(a));
 
  sort(all(b));
  reverse(all(b));
  ll ans =0;
  rep(i,N){
    if(a[0]<=b[i]){H -= b[i];ans++;}
    if(H<=0)break;
  }
  while(H>0){
    H -= a[0];
    ans++;
  }
  cout<<ans<<endl;
  
  
}
  


Measured memory_bytes: 1792
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < ll >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < ll , ll >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 
const ll inf=1e18+1e17;
const ll mod =1e9+7;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=	(a*a)%mod;b>>=1;}return (res%mod);}
const int N = 2e5 + 5 ;

ll arr[N];
void solve(){
	int n;
	cin>>n;
	ll x=0;
	for ( int i=0;i<n;i++){
		cin>>arr[i];
		if ( i!=0)
			x=x^arr[i];
	}
	cout<<x<<' ';	
	for ( int i=1;i<n;i++){
		ll val=( arr[i]^arr[i-1]);
		cout<<(val^x)<<' ';
		x=(val^x);
	}


}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	cout.tie(NULL);
//	/*
	#ifndef ONLINE_JUDGE
		freopen ("INPUT.txt" , "r" , stdin);
		freopen ("OUTPUT.txt", "w" , stdout);
	#endif
// */
	ll t=1;
	//cin>>t;
	for ( ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
    	solve();
    }
}

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

const int maxN=1e5+2;

int n,m;
vector<int> v[maxN];

int vis[maxN];
int dp[maxN];

void dfs(int nod){
    vis[nod]=true;
    for(int i=0;i<(int)v[nod].size();i++){
        if(vis[v[nod][i]]==false){
            dfs(v[nod][i]);
        }
        dp[nod]=max(dp[nod],dp[v[nod][i]]+1);
    }
}

int main(){
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
    }

    for(int i=1;i<=n;i++){
        if(vis[i]==false){
            dfs(i);
        }
    }

    int sol=0;
    for(int i=1;i<=n;i++){
        sol=max(sol,dp[i]); 
    }

    cout<<sol;

    return 0;
}

Measured memory_bytes: 8576
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int n, i, j;
	
	scanf("%d ", &n);
	char aux[n+1];
	fgets(aux, n+1, stdin);

	if (n%2 != 0)
	{
		printf("No\n");
		return 0;
	}

	for (i = 0, j = n/2; j < n; ++i, ++j)
	{
		if(aux[i] != aux[j]){
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int d, l;
    cin >> d >> l;
    cout << d / l + d % l << "\n";
}



Measured memory_bytes: 3112
#include<stdio.h>
int a, b, i;
char x[5];
int ans;
int main(){
	scanf("%d%d", &a, &b);
	for(i=a; i<=b; i++){
		if((i%10)==(i/10000%10) && (i/10%10)==(i/1000%10)){
			ans++;
		}
	}
	printf("%d\n", ans);
}

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

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if (A+B>=C-1){
        cout << B+C << endl;
    }
    else {
        cout << A+2*B+1 << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, x; cin >> n >> x;
  vector<int> s(n); REP(i, n) cin >> s[i];
  sort(ALL(s), greater<int>());
  vector<vector<long long> > dp(n + 1, vector<long long>(x + 1, 0));
  dp[0][x] = 1;
  REP(i, n) REP(j, x + 1) {
    (dp[i + 1][j % s[i]] += dp[i][j]) %= MOD;
    (dp[i + 1][j] += dp[i][j] * (n - i - 1) % MOD) %= MOD;
  }
  long long ans = 0;
  REP(j, x + 1) (ans += dp[n][j] * j % MOD) %= MOD;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 158592
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) puts("error")
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> inline void add(T &x,const T y){x=mm(x+y);}
    inline ll qpower(ll x,ll e)
    {
        ll ans=1;GG(e<0);
        while(e){if(e&1)ans=ans*x%MOD;x=x*x%MOD;e>>=1;}return ans;
    }
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    char str[N];int ct[100];
    void main()
    {
        scanf("%s",str+1);int n=strlen(str+1);
        fo(i,1,n) ct[str[i]-'A']++;
        if(ct['E'-'A']+ct['W'-'A']>0 and min(ct['E'-'A'],ct['W'-'A'])==0) puts("No");
        else if(ct['S'-'A']+ct['N'-'A']>0 and min(ct['S'-'A'],ct['N'-'A'])==0) puts("No");
        else puts("Yes");
    }
};//(ans+MOD)%MOD
int main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
a, b, c = map(int, input().split())
if a == 5 and b == 5 and c == 7:
  print ("YES")
elif a == 5 and b == 7 and c == 5:
  print ("YES")
elif a == 7 and b == 5 and c == 5:
  print ("YES")
else:
  print("NO")

Measured memory_bytes: 3060
using System.Linq;
using static System.Console;
class K
{
	static int[] G => ReadLine().Split().Select(int.Parse).ToArray();
	const int MOD = 1000000007;
	static void Main()
	{
		var N = G[0];
		var A = G;
		var inv = new long[N + 1];
		for (var i = 1; i <= N; i++) inv[i] = Inverse(i, MOD);
		var sum = new long[N + 2];
		for (var i = 0; i <= N; i++) sum[i + 1] = (sum[i] + inv[i]) % MOD;
		var ans = 0l;
		for (var i = 0; i < N; i++)
		{
			var x = (sum[i + 2] - sum[2]) + (sum[N - i + 1] - sum[1]);
			x %= MOD;
			if (x < 0) x += MOD;
			ans += x * A[i] % MOD;
		}
		ans %= MOD;
		for (var i = 1; i <= N; i++) ans = ans * i % MOD;
		WriteLine(ans % MOD);
	}
	static long Inverse(long n, long mod)
	{
		long a = 1, b = 0, c = 0, d = 1;
		while (mod > 0)
		{
			var r = n % mod;
			var q = n / mod;
			n = mod;
			mod = r;
			var tmp = a;
			a = -a * q + b;
			b = tmp;
			tmp = c;
			c = -c * q + d;
			d = tmp;
		}
		return d;
	}
}


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

int min(int a, int b){
	if( a <= b ) return a;
	else return b;
}

int main(void){
	int w, h, x, y, r;
	int d_edge;
	cin >> w >> h >> x >> y >> r;
	if( x < 0 || w < x || y < 0 || h < y ) cout << "No" << endl;
	else{
		d_edge = min( min(x, w-x), min(y, h-y) );
		if( d_edge < r ) cout << "No" << endl;
		else cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, q, ans = 0;
    cin >> n;
    int s[n];
    for (int i = 0; i < n; i++)
        cin >> s[i];

    cin >> q;
    int t;
    for (int i = 0; i < q; i++)
    {
        cin >> t;
        int right = n - 1;
        int left = 0;
        while (right >= left)
        {
            int mid = (right + left) / 2;
            if (t > s[mid])
            {
                left = mid + 1;
            }
            else if (t < s[mid])
            {
                right = mid - 1;
            }
            else
            {
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int k, t;
  cin >> k >> t;
  map<int, int> mp;
  int all = 0;
  rep(i, t){
    int a;
    cin >> a;
    mp[i+1] = a;
    all += a;
  }
  int mx = 0;
  repit(itr, mp){
    mx = max(mx, itr->second);
  }
  int o = all - mx;
  int ans = max(0, mx - o - 1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
/*
 * Author : Sadi
 * Tue 21/07/2020
 * 18:07:22.75
 */
#include <bits/stdc++.h>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n;
    cin >> n;
    set<string> s;
    for(int i = 0; i < n; ++i) {
        string str;
        cin >> str;
        s.insert(str);
    }
    cout << s.size() << '\n';
    return 0;
}


Measured memory_bytes: 19232
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
#define int long long
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
signed main(){
	sc(s)
	int n=s.size();
	int sum=0;
	for(int i=n-1;i>0;i-=1){
		sum=0;
		if(i%2==0){
			rep(0,j,i/2){	
				if(s[j]==s[j+i/2])sum++;
			}
			if(sum==i/2){
				c(i)
				return 0;
			}
		}
	}
}				

Measured memory_bytes: 256