akhauriyash/Code-Regression huggingface dataset:
size, count = list(map(int,input().split()))
dices = list(map(int,input().split()))

max_sum = sum(dices[0:count])
now_sum = max_sum

for p,d in zip(dices,dices[count:]):
    now_sum = now_sum - p + d
    if max_sum < now_sum:
        max_sum = now_sum

print((max_sum+count)/2)

Measured memory_bytes: 25060
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;


vector<int> G[100010];
vector<int> path;
int f[100010];

void dfs(int now, int pre){
    // cout << now << endl;
    rep(i, 0, G[now].size()){
        int next = G[now][i];
        if(next != pre){
            if(f[next] == -1) continue;
            f[next] = 1;
            path[next] = now;
            dfs(next, now);
        }
    }
    return;
}  

signed main(){
    int n;
    cin >> n;
    path.resize(n, -1);
    rep(i, 0, n - 1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a]. push_back(b);
        G[b]. push_back(a);
    }
    dfs(0, -1);
    
    vector<int> root;
    int now = n - 1;
    root. push_back(now);
    while(1){
        int pre = path[now];
        root. push_back(pre);
        now = pre;
        if(pre == 0){
            break;
        }
    }
    // reverse(all(root));
    rep(i, 0, n) f[i] = 0;
    int sz = root.size();
    rep(i, 0, sz / 2){
        // cout << " " << root[i] ;
        f[root[i]] = -1;
    }
    // cout << endl;
    f[0] = 1;
    dfs(0, -1);
    int cnt = 0;
    rep(i, 0, n) if(f[i] == 1){
        // cout << i << endl;
        cnt++;
    }
    // cout << cnt << endl;
    if(cnt > n / 2) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
}

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

int main() {
  int X, Y;
  cin >> X >> Y;
  int prize=0;
  if(X==3){
    prize+=100000;
  }
  if(X==2){
    prize+=200000;
  }
  if(X==1){
    prize+=300000;
  }
  if(Y==3){
    prize+=100000;
  }
  if(Y==2){
    prize+=200000;
  }
  if(Y==1){
    prize+=300000;
  }
  if(X==1&&Y==1){
    prize+=400000;
  }
    cout<<prize<<endl;
}


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

int main() {
    int c[4][4],x[4],y[4];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> c[i][j];
        }
    }
    x[0]=0;
    for(int i=0;i<3;i++)y[i]=c[0][i]-x[0];
    for(int i=0;i<3;i++)x[i]=c[i][0]-y[0];
    bool good = true;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(x[i]+y[j]!=c[i][j]){
                good = false;
            }
        }
    }
    if(good) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
/*
shakespere said: 

I always feel happy, you know why? Because I don’t expect anything from anyone; expectations always hurt. Life is short. So love your life. Be happy. And keep smiling.

Just live for yourself and always remember:

Before you speak… Listen
Before you write… Think
Before you spend… Earn
Before you pray… Forgive
Before you hurt… Feel
Before you hate… Love
Before you quit… Try
Before you die… Live
/**********************************************
#code by --> @ { shadat </> sk40 [ o_o  ^_^ ] } }
-----------------------------------------------
# The Quick Brown Fox Jumps over the Lazy Dog. 
**********************************************/
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
 
const ll inf = 1e18;
const int N = 1 * 1e5 + 10;
 
ll res;
std::vector<ll> v[N];
std::map<ll, ll> mp;
std::vector<pair<ll, ll>> vv;
std::vector<ll> x, xx;
bool isprime(ll n){
    if(n<=1) return false;
    if(n==2 || n==3) return true;
    if(n%2==0 || n%3==0) return false;
    for(ll i=5;i*i<=n;i+=6){
        if(n%i==0 || n%(i+2)==0) return false;
    }
    return true;
} 

int mss() {    
        	ll n;
    	cin >> n;
    	vv.push_back({0, 0});
    	for (int i = 1; i <= n; ++i){
    		ll len;
    		ll mx = 0, mn = inf;
    		cin >> len;
    		for (int j = 0; j < len; ++j){
    			cin >> res;
    			mx = max(res, mx);
    			mn = min(res, mn);
    			v[i].push_back(res);
    		}
    		vv.push_back({mn, mx});
    	}
    	for (int i = 1; i <= n; ++i){
    		std::map<ll, ll> mpp;
    		mpp[0]++;
    		for(auto j : v[i]){
    			mpp[j]++;
    		}
    		bool flag = 0;
    		for(auto j : v[i]){
    			mpp[j]--;
    			if(!mpp[j])mpp.erase(j);
    			auto itr = mpp.rbegin();
    			if(itr->first > j) {flag = 1; break;}
    		}
    		if(!flag){mp[i]++;}
    		mpp.clear();
    	}
    	ll ans = (n - mp.size()) * n + mp.size() * (n - mp.size());
     
    	for(auto i : mp){
    		x.push_back(vv[i.first].first);
    		xx.push_back(vv[i.first].second);
    	}
    	sort(x.begin(), x.end());
    	sort(xx.begin(), xx.end());
     
    	for (int i = 0; i < x.size(); ++i){
    		auto idx = upper_bound(xx.begin(), xx.end(), x[i]) - xx.begin();
    		ans += xx.size() - idx;
    	}
    	cout << ans;

	return 0;
}
struct record{
	short bit;
	short up;
	short down;
	short vrtx;
}; 
int main(){
   int a,b;
   cin>>a>>b;
   string x[b],y[a];
   for(int i=0;i<b;i++) x[i]=to_string(a);
   for(int i=0;i<a;i++) y[i]=to_string(b);
   if(lexicographical_compare(x,x+b,y,y+a)){
       for(int i=0;i<b;i++) cout<<x[i];
   }
   else{
       for(int i=0;i<a;i++) cout<<y[i];
   }
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h> 
typedef long long LL; 
int main()
{
	LL sum=1;
	LL D,M;
	scanf("%lld%lld",&D,&M);
	if(D<M)
	{
		LL zhan=D;
		D=M;
		M=zhan;
	}
	if(D-M>1)
		printf("0\n");
	else
	{
		for(LL l=1;l<=D;l++)
		{
			sum=(sum*l)%1000000007;
		}
		for(LL l=1;l<=M;l++)
			sum=(sum*l)%1000000007;
		if(D==M)
			sum=(sum*2)%1000000007;
		printf("%lld\n",sum);
	}
	
    return 0;
 } 

Measured memory_bytes: 128
#include<stdio.h>
int main(){
   int k,a,b,judg=0;
   scanf("%d",&k);
   scanf("%d%d",&a,&b);
   for(int i=a;i<=b;i++){
      if(i%k==0){
         judg++;
         break;
      }
   }
   if(judg==0){
      printf("NG");
   }else{
      printf("OK");
   }
   return 0;
}
         


Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,M;
    cin >> N >> M;
    vector<long long> a(N),b(N),c(M),d(M);
    vector<pair<long long,long long>> P(N),Q(M);
    for(int i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
        P[i] = make_pair(a[i],b[i]);
    }
    for(int i = 0; i < M; i++){
        cin >> c[i] >> d[i];
        Q[i] = make_pair(c[i],d[i]);
    }
    
    for(int i = 0; i < N; i++){
        long long ans = 0;
        int D = 1000000000;
        for(int j = M-1; 0 <= j; j--){
            int NowD = abs(P[i].first - Q[j].first) + abs(P[i].second - Q[j].second);
            D = min(NowD,D);
            if(D == NowD) ans = j + 1; 
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


int main() {
	ll a, b;
	cin >> a >> b;
	cout << max({ a + b,a - b,a*b }) << endl;
}
	

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  double are,circ,r;
  scanf("%lf",&r);
  
  are = 2 * r * 3.141592653589;
circ = 3.141592653589 * r * r;
printf("%.6lf %.6lf\n",circ,are);
  return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define reg(i,a,b) for(int i=a;i<b;i++)
#define reh(i,a,b) for(int i=a;i>=b;i--)
#define in(x) scanf("%d",&x)
#define fro freopen("D:\\testdata.in", "r", stdin)
#define il inline
using namespace std;
typedef long long ll;
const int mx=1e5+10;


int main() {
	int a,b,k;
	in(a),in(b),in(k);
	int tem=min(k,b/a);
	printf("%d",tem<=k?tem:k);
	return 0;
}



Measured memory_bytes: 256
<?php

[$N ] = fscanf(STDIN, "%d");
$ans= 0;
$ans = array_fill(1,$N,0);
for($x=1;$x<100;$x++){
    for($y=1;$y<100;$y++){
        for($z=1;$z<100;$z++){
            $tmp = $x**2 + $y**2 + $z**2 + $x * $y + $y * $z + $z * $x;
            if($tmp<=$N){
                $ans[$tmp]++;
            }
        }
    }
}

echo implode("\n", $ans);

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

int main()
{
int A;
int P;

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

	cin >> A;
	cin >> P;

	cout << ( 3 * A + P ) / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    #include <ext/pb_ds/tree_policy.hpp> 
    #include <functional> // for less 
    using namespace __gnu_pbds; 
    using namespace std;
    //typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;    
    #define ll            long long
    #define pb            push_back
    #define ppb           pop_back
    #define si            set <ll>
    #define endl          '\n'
    #define fr            first
    #define sc            second
    #define mii           map<ll,ll>
    #define msi           map<string,ll>
    #define mis           map<ll,string>
    #define rep(i,a,b)    for(ll  i=a;i<b;i++)
    #define all(v)        v.begin(),v.end()
    #define sort(v)       sort(all(v))
    #define pii           pair<ll ,ll >
    #define vi            vector<ll >
    #define vii           vector<pair<ll,ll>>
    #define vs            vector<string>
    #define sz(x)         (ll)x.size()
    #define M             1000000007
    #define bs            binary_search
    #define rev(a)        reverse(all(a));
    #define sp(n)         setprecision(n)
    #define spl           " "
    #define arr(a,n)      rep(i,0,n) cin>>a[i]
    #define mod           998244353
    #define print_vector(a)  for(auto t:a) cout<<t<<" ";cout<<endl;
    #define print_arr(a,n)   rep(i,0,n) cout<<a[i]<<" "; cout<<endl;        
    #define show(a,n)     for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
    #define debug(x)      cout << #x << " is " << x << endl;
    #define time          cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    #define INF           1ll<<31
    #define hi            cout<<"hi"<<endl;
    const ll maxn=int(3e5)+500;
    const ll maxa=(1<<20)+3;
    ll bpow(ll a, ll b, ll mm = M)
    {
        ll res = 1;
     
        while(b)
        {
            if(b & 1)
                res = (res * a) % mm;
            a = (a * a) % mm;
     
            b >>= 1;
        }
     
        return res;
    }
    bool cmp(pair<ll,ll> a,pair<ll,ll> b)
    {
      if(a.sc!=b.sc) return a.sc<b.sc;
      else return a.fr<b.fr;
    }
    void solve()
    {
     ll n;
     cin>>n;
     vi v(n);arr(v,n);
     vi b=v;
     sort(b);
     ll x=b[n-1];
     ll y=b[n-2];
     for(auto t:v) if(t==x) cout<<y<<endl; else cout<<x<<endl;

    } 
    signed main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        ll t=1;
        //cin>>t;
        while(t--) solve();
    }

  

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

int main(){
    ll A, B, K;
    cin >> A >> B >> K;
    if (A < K) {
        K = K - A;
        A = 0;
        if (B < K) {
            B = 0;
        } else {
            B = B - K;
        }
    } else {
        A = A - K;
    }
    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

class Radix {
private:
  const char* s;
  int a[128];
public:
  Radix(const char* s = "0123456789ABCDEF") : s(s) {
    int i;
    for(i = 0; s[i]; ++i)
      a[(int)s[i]] = i;
  }
  std::string to(long long p, int q) {
    int i;
    if(!p)
      return "0";
    char t[64] = { };
    for(i = 62; p; --i) {
      t[i] = s[p % q];
      p /= q;
    }
    return std::string(t + i + 1);
  }
  std::string to(const std::string& t, int p, int q) {
    return to(to(t, p), q);
  }
  long long to(const std::string& t, int p) {
    int i;
    long long sm = a[(int)t[0]];
    for(i = 1; i < (int)t.length(); ++i)
      sm = sm * p + a[(int)t[i]];
    return sm;
  }
};


string bist(ll n, ll dig){
    Radix r;
    string p = r.to(n, 2);
    string q = "";
    if(p.size() < dig){
        for(int i=0; i<dig - p.size(); i++){
            q += '0';
        }
        p = q + p;
    }
    return p;
} //［警告］nbaseの呼び出しを先にすること

int main(){
    ll n; string s; cin >> n >> s;
    map<char, ll> m;
    rep(i, 0, n){
        m[s[i]]++;
    }
    ll f = sz(m);
    ll ans = 1;
    for(auto x: m){
        ans *= x.second+1;
        ans %= M;
    }
    prtl(ans - 1);
}



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

int main(){
  long long int n,d;
  cin >> n >> d;
  vector<long long int> x(n);
  vector<long long int> y(n);
  int sum = 0;
  long long int xx,yy;
  long long int dd = d*d;
  for(long long int i = 0; i < n; i++){
    cin >> x.at(i) >> y.at(i);
    xx = x.at(i) * x.at(i);
    yy = y.at(i) * y.at(i);
    if(xx+yy <= dd)sum++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 6420
#include<iostream>
using namespace std;
int main()
{
	unsigned int a, b, c, d, p, w_x, w_y;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	cin >> p;
	w_x = a * p;
	if (p < c){
		w_y = b;
	}
	else{
		w_y = b + (p - c) * d;
	}
	if (w_x < w_y){
		cout << w_x << endl;
	}
	else{
		cout << w_y << endl;
	}
}

Measured memory_bytes: 1152
#include <iostream>

using namespace std;
int main(){
  int n;cin>>n;
  int A[n][10];
  for(int i = 0; n > i; i++){
    for(int j = 0; 10 > j; j++){
      cin>>A[i][j];
    }
  }
  int B[n][11];
  for(int i = 0; n > i; i++){
    for(int j = 0; 10 >= j; j++){
      cin>>B[i][j];
    }
  }
  long long ans = -1000000000000;
  for(int bit = 1; (1<<10) > bit; bit++){
    long long tmp = 0;
    for(int i = 0; n > i; i++){
      long long nw = 0;
      for(int j = 0; 10 > j; j++){
        if(bit & (1<<j)){
          if(A[i][j]){
            nw++;
          }
        }
      }
      tmp += B[i][nw];
    }
    
    ans = max(ans,tmp);
  }
  cout << ans << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

#define minimum(a)					*min_element(a.begin(), a.end())
#define maximum(a)					*max_element(a.begin(), a.end())
#define fo(i,a,b)                   for(int i=a;i<=b;i++)
#define fo2(i, a, b)                for(int i = a; i>=b; i--)
#define foreach(x, v)               for(auto x : v)
#define all(v)                      v.begin(), v.end()
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define mp make_pair

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin>>n>>m;
    int l, r;
    l = 1;
    r = n;
    for(int i = 0; i<m; i++){
        int l1, r1;
        cin>>l1>>r1;
        l = max(l, l1);
        r = min(r, r1);
    }

    if(r >= l){
        cout<<(r-l+1)<<endl;
    }else{
        cout<<0<<endl;
    }

    
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

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

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
  char tmp = S[0];
  REP(i, 3){
    if(tmp != S[i]) { cout << "Yes" << endl; return; }
  }
  cout << "No" << endl;
  return;
}

int main(){
    std::string S;
  std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
long long A[100000];
int ok[60];
int main(){
  int i;
  int j;
  int k;
  long long res = 0;
  long long s = 0;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(i=0;i<(N);i++){
    s ^= A[i];
  }
  for(i=0;i<(60);i++){
    if(s & (1LL<<i)){
      res += (1LL<<i);
      for(j=0;j<(N);j++){
        if(A[j] & (1LL<<i)){
          A[j] ^= (1LL<<i);
        }
      }
    }
  }
  k = 0;
  for(i=59; i>=0; i--){
    for(j=(k);j<(N);j++){
      if(A[j] & (1LL<<i)){
        break;
      }
    }
    if(j==N){
      continue;
    }
    if(j!=k){
      swap(A[k], A[j]);
    }
    for(j=(k+1);j<(N);j++){
      if(A[j] & (1LL<<i)){
        A[j] ^= A[k];
      }
    }
    k++;
    if(k >= N){
      break;
    }
  }
  s = 0;
  for(i=0;i<(N);i++){
    if(s < (s^A[i])){
      s ^= A[i];
    }
  }
  res += 2*s;
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190914-1

// --- original code ---
// int N;
// ll A[1d5];
// int ok[60];
// {
//   int i, j, k;
//   ll res = 0, s = 0;
//   
//   rd(N,A(N));
//   rep(i,N) s ^= A[i];
// 
//   rep(i,60) if(s & (1LL<<i)){
//     res += (1LL<<i);
//     rep(j,N) if(A[j] & (1LL<<i)) A[j] ^= (1LL<<i);
//   }
// 
//   k = 0;
//   for(i=59; i>=0; i--){
//     rep(j,k,N) if(A[j] & (1LL<<i)) break;
//     if(j==N) continue;
//     if(j!=k) swap(A[k], A[j]);
//     rep(j,k+1,N) if(A[j] & (1LL<<i)) A[j] ^= A[k];
//     k++;
//     if(k >= N) break;
//   }
// 
//   s = 0;
//   rep(i,N) if(s < (s^A[i])) s ^= A[i];
//   res += 2s;
// 
//   wt(res);
// }


Measured memory_bytes: 1024
def f(x, A, B):
    return ((A*x)//B) - A*(x // B)

def main():
    A, B, N = map(int, input().split())
    ans = -1
    for x in range(min(B-1, N), max(min(B-1, N)-N, -1), min(-B+1, -1)):
        ans = max(ans, f(x, A, B))
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 61884
#include <iostream>
using namespace std;
 
int main() {
 	
 	int n, cont = 0;
    cin >> n;
    
    int p[n];
    for (int i = 0; i < n; ++i)
    {
        cin >> p[i];
    }

    for (int i = 1; i < n-1; ++i)
    {
        if (p[i] > p[i+1] || p[i] > p[i-1])
        {
            if (p[i] < p[i+1] || p[i] < p[i-1])
            {
                cont++;            }
        }
    }
    cout << cont << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
int main()
{
    fastio;
    int n,m;cin>>n>>m;
    double a[n];
    double sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    int c=0;
    double d=sum/(4*m);
    for(int i=0;i<n;i++)
    {
        if(a[i]>=d)
        c++;
    }
    if(c>=m)
    cout<<"Yes";
    else 
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long a, b, x, ans;
    cin >> a >> b >> x;
    if (a >= 1) {
        ans = b / x + 1 - ((a - 1) / x + 1);
    } else {
        ans = b / x + 1;
    }
    cout << ans << endl;
}
/*
a以上b以下に存在する、xの約数の数：
(0以上b以下の約数の数)-(0以上a「未満」の約数の数)
0も約数なので+1。
*/

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	cin >> n;
	vector<string> s(n);
	rep(i, n) cin >> s[i];
	vector<int> a(26, INF);
	rep(i, n) {
		vector<int> cnt(26);
		rep(j, s[i].size()) {
			cnt[s[i][j] - 'a']++;
		}
		rep(j, 26) {
			chmin(a[j], cnt[j]);
		}
	}
	string ans = "";
	rep(i, 26) {
		rep(j, a[i]) {
			char c = 'a' + i;
			ans += c;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
  string s;
  cin >> s;
  int start, end;
  for (int i = 0; i < s.length(); i++) {
    if (s.at(i) == 'A') {
      start = i;
      break;
    }
  }
  for (int j = s.length() - 1; j >= 0; j--) {
    if (s.at(j) == 'Z') {
      end = j;
      break;
    }
  }
  cout << end - start + 1 << endl;
}


Measured memory_bytes: 640
import math
A,B,C = map(int,input().split())
k = [A,B,C]
k.sort()
k.reverse()
ans = 0
ans += k[0]-k[1]
now = k[2]
now += ans
if (k[0]-now)%2 == 0:
    ans += math.ceil((k[0]-now)/2)
    print(ans)
else:
    ans += math.ceil((k[0]-now)/2)
    ans += 1
    print(ans)


Measured memory_bytes: 9152
n = int(input())
m = [9 ** i for i in range(6)]
m += [6 ** i for i in range(1, 7)]
m.sort()
dp = [float("inf") for i in range(n + 1)]
dp[0] = 0
for i in range(n):
    for j in m:
        if i + j <= n:
            dp[i + j] = min(dp[i + j], dp[i] + 1)
print(dp[-1])

Measured memory_bytes: 6296
#include <stdio.h>
     
    int main(void){
        int n;
        int a;
        int min = 1000;
        int max = 0;
     
        scanf("%d",&n);
     
        for(int i = 0;i < n;i++){
            scanf("%d",&a);
        
            if(a < min){
                min = a;
            }
            if(a > max){
                max = a;
            }
        }
        printf("%d\n",max - min);

        return 0;
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,a,b;
    cin >> n >> a >> b;
    string s;
    cin >> s;

    bool ans[n];
    rep(i,n) ans[i] = false;

    int cnt_a=0;
    int cnt_b=0;

    rep(i,n)
    {
        if(s[i]=='a')
        {
            if (cnt_a+cnt_b<a+b)
            {
                ans[i] = true;
                cnt_a++;
            }
        }
        else if (s[i]=='b')
        {
            if (cnt_a+cnt_b<a+b && cnt_b<b)
            {
                ans[i] = true;
                cnt_b++;
            }
        }
    }

    rep(i,n)
    {
        if (ans[i])
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
        
    }
    
}


Measured memory_bytes: 976
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
ll MOD = 1000000007LL;
ll mod_pow(ll a, ll b) {
	if (b == 0) return 1;
	if (b % 2 == 0) {
		ll x = mod_pow(a, b / 2);
		return (x*x) % MOD;
	}
	return (a*mod_pow(a, b - 1)) % MOD;
}
ll fact[300001];
ll inv_fact[300001];
ll comb(ll n, ll k) {
	if (n < k) return 0;
	ll ret = fact[n];
	(ret *= inv_fact[k]) %= MOD;
	(ret *= inv_fact[n - k]) %= MOD;
	return ret;
}
int main() {
	fact[0] = inv_fact[0] = 1;
	for (int i = 1; i <= 300000; i++) {
		fact[i] = (fact[i - 1] * i) % MOD;
		inv_fact[i] = (inv_fact[i - 1] * mod_pow(i, MOD - 2)) % MOD;
	}
	int N, M, K;
	cin >> N >> M >> K;
	ll ans = 0;
	for (int i = 0; i <= K; i++) {
		ll sum = comb(N + M + 2 * K, N + 2 * i);
		ll X = comb(N + 2 * i, N + i);
		if (i > 0) (X += MOD - comb(N + 2 * i, i - 1)) %= MOD;
		ll Y = comb(M + 2 * (K - i), M + (K - i));
		if (K - i > 0) (Y += MOD - comb(M + 2 * (K - i), K - i - 1)) %= MOD;
		(sum *= X) %= MOD;
		(sum *= Y) %= MOD;
		(ans += sum) %= MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 7804
from collections import defaultdict

n = int(input())
S = input()
A = S[:n]
B = S[n:][::-1]
Da = defaultdict(int)
Db = defaultdict(int)
ans = 0
for i in range(2**n):
  a1, a2 = "", ""
  for j in range(n):
    if i>>j & 1:
      a1 += A[j]
    else:
      a2 += A[j]
  Da[(a1, a2)] += 1
for i in range(2**n):
  b1, b2 = "", ""
  for j in range(n):
    if i>>j & 1:
      b1 += B[j]
    else:
      b2 += B[j]
  Db[(b1, b2)] += 1

for k in Da:
  ans += Da[k] * Db[k]
print(ans)

Measured memory_bytes: 199292
N = int(input())

if 400 <= N <= 599: print(8)
elif 600 <= N <= 799: print(7)
elif 800 <= N <= 999: print(6)
elif 1000 <= N <= 1199: print(5)
elif 1200 <= N <= 1399: print(4)
elif 1400 <= N <= 1599: print(3)
elif 1600 <= N <= 1799: print(2)
elif 1800 <= N <= 1999: print(1)


Measured memory_bytes: 9176
//http://arc078.contest.atcoder.jp/tasks/arc078_a
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    int n;
    cin>>n;
    int v[n];
    ll cs[n];
    ll sum = 0;
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
        sum+=(ll)v[i];
        cs[i] = sum;
    }
    if(n==2)
    {
        cout<<abs(v[0]-v[1])<<'\n';
        return 0;
    }
    ll ans= numeric_limits<long long>::max();
    for(int i=0;i<n-1;i++)
    {
        ll k = sum - (ll)cs[i];
        ans = min(ans,abs((ll)cs[i] - k));
        //printf("ind: %d, diff: %d\n",i,abs(cs[i]-k));
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 2560
# AOJ 1593: Star
# Python3 2018.7.13 bal4u

import math
PI = 3.1415926535897932384626433832795
# area = n*r^2*sin(180/n)*cos(180k/n)*sec(180(k-1)/n), for n/k star
N, K = map(int, input().split())
print(N*math.sin(PI/N)*math.cos(K*PI/N)/math.cos((K-1)*PI/N))


Measured memory_bytes: 5692
fun readInts() = readLine()!!.split(' ').map(String::toInt)

fun main(args: Array<String>) {
    val (d, g) = readInts()
    val pp = IntArray(d)
    val cc = IntArray(d);
    for (i in 0 until d) {
        val (p, c) = readInts()
        pp[i] = p
        cc[i] = c
    }
    var ans = Int.MAX_VALUE
    root@for (i in 0 until (1 shl d)) {
        var solved = 0
        var score = 0
        for (j in 0 until d) {
            if (i and (1 shl j) == 0) continue
            solved += pp[j]
            score += 100 * (j + 1) * pp[j] + cc[j]
        }
        if (g <= score) {
            ans = Math.min(ans, solved)
            continue
        }
        for (j in d - 1 downTo 0) {
            if (i and (1 shl j) != 0) continue
            for (k in 0 until pp[j]) {
                solved++
                score += 100 * (j + 1)
                if (g <= score) {
                    ans = Math.min(ans, solved)
                    continue@root
                }
            }
        }
    }
    println(ans)
}


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

#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for ( int i = 0 ; i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

vector<Pii> G[101];
int min_bridge = INF;
int ord[101], low[101];
bool vis[101];

void dfs(int v, int p, int &k) {
  vis[v] = true;

  ord[v] = k++;
  low[v] = ord[v];

  Rep(i, G[v].size()) {
    if ( !vis[G[v][i].fr] ) {
      dfs(G[v][i].fr, v, k);
      low[v] = min(low[v], low[G[v][i].fr]);      
      if ( ord[v] < low[G[v][i].fr] ) min_bridge = min(min_bridge, G[v][i].sc);
    } else if ( G[v][i].fr != p ) {
      low[v] = min(low[v], ord[G[v][i].fr]);
    }        
  }
  
}

void dfs2(int v) {
  if ( vis[v] ) return;
  vis[v] = true;
  Rep(i, G[v].size()) {
    dfs2(G[v][i].fr);
  }  
}

signed main() {
  int n, m;
  while ( cin >> n >> m, n | m ) {
    int minus_cost = 0;
    min_bridge = INF;
    int min_1 = INF, min_2 = INF;
    Rep(i, 101) {
      G[i].clear();
      vis[i] = false;
    }
    
    Rep(i, m) {
      int a, b, c;
      cin >> a >> b >> c;
      if ( c <= 0 ) minus_cost += c;
      else {
	if ( min_1 > c ) min_2 = min_1, min_1 = c;
	else if ( min_2 > c ) min_2 = c;
	G[a].pb(Pii(b, c));
	G[b].pb(Pii(a, c));
      }
    }

    dfs2(0);
    bool is_connected = true;
    Rep(i, n) {
      if ( !vis[i] ) {
	is_connected = false;
	break;
      }
    }

    if ( !is_connected ) {
      cout << minus_cost << endl;
      continue;
    }
    
    Rep(i, n) vis[i] = false;
    int k = 0;
    Rep(i, n) {
      if ( !vis[i] ) dfs(i, -1, k);
    }

    if ( min_bridge == INF ) cout << minus_cost << endl;
    else cout << min(min_bridge, min_1+min_2) + minus_cost << endl;
  }

  return 0;
}

Measured memory_bytes: 3084
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    string s,t,u;
    cin>>s>>t>>a>>b>>u;
    if(u==s){
        a--;
    }else if(u==t){
    b--;
    }
    cout<<a<<" "<<b;
    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
mod=10**9+7
U = 4*10**5+1
MOD = 10**9+7

fact = [1]*(U+1)
fact_inv = [1]*(U+1)

for i in range(1,U+1):
  fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U],MOD-2,MOD)

for i in range(U,0,-1):
	fact_inv[i-1] = (fact_inv[i]*i)%MOD

def comb(n,k):
  if k < 0 or k > n:
    return 0
  x = fact[n]
  x *= fact_inv[k]
  x %= MOD
  x *= fact_inv[n-k]
  x %= MOD
  return x

if n-1<=k:
    print(comb(2*n-1,n-1))
else:
    ans=0
    for i in range(1+k):
        ans+=comb(n,i)*comb(n-1,n-i-1)
        ans%=mod
    print(ans)




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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;

lint euclid( lint a, lint b ){
    lint temp;

    if( a < b ) { temp = a; a = b; b = temp; }
    if( b < 1 ) return -1;

    if( a % b == 0 ) return b;
    return euclid( b, a % b );
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    lint n; cin>>n;
    vector<lint> a(n);
    REP(i,n) cin>>a[i];
    vector<lint> l(n);//それより左のgcd
    vector<lint> r(n);//それより右のgcd
    l[0] = a[0];		//l0=a0
    r[n-1] = a[n-1];	//ln-1=an-1
    REP(i,n-1) l[i+1] = euclid(a[i+1],l[i]);					//最初にl1  =gcd(a1,  l0)
    for(int i = n-1; i>0; i--) r[i-1] = euclid(a[i-1],r[i]);	//最初にln-2=gcd(al-2,ln-1)
    
/*	
12 15 18
--------
12  3  3 l:そこより左の全てのgcd
3   3 18 r:そこより右の全てのgcd
*/


	lint tmp = r[1];
	FOR(i,1,n-1){//tmp=a[i]以外のgcdを求め、ans=max(tmp)を求める
        tmp = max(tmp, euclid(l[i-1], r[i+1]));//tmp=gcd(それより左のgcd,それより右のgcd)
	}
    tmp = max(tmp,l[n-2]);
    print(tmp);
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main() {
	int n, m, count = 0,countt=0;
	vector<string> s;
	vector<string> ss;

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

	cin >> m;
	ss.resize(m);
	for (int i = 0; i < m; i++) {
		cin >> ss[i];
		for (int j = 0; j < n; j++) {
			if (ss[i] == s[j]) {
				countt++;
				count++;
				if (count % 2 == 1) {
					cout << "Opened by " + ss[i] << endl;
				}
				else {
					cout << "Closed by " + ss[i] << endl;
				}
			}
		}
		if (countt == 0) {
			cout << "Unknown " + ss[i] << endl;
		}
		countt = 0;
	}
}

Measured memory_bytes: 3224
n=int(input())
if n in range(400,600):
    print(8)
elif n in range(600,800):
    print(7)
elif n in range(800,1000):
    print(6)
elif n in range(1000,1200):
    print(5)
elif n in range(1200,1400):
    print(4)
elif n in range(1400,1600):
    print(3)
elif n in range(1600,1800):
    print(2)
else:
    print(1)


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

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

    int k;
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= n - i; j++) {
            k = n - i - j;
            if(10000 * i + 5000 * j + 1000 * k == y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}


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

int main() {
	vector<int> o1(100000);
	vector<int> o2(50000);
	int n1;
	int n2;
	int count = 0;
	int n;
	cin >> n1;
	for (int i = 0; i < n1; i++)
	{
		cin >> o1[i];
	}
	sort(o1.begin(), o1.end());
	cin >> n2;
	for (int j = 0; j < n2; j++)
	{
		cin >> o2[j];
	}
	for (int i = 0; i < n2; i++)
	{
		if(binary_search(o1.begin(), o1.end(), o2[i]))
                      {
			count++;
                      }
	}
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3348
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))

# ===CODE===

eps = 10 ** (-9)


def main():
    h, w, k = ns()
    c = [list(input()) for _ in range(h)]

    ans = 0
    for i in range(2 ** w):
        wlist = [1 for _ in range(w)]
        for t in range(w):
            if i >> t & 1:
                wlist[t] = 0

        for j in range(2 ** h):
            hlist = [1 for _ in range(h)]
            for t in range(h):
                if j >> t & 1:
                    hlist[t] = 0

            cnt = 0
            for x in range(w):
                for y in range(h):
                    if c[y][x] == "#" and wlist[x] and hlist[y]:
                        cnt += 1

            if cnt == k:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10872
a,b,k = gets.split(" ").map(&:to_i)

array1 = []
array2 = []
a.times.each do |i|
  if a % (i + 1) == 0
    array1 << i + 1
  end
end

b.times.each do |j|
  if b % (j + 1) == 0
    array2 << j + 1
  end
end

array3 = []
array3 = array1 & array2

puts array3[-k]


Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<cstdlib>
#define neko 300010
#define chkmin(a,b) ((a)<(b)?(a):(b))
#define chkmax(a,b) ((a)>(b)?(a):(b))
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~i))
#define rf(i,a,b) for(register int i=(a);i>=(b);i=~(-i))
long long A,B,C,X,Y,a[neko];
int main()
{
	scanf("%lld%lld%lld%lld%lld",&A,&B,&C,&X,&Y);
	if(X>Y)std::swap(X,Y),std::swap(A,B);
	a[1]=X*2*C+(Y-X)*B,a[2]=X*A+Y*B,a[3]=Y*2*C;
	printf("%lld\n",chkmin(chkmin(a[1],a[2]),a[3]));
	return 0;
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(a,b) for(int a=0; a<(b); ++a)
#define FWD(a,b,c) for(int a=(b); a<(c); ++a)
#define FWDS(a,b,c,d) for(int a=(b); a<(c); a+=d)
#define BCK(a,b,c) for(int a=(b); a>(c); --a)
#define ALL(a) (a).begin(), (a).end()
#define SIZE(a) ((int)(a).size())
#define VAR(x) #x ": " << x << " "
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
#define gcd __gcd
#define x first
#define y second
#define st first
#define nd second
#define pb push_back

using namespace std;

template<typename T> ostream& operator<<(ostream &out, const vector<T> &v){ out << "{"; for(const T &a : v) out << a << ", "; out << "}"; return out; }
template<typename S, typename T> ostream& operator<<(ostream &out, const pair<S,T> &p){ out << "(" << p.st << ", " << p.nd << ")"; return out; }

typedef long long LL;
typedef pair<int, int> PII;
typedef long double K;
typedef vector<int> VI;

const int dx[] = {0,0,-1,1}; //1,1,-1,1};
const int dy[] = {-1,1,0,0}; //1,-1,1,-1};

int n;
int A[3010];
vector<int> out[3010];
bool vis[3010];

bool check(int u){
	vis[u] = 1;
	for(int v : out[u]) if(!vis[v] && A[v] < A[u] && !check(v))
		return 1;
	return 0;
}

int main(){
	scanf("%d", &n);
	FWD(i,1,n+1) scanf("%d", &A[i]);
	FWD(i,1,n){
		int a, b;
		scanf("%d %d", &a, &b);
		out[a].push_back(b);
		out[b].push_back(a);
	}
	FWD(i,1,n+1){
		FWD(j,1,n+1) vis[j] = 0;
		if(check(i)) printf("%d ", i);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 18 09:56:28 2020

@author: liang
"""
from math import ceil

N, K = map(int, input().split())
A = [int(x) for x in input().split()]
ans = ceil((N-K)/(K-1)) + 1
print(ans) 

Measured memory_bytes: 20376
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#define DEBUG 1
#define dd if (DEBUG)

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, A) for (auto & a : A)
#define all(a) (a).begin (), (a).end ()
#define rall(a) (a).rbegin (), (a).rend ()
#define sz(a) (int) (a).size ()
#define szl(a) (int) (a).length ()
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit);

typedef long long ll;
typedef pair <int, int> pii;
#define f first
#define s second
#define mp(a, b) make_pair((a), (b))
typedef vector <int> vi;
typedef vector <vi> mi;
typedef vector <ll> vll;
typedef vector <vll> mll;
#define pb(a) push_back ((a))

const ll MOD = 1e+9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int INFi = 0x3f3f3f3f;
const ll MAXN = 1e+6+7;

int main ()
{
    FASTIO;
    int i, j, n;
    cin >> i >> j;
    if (i == j) cout << "Yes";
    else cout << "No";
    cout << "\n";

    return 0;
}




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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] T = new int[N];
            int[] A = new int[N];
            for (int i = 0; i < N; i++)
            {
                string[] vals = Console.ReadLine().Split(' ');
                T[i] = int.Parse(vals[0]);
                A[i] = int.Parse(vals[1]);
            }

            long TT = T[0];
            long AA = A[0];
            for (int i = 1; i < N; i++)
            {
                long t = TT / T[i] + (TT % T[i] == 0 ? 0 : 1);
                long a = AA / A[i] + (AA % A[i] == 0 ? 0 : 1);
                TT = Math.Max(t, a) * T[i];
                AA = Math.Max(t, a) * A[i];
            }
            Console.WriteLine(TT + AA);

        }
    }
}


Measured memory_bytes: 2904
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	if(n*a<b)
		cout<<n*a;
	else if(b<n*a)
		cout<<b;
	else 
		cout<<b;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;
int a[100000];
int main(){
  int N;
  cin >> N;
  REP(i,N) cin >> a[i];
  ll ans;
  ll cnt = 0;
  ll sum = 0;
  REP(i,N){
    sum += a[i];
    if(i%2 == 0 && sum <= 0){
      cnt += 1-sum;
      sum = 1;
    }
    else if(i%2 == 1 && sum >= 0){
      cnt += 1+sum;
      sum = -1;
    }
  }
  ans = cnt;
  sum = 0;
  cnt = 0;
  REP(i,N){
    sum += a[i];
    if(i%2 == 0 && sum >= 0){
      cnt += 1+sum;
      sum = -1;
    }
    else if(i%2 == 1 && sum <= 0){
      cnt += 1-sum;
      sum = 1;
    }
  }
  ans = min(cnt,ans);
  cout << ans << endl;
  return 0;
}


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

#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define reset(x, y) memset(x, y, sizeof(x))
#define BUG(x) cerr << #x << " = " << (x) << endl
#define BUGP(x) cout << #x << " = " << (x)._1 << ", " << (x)._2 << endl
using namespace std;

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

const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
// Head

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

    int a, b;
    cin >> a >> b;

    LL ans = LL(a) * b;
    ans /= __gcd(a, b);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll M = 1000000000;
ll combi(ll m){
  return m*(m-1)/2;
}
int main(){
  int N;
  cin >> N;
  ll Sum[N+1], A;

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

  sort(Sum, Sum+(N+1));

  ll ans = 0;
  int i =0;
  while(i<=N){
    ll cnt = 1;
    while(i<N && Sum[i]==Sum[i+1]){
      cnt++;
      i++;
    }
    ans += combi(cnt);
    i++;
  }

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

Measured memory_bytes: 1792
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    ans = 0
    prev = 0
    for a in A:
        if prev and a:
            a -= 1
            ans += 1
        ans += a // 2
        prev = a % 2
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 49752
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = 2000000000;
// const ll MOD = 1000000007;

struct uf_tree {
  vector<int> par, sizes;
  uf_tree(int n) : par(n), sizes(n, 1) {
    for (int i = 0; i < n; i++) {
      par[i] = i;
    }
  }
  int find(int x) {
    if (x == par[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 (sizes[x] < sizes[y]) {
      swap(x, y);
    }
    par[y] = x;
    sizes[x] += sizes[y];
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return sizes[find(x)]; }
};

int N, M;
vector<int> p;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  p.resize(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> p[i];
  }
  uf_tree uf(N + 1);

  for (int i = 1; i <= M; i++) {
    int xi, yi;
    cin >> xi >> yi;
    uf.unite(p[xi], p[yi]);
  }

  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (uf.same(i, p[i])) {
      ans++;
    }
  }

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

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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    bool p = true;

    for (int i = 0, j = n-1; i < n/2 && j > n/2; i++, j--)
    {
        if (s[i] != s[j])
        {
            p = false;
            break;
        }
    }

    if(p)
    {
        for (int i = 0, j = (n-1) / 2 - 1; i < (n-1) / 4 && j >= (n-1) / 4; i++, j--)
        {
            if (s[i] != s[j])
            {
                p = false;
                break;
            }
        }
    }

    if(p)
    {
        int start = (n+3) / 2;
        int l = n - start + 1;
        for (int i = start-1, j = n - 1; i < start-1 + l/2 && j >= n - l/2; i++, j--)
        {
            if (s[i] != s[j])
            {
                p = false;
                break;
            }
        }

    }

    if(p)
    {
        cout << "Yes" << "\n";
    }
    else
    {
        cout << "No" << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const long long N = 10010;
#define ll long long 

struct Node{
    ll a,b;
}node[N],poll[N];

ll man(ll x,ll y){
    return abs( poll[y].a-node[x].a )+abs(poll[y].b-node[x].b);
}


int main(){
    ll a,b;
    cin >> a >> b;
    for( ll i = 0; i < a; i++ ){
        cin >> node[i].a >> node[i].b;
    }
    for( ll i = 0; i < b; i++ ){
        cin >> poll[i].a >> poll[i].b;
    }
    for( ll i = 0; i < a; i++ ){
        ll flag = -1;
        ll manhanten = 2147483648;
        for(ll j = 0; j < b; j++ ){
            if( manhanten > man( i,j ) ){
                manhanten = man(i,j);
                flag = j;
            }
        }
        cout << flag+1 << endl;
    }
}

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

namespace _025_HitandBlow
{
	class Program
	{
		static void Main ( string[] args )
		{
			string inputStr;

			while ((inputStr = Console.ReadLine ()) != null)
			{
				string[] hand1 = inputStr.Split (' ');
				string[] hand2 = Console.ReadLine ().Split (' ');

				int hit = 0;
				int blow = 0;

				for (int lp = 0; lp < 4; lp++)
				{
					if (hand1[lp] == hand2[lp])
					{
						hit++;
					}

					for (int lp2 = 0; lp2 < 4; lp2++)
					{
						if (hand1[lp] == hand2[lp2])
						{
							blow++;
						}
					}
				}

				Console.WriteLine (hit + " " + (blow - hit));
			}
		}
	}
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line[] = br.readLine().split(" ");
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        System.out.println(a/b);
        System.out.println(a%b);
        Double da = (double) a;
        //Double db = (double) b;
        System.out.println(String.format("%.8f",da/b));
    }
}

Measured memory_bytes: 16980