akhauriyash/Code-Regression huggingface dataset:
/*
 
dunjen_master
 
*/
 
 
 
 
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;
 
const int MAX_N = int(1e6) + 10;
const long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 
 
inline ll mul(ll a,ll b){
 
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}
 
  
 
 
#define all(x) (x).begin(),(x).end()
 
/* ordered_set A;
   A.insert(x);
   A.erase(x);
   A.order_of_key(x) // no of elements less than (<) x
   *A.find_by_order(k-1) // kth smallest element
*/
// int n;
// ll dp[200005][205];
// ll ans=0;
// int a[200005];
// int req;
// ll neg=-1e15;
 
 
// ll fun(int indx,int last){
//    // cout<<indx<<" "<<last<<" "<<req<<endl;
//     if(indx==n){
//         if(last==req){
//             return 0;
//         }else{
//             return neg;
//         }
//     }
 
//     if(dp[indx][last]!=-1){
//         return dp[indx][last];
//     }
    
//     ll ans=neg;
 
//     ans=max(ans,fun(indx+1,last));
 
//     if(last==0)ans=max(ans,1+fun(indx+1,a[indx]));
//     if(last==a[indx])ans=max(ans,1+fun(indx+1,a[indx]));
//     if(a[indx]==req)ans=max(ans,1+fun(indx+1,a[indx]));
 
//     return dp[indx][last]=ans;
 
 
// }
 
 
int main(){

    string s;
    cin>>s;
    if(s=="ABC")cout<<"ARC";
    else cout<<"ABC";
return 0;

 
 
    
 
    
 
    
 
 
 
 
 
 
 
 
 
   
 
 
 
    
    
 
    
 
    
 
  
    
 
 
 
    
 
 
    
    
    
    
 
    
}


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

string fj(string arg){
	int n=arg.size();
	char last=arg[n-1];
	for(int i=n-2;i>=0;--i) arg[i+1]=arg[i];
	arg[0]=last;
	return arg;
}

string fc(string arg){
	int n=arg.size();
	char first=arg[0];
	for(int i=0;i<n-1;++i) arg[i]=arg[i+1];
	arg[n-1]=first;
	return arg;
}

string fe(string arg){
	int n=arg.size();
	int odd=n%2;
	for(int i=0;i<n/2;++i)
		swap(arg[i],arg[n/2+odd+i]);
	return arg;
}

string fa(string arg){
	reverse(arg.begin(),arg.end());
	return arg;
}

string fp(string arg){
	int n=arg.size();
	for(int i=0;i<n;++i){
		if(isdigit(arg[i])){
			int d=arg[i]-'0';
			d=(d+9)%10;
			arg[i]=(d+'0');
		}
	}
	return arg;
}

string fm(string arg){
	int n=arg.size();
	for(int i=0;i<n;++i){
		if(isdigit(arg[i])){
			int d=arg[i]-'0';
			d=(d+1)%10;
			arg[i]=(d+'0');
		}
	}
	return arg;
}

int main(void){
	int t;
	cin >> t;
	rep(loop,t){
		string decode,message;
		cin >> decode >> message;
		int n=decode.size();
		for(int i=n-1;i>=0;--i){
			char cur=decode[i];
			switch(cur){
				case 'A':
					message=fa(message);
					break;
				case 'C':
					message=fc(message);
					break;
				case 'E':
					message=fe(message);
					break;
				case 'J':
					message=fj(message);
					break;
				case 'M':
					message=fm(message);
					break;
				case 'P':
					message=fp(message);
					break;
			}
		}
		cout << message << endl;
	}
	return 0;
}

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

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s; i <= e; i++)
#define LLI long long int
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

vector<pair<long long, long long>> prime_factorize(long long n) {
    vector<pair<long long, long long>> res;
    for(long long p = 2; p * p <= n; ++p) {
        if(n % p != 0)
            continue;
        int num = 0;
        while(n % p == 0) {
            ++num;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if(n != 1)
        res.push_back(make_pair(n, 1));
    return res;
}

const int MAX = 210000;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k) {
    if(n < k)
        return 0;
    if(n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

LLI power(LLI a, LLI b) {
    LLI res = 1;
    while(b > 0) {
        if(b & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

int main() {
    COMinit();
    LLI N, K;
    cin >> N >> K;
    LLI red = N - K;
    LLI blue = K;

    LLI v2[2001];
    for(int i = 1; i <= K; i++) {
        v2[i] = v2[i - 1] + power(i, K);
    }

    for(int i = 1; i <= K; i++) {
        LLI a = COM(red + 1, i);
        if(red + 1 < i)
            a = 0;
        LLI b = COM(blue - 1, i - 1);
        if(blue - 1 < i - 1)
            b = 0;
        cout << a * b % MOD << endl;
    }

    return 0;
}

Measured memory_bytes: 5120
N, W = list(map(int, input().split()))
items = [[0, 0]]
for _ in range(N):
    v, w = list(map(int, input().split()))
    items.append([v, w])
DP = [[0 for _ in range(W + 1)] for _ in range(N + 1)]
for i in range(1, N + 1):
    for j in range(W + 1):
        if items[i][1] > j:
            DP[i][j] = DP[i - 1][j]
        else:
            DP[i][j] = max(DP[i - 1][j], DP[i - 1][j - items[i][1]] + items[i][0])
print(DP[N][W])



Measured memory_bytes: 25944
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var ABC = ReadSplitInt();
            if (ABC[0] == ABC[1]) Println(ABC[2]);
            else if (ABC[0] == ABC[2]) Println(ABC[1]);
            else if (ABC[1] == ABC[2]) Println(ABC[0]);
        }


        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11348
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize,
        d: usize,
        e: usize,
        k: usize
    }
    if e - a > k {
        println!(":(");
    } else {
        println!("Yay!");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <set>
#include <utility>
using namespace std;

typedef long long ll;

int main(void) {
  ll i, j, k, n, max = 0;
  scanf("%lld", &n);
  ll d[n], sum[n];
  set< pair<int, int> > s;
  for(i = 0; i < n; ++i) {
    scanf("%lld", &d[i]);
    if(i) sum[i] = sum[i - 1] + d[i];
    else sum[i] = d[i];
  }
  for(i = 0; i < n; ++i) {
    set<pair<int, int> >::iterator it;
    pair<int, int> p = make_pair(sum[i], 0), pt = make_pair(sum[i], i);
    it = s.lower_bound(p);
    if(sum[i] == 0){
      if(max < i + 1) max = i + 1;
      continue;
    }
    if(it == s.end() || (*it).first != sum[i]) 
     s.insert(pt);
    else 
      if(max < i - (*it).second) max = i - (*it).second;
  }
  printf("%lld\n", max);
  return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

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

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    string s;
    cin >> s;
    if (s == "ARC") cout << "ABC" << endl;
    else cout << "ARC" << endl;
    
    return 0;
}



Measured memory_bytes: 3612
#include <iostream>
using namespace std;
struct dice{
    int x[6];
    
    void roll(char c){
        int tmp;
        if(c == 'E'){
            tmp = x[0];
            x[0] = x[3];
            x[3] = x[5];
            x[5] = x[2];
            x[2] = tmp;
        }
        if(c == 'N'){
            tmp = x[0];
            x[0] = x[1];
            x[1] = x[5];
            x[5] = x[4];
            x[4] = tmp;
        }
        if(c == 'S'){
            tmp = x[0];
            x[0] = x[4];
            x[4] = x[5];
            x[5] = x[1];
            x[1] = tmp;
        }
        if(c == 'W'){
            tmp = x[0];
            x[0] = x[2];
            x[2] = x[5];
            x[5] = x[3];
            x[3] = tmp;
        }
        if(c == 'R'){
            tmp = x[1];
            x[1] = x[2];
            x[2] = x[4];
            x[4] = x[3];
            x[3] = tmp;
        }
    }
    int top(void){
        return x[0];
    }
    int right(void){
        return x[2];
    }
    int left(void){
        return x[3];
    }
    int front(void){
        return x[1];
    }
};

int main(void){
    dice d;
    for(int i = 0; i < 6; i++){
        cin >> d.x[i];
    }
    int n;
    cin >> n;
    int t, f;
    for(int i = 0; i < n; i++){
        cin >> t >> f;
        if(d.left() == t)   d.roll('E');
        if(d.right() == t)  d.roll('W');
        while(d.top() != t)   d.roll('N');
        while(d.front() != f) d.roll('R');

        cout << d.right() << endl;    
    }
    return 0;
}



Measured memory_bytes: 3088
/*
                                                  __          __
      /\   |   |     /\   |  | |  |     /\   | / |  )   /\   |  )
     /__\  |   |    /__\  |--| |  |    /__\  |<  |-<   /__\  |-<
    /    \ |__ |__ /    \ |  | \__/   /    \ | \ |__) /    \ |  \

*/

#import<bits/stdc++.h>
typedef long long ll;
#define num 1e9
#define root 10000
#define forll(i,a,b,c) for(int i=a; i<=b; i+=c)
#define forll2(i,a,b,c) for(int i=a; i>=b; i-=c)
#define pb(n) push_back(n)

using namespace std;

int main()
{
    int t;
    cin>>t;
    int p=7,f=0,x;
    forll(i,1,t,1)
    {
        if(p%t==0){f=1;x=i;break;}
        else{p=(p*10+7)%t;}
    }
    if(f==1){cout<<x<<"\n";}
    else{cout<<"-1\n";}
}


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


int main()
{
	//#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	//#endif
	int n,k;
	cin>>n>>k;
	int h[n];
	for(int i=0;i<n;i++)
		cin>>h[i];
	ll INF=1e9+5;
	vector<ll> dp(n,INF);
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<=i+k;j++)
		{
			if(j<n)
			{
				dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
			}	
		}
	}
	cout<<dp[n-1]<<'\n';
}

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

using namespace std; 

int main() {

	int lake, house;
	int tmp=0,first_tmp=0,old_tmp=0,big=0;
	vector<int> house_place;

	cin >> lake >> house;

	for (int i = 0; i < house; i++) {
		cin >> tmp; 
		if (i == 0) {
			first_tmp = tmp;
			old_tmp = tmp;
		}
		else {
			if (tmp - old_tmp > big) {
				big = tmp - old_tmp;
			}
			old_tmp = tmp;
		}

	}
	if (lake - tmp + first_tmp > big) {
		big = lake - tmp + first_tmp;
	}
	
	cout <<lake - big;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
const int MOD=1000000007;
const int nmax=501234;

int n,a[17][17],bt[17],flg[1<<17];
ll dp[1<<17],dp2[1<<17];
queue<int> q2;

int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; ++i)
    {
        bt[i]=1<<i-1;
        for(int j=1; j<=n; ++j)
            scanf("%d",&a[i][j]);
    }
    bt[n+1]=1<<n;
    for(int i=2,l=0,r=0; i<=n; ++i)
    {
        for(int j=1,tmp=0; j<i; ++j)
        {
            tmp=bt[i]|bt[j];
            dp[tmp]=a[j][i];
            flg[tmp]=1;
            q2.push(tmp);
        }
        while(!q2.empty())
        {
            int tmp=q2.front();
            q2.pop();
            for(int j=1,tmp2=0; j<i; ++j)
            {
                tmp2=tmp|bt[j];
                if(tmp2!=tmp && flg[tmp2]==0)
                {
                    dp[tmp2]=dp[tmp]+a[j][i];
                    flg[tmp2]=1;
                    q2.push(tmp2);
                }
            }
        }
    }
    for(int i=2; i<=n; ++i)
        for(int j=bt[i]+1; j<1<<i; ++j)
            dp[j]+=dp[j^bt[i]];
    for(int i=2; i<=n; ++i)
        for(int i2=bt[i]+1,j2=0; i2<1<<i; ++i2)
        {
            dp2[i2]=dp[i2];
            j2=i2&-i2;
            for(int j=bt[i]; j<i2; j+=j2)
            {
                while((j|i2)!=i2)
                    j+=j&-j;
                ll tmp3=dp[j]+dp2[j^i2];
                if(dp2[i2]<tmp3)
                    dp2[i2]=tmp3;
            }
        }
    printf("%lld",dp2[(1<<n)-1]);
    return 0;
}


Measured memory_bytes: 1536
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())

edge = np.zeros(n, dtype=int)
for _ in range(m):
    a, b = map(int, readline().split())
    edge[a - 1] += 1
    edge[b - 1] -= 1

np.add.accumulate(edge, out=edge)
if all(edge % 2 == 0):
    ans = "YES"
else:
    ans = "NO"

print(ans)


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

typedef vector<int> veci;
typedef pair<int, int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9 + 7)
#define fi first
#define se second
#define endl '\n'

void solve() {
    ll n;
    cin >> n;

    vector<int> cum{0};
    int p = 0;
    while (p <= 60) {
        p += 1;
        cum.push_back(p);
    }
    for (int i = 1; i < cum.size(); ++i) {
        cum[i] += cum[i - 1];
    }

    vector<int> power;
    int ans = 0;
    for (ll i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            int p = 0;
            while (n % i == 0) {
                p += 1;
                n /= i;
            }
            power.push_back(p);
        }
    }
    if (n > 1) power.push_back(1);

    for (auto& e : power) {
        auto it = upper_bound(cum.begin(), cum.end(), e);
        ans += it - cum.begin() - 1;
    }
    cout << ans << endl;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL_TEST
    (void)argc;
    const string strpath = string(argv[0]) + string("-test.in");
    freopen(strpath.c_str(), "r", stdin);
#endif
    solve();
}


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

#include <math.h>
#include <stdlib.h>


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

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; }


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n, k; cin >> n >> k;
    vector<int> x(n), y(n);
    for(int i= 0; i < n; i++) cin >> x[i] >> y[i];

    ll ans = 9001001001001001001;
    for(int ix = 0 ; ix < n; ix++){
        for(int jx = ix+1; jx < n; jx++){
            int l = x[ix]; int r = x[jx];
            if(l > r) swap(l, r);
            for(int iy = 0; iy < n; iy++){
                for(int jy = iy+1; jy < n; jy++){
                    int t = y[iy]; int b = y[jy];
                    if(t < b) swap(t,b);
                    int cnt = 0;
                    for(int a = 0; a < n; a++){
                        if(l <= x[a] && x[a] <= r && b <= y[a] && y[a]<=t) cnt++;
                        if(cnt == k) ans = min(ans, (ll)(r-l)*(t-b));
                    }
                }
            }
        }
    }

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


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c,d,p,x,y;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&p);
	x=a*p;
	if(p<=c){
		y=b;
	}else{
		y=b+(p-c)*d;
	}
	if(x<=y){
		printf("%d\n",x);
	}else{
		printf("%d\n",y);
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(int argc, char const *argv[]) {
	string in;
	std::cin >> in;

	for (size_t i = 0; i < in.size(); i+=2) {
		std::cout << in[i];
	}
	std::cout << '\n';
	return 0;
}


Measured memory_bytes: 512
h, n = map(int, input().split())
inf = 10 ** 9
dp = [inf for _ in range(h + 1)]
dp[0] = 0
for _ in range(n):
    a, b = map(int, input().split())
    for i in range(h + 1):
        if i < a:
            dp[i] = min(dp[i], b)
        else:
            dp[i] = min(dp[i], dp[i - a] + b)
print(dp[-1])

Measured memory_bytes: 74680
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g,ko;
    ll x,y;
    char hoge;
    cin>>n;
    REP(i,1,n+1){
        sum+=800;
        if(i%15==0) sum-=200;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>

using namespace std;

int main()
{
    int n, idx;

    while (cin >> n, n) {
        int ice[10] = {0};

        for (int i = 0; i < n; i++) {
            cin >> idx;
            ice[idx]++;
        }

        for (int i = 0; i < 10; i++) {
            if (ice[i] == 0)
                cout << '-';
            else 
                while (ice[i]--)
                    cout << '*';
            cout << endl;
        }
    }
    
    return 0;
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

auto chmin = [](auto&& a, auto b) { return b < a ? a = b, 1 : 0; };

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> p(n * n);
  for (auto&& e : p) {
    cin >> e;
    --e;
  }
  vector d(n, vector<int>(n));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      d[i][j] = min({i, n - i - 1, j, n - j - 1}) + 1;
    }
  }
  auto in = [&](int i, int j) {
    return 0 <= i and i < n and 0 <= j and j < n;
  };
  array<int, 4> di{1, 0, -1, 0};
  array<int, 4> dj{0, 1, 0, -1};
  int res = 0;
  vector used(n, vector<bool>(n));
  for (auto e : p) {
    int si = e / n, sj = e % n;
    used[si][sj] = true;
    queue<pair<int, int>> que;
    res += --d[si][sj];
    que.emplace(si, sj);
    while (not empty(que)) {
      auto [i, j] = que.front();
      que.pop();
      for (int k = 0; k < 4; ++k) {
        int ni = i + di[k];
        int nj = j + dj[k];
        if (not in(ni, nj)) continue;
        if (chmin(d[ni][nj], d[i][j] + not used[ni][nj])) {
          que.emplace(ni, nj);
        }
      }
    }
  }
  cout << res << '\n';
}


Measured memory_bytes: 5316
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int c=0;
  int n,i;
  scanf("%d",&n);
  int a[n+1];
  for(i=1;i<=n;i++){
    scanf("%d",&a[i]);
  }
  sort(a,a+n+1);
  for(i=2;i<=n;i++){
    if(a[i-1]==a[i]){
      c=1;
    }
  }if(c==1){
    cout<<"NO"<<endl;
  }else{
    cout<<"YES"<<endl;
  }
}

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

namespace ConsoleApplication1
{
    class Player : IComparable
    {
        internal int id, point;

        public Player(int id, int point)
        {
            this.id = id;
            this.point = point;
        }

        public override string ToString()
        {
            return id + " " + point;
        }

        public int CompareTo(object obj)
        {
            Player other = obj as Player;

            if (point == other.point)
            {
                return id - other.id;
            }
            return other.point - point;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                Player[] players = new Player[n];

                for (int i = 0; i < n; i++)
                {
                    int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                    List<int> game = new List<int>();

                    for (int j = 1; j < input.Length; j++)
                    {
                        game.Add(input[j]);
                    }

                    int point = CalcPoint(game);

                    players[i] = new Player(input[0], point);
                }

                Array.Sort(players);

                foreach (var p in players)
                {
                    sb.AppendLine(p.ToString());
                }
            }
            Console.Write(sb);
        }

        static int CalcPoint(List<int> list)
        {
            int ret = 0, idx = 0;

            for (int game = 1; game < 10;)
            {
                if (list[idx] == 10)
                {
                    ret += (list[idx] + list[idx + 1] + list[idx + 2]);
                    idx++;
                    game++;
                }
                else
                {
                    int temp = list[idx] + list[idx + 1];

                    if (temp == 10)
                    {
                        ret += (temp + list[idx + 2]);
                    }
                    else
                    {
                        ret += temp;
                    }

                    idx += 2;
                    game++;
                }
            }

            for (int i = idx; i < list.Count; i++)
            {
                ret += list[i];
            }
            return ret;
        }
    }
}

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

int calc(const vector<pair<int, int> >& M, int idx_b, int idx_e,
         vector<vector<int> >& Memo) {
    if (idx_b == idx_e) return 0;
    if (Memo[idx_b][idx_e]) return Memo[idx_b][idx_e];
    int min = 2e9;
    for (int i = idx_b; i < idx_e; i++) {
        int val  = calc(M, idx_b, i, Memo) + calc(M, i + 1, idx_e, Memo)
                   + M[idx_b].first * M[i].second * M[idx_e].second;
        if (val < min) min = val;
    }
    return Memo[idx_b][idx_e] = min;
}

int main(){
    int n;
    cin >> n;
    vector<pair<int, int> > M;

    for (int i = 0; i < n; i++) {
        pair<int, int> input;
        cin >> input.first >> input.second;
        M.push_back(input);
    }
    vector<int> tmp(n, 0);
    vector<vector<int> > Memo(n, tmp);
    cout << calc(M, 0, M.size() - 1, Memo) << endl;

    return 0;
}

Measured memory_bytes: 3168
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()
	m := scanInt()

	p,q := 0,n
	for i := 0; i < m; i++ {
		l := scanInt()
		r := scanInt()

		if p < l {
			p = l
		}

		if q > r {
			q = r
		}
	}

	if q < p {
		fmt.Println(0)
	} else {
		fmt.Println(q-p+1)
	}
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>

#pragma GCC optimize("O3")

using namespace std;

int main()
{
    long long N;
    int nines = 0;
    scanf("%lld", &N);
    bool allNines = true;

    for (; 9 < N; N = N / 10) {
        if (N % 10 != 9) {
            allNines = false;
        }
        ++nines;
    }

    cout << nines * 9 + (!allNines ? N - 1 : N) << endl;

    return 0;
}

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

long long cnt;
int v,j;
vector<int> G;

void insert(long int a[],int n, int g){
	rep(i,g,n){
		v = a[i];
		j = i-g;
		while(j>=0&&a[j]>v){
			a[j+g] = a[j];
			j = j-g;
			cnt++;
		}
		a[j+g] = v;
	}
}

void shellsort(long int a[],int n){
	for(int h=1;;){
		if(h>n) break;
		G.push_back(h);
		h = 3*h+1;
	}
	for(int i=G.size()-1;i>=0;i--) insert(a,n,G[i]);
}

int main() {
	int n; cin >> n;
	cnt=0;
	long int a[1000000];
	
	rep(i,0,n) cin >> a[i];
	
	shellsort(a,n);
	
	cout << G.size() << endl;
	for(int i=G.size()-1;i>=0;i--){
		if(i==G.size()-1) cout << G[i];
		else cout << " " << G[i];
	}
	cout <<endl<<cnt<<endl;
	rep(i,0,n) cout << a[i] <<endl;
	
	return 0;
}


Measured memory_bytes: 10968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=55;
int n,a[N],b[N],m=0;bool v[N][N],f[N][N];
ll bin[N],ans=0;
inline bool check(int x){
	for(int i=0;i<=m;i++)for(int j=0;j<=m;j++)f[i][j]=v[i][j];
	for(int i=0;i<=m;i++)
		for(int j=1;j<=x;j++)f[i][i%j]=1;
	for(int k=0;k<=m;k++)
		for(int i=0;i<=m;i++)
			for(int j=0;j<=m;j++)f[i][j]|=f[i][k]&f[k][j];
	for(int i=0;i<=n;i++)if(!f[a[i]][b[i]])return true;
	return false;
}
int main(){
	scanf("%d",&n);
	bin[0]=1;
	for(int i=1;i<=50;i++)bin[i]=bin[i-1]<<1;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),m=max(m,a[i]);
	for(int i=1;i<=n;i++)scanf("%d",&b[i]);
	for(int i=0;i<=m;i++)v[i][i]=1;
	for(int i=m;i>=1;i--)
		if(check(i-1)){
			for(int j=0;j<=m;j++)v[j][j%i]=1;
			ans+=bin[i];
		}	
	for(int k=0;k<=m;k++)
		for(int i=0;i<=m;i++)
			for(int j=0;j<=m;j++)v[i][j]|=v[i][k]&v[k][j];
	for(int i=1;i<=n;i++)
		if(!v[a[i]][b[i]])puts("-1"),exit(0);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
	bool flag = true;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i += 2) {
		if (s[i] == 'L')flag = false;
	}
	for (int i = 1; i < s.size(); i += 2) {
		if (s[i] == 'R')flag = false;
	}
	if (flag)cout << "Yes";
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 256
/**
*    created: 03.07.2020 17:38:04
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int n, k;
    cin >> n >> k;
    int sum = 0;
    rep(i,n) {
        int x;
        cin >> x;
        sum += min(abs(x),abs(k-x));
    }
    cout << 2*sum << endl;
    return 0;
}

Measured memory_bytes: 3652
import math 

num = int(input())
for i in range(num):
    ax,ay,ar,bx,by,br=map(float,input().split())
    d = ((ax-bx)* (ax - bx))+((ay-by)*(ay-by))
    r1 = (ar+br)*(ar+br)
    r2 = (ar-br)*(ar-br)
    if d <= r1 and d >= r2:
        print(1);
    elif d<r2 and ar>=br:
        print(2)
    elif d < r2 and ar <= br:
        print(-2)
    else:
        print(0)
    

Measured memory_bytes: 7532
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template<class T> void _out(const T &x) { cout << x; }
void _out(const int &x) { printf("%d", x); }
void _out(const ll &x) { printf("%lld", x); }
void _out(const double &x) { printf("%.16f", x); }
void _out(const char &x) { putchar(x); }
void _out(const char *x) { printf("%s", x); }
template<class T,class U> void _out(const pair<T,U> &x) {_out(x.F); putchar(' '); _out(x.S);}
template<class T> void _out(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _out(*i++)) if (i != x.cbegin()) putchar(' '); }
void out() {}
template<class T, class... U> void out(const T &head, const U &... tail) { _out(head); putchar(sizeof...(tail) ? ' ' : '\n'); out(tail...); }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
unordered_map<int, int> mm;

int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int n;
    sf(n);
    vector<int> a(n + 1);
    rep(i, 1, n) {
        a[i] = read();
        mm[a[i]]++;
    }
    ll ans = 0;
    for (auto temp : mm) {
        ans += 1ll * temp.second * (temp.second - 1) / 2;
    }
    for (int i = 1; i <= n; ++i) {
        ll t = ans - (mm[a[i]] - 1);
        out(t);
    }
    return 0;
}

Measured memory_bytes: 8392
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
using namespace std;
int main(void)
{
	int a;
	char s[11];
	scanf("%d",&a);
	scanf("%s",s);
	if(a>=3200)	printf("%s\n",s);
	else printf("red\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using LP = pair<int, int>;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

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; }

const double PI=3.14159265358979323846;

int mod = 1e9+7;
const long long INF = 1LL<<60;


int main(){
  ll N, M;
  cin >> N >> M;
  vector<ll> H(N);
  rep(i, N) cin >> H[i];

  vector<bool> rivals(N, true);

  rep(_, M){
    int A, B;
    cin >> A >> B;
    A--; B--;
    rivals[A] = rivals[A] && H[A] > H[B];
    rivals[B] = rivals[B] && H[B] > H[A];
  }

  int ans = 0;
  rep(i, N){
    if(rivals[i]) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4068
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int H, W;
	for (int i = 0; i < 300; i++){
		cin >> H >> W;
		for (int n = 0; n < H;  n++){
			for (int n = 0; n < W; n++){
				cout << '#';
			}
			cout << endl;
		}
		if (H == 0 && W == 0){
			break;
		}

		cout << endl;

	}
	return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

int H[20];

int main()
{
  int cnt;
  int N;
  int max = 0;
  int i;
  int result = 0;

  cnt = scanf("%d", &N);

  if (N == 1) {
    printf("1");
    return 0;
  }

  for (i=0; i<N; i++) {
    cnt = scanf("%d", &H[i]);
  }

  max = H[0];
  result++;

  for (i=1; i<N; i++) {
    if (max == H[i]) {
      result++;
    } else if (max < H[i]) {
      result++;
      max = H[i];
    }
  }
  
  printf("%d", result);

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
  char s[3];
  for(int i=0;i<3;i++){
    scanf("%c",&s[i]);
  }
  if(s[0]!=s[1]&&s[0]!=s[2]&&s[1]!=s[2]){
    printf("Yes");
  }
  else printf("No");
  return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int N;
	cin >> N;
	deque<int> A;
	fx(N) {
		vecp(A);
	}

	sorts(A);

	int two = 1;
	while(two<=A[N-1]) {
		two <<= 1;
	}
	int ans = 0;

	while (A.size()>0) {
		int a = A[A.size() - 1];
		A.pop_back();
		while (two>a*2) {
			two >>= 1;
		}
		if (A.size() == 0) { break; }
		auto b = lower_bound(A.begin(), A.end(), two-a);
		if (b>=A.begin()&&b<A.end()&&a+*b==two) {
			ans++;
			A.erase(b);
		}
	}
	ce(ans)
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
ll f(vector<pair<int,int> >a){
    ll ans=0;
    sort(a.begin(),a.end());
    priority_queue<int,vector<int>,greater<>>q;
    for(auto i:a){
        q.emplace(i.second);
        ans+=i.second;
        while(q.size()>i.first) ans-=q.top(),q.pop();
    }
    return ans;
}

int main(){
    int t,n,k,l,r;
    cin>>t;
    while(t--){
        cin>>n;
        ll sum=0;
        vector<pair<int,int> >L,R;
        for(int i=0;i<n;i++){
            cin>>k>>l>>r;
            if(l>r) L.emplace_back(k,l-r),sum+=r;
            else if(r>l) R.emplace_back(n-k,r-l),sum+=l;
            else sum+=l;
        }
        cout<<sum+f(L)+f(R)<<endl;
    }
	return 0;
}


Measured memory_bytes: 7080
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n;
    cin>>n;
    vl as(n);
    cin>>as;

    ll l = -1, r = LINF;
    while (l + 1 < r) {
        ll m = (l + r) / 2;
        ll temp = m;
        bool f = true;
        rep(i, n) {
            ll c = (as[i] + m - n + 1) / (n + 1);
            if ((as[i] + m - n + 1) % (n + 1)) c++;
            if (temp >= c) temp -= c;
            else {
                f = false;
                break;
            }
        }
        if (f) r = m;
        else l = m;
    }

    ll u = max(0ll, r - 100000);
    for (ll m = u; m < r; ++m) {
        ll temp = m;
        bool f = true;
        rep(i, n) {
            ll d = (as[i] + m - n + 1);
            ll c = d / (n + 1);
            if (d >= 0 && d % (n + 1)) c++;
            c = max(c, 0ll);
            if (temp >= c) temp -= c;
            else {
                f = false;
                break;
            }
        }
        if (f) {
            cout<<m<<endl;
            return 0;
        }
    }
    cout<<r<<endl;
}

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

using namespace std;

using ll = long long;

bool Check(int n) {
    string s = to_string(n);
    for (auto c : s)
        if (c != s[0]) return false;
    return true;
}

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

    int n;
    cin >> n;
    while (true) {
        if (Check(n)) {
            cout << n << "\n";
            break;
        }
        ++n;
    }

    return 0;
}


Measured memory_bytes: 256
for i in [0]*input():
  s=raw_input()
  n=(len(s)-4)/2
  if s==">'"+"="*n+"#"+"="*n+"~": t="A"
  elif s==">^"+"Q="*n+"~~": t="B"
  else: t="NA"
  if n<1: t="NA"
  print t

Measured memory_bytes: 4208
import std.stdio, std.conv, std.string, std.algorithm,
       std.math, std.array, std.container, std.typecons;

void main() {
  string s = readln.chomp;
  if(s[0]=='7' || s[1]=='7' || s[2]=='7') writeln("Yes");
  else writeln("No");
}



Measured memory_bytes: 2572
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 2e5+10;

vector<int> adj[N];

bool vis[N];
int d[N];
void dfs(int u) {
  vis[u] = 1;
  for (int v : adj[u]) {
    if (!vis[v]) {
      d[v] = d[u]+1;
      dfs(v);
    }
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n; cin >> n;
  for (int i = 0; i < n-1; i++) {
    int u, v; cin >> u >> v; u--; v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(0);
  int u = max_element(d, d + n) - d;
  d[u] = 0;
  memset(vis, 0, sizeof vis);
  dfs(u);
  int diam = *max_element(d, d + n);
  puts(diam % 3 != 1 ? "First" : "Second");
  return 0;
}


Measured memory_bytes: 18432
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

void solve(int tc)
{
	int n;
	cin >> n;
	v32 arr(n, 0);
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	int cnt = 0, req = 1;
	for (int i = 1; i < n + 1; i++)
	{
		if (arr[i - 1] == req)
		{
			req++;
			cnt++;
		}
	}
	if (cnt == 0)
		cnt = n + 1;
	cout << (n - cnt) << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve(tc);
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 3996
N, M = map(int, input().split())
H = list(map(int, input().split()))
ANS = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    ANS[A-1].append(H[B-1])
    ANS[B-1].append(H[A-1])
cnt = 0
for i, value in enumerate(ANS):
    if value == [] or H[i] > max(value):
        cnt += 1
print(cnt)


Measured memory_bytes: 23036
# B - Palace
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

lst = []
for i in range(N):
	ref = abs(A-(T-0.006*H[i]))
	lst.append(ref)

ans = lst.index(min(lst))+1
print(ans)


Measured memory_bytes: 8900
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

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

    int r[n];

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

    int _max = r[1] - r[0];
    int _min = pow(10, 9);

    for (int i = 1; i < n; i++) {
        _min = min(_min, r[i - 1]);
        _max = max(_max, r[i] - _min);
    }

    cout << _max << endl;

    return 0;
}



Measured memory_bytes: 3844
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		StringBuffer sb = new StringBuffer(scan.next());
		int count = scan.nextInt();
		
		for(int i = 0;i < count;i++)
		{
			String cmd = scan.next();
			int a = scan.nextInt();
			int b = scan.nextInt() + 1;
			
			if(cmd.equals("print")){
				System.out.println(sb.substring(a,b));
			}else if(cmd.equals("reverse")){
				StringBuffer tmpsb = new StringBuffer(sb.substring(a,b)).reverse();
				String tmp = tmpsb.toString();
				sb = sb.replace(a,b,tmp);
			}else if(cmd.equals("replace")){
				String p = scan.next();
				sb = sb.replace(a,b,p);
			}
		}
	}
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int last = 10000;
  int cnt = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] == a[i - 1]) {
      a[i] = last--;
      ++cnt;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int mod = 1e9 + 7;

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

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

int n, k, a[100];

bool dp[100009];

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

    cin >> n >> k;
    rep(i, n) cin >> a[i];

    rep(i, k) if(!dp[i]) rep(j, n) if(i + a[j] <= k) dp[i + a[j]] = true;

    cout << (dp[k] ? "First\n" : "Second\n");

    return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  int total = 0;
  for(int i = 0; i < m; i++) {
    int a;
    cin >> a;
    total = total + a;
  }
  int answer = n - total;
  if(answer >= 0) {
    cout << answer << endl;
  } else {
    cout << "-1" << endl;
  }
}


Measured memory_bytes: 3624
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 10**8
for i in range(m):
    x,y,c = map(int,input().split())
    x-= 1
    y -=1
    ans = min(ans,a[x]+ b[y]-c)
a.sort()
b.sort()
ans = min(ans,a[0] + b[0])
print(ans)


    
    


Measured memory_bytes: 18736