akhauriyash/Code-Regression huggingface dataset:
X, N = map(int, input().split())
p_s = list(map(int, input().split()))

p_s.sort()
ans = 0
tmp_diff = float('inf')

for num in range(-300,301):
    if(num not in p_s):
        diff = abs(X - num)
        if (diff < tmp_diff):
            ans = num
            tmp_diff = diff
            
print(ans)

Measured memory_bytes: 9192
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <iterator>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <map>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	if (K >= N) {
		cout << "0";
		return 0;
	}
	vector<int> A(N);
	rep(i, N) {
		cin >> A[i];
	}
	long long ans = 0;
	sort(A.begin(), A.end(), greater<int>());
	for (auto itr = A.begin()+K; itr != A.end(); itr++) {
		ans += *itr;
	}
	cout << ans;
}

Measured memory_bytes: 3996
#include<iostream>
using namespace std;
int main(){
  int a,b,c,x;
  int count=0;
  cin >> a >> b >> c >> x;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        int temp=500*i+100*j+50*k;
        if(x==temp){
          count++;
        }
      }
    }
  }
  cout<<count;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
         for j in range(1,105):
                  for k in range(1,105):
                           v = i*i+j*j+k*k+i*j+j*k+k*i;
                           if v<10050:
                                    ans[v]+=1
for i in range(n):
         print(ans[i+1])


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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define RREP(i, a, n) for(int i = (int)(n); i >= a; i--)
#define all(x) (x).begin(),(x).end()

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

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    int H,W;
    cin >> H >> W;

    vector<string> s(H);
    rep(i,H) cin >> s[i];

    vector<vector<ll> >width_dp(H, vector<ll>(W,0) );
    vector<vector<ll> >high_dp(H, vector<ll>(W,0) );

    rep(i,H)
    {
        rep(j,W)
        {
            if( s[i][j] != '#' )
            {
                if( j > 0 && width_dp[i][j-1] != 0 ) chmax(width_dp[i][j], width_dp[i][j-1]);
                else
                {
                    int tmp_j = j;
                    for( tmp_j; tmp_j < W; tmp_j++ )
                    {
                        if( s[i][tmp_j] == '#' ) break;
                        else width_dp[i][j]++;
                    }
                }

                if( i > 0 && high_dp[i-1][j] != 0 ) chmax(high_dp[i][j], high_dp[i-1][j]);
                else
                {
                    int tmp_i = i;
                    for( tmp_i; tmp_i < H; tmp_i++ )
                    {
                        if( s[tmp_i][j] == '#' ) break;
                        else high_dp[i][j]++;
                    }
                }
            }
        }
    }

    ll ans = 0;
    rep(i,H)
    {
        rep(j, W) chmax(ans, high_dp[i][j] + width_dp[i][j]-1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 67072
N, M = map(int, input().split())
K = [0] * N
A = [0] * N
for i in range(N):
    A[i] = list(map(int, input().split()))
    K[i] = A[i][0]
    A[i].pop(0)

S = set(A[0])
for i in range(1, N):
    S &= set(A[i])
print(len(S))


Measured memory_bytes: 3064
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=2e5+5,inf=0x3f3f3f3f;
int a[N],l[N],r[N],st[N],n,top;ll res;
int main(){
	scanf("%d",&n);
	fp(i,1,n)scanf("%d",&a[i]);
	a[0]=a[n+1]=0,st[++top]=0;
	fp(i,1,n){
		while(top&&a[i]<a[st[top]])--top;
		l[i]=st[top],st[++top]=i;
	}
	st[top=1]=n+1;
	fd(i,n,1){
		while(top&&a[i]<a[st[top]])--top;
		r[i]=st[top],st[++top]=i;
	}
	fp(i,1,n)res+=1ll*a[i]*(i-l[i])*(r[i]-i);
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <queue>
#include <vector>
#include <numeric>
using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    priority_queue<int> q;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        q.push(a);
    }

    for(int i=0; i<m; i++){
        int a = q.top();
        q.pop();
        q.push(a/2);
    }
    long long sum = 0;
    while(!q.empty()){
        sum += q.top();
        q.pop();
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cout<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}


typedef long long int64;
typedef pair<int64,int64> P;

int64 msd(int64 n) {
    while(n/10){
        n /= 10;
    }
    return n;
}

int main() {
    int n;
    cin >> n;
    map<P,int> mp;

    for (int i=1; i<=n; i++) {
        mp[P(msd(i), i % 10)]++;
    }

    int64 ans = 0;
    for (int i=1; i<=n; i++) {
        ans += mp[P(i%10,msd(i))];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>
int main()
{
	int n,m,s,g1,g2,b1,b2,c,i,j,k,d[101][101],V=INT_MAX/5;
	while(scanf("%d%d%d%d%d",&n,&m,&s,&g1,&g2),n)
	{
		for(i=1;i<=n;d[i][i]=0,++i)for(j=1;j<=n;++j)d[i][j]=V;
		while(m--)scanf("%d%d%d",&b1,&b2,&c),d[b1][b2]=c;
		for(k=1;k<=n;++k)for(i=1;i<=n;++i)for(j=1;j<=n;++j)
			c=d[i][k]+d[k][j],d[i][j]=(d[i][j]<c?d[i][j]:c);
		for(c=V,i=1;i<=n;++i)
			k=d[s][i]+d[i][g1]+d[i][g2],c=(c<k?c:k);
		printf("%d\n",c);
	}
	return 0;
}

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

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

  if (K % 2 == 0)
    cout << (K / 2) * (K / 2) << endl;
  else
    cout << (K / 2 + 1) * (K / 2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int Al=0,Bo=0;
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  bool f = 1;
  for(int i=N-1;i>=0;i--){
    if(f==1){
      Al+=vec[i];
      f=0;
    }
    else{
      Bo+=vec[i];
      f=1;
    }
  }
  cout << Al-Bo << endl;
}

Measured memory_bytes: 256
// Author : Nachiket Kanore
// Institute : PICT, Pune

#include <stdexcept>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstring>
#include <cstdarg>
#include <cstdio>
#include <memory>
#include <random>
#include <cmath>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
#include <limits>
#include <bitset>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <array>
#include <list>
#include <map>
#include <set>

using namespace std;

#define int long long
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<(e);x++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
 
 
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
 
const int mod = 1e9+7;
const int inf = 1e18;



int32_t main(){
    FAST;

    string s;   cin >> s;
    for(int x=0;x<s.size()-1;x++){
        if(s[x] == s[x+1])
            return cout << "Bad" , 0;
    }

    cout << "Good";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <chrono>
using namespace std::chrono;
using namespace std;
#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<int,int>
#define ll long long int
const int mod=1e9+7;
/*    auto start = high_resolution_clock::now();
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cout << "\nduration="<<duration.count()/1e6 << endl;
*/
void solve(){
    int n;
    cin>>n;
    int a[n];
    fr(i,0,n)
    cin>>a[i];
    ll ans=0;
    int j=0;
    int sum=a[0],xr=a[0];
    fr(i,0,n){
        while(j<n&&sum==xr){ 
            j++;
            sum+=a[j];
            xr^=a[j];

        }
        ans+=(ll)(j-i);
        sum-=a[i];
        xr^=a[i];
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    while(t--)
    solve();

}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)

void printVec(std::vector<int> & vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec1(std::vector<string>& vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec2(std::vector<Int>& vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}

Int gcd(Int a, Int b)
{
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b)
{
	return a / gcd(a, b) * b;
	//a*bは64bit integer overflow
}

bool integer(double num)
{
	return floor(num) == num;
}

Int fact(int num)
{
	if (num == 0)
		return 1;
	else
		return num * fact(num - 1);
}

int main() {
	IOS;
	// cout << fixed << setprecision(20);
	// int a;cin >> a;
	// string s;cin>>s;
	Int n, k; cin >> n >> k;
	vector<int> a(n), b;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	Int cnt = 0, cnt2 = 0;
	Int ans = 0;
	for (int i = 0; i < n; i++) {
		int num = a[i];
		cnt = 0;
		cnt2 = 0;
		for (int j = i + 1; j < n; j++) {
			if (num > a[j])cnt++;
		}
		for (int k = 0; k < n; k++) {
			if (num > a[k])cnt2++;
		}
		//cout << num << " " << cnt << endl;
		Int dif = cnt2 - cnt;
		//ans += k *(k + 1) / 2 % MOD *cnt2 % MOD - (k *dif) % MOD;//WA
		ans += k * (k - 1) / 2 % MOD * cnt2 % MOD + k * cnt % MOD;//AC
		//ans%=MOD;
	}

	cout << ans % MOD;

	cout << endl;
	return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;

int main()
{
	ll n;
	scanf("%lld", &n);
	ll x = ceil((sqrt(8 * n + 1) - 1) / 2);
	printf("%lld\n", x);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second

int main() {

   int a,b;
   cin>>a>>b;
   
   cout<<(a*b)-(a+b)+1;
   
	return 0;
}

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

int main(){
	int n, temp;
	cin >> n;
	int mini = 1e9, count = 0;
	for (int i=0; i<n ; i++){
		cin >> temp;
		if (temp < mini) count ++;
		mini = min(temp,mini);
	}
	cout << count;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; cin >> N; 
	int V[30] = {}; 
	int C[30] = {}; 
	for(int i = 0; i < N; i++){
		cin >> V[i]; 
	}
	for(int i = 0; i < N; i++){
		cin >> C[i]; 
	}
	int ans = 0; 
	for(int i = 0; i < N; i++){
		if(V[i] > C[i]) ans += V[i] - C[i]; 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

typedef long long ll;
#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

int main(){
	int N, A, B;
	cin >> N >> A >> B;
	
	cout << MIN((N * A), B) << endl;
}



Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int a = 0;
  int ans = 0;
  
  scanf("%d",&a);
  
  ans = a /2;
  if(a%2 == 1)
  {
    ans += 1;
  }
  
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

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

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
inline vll sieve(ll n) {
    str flg = str(n + 1, '1');
    for (ll i = 2; i * i <= n; i++) if (flg[i] ^ '0')
        for (ll j = i * i; j <= n; j += i)
            flg[j] = '0';
    vll res;
    for (ll i = 2; i <= n; i++)
        if (flg[i] ^ '0') res.push_back(i);
    return res;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

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

constexpr ll MOD = 1e9 + 7;

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}
void solve() {
    ll n;
    std::cin >> n;

    auto legendre = [&](ll n, ll p) -> ll {
        ll res = 0;
        for (ll i = p; i <= n; i *= p)
            res += n / i;

        return res;
    };

    ll ans = 1;
    for (ll p : sieve(n))
        (ans *= legendre(n, p) + 1) %= MOD;

    std::cout << ans << '\n';
}


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int x,y;
    cin >> x >> y;
    vector<int> group2 = {4,6,9,11};
    vector<int> group1 = {1,3,5,7,8,10,12};
    string ans;
    if (x == 2 && y == 2) {
        ans = "Yes";
    } else if (find(all(group2),x) != group2.end() && find(all(group2),y) != group2.end()){
        ans = "Yes";
    } else if (find(all(group1),x) != group1.end() && find(all(group1),y) != group1.end()){
        ans = "Yes";
    } else {
        ans = "No";
    }
    cout << ans << endl;


    return 0;
}


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

template <typename D, typename T = D>
class Tree
{
public:
	Tree( long long int size = 0, D InitialValueArg = D() ) {
		long long int n = 1LL;
		CalcTree.emplace_back( vector<T>( n ) );
		while( n <= size ) {
			n <<= 1LL;
			addOneLine( n );
		}
		InitialValue = InitialValueArg;
		Data.resize( n, InitialValue );
		for( size_t i = 0; i < Data.size(); i++ ) {
			update( i, Data[i] );
		}
		MaxSize = n;
		NowIndex = 0LL;
	}

	virtual T preprocessing( D a ) {
		return T( a );
	}

	virtual T treeupdate( T a, T b ) {
		return a;
	}

	void update( long long int idx, D data ) {
		Data[idx] = data;
		(*(CalcTree.rbegin()))[idx] = preprocessing( data );
		for( auto ite = CalcTree.rbegin(); ite + 1 < CalcTree.rend(); ) {
			idx >>= 1LL;
			T updatedata = treeupdate( (*ite)[idx * 2], (*ite)[idx * 2 + 1] );
			ite++;
			if( (*ite)[idx] != updatedata ) {
				(*ite)[idx] = updatedata;
			} else {
				break;
			}
		}
	}

	void show() {
		for( auto x : CalcTree ) {
			for( auto y : x ) {
				cout << y << " ";
			}
			cout << endl;
		}
	}

	void push( D data ) {
		if( NowIndex == MaxSize ) {
			MaxSize <<= 1LL;
			addOneLine( MaxSize );
			vector<D>Datamemo( MaxSize, InitialValue );
			copy( Data.begin(), Data.end(), Datamemo.begin() );
			for( long long int i = 0; i < Datamemo.size(); i++ ) {
				update( i, Datamemo[i] );
			}
		}
		Data[NowIndex] = data;
		update( NowIndex, data );
		NowIndex++;
	}

	T range( long long int l, long long int r ) {
		return rangeProcessing( 0, l, r, 0, 0, MaxSize );
	}

	long long int t() {
		return 10;
	}

private:
	vector<vector<T>> CalcTree;
	vector<D> Data;
	long long int MaxSize;
	long long int NowIndex;
	D InitialValue;

	void addOneLine( long long int n ) {
		CalcTree.emplace_back( vector<T>( n ) );
	}

	T rangeProcessing( long long int d, long long int a, long long int b, long long int k, long long int l, long long int r ) {
		if( !(r <= a || b <= l) && d < CalcTree.size() ) {
			if( a <= l&&r <= b ) {
				return CalcTree[d][k];
			} else {
				return treeupdate( rangeProcessing( d + 1, a, b, k * 2, l, (l + r) / 2 ), rangeProcessing( d + 1, a, b, k * 2 + 1, (l + r) / 2, r ) );
			}
		}
		return InitialValue;
	}
};

class RQM : public Tree<long long int>
{
public:
	RQM( long long int a, long long int b ) :Tree( a, b ) {

	}
	long long int treeupdate( long long int a, long long int b ) {
		return min( a, b );
	}
};

int main() {
	long long int n, q;
	cin >> n >> q;
	RQM rqm( n, (1LL << 31) - 1 );
	for( long long int i = 0; i < q; i++ ) {
		long long int c, x, y;
		cin >> c >> x >> y;
		if( c == 0 ) {
			rqm.update( x, y );
		} else {
			cout << rqm.range( x, y + 1 ) << endl;
		}
	}
}

Measured memory_bytes: 5960
L,R=map(int,input().split())
if R-L>=670:
    print(0)
    exit()

else:
    ans=2020
    for i in range(L,R):
        for j in range(i+1,R+1):
            tmp=(i*j)%2019
            if ans>tmp:
                ans=tmp

print(ans)

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

int main(){
    int k,s;
    cin >> k >> s;

    int cnt = 0;
    for ( int x = 0 ; x <= k ; x++ ){
        for ( int y = 0 ; y <= k ; y++){
            int z = s - ( x + y );
            if ( z >= 0 && z <= k) cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0xff,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int n,m,x,cnt;
bool b[60];
vector<pair<int,int> > v[60];
void dfs(int i){
    b[i]=1;
    cnt++;
    for(int j=0;j<v[i].size();j++){
        if(v[i][j].second==x||b[v[i][j].first]){
            continue;
        }
        dfs(v[i][j].first);
    }
}
int main() {
    int ans=0;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        v[a].push_back(make_pair(b,i));
        v[b].push_back(make_pair(a,i));
    }
    for(int i=0;i<m;i++){
        x=i;
        memset(b,0,sizeof(b));
        cnt=0;
        dfs(1);
        if(cnt!=n)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

template <class T>
void read(T &x)
{
	char ch;
	for (ch=getchar();(ch<'0'||ch>'9')&&ch!='-';) ch=getchar();
	x=0;int t=1;if (ch=='-') {ch=getchar();t=-1;}
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	x*=t;
}

int main()
{
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	int n;scanf("%d",&n);
	int ans1=1,ans2=1;
	for (int i=0;i<n;i++)
	{
		int x;scanf("%d",&x);
		ans1*=3;if (x%2==0) ans2*=2;
	}
	printf("%d\n",ans1-ans2);
	return 0;
}



Measured memory_bytes: 256
fn read() -> (u32, u32, Vec<u32>) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut ws = s.split_whitespace();
    let bill: u32 = ws.next().unwrap().parse().unwrap();
    let n: u32 = ws.next().unwrap().parse().unwrap();

    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    ws = s.split_whitespace();
    let mut hate_nums = vec![];
    for _ in 0..n {
        hate_nums.push(ws.next().unwrap().parse::<u32>().unwrap());
    }
    (bill, n, hate_nums)
}

fn like_number_check(hate_nums: &Vec<u32>, bill: u32) -> bool {
    let flag = bill.to_string().chars().any(|char_digit| {
        let digit = char_digit.to_digit(10).unwrap();
        hate_nums.iter().any(|&hate| hate == digit)
    });
    !flag
}

fn main() {
    let (bill, n, hate_nums) = read();
    for i in bill..100000 {
        if like_number_check(&hate_nums, i) {
            println!("{}", i);
            break;
        }
    }
}


Measured memory_bytes: 2092
#include <stdio.h>
#include <math.h>
#include <string.h>
int max(int a,int b)
{
    if (a>b) {
        return a;
    }
    else return b;
}
int main()
{
    char s[1000];int l;
    scanf("%d %s",&l,s);
    int x=0,p=0;
    int i;
    for (i=0; i<l; i++) {
        if (s[i]=='I') {
            x++;
        }
        else if(s[i]=='D')
        {
            x--;
        }
        p=max(p, x);
    }
    printf("%d",p);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main() {
	int n;

	cin >> n;

	bool f = false;
	for (int x = 0; x <= 100; x++) {
		for (int y = 0; y <= 100; y++) {
			if (4 * x + 7 * y == n) {
				f = true;
				break;
			}
		}
	}

	if (f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}


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

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

    if((A * C) < B){
        cout << C << endl;
    }else{
        cout << (B / A) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

int inf = std::numeric_limits<int>().max();

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define ll long long
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

void calc(string & s, vector<int> & v, vector<int> & w) {
	int rp = 0;
	int ri = 0;
	
	int n = s.size();
	for(int i=0; i<n; i++) {
		if (s[i] == 'R') {
			if (i % 2) ri++; 
			else rp++;
		} else {
			if (i % 2) {
				v[i] = rp;
				w[i] = ri;
			} else {
				v[i] = ri;
				w[i] = rp;
			}
			rp=0;
			ri=0;
		} 
	}
}

int main() {
	string s;
	cin >> s;
	int n = s.size();
	vector<int> v(n), w(n), ans(n); 
	vector<int> v2(n), w2(n);

	calc(s, v, w);
	reverse(s.begin(), s.end());
	for(int i=0; i<n; i++) {
		if (s[i] == 'R') s[i] = 'L';
		else s[i] = 'R';
	}
	calc(s, v2, w2);
	reverse(v2.begin(), v2.end());
	reverse(w2.begin(), w2.end());

	for(int i=0; i<n; i++) {
		ans[i] = w[i] + w2[i];
	}
	for(int i=1; i<n; i++) {
		ans[i-1] += v[i];
	}

	for(int i=n-2; i>=0; i--) {
		ans[i+1] += v2[i];
	}

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


Measured memory_bytes: 2688
a, b = gets.split.map(&:to_i)

#f(0,a)を求める
def f(a)
  i = 0
  sum = 0
  #49桁分計算 ∵10**12 < 2**48
    while (i < 49) do
    cnt = 0
    #周期2**(i+1)→一応ビット演算しとく
    cycle = 1 << (i+1)
    #周期内の1の数を数える
    cnt += (a+1)/cycle * cycle/2
    #はみ出た分を足す
    rest = (a+1)%cycle - cycle/2
    cnt += rest if rest > 0
    if (cnt%2 == 1) then
      sum += 1 << i
    end
    i += 1
  end
  return sum
end
#f(a,b) = f(0,a-1)^f(0,b)
puts f(a-1)^f(b)

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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    ans += (a - 1);
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

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

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

using pii = pair<size_t, size_t>;

vector<pii> G[int(1e2)]; // {node, cost}
size_t N;

vector<size_t> cost(int(1e2), INF);

void dijkstra() {
    priority_queue<pii, vector<pii>, greater<>> que; // {cost, node}
    cost[0] = 0;
    que.emplace(0, 0);

    while (!que.empty()) {
        size_t nowcost = que.top().first;
        size_t nownode = que.top().second;
        que.pop();
        if (cost[nownode] < nowcost) continue;

        for (auto next: G[nownode]) {
            if (chmin(cost[next.first], cost[nownode] + next.second)) {
                que.emplace(cost[next.first], next.first);
            }
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N; cin >> N;

    for (size_t i = 0; i < N; ++i) {
        size_t u, k; cin >> u >> k;
        for (size_t j = 0; j < k; ++j) {
            size_t v, c; cin >> v >> c;
            G[u].emplace_back(v, c);
        }
    }

    dijkstra();

    for (size_t node = 0; node < N; ++node) {
        cout << node << " " << cost[node] << "\n";
    }

    return 0;
}



Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
const int inf = 1001001000;

void print(vector<vector<int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

int main(){
	while (true){
		int n, m;
		cin >> n >> m;
		if (n == 0 && m == 0)
			break;
		vector<int> c(m);
		vector<int> y(n);
		rep(i, m) cin >> c[i];
		rep(i, n) cin >> y[i];
		vector<vector<int>> dp(n + 1, vector<int>(256, inf));
		dp[0][128] = 0;
		rep(i, n)
		{
			rep(j,256){
				if (dp[i][j] == inf){
					continue;
				}
				rep(k,m){
					if (j + c[k] < 0) dp[i + 1][0] = min(dp[i + 1][0], dp[i][j] + (0 - y[i]) * (0 - y[i]));
					else if (j + c[k] > 255) dp[i + 1][255] = min(dp[i + 1][255], dp[i][j] + (255 - y[i]) * (255 - y[i]));
					else dp[i + 1][j + c[k]] = min(dp[i + 1][j + c[k]], dp[i][j] + (j + c[k] - y[i]) * (j + c[k] - y[i]));
				}
			}

		}
		int ans = inf;
		rep(i, 256) ans = min(ans, dp[n][i]);
		cout << ans << endl;
	}

	return 0;
}


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

namespace ABC085B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var nums = new List<int>();
            foreach (var d in Enumerable.Range(0, n))
            {
                nums.Add(int.Parse(Console.ReadLine()));
            }

            Console.WriteLine(nums.Distinct().Count());
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>
#include <iomanip>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	vector<ll> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	ll ans = 0;
	ll factor = 1;
	
	for(int i = 0; i < 60; ++i) {
		ll one = 0;
		ll zero = 0;
		
		for(int j = 0; j < n; ++j) {
			if( a[j] & (1LL << i) ) {
				one++;
			} else {
				zero++;
			}	
		}
		
		ans += (one * zero) % MOD_LL * (factor % MOD_LL);
		ans %= MOD_LL;
		factor *= 2;
		factor %= MOD_LL;
	}

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


Measured memory_bytes: 5520
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <tuple>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG

int main(void){

    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for(int i=0; i < N; i++){
        cin >> p.at(i);
    }

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

    int sum =0;

    for(int i=0; i<K; i++){
        sum += p.at(i);
    }

    cout << sum << endl;

}

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

int main() {
  int H,W,Z=0,A,B;
  cin>>H>>W;
  vector<vector<char>> p(H,vector<char>(W));
  for(int i=0;i<H;i++){
    string S;
    cin>>S;
    for(int j=0;j<W;j++){
      p.at(i).at(j)=S.at(j);
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      queue<int> q;
      if(p.at(i).at(j)=='.'){
        q.push(i*W+j);
        vector<vector<int>> r(H,vector<int>(W,-1));
        while(!(q.empty())){
          A=q.front()/W,B=q.front()%W;
          r.at(i).at(j)=0;
          q.pop();
          if(A>0){
            if(r.at(A-1).at(B)==-1&&p.at(A-1).at(B)=='.'){
              r.at(A-1).at(B)=r.at(A).at(B)+1;
              q.push((A-1)*W+B);
            }
          }
            if(A<H-1){
            if(r.at(A+1).at(B)==-1&&p.at(A+1).at(B)=='.'){
              r.at(A+1).at(B)=r.at(A).at(B)+1;
              q.push((A+1)*W+B);
            }
            }
              if(B>0){
            if(r.at(A).at(B-1)==-1&&p.at(A).at(B-1)=='.'){
              r.at(A).at(B-1)=r.at(A).at(B)+1;
              q.push(A*W+B-1);
            }
              }
                  if(B<W-1){
            if(r.at(A).at(B+1)==-1&&p.at(A).at(B+1)=='.'){
              r.at(A).at(B+1)=r.at(A).at(B)+1;
              q.push(A*W+B+1);
            }
                  }
          
                  }
              Z=max(Z,r.at(A).at(B));
             
      }
            }
          }
  cout<<Z<<endl;
            
}

Measured memory_bytes: 256
s = input()

if 0 < int(s[2:]) < 13 and 0 < int(s[:2]) < 13:
    print('AMBIGUOUS')
elif 0 < int(s[2:]) < 13:
    print('YYMM')
elif 0 < int(s[:2]) < 13:
    print('MMYY')
else:
    print('NA')


Measured memory_bytes: 2940
N = int(input())
si = [[]]*N
for i in range(N):
  s, t = map(str,input().split())
  si[i] = [s,int(t)]
X = input()
flg = False
ans = 0
for i in si:
  if flg:
    ans += i[1]
  if i[0]==X:
    flg = True
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.10lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
const int mod = 1000 * 1000 * 1000 + 7;
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;
 
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;
 
int dx[6] = {-1,-1,0,0,1,1};
int dy[6] = {-1,0,-1,1,0,1};

int n;
int a[200005];


int main(){
    string a,b;
    cin>>a>>b;
    int n,m;
    cin>>n>>m;
    string x;
    cin>>x;
    if(x==a)
        return cout<<n-1<<" "<<m<<endl,0;
    cout<<n<<" "<<m-1<<endl;
    return 0;
}

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

int main() {
	int n, m = 0; cin >> n;
	long long s = 0;
	while(n--) {
		int x; cin >> x;
		if(x >= m) m = x;
		else s += m - x;
	}
	cout << s;
}


Measured memory_bytes: 3596
#include<stdio.h>
 
int main(){
	int n;
	int key = 0;
	scanf("%d", &n);
	for(int i = 1; i < 10; i++){
		if(n % i == 0 && (n / i) < 10){
			printf("Yes\n");
			key++;
			break;
		}
	}
	if(key == 0){
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
#include<stdlib.h>
#define NIL -1
typedef struct {
  int key,right,left;

} N;
void Insert(N *, int , int);
void Preorder(N *, int );
void Inorder(N *, int );
int main (){
  int i,n=0,key,j=0;
  char com[8];
  N *Tree;
  scanf("%d",&n);
  Tree = malloc(sizeof(N)*n);

  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='i'){
    scanf("%d",&key);
    Insert(Tree,j,key);
    j++;
  }
  else if(com[0]=='p'){
    if(j>0){
      Inorder(Tree,0);
      printf("\n");

      Preorder(Tree,0);
      printf("\n");

    }
  }
}
  free(Tree);
  return 0;
}
void Insert(N *Tree,int j,int key ){
  int x=0,y;
  Tree[j].key=key;
  Tree[j].left=NIL;
  Tree[j].right=NIL;
  if(j==0){
    return ;
  }
  while( x!= NIL){
    y=x;
    if(key<Tree[x].key){
      x=Tree[x].left;

    }
    else{
      x=Tree[x].right;
    }
  }
  if(key<Tree[y].key){
    Tree[y].left=j;
  }
  else{
    Tree[y].right=j;
  }
}
void Preorder(N *Tree, int k){
  if(k==NIL){
    return;
  }
  printf(" %d",Tree[k].key);
  Preorder(Tree,Tree[k].left);
  Preorder(Tree,Tree[k].right);

}
void Inorder(N *Tree, int k){
  if(k==NIL){
    return;
  }
    Inorder(Tree,Tree[k].left);
  printf(" %d",Tree[k].key);

  Inorder(Tree,Tree[k].right);

}

Measured memory_bytes: 6296
import sys
from functools import lru_cache
def input(): return sys.stdin.readline().strip()


def main():
    N, X = map(int, input().split())

    @lru_cache(maxsize=None)
    def func(n, x):
        if n == 0:
            if x <= 0: return 0
            if x >= 1: return 1
        if x >= 2 ** (n + 2) - 3:
            return func(n - 1, x) * 2 + 1
        if x >= 2 ** (n + 1) - 1:
            return func(n - 1, x) + 1 + func(n - 1, x - (2 ** (n + 1) - 1))
        if x >= 1:
            return func(n - 1, x - 1)
        return 0

    print(func(N, X))




if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
//2017-11-4
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)

#define N (300+5)

int a[N][N];

int main(){
	int n;

	scanf("%d", &n);
	For(i, 1, n) For(j, 1, n) scanf("%d", &a[i][j]);
	
	bool flag;
	LL ans = 0;

	For(i, 1, n) For(j, i+1, n){
		if(i == j) continue;

		flag = true;
		For(k, 1, n) if(k != i && k != j){
			if(a[i][k] + a[k][j] < a[i][j]){puts("-1"); return 0;}
			else if(a[i][k] + a[k][j] == a[i][j]) flag = false;
		}
		ans += flag * a[i][j];
	}

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

	return 0;
}

Measured memory_bytes: 1148
#include <stdio.h>

int main(void){
    int n,i;
    scanf("%d",&n);
    for(i=3;i<=n;i++){
        if(i%3==0||i%10==3||i/10==3||i/100==3||i/1000==3||(i%100)/10==3||(i%1000)/10==3||(i%1000)/100==3)
            printf(" %d",i);
    }
    printf("\n");
    return 0;
}


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

int main() {
    long long N, M;
    cin >> N >> M;
    long long sum = 0;
    for (int i = 0; i < M; i++) {
        int a;
        cin >> a;
        sum += a;
    }

    if (N - sum >= 0) {
        cout << N - sum << endl;
    }
    else {
        cout << -1 << endl;
    }
}

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

typedef long long ll;

int n;
int a[100010];

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

    while(true) {
	cin >> n;
	if(n==0) break;
	for (int i = 1; i <= n; i++) cin >> a[i];
	a[0] = a[n+1] = 4;

	int res = 0;
	n += 2;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= 3; j++) {
			int color = j;
			int sum = 0, cnt = 1;
			int l = i - 1, r = i + 1;
			while (true) {
				while (a[l] == color) l--, cnt++;
				while (a[r] == color) r++, cnt++;
				if (cnt < 4) break;
				sum += cnt;
				cnt = 0;
				if (a[l] != a[r]) break;
				color = a[l];
			}
			res = max(res, sum);
		}
	}

	cout << n - res - 2 << endl;
    }

	return 0;
}



Measured memory_bytes: 3048
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500 * i + 100 * j + 50 *k == x:
                cnt += 1
print(cnt)


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

a, b, c, d = map(int, input().split())

a_hp = (a // d) + 1 if a%d!=0 else a//d
c_hp = (c // b) + 1 if c%b!=0 else c//b

if a_hp >= c_hp:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9180
#include<iostream>
using namespace std;
int main()
{
	int n, i;
	cin >> n;
	int a[n];
	for (i = 0; i < n; i++)
		cin >> a[i];
	int p, key, x, t;
	cin >> p;
	while (p--)
	{
		int coun = 0;
		cin >> x >> t >> key;
		for (i = x; i < t; i++)
			if (a[i] == key)
				coun++;
		cout << coun << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>

int main()
{
	int n, m, l;
	std::cin >> n >> m >> l;

	int A[100][100] = { 0 };
	int B[100][100] = { 0 };
	long C[100][100] = { 0 };

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			std::cin >> A[i][j];
		}
	}

	for (int i = 0; i < m; i++) {
		for (int j = 0; j < l; j++) {
			std::cin >> B[i][j];
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			for (int k = 0; k < l; k++) {
				C[i][k] += A[i][j] * B[j][k];
			}
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l-1; j++) {
			std::cout << C[i][j] << " ";
		}
		std::cout << C[i][l - 1] << std::endl;
	}
}

Measured memory_bytes: 1324
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <unordered_map>

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

using namespace std;

struct UnionFind
{
  vector<int> par; //par[i]が親を表す

  // コンストラクタ
  UnionFind(int n)
  {
    par = vector<int>(n);
    for (int i = 0; i < n; i++)
    {
      par[i] = i;
    }
  }

  // データxの根を求める
  int root(int x)
  {
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]); // 木構造の縮約を行っている
  }

  // xとyの親が違うとき、マージする。そのときyの根がxの根の子になる
  void merge(int x, int y)
  {
    int rootx = root(x);
    int rooty = root(y);
    if (rootx == rooty)
      return;
    par[rooty] = rootx;
  }

  // 同じグループに属しているか
  bool isSame(int x, int y)
  {
    return root(x) == root(y);
  }
};

int main()
{
  ll n, m;
  cin >> n >> m;
  ll a[100000], b[100000];
  REP(i, m)
  {
    cin >> a[i] >> b[i];
  }
  ll ans[100000] = {};
  ans[m - 1] = n * (n - 1) / 2;
  UnionFind island(n + 1);

  ll connect[100000] = {};
  for (int i = m - 1; i > -1; i--)
  {
    if (connect[island.root(a[i])] == 0)
    {
      connect[island.root(a[i])] = 1;
    }
    if (connect[island.root(b[i])] == 0)
    {
      connect[island.root(b[i])] = 1;
    }

    if (!island.isSame(a[i], b[i]))
    {
      if (i != 0)
      {
        ans[i - 1] = ans[i] - (connect[island.root(a[i])] * connect[island.root(b[i])]);
      }
      connect[island.root(a[i])] += connect[island.root(b[i])];
      connect[island.root(b[i])] = connect[island.root(a[i])];
      island.merge(a[i], b[i]);
    }
    else
    {
      ans[i - 1] = ans[i];
    }
  }

  REP(i, m)
  {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 5248
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int a,b,n;
	cin>>n>>a>>b;
	int out=0;
	while(n--){
		int t;cin>>t;
		if(!(a<=t&&t<b))out++;
	}
	cout<<out<<endl;
}








Measured memory_bytes: 256
program main
  implicit none
  integer a, b, c, d, e, k
  read(*, *) a
  read(*, *) b
  read(*, *) c
  read(*, *) d
  read(*, *) e
  read(*, *) k
  if (e-a > k) then
    write(*, '(A)') ':('
  else
    write(*, '(A)') 'Yay!'
  end if
end program main

Measured memory_bytes: 640
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim S As String = NextString()
        Dim ans As Integer = 0
        Dim pre As Char = " "c

        For Each c As Char In S
            If pre <> " "c And pre <> c Then ans += 1
            pre = c
        Next

        WriteLine(ans)
    End Sub

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function
End Module


Measured memory_bytes: 21212
def mips():
    return map(int,input().split())
def msps():
    return map(str,input().split())

import sys
A,B,C,K = mips()
ans = 0
reste = K
if A >= K:
    print(K)
    sys.exit(0)
if A < K:
    ans += A
    reste -= A
if reste <= B:
    print(ans)
    sys.exit(0)
reste -= B
if reste <= C:
    ans -= reste
    print(ans)
else:
    ans -= C
    print(ans)

Measured memory_bytes: 9232
#include <iostream>
#include <stack>
#include <map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <string.h>

using namespace std;

int N;
char S[1000000];
int c[1000000];

int main(int argc, char** argv) {
    cin >> S;
    int N = strlen(S);
    int ans = 0;
    for (int i=0; i < N; i++)
        if (S[i] == '+')
            ans++;
        else
            ans--;
    cout << ans << endl;
}

Measured memory_bytes: 2304
def main():
    odd_move = ['R', 'U', 'D']
    even_move = ['L', 'U', 'D']

    move_list = [
        odd_move, even_move
    ]

    s = input()
    count = 0
    flag = True
    for c in s:
        if not (c in move_list[count]):
            flag = False
            break
        count = (count+1) % 2

    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pi acos(-1)
#define inf 0x3f3f3f3f
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define rep(i,x,n) for(int i=x;i<n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
using namespace std;
typedef pair<int,int>P;
const int MAXN=100010;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int main()
{
	ll a, b;
	while(cin >> a >> b)
	{
		ll c = __gcd(a, b);
		cout << c << " " << a / c * b << endl;
	}
 	return 0;
}

Measured memory_bytes: 3088