akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=200005;
int a[N],b[N];
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int n=read(),k=read();
	For(i,1,n)a[i]=read();
	For(i,1,k){
		mem(b);
		int f=1;
		For(i,1,n){
			if(a[i]!=n)f=0;
			b[max(1,i-a[i])]++;
			b[min(n+1,i+a[i]+1)]--;
		}
		For(i,1,n)b[i]+=b[i-1];
		swap(a,b);
		if(f)break;
	}
	For(i,1,n)wri(a[i]);
}


Measured memory_bytes: 5180
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt();
		int dif=b-a;

		int towerA=dif*(dif-1)/2;
		System.out.println(towerA-a);
	}
}

Measured memory_bytes: 21844
N, M = map(int, input().split())
maxL = 0
minR = N-1
LR = [0, N-1]
for i in range(M):
  LR = [int(i)-1 for i in input().split()]
  maxL = max(maxL, LR[0])
  minR = min(minR, LR[1])
if minR-maxL>=0:
  print(minR-maxL+1)
else:
  print(0)


Measured memory_bytes: 69688
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::*;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    s:Chars,
    t:Chars
    }

    let mut cnt = 0;
    for i in 0..s.len() {
      if s[i] != t[i] {
        cnt += 1;
      }
    }

     println!("{}", cnt);
}


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

int main() {
    int N, K; cin >> N >> K;
    priority_queue<ll> H;

    rep(i,N){
        ll h;
        cin >> h;
        H.push(h);
    }

    rep(i,K){
        if(H.empty())break;
        H.pop();
    }

    ll ans = 0;
    while(!H.empty()){
        ll a;
        a = H.top();
        H.pop();
        ans += a;
    }

    cout << ans << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int get(int n) {
    if (n == 2) {
        return 0;
    } else if (n == 4 || n == 6 || n == 9 || n == 11) {
        return 1;
    } else {
        return 2;
    }
}

int main() {
    string S;
    cin >> S;
    set<char> s;
    for (auto c : S) {
        if (s.count(c)) {
            cout << "no\n";
            return 0;
        } else {
            s.insert(c);
        }
    }
    cout << "yes\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;

int main(){
  long long n,k;cin>>n>>k;
  long long  p=n;
  for(int i=0;i<n;i++){
    if(pow(2,i-1)<=k&&pow(2,i)>k){
      p=i;
    }
  }
  cout<<pow(2,p)+k*(n-p)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

struct node{
    ll cost;
    ll where;
    ll done;
    
    bool operator < (const node &n) const {
        if(n.cost<this->cost){return true;}
        return false;
    }
    
    bool operator == (const node &n) const {
        if(n.cost==cost){return true;}
        return false;
    }
};

node err={MOD,-1,-1};

int main(){
    ll v,e;
    cin>>v>>e;
    vector<vector<pll>> E(v);
    vector<pll> S;
    for(int i=0;i<e;i++){
        ll s,t,d;
        cin>>s>>t>>d;
        E[s].push_back({t,d});
        if(t==0){S.push_back({s,d});}
    }
    vector<vector<node>> dp(v,vector<node>((1<<v),err));
    priority_queue<node> q;
    dp[0][0]=(node){0,0,1};
    q.push((node){0,0,1});
    while(!q.empty()){
        node N=q.top(); q.pop();
        if(N<dp[N.where][N.done]){continue;}
        for(int i=0;i<E[N.where].size();i++){
            pll &e=E[N.where][i];
            if((N.done>>e.F)&1){continue;}
            node New={N.cost+e.S,e.F,N.done|((ll)1<<e.F)};
            if(dp[New.where][New.done]<New){dp[New.where][New.done]=New; q.push(New);}
        }
    }
    ll ad=1; ad<<=v; ad--;
    ll mi=MOD;
    for(int i=0;i<S.size();i++){
        pll &e=S[i];
        if(dp[e.F][ad]==err){continue;}
        mi=min(mi,dp[e.F][ad].cost+e.S);
    }
    if(mi==MOD){cout<<-1<<endl;}
    else{cout<<mi<<endl;}
    
    return 0;
}



Measured memory_bytes: 17596
import math
shuu = input()
num = int(shuu)
ganpon = 100000
i = 1
while i <= num:
    ganpon *= 1.05
    ganpon /= 1000
    ganpon = math.ceil(ganpon)
    ganpon *= 1000
    i += 1
    pass
#ganpon /= 1000
#ganpon = math.ceil(ganpon)
#ganpon *= 100000
print(ganpon)

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define LOOP(i, N) for (int i = 1; i <= (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define RLOOP(i, N) for (int i =(int)N; i > 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define pb push_back

typedef long long ll;

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
//cout<<"Yes"<<endl;
//cout<<"No"<<endl;

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0){
    cout<<1<<endl;
  }else if(b==0){
    cout<<2<<endl;
  }else if(c==0){
    cout<<3<<endl;
  }else if(d==0){
    cout<<4<<endl;
  }else{
    cout<<5<<endl;
  }
  return 0;
}

Measured memory_bytes: 3628
//~#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//~#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//~#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) begin(a),end(a)
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

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

const int mod=998244353;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}

void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

template<typename T>
vector<pair<T,int>> getvec(int n){
  vector<pair<T,int>>a(n);
  for(int i=0;i<a.size();i++){
    cin>>a[i].F;
    a[i].S=i;
  }
  return a;
}

void clr(auto &a,int n){
  a.clear();
  a.resize(n);
}

void unq(auto &a){
  sort(all(a));
  a.resize(unique(all(a))-a.begin());
}

const int N=300005;	

void solve(){
	int k,n;
	cin>>k>>n;
	vi a(n);
	cin>>a;
	ll ans=a[n-1]-a[0];
	int sum=a[n-1]-a[0],sum2=0;
	for(int i=1;i<n;i++){
		sum-=(a[i]-a[i-1]);
		if(i>1){
			sum2+=a[(i-1+n)%n]-a[(i-2+n)%n];
		}
		else{
			sum2+=k-a[n-1]+a[0];
		}
		ans=min(ans,sum+sum2);
		debug(sum,sum2);
	}
	cout<<ans;
}


signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //~cin>>tc;
  for(int _=0;_<tc;_++){
    // cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}
 


Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

const ll M = 1e9+7;
const ll INF = 1e9+7;

ll h, w;
ll a[100][100];
bool dp[100][100][7000];

int main() {
  cin >> h >> w;

  for (ll i = 0; i < h; ++i) {
    for (ll j = 0; j < w; ++j) {
      cin >> a[i][j];
    }
  }
  
  for (ll i = 0; i < h; ++i) {
    for (ll j = 0; j < w; ++j) {
      ll b;
      cin >> b;
      a[i][j] = abs(a[i][j]-b);
      if (i == 0 and j == 0) {
        dp[i][j][a[i][j]] = true;
      }
      if (i != 0) {
        for (ll k = 0; k < 7000; ++k) {
          if (dp[i-1][j][k]) {
            if (k+a[i][j] < 7000) dp[i][j][k+a[i][j]] = true;
            dp[i][j][abs(k-a[i][j])] = true;
          }
        }
      }
      if (j != 0) {
        for (ll k = 0; k < 7000; ++k) {
          if (dp[i][j-1][k]) {
            if (k+a[i][j] < 7000) dp[i][j][k+a[i][j]] = true;
            dp[i][j][abs(k-a[i][j])] = true;
          }
        }
      }
    }
  }
  
  for (ll k = 0; k < 7000; ++k) {
    if (dp[h-1][w-1][k]) {
      cout << k << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 55040
using System;
using System.Linq;

class F2
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var n2 = n / 2;
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

		if (n % 2 == 0)
		{
			long M = a.Where((x, i) => i % 2 == 1).Sum(x => (long)x), t = M;
			for (int i = 0; i < n2; i++)
				M = Math.Max(M, t += a[2 * i] - a[2 * i + 1]);
			Console.WriteLine(M);
		}
		else
		{
			var dp = CreateArray(n2 + 1, 3, -1L << 60);
			dp[0, 0] = dp[0, 1] = dp[0, 2] = 0;

			for (int i = 0; i < n2; i++)
				for (int j = 0; j < 3; j++)
					for (int k = j; k < 3; k++)
						dp[i + 1, k] = Math.Max(dp[i + 1, k], dp[i, j] + a[2 * i + k]);
			Console.WriteLine(Enumerable.Range(0, 3).Max(j => dp[n2, j]));
		}
	}

	static T[,] CreateArray<T>(int l1, int l2, T v = default)
	{
		var a = new T[l1, l2];
		for (int i = 0; i < l1; i++)
			for (int j = 0; j < l2; j++)
				a[i, j] = v;
		return a;
	}
}


Measured memory_bytes: 49384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int,int>;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main() {
    int n, x = 0, ans = 0, temp = 0;
    cin >> n;
    string s;
    cin >> s;
    rep(i, n) {
        if(s[i] == 'I') temp++;
        else temp--;
        ans = max(ans, temp);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	int a[100];

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

	sort(begin(a), begin(a) + N, [](int a, int b) { return a > b; });

	int alice = 0;
	int bob = 0;
	for (int i = 0; i < N; i++)
	{
		if (i % 2 == 0)
		{
			alice += a[i];
		}
		else
		{
			bob += a[i];
		}
	}

	int ans = alice - bob;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char move[4] = {'L','R','U','D'};
    ll h,w,n,s1,s2;
    string s,t;
    cin >> h >> w >> n >> s1 >> s2 >> s >> t;
    ll out[4] = {s2,w-s2+1,s1,h-s1+1};
    bool ok = 0;
    rep(ti,2){
        rep(tj,2,4){
            ll x = 0,y = 0;
            rep(i,n){
                if (s[i] == move[ti]) x++;
                if (s[i] == move[tj]) y++;
                if (x >= out[ti]) ok = 1;
                if (y >= out[tj]) ok = 1;
                if (t[i] == move[1-ti] && x > -out[1-ti]+1) x--;
                if (t[i] == move[5-tj] && y > -out[5-tj]+1) y--;
            }
        }
    }
    if (ok) PRINT("NO");
    else PRINT("YES");
}





Measured memory_bytes: 920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
const int INF = 2e9;
const int N_MAX = 200010;
int a[N_MAX];
vector<vector<int>> tree(N_MAX);
int ans[N_MAX];
vector<pair<int,int>> update(N_MAX);
void calc(int now,int root,vector<int> &vec){
    auto itr = lower_bound(ALL(vec),a[now]);
    update[now] = (make_pair(itr-vec.begin(),*itr));
    *itr = a[now];
    if(itr-vec.begin()!=ans[root]){
        ans[now] = ans[root];
    }
    else{
        ans[now] = ans[root] + 1;
    }
    for(int i:tree[now]){
        if(i==root) continue;
        calc(i,now,vec);
    }
    auto p=update[now];
    vec[p.first]=p.second;
}
void Main(){
    int n;cin>>n;
    For(i,0,n) cin>>a[i];
    For(i,0,n-1){
        int u,v;
        cin >> u >> v;
        u--;
        v--;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }
    vector<int> vec(n,INF);
    vec[0]=a[0];
    ans[0]=1;
    for(int i:tree[0]) calc(i,0,vec);
    For(i,0,n) cout << ans[i] << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}


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

using info = array<int, 3>;

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

    int d;
    long long g;
    cin >> d >> g;
    vector<info> v;
    for (int i = 1; i <= d; ++i) {
        info a;
        a[0] = i * 100;  // score
        cin >> a[1] >> a[2]; // count, bonus
        v.push_back(a);
    }
    auto res = static_cast<int>(g / 100);
    do {
        long long g_copy = g;
        int total_count = 0;
        for (info a: v) {
            int count = ceil(g_copy * 1.0 / a[0]);
            count = min(count, a[1]);
            g_copy -= a[0] * count;
            if (count == a[1]) g_copy -= a[2];
            total_count += count;
            // a[1] -= count;
            if (g_copy <= 0 || total_count >= res) break;
        }
        res = min(res, total_count);
    } while (next_permutation(v.begin(), v.end()));

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
using namespace std;

#include <iostream>
#include <vector>
#include <cmath>

typedef long long ll;

int N, Y;

int main() {
  cin >> N >> Y;
  Y /= 1000;
  
  for (int z = 0; z <= N; z++) {
    for (int y = 0; y <= N - z; y++) {
      int x = N - y - z;
      if (10*x + 5*y + z == Y) {
        cout << x << " " << y << " " << z << endl;
        return 0;
      }
    }
  }
  
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
  
  
}

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

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    int sum=0;
    rep(i,n){
        sum^=a[i];
    }
    cout<<(sum!=0?"No":"Yes")<<endl;
    return 0;
}

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


#define M_MAX 20
#define N_MAX 50000
#define INFTY 1 << 29

int main(){
int n;
cin >> n;
int data[n];
int count=0;
for(int i=0;i<n;i++)cin >> data[i];
for(int i=1;i<n-1;i++){
int maxi=max(max(data[i-1],data[i]),data[i+1]);
int mini=min(min(data[i-1],data[i]),data[i+1]);
if(data[i]>mini && data[i]<maxi)count++;
}
cout << count;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		while(n != 0){
			int max = 0;
			int min = 0;
			int array[] = new int[n];

			for(int i = 0; i < n; i++){
				array[i] = sc.nextInt();
				if(array[i] > array[max]){
					max = i;
				}
				else if(array[min] > array[i]){
					min = i;
				}
			}
			int sum = 0;
			//calc adv.
			for(int i = 0; i < n; i++){
				if(i != max && i != min){
					sum += array[i];
				}
			}
			double adv = sum / (n - 2);
			int ans = (int)adv;
			System.out.println(ans);
			n = sc.nextInt();
		}

	}
}

Measured memory_bytes: 12000
// OURL: https://atcoder.jp/contests/abc166/tasks/abc166_c
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));  }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v);  }

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", ";  } first = false; res += to_string(x);  } res += "}"; return res;  }

string to_string(string s) { return '"' + s + '"';  }
string to_string(const char* s) { return to_string((string) s);  }
string to_string(bool b) { return (b ? "true" : "false");  }
string to_string(vector<bool>::reference b) { return to_string(bool(b));  }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";  }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res; }

void debug_out() { cerr << endl;  }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...);  }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

  int n,m;
  cin >> n >> m;
  auto hs = make_v<ll>(n);
  for (int i = 0; i < n; ++i) {
    cin >> hs[i];
  }
  auto isbad = make_v<int>(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    if (hs[a-1] == hs[b-1]) {
      isbad[a-1] = isbad[b-1] = 1;
    } else if (hs[a-1] > hs[b-1]) {
      isbad[b-1] = 1;
    } else {
      isbad[a-1] = 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (isbad[i] == 0) ans++;
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
    int n; cin >> n;
    set<int> pre_nums;
    int ans = 1;
    int num; cin >> num;
    pre_nums.insert(num);
    for (int i=1; i<n; i++) {cin >> num;
        if (*begin(pre_nums) >= num) ans++;
        pre_nums.insert(num);
    }
    cout << ans << endl;
}

Measured memory_bytes: 9600
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 10004
#define D 104
#define INF 1e9+7

using namespace std;

string k;
ll d,n,mod=1e9+7;
ll dp[N][D][2];

ll solve(ll digit,ll sum,ll smaller)
{
    if(digit == n)
        return (sum == 0) ? 1 : 0;

    if(dp[digit][sum][smaller] != -1)
        return dp[digit][sum][smaller];

    ll res = 0;

    rep(c,0,10)
    {
        if(c == k[digit]-'0')
            res = (res+solve(digit+1,(sum+c)%d,smaller))%mod;
        else if(!smaller && c > k[digit]-'0')
            continue;
        else
            res = (res+solve(digit+1,(sum+c)%d,1))%mod;
    }

 //   cout << digit << " " << sum << " "<< smaller << "   " << res << endl;

    return dp[digit][sum][smaller] = res;
}

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

    memset(dp,-1,sizeof dp);

    cin >> k >> d;
    n=k.size();

    cout << (solve(0,0,0)+mod-1)%mod;

    return 0;
}



Measured memory_bytes: 17280
N = int(input())
A = list(map(lambda x: int(x), input().split()))
B = list(map(lambda x: int(x), input().split()))

sum = 0
for i in range(N):
    if A[i] <= B[i]:
        sum += A[i]
        if A[i+1] <= B[i] - A[i]:
            sum += A[i+1]
            A[i+1] = 0
        else:
            A[i+1] -= B[i] - A[i]
            sum += B[i] - A[i]
    else:
        sum += B[i]

print(sum)

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


int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<bool>> road(h, vector<bool>(w));
    for(int i=0; i<h; i++){
        string s;
        cin >> s; 
        for(int j=0; j<w; j++){
            if (s[j] == '.'){
                road[i][j] = true;
            }
            else{
                road[i][j] = false;
            }
        }
    }

    int ans = 0;
    for (int i=0; i<h; i++){
        for (int j=0; j<w; j++){
            vector<vector<int>> cost(h, vector<int>(w, -1));
            int move[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
            queue<tuple<int, int, int>> next_go;
            if (!road[i][j]) continue;
            next_go.push(make_tuple(i, j, 0));
            while (!next_go.empty()){
                int x, y, c;
                tie(x, y, c)= next_go.front();
                next_go.pop();
                cost[x][y] = c;
                for (int k=0; k<4; k++){
                    int xx = x+move[k][0], yy = y+move[k][1];
                    if (0<=xx && xx<h && 0<=yy && yy<w){
                        if (cost[xx][yy] == -1 && road[xx][yy]){
                            cost[xx][yy] = c + 1;
                            next_go.push(make_tuple(xx, yy, c+1));
                        }
                    }
                }
                ans = max(ans, c);
            }
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

template<typename T = int>
struct min_of {
    static const T identity;
    constexpr T operator ()(T& lhs, T& rhs) const { return min<T>(lhs, rhs); }
};
template<typename T> const T min_of<T>::identity = std::numeric_limits<T>::max();
template<typename T, class F, const T& I>
struct SegmentTree {
    const F op = F();
    int n; vector<T> dat;
    void init(int n_) { n = 1; while (n < n_) n *= 2; dat.assign(n * 2, I); }
    void build(const vector<T>& v) {
        int n_ = v.size(); init(n_);
        for (int i = 0; i < n_; ++i) dat[n + i] = v[i];
        for (int i = n - 1; i; --i) dat[i] = op(dat[i << 1], dat[(i << 1) + 1]);
    }
    void update(int k, T x) { dat[k += n] = x; while (k >>= 1) dat[k] = op(dat[k << 1], dat[(k << 1) + 1]); }
    T query(int a, int b) {
        T vl = I, vr = I;
        for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) { if (l & 1) vl = op(vl, dat[l++]); if (r & 1) vr = op(dat[--r], vr); }
        return op(vl, vr);
    }
    template<class C> int find(int a, int b, C& check) { return find(a, b, check, 1, 0, n); }
private:
    template<class C> int find(int a, int b, C& check, int k, int l, int r) {
        if (!check(dat[k]) || r <= a || b <= l) return -1; if (k >= n) return k - n;
        int m = (l + r) >> 1; int vl = find(a, b, check, (k << 1) | 0, l, m);
        if (~vl) return vl; return find(a, b, check, (k << 1) | 1, m, r);
    }

    void test() {
        SegmentTree<int, min_of<int>, min_of<int>::identity> st;
        vector<int> v = { 1, 3, 5, 2, 4 };
        st.build(v);
        cout << st.query(1, 5) << endl;
        st.update(2, 6);
        cout << st.query(0, 3) << endl;
    }
};

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

    vector<int> aa(2 * N);
    rep(i, 2 * N) aa[i] = a[i % N];
    SegmentTree<int, min_of<int>, min_of<int>::identity> amin;
    amin.build(aa);

    ll ans = LINF;
    for (int d = 0; d < N; ++d) {
        ll t = x * d;
        rep(i, N) {
            t += amin.query(N + i - d, N + i + 1);
        }
        ans = min(ans, t);
    }
    write(ans);
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
double A[10000]={};
double B[10000]={};

int main(){
    int N;
    double res=0;
    double sum=1;
    cin >> N;
    rep(i,N){
        cin >> A[i];
        sum *= A[i];
        B[i] = 1;
    }
    rep(i,N){
        rep(j,N){
            if(j==i){
                continue;
            }
            B[i] *= A[j];
        }
        res += B[i];
    }
    cout << std::fixed;
    //cout << sum <<" "<<res<<endl;
    cout << std::setprecision(7) << (sum / res) << endl;
}

Measured memory_bytes: 256
s = input()
year = int(s[:4])
month = int(s[5:7])
day = int(s[8:10])
if year < 2019:
  print("Heisei")
  exit()
elif year > 2019:
  print("TBD")
  exit()
if month < 4:
  print("Heisei")
  exit()
elif month > 4:
  print("TBD")
  exit()
print("Heisei")

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    if(n < 3){
        cout << 1 << endl;
        return 0;
    }
    int ans = 1;
    int d = 0;
    for(int i=0;i<n-1;i++){
        if(a[i] == a[i+1]) continue;
        if(d == 0){
            if(a[i] > a[i+1]){
                d = -1;
            }else{
                d = 1;
            }
        }else if(d == 1){
            if(a[i] > a[i+1]){
                d = 0;
                ans++;
            }
        }else{
            if(a[i] < a[i+1]){
                d = 0;
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
//int dx[]={+1,-1,+0,+0};///Four Directions
//int dy[]={+0,+0,+1,-1};///Four directions
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions

//int mark[10007];vi prime;void seive(){for(int i=2;i<10000;i++){if(mark[i]==0){prime.pb(i);for(int j=i+i;j<=10000;j+=i)mark[j]=1;}}}

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

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

   ll n,k; cin>>n>>k;
   ll rim=n%k;
   if(rim==0){
    cout<<rim<<endl;
    End;
   }

   ll a=abs(rim-k);
   ll b=abs(a-k);
   cout<<min(a,b)<<endl;
   End;
}


Measured memory_bytes: 256
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
	int n;
	cin>>n;
	int p[n];
	for(auto &x:p)
		cin>>x;
	int des[n];
	for(int i=0;i<n;i++)
		des[i]=i+1;
	int c=0;
	for(int i=0;i<n;i++)
	{
		if(p[i]!=des[i])
		{
c++;
		}
	}
	if(c>2)
		cout<<"NO";
	else
		cout<<"YES";
}
int main()
{
//code
	
fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define c cin
#define o cout
#define el endl
using namespace std;

int main(){
	int mount[10];
	for(int i=0;i<10;i++) c>>mount[i];
	sort(mount, mount+10);
	for(int i=9;i>6;i--) o<<mount[i]<<el;
}

Measured memory_bytes: 1176
N = int(input())
A = [0] * N
for i in range(N):
    A[i] = int(input())
A.sort()

#print(A)

check = [0]
for i in range(1, N):
    if A[i] != A[i-1]:
        check.append(i)
check.append(N)

l = []
for i in range(1, len(check)):
    tmp = check[i] - check[i-1]
    l.append(tmp)

#print(l)

ans = 0
for i in range(len(l)):
    if l[i] % 2 == 1:
        ans += 1

print(ans)

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

int main(){
	int n, m, s = 1;
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		s = s * 2;
	}
	cout << (1900 * m * s) + (100 * (n - m) * s) << endl;
	return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
A=[0]*N
B=[0]*M
for i in range(N):
  A[i]=str(input())
for i in range(M):
  B[i]=str(input())
k=N//M + N%M

def macthing(y,x):
  flag=0
  for p in range(M):
    if A[y+p][x:x+M]!=B[p]:
      flag=1
      break
  if flag==0:
    return True
  else:
    return False

for i in range(k):
  for j in range(k):
    if macthing(i,j):
      print('Yes')
      exit()
print('No')


Measured memory_bytes: 9184
#include<cstdio>
//#include<Hatsune_Miku>
using namespace std;
char s[10],t[10];
int main(){
    scanf("%s%s",s,t);
    if(s[0]==t[2] && s[1]==t[1] && s[2]==t[0])puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define reps(i, s, n) for(int i = (s); i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, s, n) for(int i = (n) - 1; i >= (s); i--)
#define INF ~(1 << 31)
#define INFL ~(1LL << 63)

int main()
{
    int x;
    cin >> x;
    if(x == 0){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3628
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int ans = 0;
		int count = 1;
		boolean flg = false;
		for(int i = 0;i < n;i++){
			int num = saori.saori_hayami();
			if(num == count){
				count++;
			} else {
				ans++;
			}
			if(num == 1){
				flg = true;
			}
		}
		if(flg){
			System.out.println(ans);
		} else {
			System.out.println(-1);
		}

		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22572
#include<stdio.h>
#define N 100000

int partition( int a[] , int p , int r ){
  int i = -1;
  int j;
  int key;
  int count = a[r];

  for( j = 0 ; j < r ; j++ ){
    if(count>=a[j]){
      i++;
      key = a[i];
      a[i] = a[j];
      a[j] =  key;
    }
  }
  key = a[r];
  a[r] = a[i+1];
  a[i+1] = key;
  return i+1;
}

int main(){
  int i,n,count=0;
  int a[N];

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);

  count = partition(a,0,n-1);

  for(i=0;i<n-1;i++){
    if(count==i) printf("[%d] ",a[i]);
    else printf("%d ",a[i]);
  }

  printf("%d\n",a[n-1]);

  return 0;
}

Measured memory_bytes: 992
#include <algorithm>
#include <vector>
#include <iostream>
#include <iomanip>
#include <map>
#include <queue>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <bitset>
#include <cstdint>
#include <unordered_map>
using namespace std;

using i64 = int64_t;
using ui64 = uint64_t;
using d64 = long double;

constexpr int MOD = 1000000000 + 7;
constexpr int INF = (1 << 30);
constexpr i64 INF64 = INT64_MAX;
const long double PI = 3.141592653589793;

template <typename T>
void print(const vector<T> vec) {
  for (auto &e : vec) {
    cout << e << " ";
  }
  cout << endl;
}

int next_combination(int sub) {
  int x = sub & -sub, y = sub + x;
  return (((sub & ~y) / x) >> 1) | y;
}

template <typename T>
vector<T> sieve(const T& n) {
  vector<bool> is_prime(n + 1, true);
  vector<i64> prime;
  is_prime[0] = is_prime[1] = false;
  for (T i = 2; i <= n; i++) {
    if (is_prime[i]) {
      prime.emplace_back(i);
      for (T j = 2 * i; j <= n; j += i) is_prime[j] = false;
    }
  }
  return prime;
}

template <typename T>
vector<T> dijkstra(vector<vector<pair<int, T>>> &G, int s, T INF) {
  vector<T> dist(G.size(), INF);

  using P = pair<int, T>;
  priority_queue<P, vector<P>, greater<P>> que;
  dist[s] = 0;
  que.emplace(s, dist[s]);
  while(!que.empty()) {
    int idx;
    T cost;
    tie(idx, cost) = que.top(); que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : G[idx]) {
      T next_cost = cost + e.second;
      if(dist[e.first] > next_cost) {
        dist[e.first] = next_cost;
        que.emplace(e.first, dist[e.first]);
      }
    }
  }
  return dist;
}


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

  int v, e, r;
  cin >> v >> e >> r;
  vector<vector<pair<int, i64>>> G(v);
  for(int i=0; i<e; i++) {
    int s, t, d; cin >> s >> t >> d;
    G[s].emplace_back(t, d);
  }

  vector<i64> dist = dijkstra(G, r, INF64);
  for(auto &e : dist) {
    if(e == INF64) cout << "INF" << '\n';
    else cout << e << '\n';
  }
}


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

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long MOD=1e9+7;
const long long LINF=1e18;
const int INF=0x3f3f3f3f;
const int MAXN=100050;

void solve(int T){
	ll a,b,c,d;
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	ll ans=max(a*c,max(b*d,max(a*d,b*c)));
	printf("%lld\n",ans);
}
signed main(){
	int t=1;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	//scanf("%d",&t); 
	for(int i=1;i<=t;i++){
		solve(i);
	}
}

Measured memory_bytes: 3824
fun main(args: Array<String>) { 
    when (readLine()!!) {
        "MON" -> {
            println(6)
        }
        "TUE" -> {
            println(5)
        }
        "WED" -> {
            println(4)
        }
        "THU" -> {
            println(3)
        }
        "FRI" -> {
            println(2)
        }
        "SAT" -> {
            println(1)
        }
        "SUN" -> {
            println(7)
        }
    }
}

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

int main() {
  string S;
  int N, K;
  cin >> N >> K;
  cin >> S;
  if (S.at(K - 1) == 'A') {
    S.at(K - 1) = 'a';
  }
  else if (S.at(K - 1) == 'B') {
    S.at(K - 1) = 'b';
  }
  else {
    S.at(K - 1) = 'c';
  }
  cout << S << endl;
  
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n, k;
  cin >> n >> k;
  int Q;
  cin >> Q;
  vector<int> a(n, k - Q);
  while (Q--) {
    int x;
    cin >> x;
    x--;
    a[x]++;
  }
  rep(i, n) cout << (a[i] > 0 ? "Yes" : "No") << endl;
}


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

ll getpair(ll in){
    if(in <= 0) return 0;
    else return (in * (in - 1)) / 2;
}

int main(){
    int N;
    cin >> N;
    vector<ll> A(N); //こっちは0オリジン
    vector<ll> pcs(N + 1, 0); //こっちは1オリジン
    rep(i,N){
        int x;
        cin >> x;
        pcs.at(x)++;
        A.at(i) = x;
    }

    //答えの配列2つ生成
    vector<ll> sum(N + 1,0);
    vector<ll> pairpcs_d(N + 1,0);
    for(int i = 1; i <= N; i++) {
        sum.at(i) = sum.at(i - 1) + getpair(pcs.at(i)); //累積和配列
        pairpcs_d.at(i) = getpair(pcs.at(i) - 1); //1つ減らしたペアの配列
    }

    rep(i,N){ //0オリジン
        ll y = A.at(i); //yを除くので、sum(n)-sum(y)+sum(y-1) + pcs_d(y)を出力
        cout << sum.at(N) + sum.at(y - 1) - sum.at(y) + pairpcs_d.at(y) << endl;
    }
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
template<typename T>
T gcd(T x, T y){
    if ((x==1)||(y==1)) return 1;
    if (x>y) {
        if (x%y==0) {
            return y;
        }else{
            return gcd(y, x%y);
        }
    }else{
        if (y%x==0) {
            return x;
        }else{
            return gcd(x, y%x);
        }
    }
}

ll goch(ll a){
    for (ll i = 0; i*i*i*i*i <= a; i++) {
        if (i*i*i*i*i == a) {
            return i;
        }
    }
    return -1;
}

int main() {
    ll koeru;
    IN(ll, x);
    for (ll i = 0; i*i*i*i*i<=(x+1)/2; i++) {
        koeru = i;
        ll aja = x-i*i*i*i*i;
        ll hoge = goch(aja);
        if (hoge != -1) {
            cout << i << " " << -1*hoge << endl;
            return 0;
        }
    }
    while (true) {
        koeru++;
        ll aja = goch(koeru*koeru*koeru*koeru*koeru-x);
        if (aja!=-1) {
            cout << koeru <<  " " << aja << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3636