akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n-h+1) * (n-w+1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
unsigned long long gcd(unsigned long long a,unsigned long long b){
  while(b!=0){
    
    long long r=a%b;
    a=b;
    b=r;
  }
  return a;
}
int main(){
  long long n;
  cin >> n;
  vector<long long> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  unsigned long long ans=a.at(0);
  rep(i,n){
    ans=ans/gcd(ans,a.at(i))*a.at(i);
  }
  cout << ans;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=(a);i<=(int)(n);++i)
#define lpd(i,a,n) for(int i=(a);i>=(int)(n);--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-8
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
int n,x11,y11,x22,y22;
vector<pii> a;

int CeilIndex(vi &v, int l, int r, int key) {
    while (r-l > 1){
        int m = l + (r-l)/2;
        if (v[m] >= key) r = m;
        else l = m;
    }

    return r;
}

int LISLength(vi &v){
    if(!sz(v)) return 0;

    vi tail(sz(v), 0);
    int length = 1;

    tail[0] = v[0];
    lp(i,1,sz(v)-1){
        if (v[i] < tail[0])
            tail[0] = v[i];
        else if (v[i] > tail[length-1])
            tail[length++] = v[i];
        else
            tail[CeilIndex(tail, -1, length-1, v[i])] = v[i];
    }

    return length;
}

int main(){
    read2i(x11,y11);
    read2i(x22,y22);
    if(x11 > x22) swap(x11, x22), swap(y11, y22);

    readi(n);
    lp(i,1,n){
        int x,y;
        read2i(x,y);
        if(x < x11 or x > x22) continue;
        if(y < min(y11, y22) or y > max(y11, y22)) continue;
        a.pb({x,y});
    }
    sort(all(a));

    if(y11 > y22) reverse(all(a));

    vi x;
    for(pii p : a) x.pb(p.s);
    int l = LISLength(x);

    if(x11 == x22 or y11 == y22){
        cout <<setprecision(12) <<fixed <<100ll * (abs(x11 - x22) + abs(y11 - y22)) + l * ((long double)10*acos(-1) - 20);
        return 0;
    }

    long double twfeer = 20 - (long double)5*acos(-1);
    if(l <= min(abs(x11 - x22), abs(y11 - y22))) cout <<setprecision(12) <<fixed <<100ll * (abs(x11 - x22) + abs(y11 - y22)) - l * twfeer;
    else cout <<setprecision(12) <<fixed <<100ll * (abs(x11 - x22) + abs(y11 - y22)) - (l-1) * twfeer + ((long double)10*acos(-1) - 20);
}

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


Measured memory_bytes: 3568
from itertools import permutations

N=int(input())
ans = ['']*N

al = 'abcdefghij'
d = {al[i]:i for i in range(N)}

def dfs(h=[]):
    if len(h)==N:
        print(''.join(h))
        return
    for i in range(max([d[h[-1-i]] for i in range(len(h))])+2):
        h.append(al[i])
        dfs(h)
        h.pop()
    return
  
dfs(['a'])

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

int main()
{
    int a,b;
    cin>>a>>b;
    int curr=1,ans=0;
    while(curr<b)
    {
        curr-=1;
        curr+=a;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
when = [0] * 26
sat = 0
for i in range(1, d + 1):
    t = int(input()) - 1
    sat += s[i - 1][t]
    when[t] = i
    for j in range(26):
        sat -= c[j] * (i - when[j])
    print(sat)


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

int main(){
  int t;
  cin>>t;
  double ans[t+1];
  for(int i=0;i<t+1;i++){
    //cout << "i " << i << endl;
    int n,m;
    cin>>n>>m;
    int val[m];
    double p[m];
    for(int j=0;j<m;j++){
      cin>>val[j]>>p[j];
    }
    //cout << "val" << endl;
    //for(int a:val)cout << a << endl;
    double pp=0;
    for(int k=0;k<m;k++) pp+=p[k];
    for(int j=0;j<m;j++){
      p[j]/=pp;
      //cout << "p["<<j<<"] "<<p[j] << endl;
    }
    for(int j=0;j<m;j++){
      ans[i]+=val[j]*p[j];
    }
    //cout << endl;
  }
  bool flag = false;
  //for(double a:ans)cout << a << endl;
  for(int i=0;i<t;i++){
    if(ans[t] < ans[i]){
      cout << "YES" << endl;
      flag=true;
      break;
    }
  }
  if(flag==false)
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define int long long
#define rint register int
#define fo(i, n) for(rint i = 1; i <= (n); i ++)
#define out(x) cerr << #x << " = " << x << "\n"
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); ++ it)
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
  x = 0;char c = getchar(); bool f = 0;
  for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if(f) x = -x;
}
const int N = 2333;
const int mo = 998244353;
int n, x[N], y[N], pw[N], ans = 0;
main(void) {
  read(n); fo(i, n) read(x[i]), read(y[i]);
  pw[0] = 1; fo(i, n) pw[i] = pw[i - 1] * 2 % mo;
  int ans = pw[n] - 1 - n;
  // out(ans);
  fo(i, n) fo(j, n) if(i != j) {
    vector<pair<int, int> > vec;
    vec.push_back({x[i], y[i]});
    vec.push_back({x[j], y[j]});
    fo(k, n) if(k != i && k != j) {
      int x1 = x[k] - x[i], y1 = y[k] - y[i];
      int x2 = x[j] - x[i], y2 = y[j] - y[i];
      if(x1 * y2 - x2 * y1 == 0) {
        vec.push_back({x[k], y[k]});
      }
    }
    sort(vec.begin(), vec.end());
    if(vec[0].first == x[i] && vec[0].second == y[i]
       && vec[1].first == x[j] && vec[1].second == y[j]) {
      int cnt = (int) vec.size();
      ans = (ans - (pw[cnt] - 1 - cnt) + mo) % mo;
    }
  }
  cout << (ans + mo) % mo << "\n";
}


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

int main(){
	int x,y,z;
	cin>>x>>y>>z;

	int count = 0;
	x-=z;
	while(x>=y+z){
		x-=z;
		x-=y;
		count++;
	}
	cout<<count;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define FASTIO
#define endl "\n" // Since endl forces a buffer flush which slows down large I/O operations.
#define ff first
#define ss second
#define pb push_back
#define input(c, n)             \
	for (int i = 0; i < (n); i++) \
		cin >> (c)[i];
#define exit_message(s) return 0 * printf(s)
#define show(c)           \
	for (auto i : (c))      \
		cout << i << " "; \
	cout << "\n";
#define display(c, n)           \
	for (int i = 0; i < (n); i++) \
		cout << (c)[i] << " ";    \
	cout << "\n";
#define forl(i, a, n) for (int (i) = (a); (i) < (n); (i)++)
#define dugbe(k) cout << "-\t> " << #k << " = " << k << "\n";

/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/

using namespace std;
typedef long long ll;
typedef pair<int, int> pr;
typedef pair<ll, ll> prll;
typedef vector<int> vi;
typedef vector<ll> vill;
typedef vector<pr> vpr;
ifstream in("input.txt");
const ll mod = 1e9 + 7;

ll mod_pow(ll a, ll b)
{
	if (b == 0)
		return 1LL;

	ll res = mod_pow(a, b >> 1);
	res = (res * res) % mod;
	if (b & 1LL)
		res = (res * a) % mod;

	return res;
}

const int N = 21 + 5;
const int SZ = 2100000;

int n;
int a[N][N];
int dp[SZ];

int solve(int mask)
{
	int idx = 1;
	for (int i = 1; i <= mask; i *= 2)
		if (mask & i)
			idx++;

	if (idx > n)
		return 1;

	int &memo = dp[mask];
	if (memo != -1)
		return memo;

	memo = 0;
	for (int i = 1; i <= n; i++)
	{
		int temp = 1 << (i - 1);
		// cerr << "temp : " << bitset<32>(temp) << " mask : " << mask << "\n";
		if (a[idx][i] == 1 && (mask & temp) == 0)
		{
			// cerr << "entry\n";
			mask ^= temp;
			memo += solve(mask);
			memo %= mod;
			mask ^= temp;
		}
	}
	// cerr << "idx : " << idx << " memo : " << memo << "\n";
	return memo;
}

int32_t main()
{
#ifdef FASTIO
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#endif
	// freopen("in.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	memset(dp, -1, sizeof dp);

	cin >> n;
	forl(i, 1, n + 1)
	{
		forl(j, 1, n + 1)
		{
			cin >> a[i][j];
		}
	}

	int mask = 0;
	int ans = solve(mask);
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 8448
import numpy as np

N = int(input())

# init
# dp[day][action]
# day: 1-N, action: 0-2(a-c)
dp = np.zeros((N + 1, 3)).astype(int)

# loop
for i in range(1, N + 1):
    abc = list(map(int, input().split()))
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + abc[0]
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + abc[1]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + abc[2]

# output
print(max(dp[N]))

Measured memory_bytes: 19732
N_ko, L_aji = map(int, input().split())

taste = list(L_aji + i for i in range(N_ko))
taste.sort()

if (taste.count(0) > 0):
    ans = sum(taste)
elif (min(taste) > 0):
    ans = sum(taste[1:])
else:
    ans = sum(taste[:-1])

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
int h;
void maxHeapify(int *A,int i){
  int l=i*2+1;
  int r=i*2+2;
  int largest;
  if(l<h&&A[l]>A[i]) largest=l;
  else largest=i;
  if(r<h&&A[r]>A[largest]) largest=r;
  if(largest!=i){
    swap(A[i],A[largest]);
    maxHeapify(A,largest);
  }
}
void buildMaxHeap(int *A){
  for(int i=h/2;i>=0;i--)
    maxHeapify(A,i);
}
signed main(){
  cin>>h;
  int A[h];
  for(int i=0;i<h;i++) cin>>A[i];
  buildMaxHeap(A);
  for(int i=0;i<h;i++) cout<<" "<<A[i];
  cout<<endl;
  return 0;
}

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

bool serch(vector<int> a, int n, int key) {
  int i = 0;
  a.at(n) = key;
  while (a.at(i) != key) i ++;
  return i != n;
}

int main() {
  int i, n, q, key, sum = 0;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 0; i < n; i ++) cin >> a.at(i);

  cin >> q;
  for (int i = 0; i < q; i ++) {
    cin >> key;
    if (serch(a, n, key)) sum ++;
  }

  cout << sum << endl;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

class UF{
public:
  int V;
  vector<int> par,rnk,sz;
  UF(){}
  UF(int V):V(V),par(V),rnk(V,0),sz(V,1){for(int i=0;i<V;i++)par[i]=i;}
  
  int find(int x){
    assert(x < V);
    if(par[x]==x)return x;
    return par[x]=find(par[x]);
  }
  
  void unite(int x,int y){
    x=find(x), y=find(y);
    if(x==y)return;
    if(rnk[x]<rnk[y])par[x]=y, sz[y] += sz[x];
    else{
      par[y]=x;
      sz[x] += sz[y];
      if(rnk[x]==rnk[y])rnk[x]++;
    }
  }

  bool same(int x,int y){return find(x)==find(y);}

  int size(int x){return sz[find(x)];}
};

signed main(){
  int n;
  cin>>n;
  typedef tuple<int,int,int> T;
  vector<T> edge;
  for(int i=0;i<n-1;i++){
    int a,b,c;
    cin>>a>>b>>c;
    edge.push_back(T(c,a,b));
  }

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

  int ans = 0;
  UF uf(n);
  for(auto e:edge){
    int c,a,b; tie(c,a,b) = e;
    ans += c * uf.size(a) * uf.size(b);
    uf.unite(a,b);
  }

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



Measured memory_bytes: 12252
n, k = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)
l = -1
r = 10 ** 13
while r - l > 1:
  m = (l + r) // 2
  if sum([(a - m // f) if a * f > m else 0 for a, f in zip(A, F)]) <= k:
    r = m
  else:
    l = m
    
print(r)

Measured memory_bytes: 137456
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define exist(s,x) (s).find(x)!=(s).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
#define fi first
#define se second
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}
inline ll modpow(ll x, ll y) {
    ll res = 1;
    while(y) {
        if(y&1) res = mul(res,x);
        y >>= 1;
        x = mul(x,x);
    }
    return res;
}

int main(){
    int N, K; cin >> N >> K;
    vector<double> p(N);
    REP(i,N) { cin >> p[i]; p[i] = (p[i]+1) / 2.0;}
    double ans = 0;
    double tmp = 0;
    REP(i,K) tmp += p[i];
    ans = tmp;
    FOR(i,K,N) {
        tmp += p[i];
        tmp -= p[i-K];
        ans = max(ans, tmp);
    } 
    cout << fixed << setprecision(10);
    cout << ans << endl;
    return 0;
}

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

#define ll long long int
//#define PI acos(1.0)

#define Bit_off(val,pos)       (val & (~(1<<pos)))
#define Bit_on(val,pos)        (val | (1<<pos))
#define Bit_toggle(val,pos)    (val ^ (1<<pos))
#define Bit_check(val,pos)     (bool)(val & (1<<pos))
#define odd_even(val)          (bool)(val & 1)
#define koita_1_ase(val)       (__builtin_popcount(val))

ll ar[500009],br[500009],cr[500009];
map<ll,ll>mp,mp1;
vector<ll>v;
string s,d;

int main()
{
   // ll a,b,c,i,j,k,x,y,z,f,g,h;
   ll a;
    double q,r;

    cin>>a;
    q=a;
    r=(2.0*q*3.1416);

    cout<<fixed<<setprecision(6)<<r<<endl;
}



Measured memory_bytes: 3804
#include<iostream>

using namespace std;

const long long int MOD=1e9+7;

int main(){
  long long int m, n;
  cin >> m>> n;
  long long ans = 1;
  for(;n>0;n>>=1){
    if((n&1)==1)ans = (ans*m)%MOD;
    m = (m*m)%MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3120
import heapq

n = int(input())
v = list(map(int, input().split()))

heapq.heapify(v)
while len(v) > 1:
    v1 = heapq.heappop(v)
    v2 = heapq.heappop(v)
    heapq.heappush(v, (v1 + v2) / 2)
print(v[0])


Measured memory_bytes: 3060
#include <iostream>

int main() {
  int m, f, r;
  std::cin >> m >> f >> r;
  while (!(m == -1 && f == -1 && r == -1)) {
    if (m == -1 || f == -1 || m + f < 30) std::cout << "F\n";
    else if (m + f < 50 && r < 50) std::cout << "D\n";
    else if (m + f < 65) std::cout << "C\n";
    else if (m + f < 80) std::cout << "B\n";
    else std::cout << "A\n";
    std::cin >> m >> f >> r;
  }
  return 0;
}



Measured memory_bytes: 3092
#include <iostream>
using namespace std;
 
int main(){
   int a,b;
cin >> a >> b;
a = (a+ 11)%13;
b = (b + 11) % 13;
if(a < b) cout << "Bob" << endl;
else if(a > b) cout << "Alice" << endl;
else cout << "Draw" << endl;
   return 0;
}

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

    #define ll long long
    #define pb push_back
    #define mod 1000000007

    int main() {


      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);
      
      
     ll i,j,m,n;
     cin>>n>>m;
     map<ll,ll> mt;
     for(i=0;i<m;i++)
     {
      cin>>j;
      mt[j]=1;
     }

     ll dp[n+1];
     memset(dp,0,sizeof dp);

     ll ctr=0;
     dp[0]=1;
     if(mt[1]==0){
      dp[1]=1;
      if(mt[2]==0)dp[2]=dp[1]+dp[0];
     }else if(mt[2]==0){
      dp[2]=1;
     }

     for(i=3;i<=n;i++)
     {
      if(mt[i]==1) continue;

      dp[i]= (dp[i-1]+dp[i-2])%mod;
      
     }
     
     
     cout<<dp[n];
      return 0;
    } 

Measured memory_bytes: 7424
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
  int h, w, n;
  scanf("%d%d%d", &h, &w, &n);
  if (h > w) {
    swap(h, w);
  }
  printf("%d\n", (n + w - 1) / w);
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();	//切られた羊羹の数
		long [] s = new long[n + 1];	//累積和用の配列
		for(int i = 1;i <= n;i ++) {
			s[i] = sc.nextLong();
			s[i] += s[i - 1];	//累積和を取る
		}
		int l = 1,r = 3;	//左（中央）右の切込みを入れるところ
		long ans = s[n];	//MAX-MINの値
		for(int i = 2;i < n - 1;i ++) {	//中央の切り口
			long last = s[n];	//一時的な変数
			while(l < i) {		//左の切り口は必ず中央よりも左にある
				long d = Math.abs(s[i] - s[l] * 2);	//左から1番目の羊羹と左から2番めの羊羹の長さの差の絶対値
				if(d > last) break;	//あるところまでは単調減少だが、あるところから単調増加に転じるので、単調増加に転じ始めたらそれ以降が答えになることはありえないのでそこで探索を切る
				else last = d;		//単調減少のときは、できるだけ差をちいさくすべく、値を更新する
				l ++;	//どんどん切り口を右に寄せる
			}
			l --;	//単調増加に転じはじめたところにlがなっているので1減らして、ギリギリ単調減少のところまで戻す
			last = s[n];		//一時的な変数
			while(r < n) {		//右側も同様　必ず、右の切り口は中央よりも右に存在する
				long d = Math.abs(s[n] + s[i] - s[r] * 2);	//右から1番目の羊羹と、右から2番めの羊羹の差の絶対値
				if(d > last) break;	//単調増加になったらやめる
				else last = d;	//そうでなければ更新
				r ++;	//切り口を右にやる
			}
			r --;	//単調増加してしまったものを単調減少まで戻す
			long max = Math.max(Math.max(Math.max(s[l], s[i] - s[l]), s[r] - s[i]), s[n] - s[r]);
			long min = Math.min(Math.min(Math.min(s[l], s[i] - s[l]), s[r] - s[i]), s[n] - s[r]);
			ans = Math.min(max - min, ans);	//答えの更新
		}
		System.out.println(ans);	//答えの出力
	}
}


Measured memory_bytes: 81976
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
//	cut here before submit 
//	freopen ("testcase.seq", "r", stdin );

	double a0;
	while (cin >> a0 ){
		vector<double> a(11, 0. );
		a[1] = a0;
		for (int i = 2; i <= 10; i++ ){
			if (i % 2 == 0 ){
				a[i] = 2.*a[i-1];
			}else{
				a[i] = a[i-1]/3.;
			} // end if
		} //end for
		double sum = accumulate (ALL (a ), 0. );
		printf ("%.12lf\n", sum );
	} // end loop
		
	return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int x;
  cin>>x;
  if(x>=30){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

const int MAX = 1000010;//nCkのn,kの取りうるMAX
const int MOD = 1000000007;

long long fac[MAX],finv[MAX],inv[MAX];

//階乗のテーブルを作る
void COM_initialize(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2 ; i < MAX ; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD -inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

//二項係数計算,nCkのn,kを引数として渡す
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD)% MOD;
}

int main() {

   long long X;
   long long Y;
   cin>>X>>Y;
   if((X+Y)%3!=0){
       cout<<0<<endl;
       return 0;
   }

   long long ans;

   COM_initialize();
   ans = COM(((2*X-Y)/3)+((2*Y-X)/3),(2*X-Y)/3);
   cout<<ans<<endl;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
int k[2020],f[2000005],a[2000005],g[2000005];
int main()
{
	string s;
	cin>>s;
	int n=s.size(),i;
	for(i=0; i<n; i++)
		a[i+1]=s[i]-'0';
	int l=1;
	for(i=n; i>=1; i--)
	{
		g[i]=l;
		l*=10;
		l%=2019;
	}
	for(i=n; i>=1; i--)
	{
		f[i]=(f[i+1]+a[i]*g[i])%2019;
		k[f[i]]++;
	}
	int sum=k[0];
	for(i=0; i<=2018; i++)
		sum+=(k[i]*(k[i]-1)/2);
	cout<<sum;
	return 0;
 } 

Measured memory_bytes: 6056
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
	int n, m;
	
	while(std::cin >> n >> m){
		if(n == 0 && m == 0){ break; }
		
		std::vector<int> price(n, 0);
		int sum_price = 0; //全ての値段の合計
		
		for(int i = 0 ; i < n ; ++i){
			std::cin >> price[i];
			sum_price += price[i];
		}
		
		std::sort(price.begin(), price.end(), std::greater<int>());
		
		for(int i = m - 1 ; i < n ; i += m){
			sum_price -= price[i];
		}
		std::cout << sum_price << std::endl;
	}
    return 0;
}

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

int seg = 1;

class RAQ{
	vector<int> dat;
public:
	RAQ() : dat(seg * 2 - 1){}
	void add(int a,int b,int x,int k = 0,int l = 0,int r = seg){
		if(b <= l || r <= a) return;
		if(a <= l && r <= b){
			dat[k] += x;
			return;
		}
		add(a,b,x,k * 2 + 1,l,(l + r) / 2);
		add(a,b,x,k * 2 + 2,(l + r) / 2,r);
	}
	int get(int i){
		int s = 0;
		i += seg - 1;
		s += dat[i];
		while(i){
			i = (i - 1) / 2;
			s += dat[i];
		}
		return s;
	}
};

signed main(){
	int n,q,x[200000],d[200000],l[200000];
	cin >> n >> q;
	while(seg < n) seg *= 2;
	vector<RAQ> ps(2);
	for(int i = 0;i < n;i++){
		ps[0].add(i,i + 1,i);
		ps[1].add(i,i + 1,n - i - 1);
	}
	for(int i = 0;i < q;i++) cin >> x[i] >> d[i] >> l[i];
	for(int i = q - 1;i >= 0;i--){
		int low = -1,up = n;
		while(up - low > 1){
			int mid = (up + low) / 2;
			if(d[i] == 1){
				if(ps[0].get(mid) < x[i]) low = mid;
				else up = mid;
			}else{
				if(ps[1].get(mid) < n - x[i]) up = mid;
				else low = mid;
			}
		}
		if(d[i] == 1) ps[1].add(0,up,l[i] * 2);
		else ps[0].add(up,seg,l[i] * 2);
	}
	for(int i = 0;i < n;i++) cout << (ps[0].get(i) + ps[1].get(i) - n + 1) / 2 << endl;
	return 0;
}


Measured memory_bytes: 15712
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
#define ar array
const int mxN=2e5;
const int MOD=1e9+7;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
int main()
{
    fastio;
    ll n;
    cin>>n;
    set<ll>s;
    while(n--)
    {
        ll x;
        cin>>x;
        if(s.count(x)==0)
        {
            s.in(x);
        }
        else
        {
            s.erase(x);
        }
    }
    cout<<s.size()<<endl;
}


Measured memory_bytes: 8200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Adly
 */
public class Main {

    static int t;
    static int[] dp;
    static int[] a;

    public static int re(int i) {
        if (i > 0) {
            if (i == 1 || i == 2) {
                return dp[i] = Math.abs(a[i] - a[0]);
            }
            if (dp[i] != -1) {
                return dp[i];
            } else {
                if (dp[i] == -1) {
                    dp[i] = 0;
                }
                return dp[i] += Math.min(Math.abs(re(i - 1) + Math.abs(a[i - 1] - a[i])), Math.abs(re(i - 2) + Math.abs(a[i - 2] - a[i])));
            }
        }
        return dp[0] = Integer.MAX_VALUE;//bad path
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());
        t = Integer.parseInt(st.nextToken());
        a = new int[t];
        dp = new int[t];
        st = new StringTokenizer(br.readLine());
        for (int i = 0; i < t; i++) {
            a[i] = Integer.parseInt(st.nextToken());
            dp[i] = -1;
        }
        out.println(re(t - 1));
        out.flush();
    }
}
/*
10
0 0 0 0 0 0 0 0 123 23
*/


Measured memory_bytes: 47464
import java.util.*;

public class Main {
  private static final char[] PATTERN = "AKIHABARA".toCharArray();

  public static boolean solve(char[] cs) {
    int patternIndex = 0;
    int csIndex = 0;
    while (csIndex < cs.length && patternIndex < PATTERN.length) {
      char c1 = cs[csIndex];
      char c2 = PATTERN[patternIndex];
      if (c1 == c2) {
        csIndex++;
        patternIndex++;
      } else if (c2 == 'A') {
        patternIndex++;
      } else {
        return false;
      }
    }
    return csIndex >= cs.length && patternIndex >= PATTERN.length - 1;
  }

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    char[] cs = scanner.next().toCharArray();
    System.out.println(solve(cs) ? "YES" : "NO");
  }
}


Measured memory_bytes: 35640
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>A;//きゅー
int main(void)
{
	long long int H[100010];
	int N;
	int count = 0, max = 0;
	scanf("%d", &N);
	for (int i = 0; i < N;i++) {
		scanf("%lld", &H[i]);
	}
	for(int i=0;i<N-1;i++) {
		if (H[i] >= H[i + 1]) {
			count++;
		}
		else {
			if (max < count) {
				max = count;
			}
			count = 0;
		}
	}
	if (max < count) {
		max = count;
	}
	printf("%d", max);

	return 0;

}


Measured memory_bytes: 1024
use std::io;
fn main() {
    let mut l1 = String::new();
    let mut l2 = String::new();
    let stdin = io::stdin();
    stdin.read_line(&mut l1).unwrap();
    stdin.read_line(&mut l2).unwrap();
    let trimed = l1.trim_end();
    let trimed2 = l2.trim_end();
    let mut itr = trimed.split_ascii_whitespace();
    let mut itr2 = trimed2.split_ascii_whitespace();
    let s = itr.next().unwrap();
    let t = itr2.next().unwrap();
    let length = s.len() as usize;
    if s.len() + 1 == t.len() && s == &t[0..length] {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(c - (a - b), 0) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        int D = scan.nextInt();
        
        	System.out.print(Math.min(A,B)+Math.min(C,D));
      
    }
}

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

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

  vector<string> v(H);
  for (int i = 0; i < H; i++) {
    cin >> v.at(i);
  }

  vector<int> dx{-1, 0, 1, 0};
  vector<int> dy{ 0, 1, 0, -1};

  bool can = true;
  for (int x = 0; x < H; x++) {
    for (int y = 0; y < W; y++) {
      char c = v.at(x).at(y);

      if (c == '.') { continue; }

      bool has_sharp = false;
      for (int i = 0; i < 4; i++) {
        int rx = x + dx.at(i);
        int ry = y + dy.at(i);

        if (rx >= 0 && rx < H && ry >= 0 && ry < W) {
          if (v.at(rx).at(ry) == '#') {
            has_sharp = true;
            break;
          }
        }
      }

      if (!has_sharp) {
        can = false;
      }
    }
  }

  cout << (can ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3596
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string s = Console.ReadLine();
    int n = s.Length;
    int[] news = new int[4];
    bool answer = true;

    for(int i = 0; i < n; i++)
    {
      if(s[i] == 'N') news[0]++;
      if(s[i] == 'E') news[1]++;
      if(s[i] == 'W') news[2]++;
      if(s[i] == 'S') news[3]++;
    }

    if(news[0] > 0 && news[3] == 0) answer = false;
    if(news[1] > 0 && news[2] == 0) answer = false;
    if(news[2] > 0 && news[1] == 0) answer = false;
    if(news[3] > 0 && news[0] == 0) answer = false;
    
		Console.WriteLine((answer) ? "Yes" : "No");
	}
}

Measured memory_bytes: 11092
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
const ll maxn=1e5+233;
const ll INF=1e18;
ll a1[maxn]={0},c1[maxn]={0},a2[maxn]={0},c2[maxn]={0};
ll cnt[maxn]={0};
ll ans=0;
ll lowbit(ll x){return x&-x;}
void update(ll *c,ll x,ll d){
	for(;x<maxn-5;x+=lowbit(x))
		c[x]+=d;
}
ll getsum(ll *c,ll x){
	ll ans=0;
	for(;x;x-=lowbit(x))
		ans+=c[x];
	return ans;
}
int main()
{
	ll n;
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++){
		scanf("%lld",&a1[i]);
	}
	for(ll i=1;i<=n;i++){
		cnt[i]=i-1-getsum(c1,a1[i]);
		update(c1,a1[i],1);
	}
	for(ll i=n;i>=1;i--){
		cnt[i]=min(cnt[i],n-i-getsum(c2,a1[i]));
		update(c2,a1[i],1);
	}
	for(ll i=1;i<=n;i++){
		//cout<<cnt[i]<<" ";
		ans+=cnt[i];
	}
	//cout<<endl;
	printf("%lld\n",ans);
    return 0;
}
/*
10
9 1 9 4 9 1 5 9 1 2

10

*/




Measured memory_bytes: 6340
#include <cstdio>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <array>

using namespace std;

int main() {
	
	int N;
	vector<int> S;
	char l;
	int ans = 0;
	int ones = 0;
	int min;
	int loss;
	
	// 入力
	scanf("%d", &N);
	scanf("%c", &l);
	for(int i = 0; i<N; i++){
		scanf("%c", &l);
		ones += (l == '.') ? 1 : 0;
		S.push_back((l == '.') ? 1 : 0);
	}
	
	loss = ones;
	min = loss;
	for(int i=0; i<N; i++){
		if(S[i] == 0) loss++;
		else loss--;
		min = (min > loss) ? loss : min;
	}
	
	// 出力
	printf("%d\n", min);
	
	return 0;
	
}


Measured memory_bytes: 1400
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    static int BinarySearch(long[] a, long key)
    {
        int left = 0, right = a.Length;
        while (left < right)
        {
            int mid = (left + right) / 2;
            if (a[mid] == key) return mid;
            if (a[mid] < key) left = mid + 1;
            if (a[mid] > key) right = mid;
        }
        return -1;
    }
    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        long[] ns = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        int q = int.Parse(Console.ReadLine());
        long[] qs = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        int res = 0;
        for (int i = 0; i < q; i++) res = (BinarySearch(ns, qs[i]) != -1)? res + 1: res;
        Console.WriteLine(res); 
    }
}


Measured memory_bytes: 35492
package main

import (
	"fmt"
	"sort"
)

func last(ar []int) int {
	return ar[len(ar)-1]
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	ar := []int{a + b, a - b, a * b}
	sort.Ints(ar)

	fmt.Println(last(ar))
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
using namespace std;

int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
int n,m;
string s;
int h,w;
char a[51][51];
const int inf=999999999;

inline int bfs(){
    queue<pair<int,pair<int,int> > > q;
    q.push(make_pair(0,make_pair(0,0)));
    int res=inf;
    bool past[51][51];
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)past[i][j]=0;
    past[0][0]=1;
    while(!q.empty()){
        int nowy=q.front().fi;
        int nowx=q.front().se.fi;
        int nowcost=q.front().se.se;
        q.pop();
        if(nowy==h-1 && nowx==w-1){
            res=min(res,nowcost);
            continue;
        }
        for(int i=0;i<4;i++){
            if(nowy+dy[i]<0 || nowy+dy[i]>=h)continue;
            if(nowx+dx[i]<0 || nowx+dx[i]>=w)continue;
            if(a[nowy+dy[i]][nowx+dx[i]]=='#')continue;
            if(past[nowy+dy[i]][nowx+dx[i]])continue;
            q.push(make_pair(nowy+dy[i],make_pair(nowx+dx[i],nowcost+1)));
            past[nowy+dy[i]][nowx+dx[i]]=1;
        }
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
#ifdef LOCAL_DEFINE
    FILE *stream1;
    //FILE *stream2;
    stream1=freopen("in","r",stdin);
    //stream2=freopen("out","w",stdout);
    if(stream1==NULL)return 0;
    //if(stream2==NULL)return 0;
#endif
    cin>>h>>w;
    int white=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
            if(a[i][j]=='.')white++;
        }
    }
    int temp=bfs();
    if(temp==inf){
        cout<<-1<<endl;
    }else
        cout<<white-temp-1<<endl;
#ifdef LOCAL_DEFINE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    fclose(stream1);
    //fclose(stream2);
#endif
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12);
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a,int b){return a*b/gcd(a,b);}
//priority_queue<int, vector<int>, greater<int> > que; //昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED
    int r;
    cin >> r;
    if(r<1200)
    {
        cout << "ABC" << endl;
    }
    else if(r<2800)
    {
        cout << "ARC" << endl;
    }
    else
    {
        cout << "AGC" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  int n;
  cin >> n;
  int a;
  int ok = 1;
  for (int i = 0; i < n; i++){
    cin >> a;
    if (a % 2 == 0 && a % 5 != 0 && a % 3 != 0)
      ok = 0;
  }


  if (ok)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  cin>>a>>b>>k;
  int cnt=0;
  int t=max(a,b);
  while(1){
    if(a%t==0&&b%t==0){
      cnt++;
      if(cnt==k){
	cout<<t<<endl;
	return(0);
      }
    }
    t--;
  }
  return(0);
}


Measured memory_bytes: 256
def main():
	n = int(input())
	if 400 <= n <= 599:
		print(str(8))
	elif 600 <= n <= 799:
		print(str(7))
	elif 800 <= n <= 999:
		print(str(6))
	elif 1000 <= n <= 1199:
		print(str(5))
	elif 1200 <= n <= 1399:
		print(str(4))
	elif 1400 <= n <= 1599:
		print(str(3))
	elif 1600 <= n <= 1799:
		print(str(2))
	elif 1800 <= n <= 1999:
		print(str(1))

			

if __name__ == '__main__':
	main()

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

int main() {
  string s;
  cin >> s;
  s.erase(s.end() - 1, s.end());
  int size      = s.size();
  string kaibun = "";
  int a         = 1;
  while (a < size) {
    string s1 = s.substr(0, a);
    string s2 = s.substr(a, a);
    if (s1 == s2) { kaibun = s1; }
    a++;
  }
  string tmp = kaibun;
  int cnt    = kaibun.size();
  while (cnt < size) {
    if (kaibun != tmp) { break; }
    tmp += kaibun;
    if (size > cnt + kaibun.size()) {
      cnt += kaibun.size();
    } else {
      break;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

// #define NDEBUG
#include "atcoder/all"
using namespace atcoder;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n, d;
    cin >> n >> d;
    two_sat ts(n);
    vector<int> xs(n), ys(n);
    for(int i = 0; i < n; i++){
        cin >> xs[i] >> ys[i];
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i == j){ continue; }
            if(abs(xs[i] - xs[j]) < d){
                // if(abs(xs[i] - ys[j]) < d){
                // }
                ts.add_clause(i, false, j, false);
            }
            if(abs(xs[i] - ys[j]) < d){
                ts.add_clause(i, false, j, true);
            }
            if(abs(ys[i] - xs[j]) < d){
                ts.add_clause(i, true, j, false);
            }
            if(abs(ys[i] - ys[j]) < d){
                ts.add_clause(i, true, j, true);
            }
        }
    }
    // for(int i = 0; i < n; i++){
    //     ts.add_clause(i, false, n + i, true);
    //     // ts.add_clause(n + i, false, i, true);
    // }
    // for(int i = 0; i < n; i++){
    //     int x = xs[i];
    //     for(int j = 0; j < n; j++){
    //         int y = ys[j];
    //         if(i != j && abs(x - y) < d){
    //             ts.add_clause(i, true, n + j, false);
    //             ts.add_clause(n + j, true, i, false);
    //         }
    //     }
    // }
    bool satisfiable = ts.satisfiable();
    cout << (satisfiable ? "Yes" : "No") << '\n';
    if(!satisfiable){
        return 0;
    }
    auto ans = ts.answer();
    printde(ans);
    for(int i = 0; i < n; i++){
        cout << (ans[i] ? xs[i] : ys[i]) << ' ';
    }
    cout << '\n';
}


Measured memory_bytes: 3284
/*
       Hi there <3 
──────▄▀▄─────▄▀▄
─────▄█░░▀▀▀▀▀░░█▄
─▄▄──█░░░░░░░░░░░█──▄▄
█▄▄█─█░░▀░░┬░░▀░░█─█▄▄█

*/
#include <bits/stdc++.h>
#define MOD 1000000007
#define re return
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repa(i, a, n) for (int i = a; i < n; i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define rrepa(i, a, n) for (int i = n; i >= a; i--)
#define fill(x, y) memset(x, y, sizeof(x))
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define ba back()
#define popcount __builtin_popcountll
#define fastIO()                 \
    {                            \
        ios::sync_with_stdio(0); \
        cin.tie(0);              \
        cout.tie(0);             \
    }
#define in(x) \
    int x;    \
    cin >> x;
#define in1(x) \
    int x;     \
    cin >> x;  \
    x--;
#define inll(x) \
    ll x;       \
    cin >> x;
#define ins(x) \
    string x;  \
    cin >> x;

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef pair<double, double> pdd;
typedef long double LD;
typedef double D;

void Solve()
{
    ll n;
    cin >> n;
    vll v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }

    int temp = 0;
    for (int i = 0; i < n; i++)
    {
        temp = temp ^ v[i];
    }
    int final = temp;
    for (int i = 0; i < n; i++)
    {
        temp = final ^ v[i];
        temp = ~temp;
        temp = temp * -1;
        temp--;
        cout << temp << " ";
    }

    cout << endl;
}

int main()
{
    fastIO();
    int t;
    t = 1;
    while (t--)
    {
        Solve();
    }
    return 0;
}

Measured memory_bytes: 4772
#include<stdio.h>

int main(){
    int a, b, sum, sub, mul, maior;
    scanf("%d %d", &a, &b);
    sum= a+b;
    sub= a-b;
    mul= a*b;
    maior=-999999999;
        if(sum>maior){
            maior=sum;
        }
        if(sub>maior){
            maior=sub;
        }
        if(mul>maior){
            maior=mul;
        }
        printf("%d\n", maior);
    return 0;
}

Measured memory_bytes: 128
import collections

n = int(input())
blue = []
for i in range(n):
    blue.append(input())

red = []   
m = int(input())
for i in range(m):
    red.append(input())
    
b1 = collections.Counter(blue)
r1 = collections.Counter(red)

ans = 0

for key, value in b1.items():
    if key in r1:
        tmp = b1[key] - r1[key]
        ans = max(ans, tmp)
    else:
        ans = max(ans, b1[key])
        
print(ans)

Measured memory_bytes: 9428
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int n;

int ltor(string s){
	int x=s[0]-'0';
	for(int i=1;i<s.size();i+=2){
		if(s[i] == '*') x *= s[i+1]-'0';
		if(s[i] == '+') x += s[i+1]-'0';
	}
	return x;
}
int mult(string s){
	stack<int> st;
	st.push(s[0]-'0');
	for(int i=1;i<s.size();i+=2){
		if(s[i] == '*') st.top() *= s[i+1]-'0';
		if(s[i] == '+') st.push(s[i+1]-'0');
	}
	int ans = 0;
	while(!st.empty()){
		ans += st.top();
		st.pop();
	}
	return ans;
}

main(){
	ios::sync_with_stdio(false);
	string s;
	cin >> s >> n;
	int ans = (ltor(s) == n)*2 + (mult(s) == n);
	puts(ans == 3 ? "U" : ans == 2 ? "L" : ans == 1 ? "M" : "I");
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define F first
#define S second
using namespace std;
string a,b;
ll memo[3005][3005];
ll solve(int i,int j)
{
    if(i == a.size() || j == b.size())
        return 0;
    if(~memo[i][j])
        return memo[i][j];
    ll ret = 0;
    if(a[i] == b[j])
        ret = max(ret,solve(i+1,j+1)+1);
    ret = max(ret,solve(i+1,j));
    ret = max(ret,solve(i,j+1));
    memo[i][j] = ret;
    return ret;
}

void print(int i,int j)
{
    if(i == a.size() || j == b.size())
        exit(0);
    ll ret = memo[i][j];
    if(a[i] == b[j])
    {
        cout << a[i];
        print(i+1,j+1);
    }
    if(solve(i+1,j)==ret)
        print(i+1,j);
    print(i,j+1);
}

int main()
{
    cin >> a>> b;
    memset(memo,-1,sizeof memo);
    solve(0,0);
    print(0,0);
    return 0;
}

Measured memory_bytes: 71296
cnt=0
l,p=[],[]
m,q={},{}
while 1:
    n,k=map(str,raw_input().split())
    cnt+=1
    n,k=int(n),float(k)
    l.append(k)
    m[k]=n
    if cnt%8==0:
        l.sort()
        for i in range(8):
            if i<2:
                print m[l[i]],'%.2f'%l[i]
            else:
                p.append(l[i])
                q[l[i]]=m[l[i]]
        l=[]
        m={}
    if cnt==24:
        break
p.sort()
for i in range(2):
    print q[p[i]],'%.2f'%p[i]

Measured memory_bytes: 6352
import java.util.Scanner;


public class Main {

	public static boolean eq(double a, double b) {
		return Math.abs(b-a) < 1e-10;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		for (int i = 0 ; i < n ; i++) {
			double xa = sc.nextDouble();
			double ya = sc.nextDouble();
			double ra = sc.nextDouble();
			double xb = sc.nextDouble();
			double yb = sc.nextDouble();
			double rb = sc.nextDouble();

			double ab = Math.sqrt((xb-xa)*(xb-xa)+(yb-ya)*(yb-ya));

			int sgn;
			if (ra > rb) {
				sgn = +1;
			} else {
				sgn = -1;
				double t = ra;
				ra = rb;
				rb = t;
			}

			if (ab > (ra+rb)) {
				System.out.println(0);
			} else if (eq(ab, ra+rb)) {
				System.out.println(1);
			} else if (ab < ra-rb) {
				System.out.println(sgn*2);
			} else {
				System.out.println(1);
			}

		}


	}
}

Measured memory_bytes: 20640