akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	ll x;
	cin>>x;
	ll l = 0;
	ll r = 1e10;
	while(r-l>1){
		ll mid = (r+l)/2;
		if(mid*(mid+1)/2>=x){
			r = mid;
		}
		else{
			l = mid;
		}
	}
	cout<<r<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = 100005;
int N, M,t;
ll ans;
priority_queue<double>pq;
int A[MAX_N];
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> M;
	for (int i = 0; i < N; i++)
	{
		cin >> t;
		pq.push(t);
	}
	for (int i = 0; i < M; i++)
	{
		pq.push(pq.top() / 2);
		pq.pop();
	}
	for (int i = 0; i < N; i++)
	{
		ans += (int)pq.top();
		pq.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N, prev_max, ret;
  ret = 1;
  cin >> N;

  cin >> prev_max;
  for (auto i = 0; i < N - 1; i++) {
    ll x;
    cin >> x;
    if (prev_max <= x) {
      ret++;
    }
    prev_max = max(prev_max, x);
  }

  cout << ret << endl;

  return 0;
}


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

int main(void){
    ll a, b;
    cin >> a >> b;

    if(a <= b){
        cout << a << endl;
    }else{
        cout << a - 1 << endl;
    }
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(a) a.begin(), a.end()
#define ll long long
#define mod 1000000007

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  int sum = 1;
  int cnt = 0;
  while (sum < b) {
    sum += (a - 1);
    ++cnt;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
#define N 4005
#define INF 0x3f3f3f3f
#define MOD 924844033
int n,k;
bool vis[N][2],ed[N];
int tot;
int d[N][N][2],f[N],fac[N];
int rd()
{
	int f=1,x=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1; c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48); c=getchar();}
	return f*x;
}
int main()
{
	n=rd(),k=rd();
	for(int i=1;i<=n;i++)
		for(int j=0;j<=1;j++)
			if(!vis[i][j])
			{
				int len=0;
				for(int x=i,y=j;x<=n;x+=k,y^=1)
				{
					vis[x][y]=1;
					len++;
				}
				tot+=len;
				ed[tot]=1;
			 }
	ed[0]=1;
	d[0][0][0]=1;
	for(int i=0;i<2*n;i++)
		for(int j=0;j<=n;j++)
		{
			d[i+1][j][0]=(d[i][j][0]+d[i][j][1])%MOD;
			if(!ed[i])
				d[i+1][j+1][1]=d[i][j][0];
		}
	for(int i=0;i<=n;i++)
		f[i]=(d[2*n][i][0]+d[2*n][i][1])%MOD;
	fac[0]=1;
    for(int i=1;i<=n;i++)
        fac[i]=1ll*fac[i-1]*i%MOD;
    int ans=0;
    for(int i=0,j=1;i<=n;i++,j=-j)
        ans=((1ll*ans+1ll*j*fac[n-i]*f[i]%MOD)%MOD+MOD)%MOD;
    printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 124544
for i in range(input()):
    y,m,d=map(int,raw_input().split())
    s=sum(200 if i%3==0 else 195 for i in range(y+1,1000))
    t=0
    for i in range(m,11):
        if y%3!=0:
            t+=20 if i%2==1 else 19
        else:
            t+=20
    print s+t-d+1

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

int main() {
	int a, b;
	cin >> a >> b;
	
	if (a > b) {
		for (int i = 0; i < a; i++) {
			cout << b;
		}
	}else {
		for (int i = 0; i < b; i++) {
			cout << a;
		}
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);



int main(){
    FIN;
    ll n,d;
    cin >> n >> d;
    d = d*d;

    ll ans = 0;
    for(ll i=0;i<n;i++){
        ll x,y;
        cin >> x >> y;
        if(x*x+y*y <= d) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3600
using System;

class Program
{
    static void Main(string[] args)
    {
        var nm = Console.ReadLine().Split(' ');
        var n = int.Parse(nm[0]);
        var m = int.Parse(nm[1]);

        var d = new int[m];
        for (int i = 0; i < n; i++)
        {
            var s = Console.ReadLine().Split(' ');
            for (int j = 1; j < s.Length; j++)
            {
                d[int.Parse(s[j]) - 1]++;
            }
        }

        var ans = 0;
        for (int i = 0; i < d.Length; i++)
        {
            if (d[i] == n) ans++;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>
#include<iomanip>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const llong MOD = 1000000007;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
int main() {
	int n, m;
	cin >> n >> m;
	int ans = n * (n - 1) / 2 + m * (m - 1) / 2;
	cout << ans << endl;
	return 0;
}


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


int main()
{ 
 string s,t;
 cin>>s>>t;
 
 int n=s.length();
 int m=t.length();
 if(n+1!=m)
  {
      cout<<"No";
      return 0;
  }
  else
  { string x="";
      for(int i=0;i<n;i++)
       x+=t[i];

      if(s==x)
       cout<<"Yes";
       else 
       cout<<"No";        
 }


  
return 0;
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main(){
    int N;
    int A, B;
    int c1 = 0, c2 = 0, c3 = 0;
    int P[100];
    cin >> N >> A >> B;
    for(int i = 0; i < N; i++){
        cin >> P[i];
        if(P[i] <= A) c1++;
        else if(P[i] <= B) c2++;
        else c3++;
    }
    cout << min(c1, min(c2, c3)) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
long long mod=998244353;
struct dijkstra{
	struct edge{int to;long long cost;};
	typedef pair<long long,long long> P;
	vector<vector<edge>> g;
	vector<long long> d,sub;
	priority_queue<P,vector<P>,greater<P>> que;
	dijkstra(int n):g(n),d(n,1e18+7),sub(n,-1){}
	void add_edge(int from,int to,long long cost){
		g[from].push_back({to,cost});
	}
	vector<long long> dist(int s){
		d[s]=0;
		que.push({0,s});
		while(!que.empty()){
			P p=que.top();
			que.pop();
			int v=p.second;
			if(d[v]<p.first){
				continue;
			}else{
				for(edge& e:g[v]){
					if(d[e.to]>d[v]+e.cost){
						d[e.to]=d[v]+e.cost;
						sub[e.to]=v;
						que.push({d[e.to],e.to});
					}
				}
			}
		}
		return d;
	}
};
int main(){
	int h,w;
	int sx,sy;
	int gx,gy;
	char m[1000][1000];
	bool used[1000][1000]={};
	cin>>h>>w;
	cin>>sx>>sy>>gx>>gy;
	sx--;sy--;
	gx--;gy--;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>m[i][j];
		}
	}
	dijkstra di(h*w);
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(m[i][j]=='#'){
				continue;
			}
			used[i][j]=1;
			for(int a=-2;a<=2;a++){
				for(int b=-2;b<=2;b++){
					if(a==0&&b==0){
						continue;
					}
					if(0<=i+a&&i+a<h&&0<=j+b&&j+b<w&&m[i+a][j+b]=='.'){
						if(!used[i+a][j+b]){
							di.add_edge(i*w+j,(i+a)*w+(j+b),(abs(a)+abs(b)<=1?1:2000000));
							di.add_edge((i+a)*w+(j+b),i*w+j,(abs(a)+abs(b)<=1?1:2000000));
						}
					}
				}
			}
		}
	}
	vector<long long> ans=di.dist(sx*w+sy);
	cout<<(ans[gx*w+gy]==1e18+7?-1:ans[gx*w+gy]/2000000)<<endl;
	return 0;
}


Measured memory_bytes: 183520
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, n;
	cin >> x >> n;
	vector<int> p(n);
	rep(i, n) cin >> p[i];
	sort(all(p));
	int num1 = x, num2 = x;
	while (1) {
		if (!binary_search(all(p), num1)) {
			cout << num1 << endl;
			return 0;
		}
		if (!binary_search(all(p), num2)) {
			cout << num2 << endl;
			return 0;
		}
		num1--; num2++;
	}
	return 0;
}


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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	map<string, int> mp;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	int mx = 0;
	for (const auto &m : mp) {
		mx = max(mx, m.second);
	}
	for (const auto &m : mp) {
		if (m.second == mx) {
			cout << m.first << endl;
		}
	}
}

Measured memory_bytes: 23808
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
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;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N;
    cin >> N;
    
    vector<string> S;
    map<string, ll> cnt;
    
    rep(i, N){
        string inp; cin>> inp;
        S.pb(inp);
        cnt[inp] ++;
    }
    
    rmsame(S);
    
    ll max_num = 1;
    rep(i, S.size()){
        max_num = max(max_num, cnt[S[i]]);
    }
    
    vector<string> ans;
    
    rep(i, S.size()){
        if(cnt[S[i]] == max_num){
            ans.pb(S[i]);
        }
    }

    sort(all(ans));
    cerr << "---------" << endl;
    rep(i, ans.size()){
        cout << ans[i] << endl;
    }
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 31404
#include <stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b)
    {
        d=a; a=b; b=d;
    }
    if(b>c)
    {
        d=b; b=c; c=d;
        if(a>b)
        {
            d=a; a=b; b=d;
        }
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}



Measured memory_bytes: 2112
import java.util.Scanner;
import java.lang.Math;

public class Main {
  public static void draw(int a, int b)
  {
    for(int j=0; j<b; j++) System.out.print("#");
    System.out.println();
    for(int i=1; i<a-1; i++)
    {
      System.out.print("#");
      for (int j = 1; j < b-1; j++) {
        System.out.print(".");
      }
      System.out.println("#");
    }
    for(int j=0; j<b; j++) System.out.print("#");
    System.out.println();
  }
  public static void main(String[] args)
  {
    Scanner scan = new Scanner(System.in);
    while(true)
    {
      int a = scan.nextInt();
      int b = scan.nextInt();
      if(a ==0 && b == 0) break;
      draw(a,b);
      System.out.println();
    }
    scan.close();
  }
}



Measured memory_bytes: 37436
#include <iostream>
using namespace std;
int main(){
int x,y;
cin >> x>>y;
if (x==2&&y==2) cout << "Yes"<<endl;
else if ((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12)) cout << "Yes"<<endl;
else if ((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)) cout <<"Yes"<<endl;
else cout << "No"<<endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long mod2019(int l, int r)
{
    long long ans = 2019;

    for(long long i = l; i < r; ++i)
        for(long long j = i + 1; j <= r; ++j) {
            ans = min(ans, (i * j) % 2019);
            if(!ans) return ans;
        }

    return ans;
}

int main()
{
    int l, r;
    cin >> l >> r;

    cout << mod2019(l, r) << '\n';
}


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

using namespace std;

#define int long long

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define VDEL(v, n) v.erase(v.begin() + (n))
#define ALL(v) v.begin(), v.end()
#define INTMAX 2147483647
#define INF 200000000
#define STOI(str) atoi(str.c_str())
#define ITOS(num) to_string(num)
#define NPT(begin, end) next_permutation(begin, end)
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<vector<int>> VII;

signed main()
{
    while(true)
    {
        int n,k;
        cin >> n >> k;
        if(n == 0 && k == 0) break;
        VI vi;
        REP(i, n)
        {
            int a;
            cin >> a;
            vi.push_back(a);
        }
        sort(ALL(vi));
        set<int> ss;
        do
        {
            int sum = 0;
            REP(i, k)
            {
                int r = vi[i];
                if(r >= 10) sum = sum * 100 + r;
                else sum = sum * 10 + r;
            }
            ss.insert(sum);
        }
        while(next_permutation(ALL(vi)));
        cout << ss.size() << endl;
    }
    return 0;
}



Measured memory_bytes: 3212
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define rep(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

int N;
double p[3000];
double dp[3000][3000];

int main(void){
    cin >> N;
    rep(i,N) scanf("%lf",&p[i+1]);

    // i番目まででj枚が表向き
    dp[0][0] = 1;
    dp[1][1] = p[1];
    dp[1][0] = 1 - p[1];
    for(int i=1;i<=N;i++) for(int j=0;j<=i;j++){
        if (j == 0) dp[i][j] = dp[i-1][j] * (1 - p[i]);
        else dp[i][j] = dp[i-1][j] * (1 - p[i]) + dp[i-1][j-1] * p[i];
    }
    double c = 0;
    for(int i=N/2+1;i<=N;i++) c += dp[N][i];
    printf("%.12f\n", c);

    return 0;
}



Measured memory_bytes: 68864
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll x, y;
    cin >> x >> y;
    ll ans = 0;
    while (x <= y)
    {
        x *= 2;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int):
    print(N//3)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/),
    cid = 0;

// number一個取得
// eslint-disable-next-line no-unused-vars
const next = () => +cin[cid++];

// 文字列一個取得
// eslint-disable-next-line no-unused-vars
const nextstr = () => cin[cid++];

// BigInteger一個取得
// eslint-disable-next-line no-unused-vars
const nextbig = () => BigInt(cin[cid++]);

// 長さnの配列として取得。aは文字列フラグ
// eslint-disable-next-line no-unused-vars
const nexts = (n, a) =>
    a ? cin.slice(cid, (cid += n)) : cin.slice(cid, (cid += n)).map((a) => +a);

// w個ずつを組にして長さhの配列。aは文字列フラグ。
// eslint-disable-next-line no-unused-vars
const nextm = (h, w, a) => {
    var r = [],
        i = 0;
    if (a) for (; i < h; i++) r.push(cin.slice(cid, (cid += w)));
    else for (; i < h; i++) r.push(cin.slice(cid, (cid += w)).map((a) => +a));
    return r;
};
// 多次元配列。v,a1,a2,a3 なら、3次元。[[値vで長さa3の配列]をa2個並べた配列]をa1個並べた配列。
// eslint-disable-next-line no-unused-vars
const xArray = (...args) => {
    var a = args,
        l = a.length,
        r = "Array(a[" + --l + "]).fill().map(x=>{return " + a[0] + ";})";
    while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")";
    return eval(r);
};
main();

function main() {
    let S = nextstr();
    let Q = next();
    let hanten = false;
    let mae = [];
    let ato = [];
    for (let i = 0; i < Q; i++) {
        let type = next();
        //console.log("type:", type);
        if (type == 1) {
            hanten = !hanten;
        } else {
            let F = next();
            //console.log("F:", F);
            if ((F == 1 && !hanten) || (F == 2 && hanten)) {
                mae.push(nextstr());
            } else {
                ato.push(nextstr());
            }
        }
    }
    let ans = "";
    if (!hanten) {
        ans = mae.reverse().join("") + S + ato.join("");
    } else {
        ans =
            ato.reverse().join("") +
            S.split("").reverse().join("") +
            mae.join("");
    }
    console.log(ans);
    return;
}


Measured memory_bytes: 65472
#include<stdio.h>
    int main()
    {
        int a,b,c;
        char s[101];
        // 整数の入力
        scanf("%d", &a);
        scanf("%d", &b);
      	b=b-1;
        // 文字列の入力
        scanf("%s",s);
        if(s[b]=='A'){
          s[b]='a';     
        }else if(s[b]=='B'){
          s[b]='b';
        }else{
          s[b]='c';
        }
        // 出力
        printf("%s",s);
        return 0;
    }

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main(){
    int N;
    cin >> N;
    cout << (N + 1) / 2 << endl;
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b and b==c and (a+b+c)%2 == 0) {
        cout << -1 << endl;
        exit(0);
    }
    int cnt = 0;
    int na, nb, nc;
    while (true){
        if (a%2 == 1 or b%2 == 1 or c%2 == 1){
            break;
        }
        na = (b+c)/2;
        nb = (c+a)/2;
        nc = (b+a)/2;
        a = na;b = nb;c = nc;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3600
#中身の数
n = int(input())
#リスト
a = list(map(int,input().split()))
#合計
p = 0
#前が使った土
q = 0

for i in range(n-1):
  #前の人との差
  e = a[i+1]-a[i]
  if e > 0:
    if e > q:
      q = 0
    else:
      q = q-e
  else:
    q = q-e
  p += q
  
print(p)

Measured memory_bytes: 32124
fun main(args: Array<String>) {
    val s = StringBuilder(readLine()!!)
    while (s.isNotEmpty()) {
        if (s.endsWith("dream")) {
            s.delete(s.length - 5, s.length)
        } else if (s.endsWith("dreamer")) {
            s.delete(s.length - 7, s.length)
        } else if (s.endsWith("erase")) {
            s.delete(s.length - 5, s.length)
        } else if (s.endsWith("eraser")) {
            s.delete(s.length - 6, s.length)
        } else {
            println("NO")
            return
        }
    }
    println("YES")
}


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



int main(){
    ll N ,M ,sum;
    cin >> N;
    vector<ll> num(N,0);
    for(int i = 0; i < N; i++) cin >> num[i];
    cin >> M;
    vector<ll> P(M,0);
    vector<ll> X(M,0);
    for(int i = 0; i < M; i++) cin >> P[i] >> X[i];

    sum = accumulate(num.begin(), num.end(),0);
    ll mem_sum;
    mem_sum = sum;

    for(int i = 0; i < M; i ++){
        sum -= num[P[i] - 1];
        sum += X[i];
        cout << sum << endl;
        sum = mem_sum;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int l = a + b;
    int r = c + d;
    if (l > r)
    {
        cout << "Left" << endl;
    }
    else if (l == r)
    {
        cout << "Balanced" << endl;
    }
    else
    {
        cout << "Right" << endl;
    }
}

Measured memory_bytes: 256
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	q := getNextInt(scanner)
	aa := make([][]int, n)
	for i := 0; i < q; i++ {
		s := getNextInt(scanner)
		switch s {
		case 0:
			t := getNextInt(scanner)
			x := getNextInt(scanner)
			aa[t] = append(aa[t], x)
		case 1:
			t := getNextInt(scanner)
			for j := 0; j < len(aa[t]); j++ {
				if j > 0 {
					fmt.Fprint(writer, " ")
				}
				fmt.Fprint(writer, aa[t][j])
			}
			fmt.Fprintln(writer, "")
		case 2:
			t := getNextInt(scanner)
			aa[t] = aa[t][:0]
		}
	}
}



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

main() {
  string s; cin >> s;
  string ans;
  for (int i = 0; i < s.length(); i++) {
    ans += s[i];
    if (s[i] == 'B') {
      ans.pop_back();
      if (!ans.empty()) ans.pop_back();
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n;
	cin >> n;
	string s[n];
	for(int i=0; i<n; i++){
		cin >> s[i];
	}
	int m;
	cin >> m;
	string t[m];
	for(int i=0; i<m; i++){
		cin >> t[i];
	}
	
	int max=0;
	for(int i=0; i<n; i++){
		int cnt=0;
		for(int j=0; j<n; j++){
			if(s[i]==s[j]) cnt++;
		}
		for(int j=0; j<m; j++){
			if(s[i]==t[j]) cnt--;
		}
		if(max<cnt) max=cnt;
	}
	cout<< max << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define foror(i,a,b) for(i=a;i<b;i++)
#define foror2(i,a,b) for(i=a;i>b;i--)
#define EPS 1e-6
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define MOD 1000000000
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("1\n")
using namespace std;
int main()
{
 int a,b,c;
 cin >> a >> b >> c;
 int pop=10000;
 for(int i=0;i<=pop;i++)
 {       if(i==pop)
         {
          printf("NO");
          break;
         }
         if((c+b*i)%a==0)
         {
          printf("YES");
          break;
         }
 }
}


Measured memory_bytes: 256
import bisect

def main():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    B = list(map(int, input().split()))
    C = sorted(list(map(int, input().split())))
    # print(N, A, B, C)
    # print(A)
    # print(B)
    # print(C)
    ans = 0
    for b in B:
        indexa = bisect.bisect_left(A, b)
        indexc = bisect.bisect_right(C, b)
        ans += indexa * (N - indexc)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 29404
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1.0)
#define pb push_back
#define vi vector<int>
#define mapii map<int , int>
#define mapci map<char, int>
#define mapsi map<string,int>
#define FOR(i,n) for(int i = 0;i<n;i++)
#define CP(n) printf("Case %d: \n",n);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdin)
#define MAX 1000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n ,r;
    cin>>r>>n;
    if(r<10)
        cout<<(n + (100 *(10 - r)))<<endl;
    else
        cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(int i = (int)(b); i < (int)(e); ++i)
#define RFOR(i, b, e) for(int i = (int)(e-1); i >= 0; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VI vector<int>
#define VVI vector<vector<int>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<int,int>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;

using namespace std;

ll conb(ll n, ll r) {
	if (n - r < r) { return conb(n, n - r); }
	ll tmp = 1;
	FOR(i, n - r + 1, n + 1) {
		tmp *= i;
	}
	FOR(i, 1, r + 1) {
		tmp /= i;
	}
	return tmp;
}

ll mod(ll n, ll r) {
	ll q = n % r;
	return (q < 0) ? q + r : q;
}

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

	RFOR(i, 1, m / n + 1) {
		if (m%i == 0) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
v = list(map(int,input().split()))
odd = []
even = []

for i in range(n):
  if i % 2 == 0:
    even.append(v[i])
  else:
    odd.append(v[i])

o_count = Counter(odd)
e_count = Counter(even)
o_count[-1] = 0
e_count[-2] = 0

if o_count.most_common(1)[0] != e_count.most_common(1)[0]:
  print(n - o_count.most_common(1)[0][1] - e_count.most_common(1)[0][1])
else:
  o1e2 = n - o_count.most_common(2)[0][1] - e_count.most_common(2)[1][1]
  o2e1 = n - o_count.most_common(2)[1][1] - e_count.most_common(2)[0][1]
  ans = min(o1e2,o2e1)
  print(ans)

Measured memory_bytes: 19168
def sffule(str, h):
    ls = []

    for ch in str:
        ls.append(ch)
        
    for _ in range(h):
        ls.append(ls.pop(0))
    t = ''
    for ch in ls:
        t += ch
    return t

while True:
    seq = input()
    
    if seq == '-':
        break
    
    m = int(input())
    for _ in range(m):
        h = int(input())
        seq = sffule(seq, h)
    print(seq)
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        


Measured memory_bytes: 5592
from fractions import gcd
from functools import reduce
import sys

N, M = map(int, input().split())
alist = list(map(lambda k: int(k) // 2, input().split()))

numdic = {}

def lcm(x, y):
    return (x * y) // gcd(x,y)

def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

lcmnum = lcm_list(alist)

for i in alist:
    if (lcmnum//i)%2==0:
        print(0)
        sys.exit()

pmax = M // lcmnum
pmax = pmax - 1 if pmax % 2 == 0 else pmax

print((pmax+1)//2)


Measured memory_bytes: 89708
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define eps 1e-6
using namespace std;
const int N = 1e6+7;
int a[N],ans=N;
int main()
{
  int k,n;
  cin>>k>>n;
  for(int i=1;i<=n;i++)cin>>a[i];
  for(int i=1;i<n;i++)
  {
    ans=min(ans,k-(a[i+1]-a[i]));
    //cout<<ans<<endl;
  }
  ans=min(ans,a[n]-a[1]);
  cout<<ans<<endl;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int d=b*10+c;
  if ( d%4==0 ) {
    cout << "YES" << '\n';
  } else {
    cout << "NO" << '\n';
  }
  return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int A[3][3] = {};
int B[3][3] = {};

int main() {
    for(int i=0; i<3; ++i) {
        for(int j=0; j<3; ++j) cin >> A[i][j];
    }

    int N; cin >> N;
    for(int i=0; i<N; ++i) {
        int b; cin >> b;
        for(int i=0; i<3; ++i) {
            for(int j=0; j<3; ++j) {
                if(A[i][j] == b) B[i][j] = true;
            }
        }
    }

    for(int i=0; i<3; ++i) {
        if(B[i][0] && B[i][1] && B[i][2]) {
            cout << "Yes\n";
            return 0;
        }
    }
    for(int i=0; i<3; ++i) {
        if(B[0][i] && B[1][i] && B[2][i]) {
            cout << "Yes\n";
            return 0;
        }
    }
    if(B[0][0] && B[1][1] && B[2][2]) {
        cout << "Yes\n";
        return 0;
    }
    if(B[0][2] && B[1][1] && B[2][0]) {
        cout << "Yes\n";
        return 0;
    }
    cout << "No\n";
}

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

using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main()
{
  int n, work1, work2;
  cin >> n;
  work1 = (n % 10) * 100;
  work2 = n % 100;
  if (n - work1 - work2 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

struct edge {
    int to, cost;
};

vector<edge> g[101010];
int ans[101010];

void solve(int v, int col) {
    for (edge e : g[v]) {
        int u = e.to;
        int cost = e.cost;
        if (ans[u] != -1) continue;
        if (cost%2 == 0) {
            ans[u] = col;
            solve(u, col);
        }
        else {
            ans[u] = !col;
            solve(u, !col);
        }
    }
}

int main() {
    int N;
    cin >> N;
    fill(ans, ans+N, -1);
    rep(i, N-1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        edge e1, e2; e1.to = u;  e1.cost = w;
        e2.to = v; e2.cost = w;
        g[v].push_back(e1);
        g[u].push_back(e2);
    }

    ans[0] = 0;
    solve(0, 0);
    rep(i, N) cout << ans[i] << endl;

}


Measured memory_bytes: 7552
n, m = map(int, input().split())
h = list(map(int, input().split()))

good = [1 for i in range(n)]

for i in range(m):
  a, b = map(int, input().split())
  if h[a - 1] <= h[b - 1]:
    good[a - 1] = 0
  if h[b - 1] <= h[a - 1]:
    good[b - 1] = 0

print(sum(good))

Measured memory_bytes: 20108
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    string S;
    cin >> S;

    if (S.back() == 's') {
        S += "es";
    } else {
        S += "s";
    }

    cout << S << endl;

    return 0;
}

Measured memory_bytes: 3592
S=input()
Q=int(input()) 

# ex
#2 1 p
#1
#2 2 c
#1
rev=False
head=[] # 後ろが先頭
tail=[] 

for _ in range(Q):
    query = input().split()

    if query[0] == "1":
        # 反転
        rev = not rev
    else:
        # T=2
        F = query[1]
        char = query[2]
        if F == "1":
            # 先頭につける
            if rev:
                # 先頭はtail
                tail.append(char)
            else:
                head.append(char)
        else:
            # 末尾につける
            if rev:
                # 先頭はtail
                head.append(char)
            else:
                tail.append(char)

head_str=''.join(head)
tail_str=''.join(tail)

if rev:
    # Sを反転
    print(tail_str[::-1]+S[::-1]+head_str)
else:
    print(head_str[::-1]+S+tail_str)

Measured memory_bytes: 71768
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int n,k;
  scanf("%d %d",&n,&k);

  int ans = 0;
  ans = n+1-k;
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void){
    int D, T, S;
    scanf("%d %d %d", &D, &T, &S);
    if((D/S) > T){
        printf("No\n");
    }
    else if((D/S) == T && D%S > 0){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 1644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	static int A;
	static int B;
	public static void main(String[] args) throws NumberFormatException, IOException {
		read();
	}

	private static void read() throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] word = br.readLine().split("\\s+");
		A = Integer.parseInt(word[0]);
		B = Integer.parseInt(word[1]);
		System.out.println(A*B);
		br.close();
	}

}


Measured memory_bytes: 33892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in(),K = in();
    vector<int> A(N);
    REP(i,N)A[i] = in();
    cout << (N-1 + K - 1 - 1)/(K-1) << "\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

const int INF = 1<<29;

int main(){
    int n, m; cin >> n >> m;
    vector<int> a(m), b(m), c(m);
    vector<vector<int>> dist(n, vector<int>(n,INF));
    rep(i,n) dist[i][i] = 0;
    rep(i,m){
        cin >> a[i] >> b[i] >> c[i];
        --a[i], --b[i];
        dist[a[i]][b[i]] = c[i];
        dist[b[i]][a[i]] = c[i];
    }
    for(int k = 0; k < n; ++k){
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    int res = 0;
    rep(i,m){
        if(c[i] > dist[a[i]][b[i]])res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
using namespace std;
int n,k;
const int mod = 1e9+7,N=2e5+5;
int h[N];
ll ans[N];
vi adj[N];
ll t[4*N];
void upd(int v,int tl,int tr,int pos,ll val) {
    if (tl == tr) t[v] = val;
    else {
        int tm = (tl + tr)/2;
        if (tm >= pos)
            upd(v*2,tl,tm,pos,val);
        else upd(v*2+1,tm+1,tr,pos,val);
        t[v] = max(t[v*2],t[v*2+1]);
    }
}
ll get(int v,int tl,int tr,int l,int r) {
    if (l > tr || r < tl) return 0;
    if (l<=tl && r >= tr) return t[v];
    int tm = (tl + tr)/2;
    return max( get(v*2,tl,tm,l,r), get(v*2+1,tm+1,tr,l,r));
}
int a[N];
main() {
    ios::sync_with_stdio(0);
    cin >> n;
    ll A = 0;
    for (int i = 1; i <= n; i++)
        cin >> h[i];
    for (int i = 1; i <= n; i++) {
            cin >> a[i];
        ans[i] = a[i] + get(1,1,n,1,h[i]);
        A = max(A,ans[i]);
        upd(1,1,n,h[i],ans[i]);
    }
    cout << A;

}


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

typedef long long ll;

/* メモリ食い過ぎ注意 */
#define int ll
#define ALL(v) v.begin(), v.end()
#define _REP(i, n) for (int i = 0; i < n; i++)
#define REP(n) _REP(i, n)

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    if (k % 2 == 0)
        cout << a - b << endl;
    else
        cout << b - a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountll
#define m_p make_pair
#define infi 1e18+1
#define eps 0.000000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
//////////////
auto clk=clock();
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define sz(x) ((long long)x.size())
#define int long long  
#define f80 __float128
#define pii pair<int,int>
/////////////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n;
	int x;
	cin>>x>>n;
	set<int> s;
	for(int i=0;i<n;++i)
	{
		int d;
		cin>>d;
		s.insert(d);
	}
	int ans=-200;
	for(int i=-200;i<=200;++i){
		if(s.find(i)!=s.end())
			continue;
		if(abs(ans-x)>abs(i-x)){
			ans=i;
		}
	}
	cout<<ans;
	#ifdef ANIKET_GOYAL
		// cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	#endif
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
  }
  vector<double> e(n);
  for (int i = 0; i < n; ++i) {
    int pp = p[i];
    e[i] = pp * (pp + 1) / (2.0) / pp;
    // cout << e[i] << endl;
  }
  vector<double> sum(n);
  partial_sum(e.begin(), e.end(), sum.begin());
  // for (int i = 0; i < n; ++i) {
  //   cout << sum.at(i) << endl;
  // }
  vector<double> foo(n - k + 1);
  for (int i = 0; i < n - k + 1; ++i) {
    if (i == 0) {
      foo[i] = sum.at(i + k - 1);
    } else {
      foo[i] = sum.at(i + k - 1) - sum.at(i - 1);
    }

    // if (i != 0) cout << "1 " << sum.at(i - 1) << endl;
    // cout << "2 " << sum.at(i + k - 1) << endl;

    // cout << "3 " << sum.at(i + k - 1) - sum.at(i) << endl;
    // cout << "debug1 " << sum.at(i) << endl;
    // if (i != k - 1) cout << "debug2 " << sum.at(i - k - 1) << endl;
    // cout << sum.at(i - 1) - sum.at(i - k) << endl;
  }
  cout << fixed << setprecision(12) << *max_element(foo.begin(), foo.end()) << endl;
}


Measured memory_bytes: 5760
#include <stdio.h>

int main(void){
  int x, y;
  while(1){
   scanf("%d %d",&x,&y);
   if(x < y){
     printf("%d %d\n",x,y);
   }else if(x > y){
     printf("%d %d\n",y,x);
   }else if(x==y && x!=0){
     printf("%d %d\n",x,y);
   }  else if(x==0 && y==0)
       break;
  }

 return 0;
  }

Measured memory_bytes: 600
use std::io;
use std::str::FromStr;
use std::collections::HashMap;

fn input_char_vec() -> Vec<char> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().chars().collect()
}

fn main() {
    let s = input_char_vec();
    let t = input_char_vec();
    let mut map1: Vec<char> = vec!['0'; 26];
    let mut map2: Vec<char> = vec!['0'; 26];
    for i in 0..s.len() {
        if map1[s[i] as usize - 'a' as usize] != '0' {
            if map1[s[i] as usize - 'a' as usize] != t[i] {
                println!("No");
                return;                    
            }
        } else if map2[t[i] as usize - 'a' as usize] != '0' {
            if map2[t[i] as usize - 'a' as usize] != s[i] {
                println!("No");
                return;                    
            } 
        } else {
            map1[s[i] as usize - 'a' as usize] = t[i];
            map2[t[i] as usize - 'a' as usize] = s[i];
        }
    }
    println!("Yes");
}

Measured memory_bytes: 3864
from itertools import permutations

N = 8

M = [['.']*N for i in range(N)]
A0 = set()
B0 = set()

K = int(input())
R = set(range(N))
C = set(range(N))
for i in range(K):
    r, c = map(int, input().split())
    R.remove(r); C.remove(c)
    M[r][c] = 'Q'
    A0.add(r+c)
    B0.add(r-c)


for CS in permutations(C):
    A = A0.copy()
    B = B0.copy()
    ok = 1
    for r, c in zip(R, CS):
        if r+c in A:
            ok = 0
        A.add(r+c)
        if r-c in B:
            ok = 0
        B.add(r-c)
    if ok:
        for r, c in zip(R, CS):
            M[r][c] = 'Q'
        break
print(*("".join(m) for m in M), sep='\n')



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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int& i : a) cin >> i;
	int m;
	cin >> m;
	vector<int> b(m);
	for (int& i : b) cin >> i;
	cout << includes(a.begin(), a.end(), b.begin(), b.end()) << endl;
}


Measured memory_bytes: 4416
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace  std;
typedef long long int ll;
typedef pair<ll, ll> pll;

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

	vector<pll> area(N);
	for (int i = 0; i < N; ++i)
	{
		ll m = std::max((ll)0, 2 * C - (D - C)*(N - 2));
		ll l = (D - C)*(N - 1);
		ll max = D * (N - 1) - (m + l)*i;

		pll p(max, max - l);
		area[i] = p;
	}

	string ans = "NO";
	for (int i = 0; i < N; ++i)
	{
		if (area[i].first >= (B - A) && area[i].second <= (B - A))
		{
			ans = "YES";
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8064