akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define INF 1000000000
#define INFLL 0x3f3f3f3f3f3f3f3fLL 
#define EPS 10e-9
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define st first
#define nd second
#define sz(v) int(v.size())
#define all(X) (X).begin(), (X).end()
#define FOR(I, A, B) for(int I = A; I < B; I++)
#define RFOR(I, A, B) for(int I = A; I >= B; I--)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<iii> viii;
typedef vector<ll> vll;

int main(){
	int n;
	scanf("%d", &n);
	vector<long double> PD(n+1, 0);
	vector<long double> curr(n+1);
	PD[0] = 1;
	FOR(j, 0, n){
		long double p;
		scanf("%Lf", &p);
		curr[0] = PD[0]*(1-p);
		FOR(i, 1, n+1){
			curr[i] = PD[i-1]*p + PD[i]*(1-p);
		}
		FOR(i, 0, n+1){
			PD[i] = curr[i];
		}
	}
	long double ans = 0;
	FOR(i, 0, n+1){
		if(i > n/2){
			ans+=PD[i];
		}
	}
	printf("%.10Lf\n", ans);
	return 0;
}

Measured memory_bytes: 384
L = input().split()
N = int(L[0])
Y = int(L[1])
c = -1
d = -1
e = -1
for a in range(N + 1):
    for b in range(N + 1):
        if 10000*a + 5000*b + 1000*(N - a - b) == Y and N - a - b >= 0:
            c = a
            d = b
            e = N - a - b
        else:
            pass
print(str(c) + " " + str(d) + " " + str(e))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

string s[10];
int main(){
    int h,w;
    cin>>h>>w;
    rep(i,h) cin>>s[i];
    rep(i,h-1)rep(j,w-1){
        if(s[i+1][j]=='#'&&s[i][j+1]=='#'){
            cout<<"Impossible"<<endl;
            return 0;
        }
    }
    cout<<"Possible"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
        int t=0;
        int a;
        cin>>a;
        while(a%2==0){
            a/=2;
            t++;
        }
        ans+=t;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	string ans;
	while (a>0) {
		c-=b;
		if(c<=0) break;
		a-=d;
	}
	if (a<=0){
		ans="No";
	}else{
		ans="Yes";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3060
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 2000000000000000005
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
 
 #define ll long long
 #define int long long
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
//ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
//int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
//ll modInverse(int a, int m){int g = gcd(a, m); { return power(a, m-2, m);}}
vi v[MAX];
ll h[MAX];
ll ans;
ll vis[MAX];
void dfs(ll root)
{
    ans++;ll f=0;vis[root]=1;
    for(auto it:v[root])
    {
        
        if(!vis[it] )dfs(it);
           if(h[it]>=h[root])
           {
               f=1;
           }
    }
    if(f)ans--;
}
void solve()
{
    ll n,m;cin>>n>>m;
    for(ll i=1;i<=n;i++)cin>>h[i];
    for(ll i=0;i<m;i++)
    {
        ll a,b;cin>>a>>b;
        v[b].pb(a);v[a].pb(b);
    }
    for(ll i=1;i<=n;i++)
    {
        if(!vis[i])dfs(i);
    }
    cout<<ans<<endl;
}
signed main()
{
 
   
    Need_for_speed(activated);
//satisfy
//    {
//   solve();
//    }

 solve();
    return 0;
}


Measured memory_bytes: 17376
#include<iostream>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b && b==c)
    cout<<1<<endl;
  else if(a==b || b==c || c==a)
    cout<<2<<endl;
  else
    cout<<3<<endl;
  return 0;
}

Measured memory_bytes: 3620
#122B
s = input()
count = 0
max_c = 0
for i in range(len(s)):
    if s[i] == "A" or s[i] == "T" or s[i] == "C" or s[i] == "G":
        count = count + 1
        if count > max_c:
            max_c = count
        else:
            pass
    else:
        count = 0

print(max_c)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
int main()
{
 int i,c,n;
 c=0;
 string s;
 cin >> n;
 cin >> s;
 for(i=0;i<(n-2);i++)
 {
  //cout << s.substr(i,i+3) << " ";
  if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
  c++;
 }
 cout << c;
 return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int D,T,S;
  cin>>D>>T>>S;
  
  float Temp=D/(float)S;
  
  if(Temp<=T&&D>0&&T>0&&S>0&&D<=10000&&T<=10000&&S<=10000)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        cout << upper_bound(all(a), r) - lower_bound(all(a), l) << endl;
    }
}


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

using namespace std;

int main(void){
    vector<tuple<string, int, int>> v;
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        string S;
        int P;
        cin >> S >> P;
        v.push_back(make_tuple(S, -P, i));
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < N; i++) cout << get<2>(v[i]) + 1 << endl;
    return 0;
}


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

ll pow_kai(ll a, ll n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a;
    }
    a = a*a;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

int main() {
    ll h;
    cin >> h;
    int n = 1;
    while (h != 1) {
        h = (h-h%2) / 2;
        n++;
    }
    ll ans = pow_kai(2, n) - 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>

using namespace std;

long long n, s, k, t;
long long a[200200];

int main () {
    cin >> n; s = 1;
    while ( n > 0 ) {
        n = n / 2;
        t = t + s;
        s = s * 2;
    }
    cout << t;
}


Measured memory_bytes: 256
#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <numeric>
#include <queue>

#include <vector>
using namespace std;
#define INF 1000000001;

int n, m;
int dist[200000];

const int MAX_V = 200000;

vector<int> G[MAX_V];  //グラフの隣接リスト

bool bfs() {
  queue<int> que;
  que.push(0);
  dist[0] = 0;
  int count = 0;
  auto start = std::chrono::system_clock::now();  // 計測スタート時刻を保存
  while (que.size()) {
    int u = que.front();
    que.pop();
    //cerr << u << endl;

    for (int i = 0; i < G[u].size(); i++) {
      if (dist[G[u][i]] > dist[u] + 1) {  //もし未訪問なら
        dist[G[u][i]] = dist[u] + 1;
        //cerr << u << "->" << G[u][i] << ":" << dist[G[u][i]] << endl;
        que.push(G[u][i]);
      }
    }
     auto end = std::chrono::system_clock::now(); 
     auto dur = end - start;
     auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
     if(msec > 1000){
       break;
     }
  }
  //cerr << dist[n - 1] << endl;
  if (dist[n - 1] > 2) {
    return false;
  } else {
    return true;
  }
}

int main() {
  cin >> n >> m;  // == V

  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
  }

  for (int i = 0; i < n; i++) {
    dist[i] = 9999999;
  }

  bool ans = bfs();

  if (ans) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }

  return 0;
}

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

flag = [0]*4
for _ in range(N):
    D1, D2 = map(int, input().split())
    if (D1 == D2):
        if (flag[2] == 1):
            flag[3] = 1
        elif (flag[1] == 1):
            flag[2] = 1
        else:
            flag[1] = 1

    else:
        flag[1] = 0
        flag[2] = 0

if (flag[3] == 1):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9196
// E - Handshake
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
using ll = long long;
using vl = vector<ll>;
#define all(x) (x).begin(),(x).end()

ll N,M;
vl A;

bool check(ll x){ // (x<=ai+aj となる aj の個数) < M?
	ll total = 0; // cnt_aj を集計
	for(auto ai:A){
		ll pos_aj = lower_bound(all(A), x-ai) - A.begin(); // x<=ai+aj -> x-ai<=aj
		ll cnt_aj = N - pos_aj; // "ai のときの" aj の個数
		total += cnt_aj;
	}
	return total < M;
}

ll solve(){
	sort(all(A));

	// binary search
	ll lower = 2*A[0], next_lower = 2*A[N-1];
	while(lower+1 < next_lower){ // l+1 < r
		ll x = (lower + next_lower)/2;
		if(check(x)) next_lower = x; else lower = x;
	}

	vl csum(N+1); rp(i,0,N) csum[i+1] = csum[i] + A[i]; // 累積和
	ll ans = 0;
	ll x = next_lower;
	for(auto ai:A){
		ll pos_aj = lower_bound(all(A), x-ai) - A.begin(); // x<=ai+aj -> x-ai<=aj
		ll cnt_aj = N - pos_aj;
		ans += ai * cnt_aj + (csum[N] - csum[pos_aj]);
		M -= cnt_aj;
	}
	ans += lower * M;

	return ans;
}

int main(){
	cin>>N>>M;
	A.resize(N);
	rp(i,0,N) cin>>A[i];
	cout<< solve() <<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
using namespace std;
#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;
using namespace std;

ll solve(ll r, ll d, ll x) {
	return r * x - d;
}

int main() {
	ll r, d, x;
	cin >> r >> d >> x;
	for (int i = 0; i < 10; i++) {
		x = solve(r, d, x);
		cout << x << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using Point = pair<int, int>;
const int INF = (int)1e9;

int N, M;
Point p[100000];

int main(void){
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int a, b; cin >> a >> b;
        p[i] = Point(a-1, b-1);
    }

    for(int i = 0; i < M; i++) p[i].second *= -1;
    sort(p, p+M);
    for(int i = 0; i < M; i++) p[i].second *= -1;

    int pos_a = INF;
    int pos_bridge = INF;
    int res = 0;
    for(int i = M-1; i >= 0; i--){
        if(pos_a == p[i].first) continue;

        pos_a = p[i].first;
        if(p[i].second <= pos_bridge){
            pos_bridge = p[i].first;
            res++;
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 1024
N=int(input())
B = list(map(int,input().split()))

A=[]
zantei=B[-1]
for i in range(N-1):
    if B[N-2-i] < zantei:
        A.append(B[N-2-i])
    else:
        A.append(zantei)
    zantei = B[N-2-i]


A.append(zantei)

print(sum(A))

Measured memory_bytes: 3064
class UnionFind(object):
  def __init__(self,n):
    self.table=[-1]*n
 
  def find(self,x):
    parent=self.table[x]
    if parent<0:
      return x
    else:
      root=self.find(parent)
      self.table[x]=root
      return root
 
  def union(self,a,b):
    root1=self.find(a)
    root2=self.find(b)
    if root1 != root2:
      if self.table[root1] != self.table[root2]:
        if self.table[root1] < self.table[root2]:
          self.table[root2]=root1
        else:
          self.table[root1]=root2
      else:
        self.table[root1]+=(-1)
        self.table[root2]=root1
        
N,M=map(int,input().split())
A=[int(x) for x in input().split()]
uf=UnionFind(N)
for i in range(M):
  a,b=map(int,input().split())
  uf.union(a-1,b-1)
ans=0
for i in range(N):
  if A[i]==i+1:
    ans+=1
  else:
    if uf.find(A[i]-1)==uf.find(i):
      ans+=1
print(ans)


Measured memory_bytes: 13812
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;

int main(){
    int a,b; cin >> a >> b;
    int out =-1;
    if(0<a && a<10  && 0<b && b<10 ){
        out = a*b;
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 3188
import Control.Monad

solve k l ak bk
 | (null ak) || (null bk) = [0]
 | (head ak + head bk) <= k = l : solve k (l+1) ak (tail bk)
 | otherwise = solve k (l-1) (tail ak) bk

main = do
 k <- read . last . words <$> getLine
 [ak,bk] <- replicateM 2 $ takeWhile (<= k) . scanl (+) 0 . map read . words <$> getLine :: IO [[Int]]
 print $ max (maximum $ solve k (length ak - 1) (reverse ak) bk) (maximum $ solve k (length bk - 1) (reverse bk) ak)

Measured memory_bytes: 124532
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    
int f(int h, int a){
    if(h % a == 0)
        return (h/a);
    else
        return h/a+1;
}


int main(){
   IOS

    int n, d, a; cin>>n>>d>>a;


   vector<ll> x(n), h(n);
   for(int i = 0; i < n; i++){
       cin>>x[i]>>h[i];
   }

   vi indices(n);
   iota(all(indices), 0);

   sort(all(indices),[&](int a, int b){return x[a] < x[b];});

   vector<ll> x2(n), h2(n);

   for(int i = 0; i < n; i++){
       x2[i] = x[indices[i]], h2[i] = h[indices[i]];
   }

   ll res = 0;

   vector<ll> CS(n+1, 0);
   for(int i = 0; i < n; i++){
       if(CS[i] < h2[i]){
           int idx = upper_bound(all(x2), x2[i] + 2*d)-x2.begin();
           ll cnt = (h2[i]-CS[i] + a-1)/a, r = a*cnt;
           res += cnt;
           CS[i] += r;
           CS[idx] -= r;
       }
       CS[i+1] += CS[i];
   }

   cout<<res<<"\n";



    








    





   


}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 8832
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int N, A, B, C;
string s[200005];

int num[3];

string ALPH = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

vector<string> CALC(void) {

	vector<string> IMPOSSIBLE;
	IMPOSSIBLE.push_back("No");

	vector<string> ans;
	ans.push_back("Yes");

	for (int i = 1; i <= N; i++) {
		int I = s[i][0] - 'A';
		int J = s[i][1] - 'A';

		if (num[I] <= 0 && num[J] <= 0) { return IMPOSSIBLE; }
		else if (num[I] == 0) {   
			num[I]++; num[J]--; ans.push_back(ALPH.substr(I, 1));
		}
		else if (num[J] == 0) {
			num[I]--; num[J]++; ans.push_back(ALPH.substr(J, 1));
		}
		else if(i<N &&num[I]==1 && num[J]==1){
			int K = s[i + 1][0] - 'A'; int U = s[i + 1][1] - 'A';
			if (I == K || I == U) { num[I]++; num[J]--; ans.push_back(ALPH.substr(I, 1));
			}
			else { num[I]--; num[J]++; ans.push_back(ALPH.substr(J, 1)); }
		}
		else if (num[I] > num[J]) {
			num[I]--; num[J]++;
			ans.push_back(ALPH.substr(J,1));
		}
		else {
			num[I]++; num[J]--;
			ans.push_back(ALPH.substr(I, 1));
		}
	}

	return ans;
}

int main(void) {

	cin >> N >> A >> B >> C;

	num[0] = A;
	num[1] = B;
	num[2] = C;

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

	vector<string> ans = CALC();

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

	return 0;
}

Measured memory_bytes: 13724
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)==3)
    {
        if(a+b>=c)
            printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long int x, y;
    cin >> x >> y;
    
    if (x >= 0 && abs(x) < abs(y) && y >= 0) {
        cout << y - x << endl;
    } else if (x >= 0 && abs(y) <= abs(x) && y > 0) {
        cout << 1 + (x - y) + 1 << endl;
    } else if (x >= 0 && abs(y) <= abs(x) && y <= 0) {
        cout << y + x + 1 << endl;
    } else if (x >= 0 && abs(y) > abs(x) && y <= 0) {
        cout << -y - x + 1 << endl;
    } else if (x < 0 && abs(x) <= y && y > 0) {
        cout << y + x + 1 << endl;
    } else if (x < 0 && abs(y) <= abs(x) && y > 0) { 
        cout << - y - x + 1 << endl;
    } else if (x < 0 && abs(y) < abs(x) && y <= 0) {
        cout << y - x << endl;
    } else {
        cout << 1 + (-y + x) + 1 << endl;
    }
}

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

using namespace std;

int c[101], n, k;

int func()
{
  int mx = 1, t;

  for(int i = 0; i < n-k+1; ++i){
    t = 1;
    for(int j = 0; j < k; ++j) t *= c[i+j];
    mx = max(t, mx);
  }

  return mx;
}

int main()
{
  int cmx, t;

  while(cin>>n>>k && n+k){
    for(int i = 0; i < n; ++i) cin >> c[i];

    t = 1;
    cmx = func();
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; ++j){
	if(i == j) continue;
	swap(c[i], c[j]);
	t = max(t, func());
	swap(c[i], c[j]);
      }
    }

    if(t < cmx) cout << "NO GAME" << endl;
    else cout << (t-cmx) << endl;
  }

  return 0;
}

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

// const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll INFL = 100000000000000000;
const int MAX_N = 100010;

ll h[MAX_N], N, A, B;

bool check(ll x) {
  ll cnt = 0;
  for (int i = 0; i < N; ++i) {
    ll rest = h[i] - B * x;
    if (rest > 0) {
      cnt += (rest + A - B - 1) / (A - B);
    }
  }
  return cnt <= x;
}

int main() {
  cin >> N >> A >> B;
  for (int i = 0; i < N; ++i) {
    cin >> h[i];
  }
  ll ng = 0;
  ll ok = 1 << 30;  //  INFL;
  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if (check(mid))
      ok = mid;
    else
      ng = mid;
  }
  cout << ok << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#define MAXN 105
#define inside(x,y) (x>0&&y>0&&x<=n&&y<=m)
const int dir[4][2]={{-1,0},{0,1},{1,0},{0,-1}};
int n,m,cnt;
bool vis[MAXN][MAXN];
char map[MAXN][MAXN];
void dfs(int x,int y,char ch)
{
	vis[x][y]=1;
	int tx,ty;
	for(int d=0;d<4;d++)
	{
		tx=x+dir[d][0];
		ty=y+dir[d][1];
		if(inside(tx,ty)&&!vis[tx][ty]&&map[tx][ty]==ch)
			dfs(tx,ty,ch);
	}
}
int main()
{
	while(1)
	{
		scanf("%d%d",&n,&m);
		if(n==0&&m==0)
			break;
		for(int i=1;i<=n;i++)
			scanf("%s",map[i]+1);
		memset(vis,0,sizeof vis);
		cnt=0;
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
				if(!vis[i][j])
				{
					cnt++;
					dfs(i,j,map[i][j]);
				}
		printf("%d\n",cnt);
	}
	return 0;
}

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

namespace ConsoleApp1
{
    struct Works
    {
        public bool[] finishedworks;
        public int[] costs;
        public int[] limits;
        public int time;
        public int worknum;
        public bool[] availableworks;
        public bool failed;
    }


    class Program
    {
        static void Main(string[] args)
        {
            // var s = Console.ReadLine();
            // int num = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            var cs = new Char[2];
            var count = new int[2];
            bool hadwritten = false;
            for (int i = 0; i < s.Length; i++)
            {
                if (cs[0] == s[i])
                {
                    count[0]++;
                }
                else if (cs[1] == s[i])
                {
                    count[1]++;
                }
                else if (hadwritten)
                {
                    cs[1] = s[i];
                }
                else
                {
                    cs[0] = s[i];
                    hadwritten = true;
                }
            }
            if (count[0] == 1 && count[1] == 1)
            {

                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");

            }




#if DEBUG
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,max=-1;
	cin>>n;
	int sum=0;
	for(int i=0;i<n;i++){
		int add;
		cin>>add;
		sum+=add;
		max=max>add?max:add;
	}
	cout<<sum-max/2;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
lst=[list(map(int, input().split())) for i in range(n)]
lst.sort(key=lambda x: -x[0]-x[1])
ans=0
for i in range(n):
  if(i%2==0):
    ans+=lst[i][0]
  else:
    ans-=lst[i][1]
print(ans)

Measured memory_bytes: 32296
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   string res = "";
   while(n){
      --n;
      int v = n%26;
      res += (v+'a');
      n /= 26;
   }
   reverse(all(res));
   cout << res << '\n';
   return 0;
} 


Measured memory_bytes: 3628
import java.util.Arrays;
import java.util.Scanner;


public class Main {
    public static void main(String[] args){
    	Scanner input = new Scanner(System.in);
    	int n = input.nextInt();
    	for(int i = 0 ; i < n ; i++){
    		int a[] = new int[3];
    		for(int j = 0 ; j < 3 ; j++){
    			a[j] = input.nextInt();
    		}
    		Arrays.sort(a);
    		if(Math.pow(a[0],2)+Math.pow(a[1],2) == Math.pow(a[2],2)){
    			System.out.println("YES");
    		}else{
    			System.out.println("NO");
    		}
    	}
    }
}

Measured memory_bytes: 23392
#include <iostream>

using namespace std;

void swap(int &x,int &y);
int main(){
  int *line=NULL,w,n;
  
  cin>>w;
  cin>>n;

  line=new int[w];
  for( int i=0;i<w;i++ )
    line[i]=i+1;
  for( int i=0;i<n;i++ ){
    int a,b;
    char c;
    cin>>a>>c>>b;
    swap(line[a-1],line[b-1]);
  }
  for( int i=0;i<w;i++ )
    cout<<line[i]<<endl;
  delete line;
  line = 0;
  return 0;
}

void swap(int &x,int &y){
  x^=y;
  y^=x;
  x^=y;
}

Measured memory_bytes: 1192
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define pb push_back
#define lp(j, n)  for(int j=0; j<(int)(n); ++j)
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
#define F first
#define S second
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int,string> > vpii;
typedef map<int, int> mii;
const ll N=1e5+5;
int arr[N],A[N],ARR[N]  ;
bool visited[N]={};
int cnt[N]={};
bool f;
bool isprime(int n)
{
    if(n<=1) return false;
    for(int i=2 ; i<n ; i++)
    {
        if(n%i==0)
            return false;
    }
    return true;

}
int main()
{
    int n;
    cin>>n;
    while(true)
    {
        if(isprime(n))
        {
            cout<<n;
            go;
        }
        n++;
    }
go;
}


Measured memory_bytes: 256
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#include         <bits/stdc++.h>
using namespace std;
#pragma GCC      optimize ("Ofast")
#pragma GCC      optimize ("unroll-loops")
#pragma GCC      target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define IOS      ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC     cout.precision (10); cout << fixed
#define bg(x)    " [ " << #x << " : " << (x) << " ] "
#define x        first
#define y        second
using ll = long long;
using ff = long double;
using pii = pair<int,int>;

#define debug(args...) { \
/* WARNING : do NOT compile this debug func calls with following flags: // \
 * // -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2*/ \
   string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');\
   stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); \ }
void err(istream_iterator<string> it) { it->empty();
   cerr << " (Line : " << __LINE__ << ")" << '\n';
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << fixed << setprecision(15) << " [ " <<  *it << " : " << a  << " ] "<< ' ';
	err(++it, args...);
}

const int N = 105, V = 1004;
const ll inf = (ll) 1e18;

ll dp[N*V];
// dp[v] := min weight attained with knapsack of value exactly v till some iteration
int n, mxv, W;
int w[N], v[N];

void solve() {
   for (int i = 1; i <= mxv; ++i) dp[i] = inf;
   dp[0] = 0;

   for (int i = 1; i <= n; ++i) for (int j = mxv; j >= 0; --j)
   {
      if (j >= v[i]) dp[j] = min(dp[j], dp[j-v[i]] + w[i]);
   }

   int mx_val = 0;
   for (int val = mxv; val >= 0; --val) {
      if (dp[val] <= W) {
         mx_val = val;
         break;
      }
   }
   cout << mx_val << '\n';
}

signed main() {
   IOS; PREC;
   cin >> n >> W;
   mxv = 0;
   for (int i = 1; i <= n; ++i)
      cin >> w[i] >> v[i], mxv += v[i];
   solve();


   return EXIT_SUCCESS;
}


Measured memory_bytes: 1024
n = int(input())
w = list(map(int,input().split()))
a = []
k = 0
while k < n-1:
  if w[k] == w[k+1]:
    k += 1
  else:
    a.append(abs(sum(w[0:k+1])-sum(w[k+1:n])))
    k += 1
print(min(a))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<char>v;
    string s;
    int i,j,cnt;
    int n;
    for(char k='A'; k<='Z'; k++)
        v.push_back(k);
        cin>>n>>s;
    for(i=0; s[i]!='\0'; i++)
    {
        cnt = s[i];
        cnt+=n;
        if(cnt>90)
            cout<<v[cnt-91];
        else
            cout<<v[cnt-65];
    }
    return 0;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    int a;
    vector<int> cnt1(n,0),cnt2(n+1,0),b(n+1),len(n+1,0);
    for (int i = 0;i < n;++i) {
        scanf("%d",&a);
        cnt1[a-1]++;
    }
    for (int i = 0;i < n;++i) cnt2[cnt1[i]]++;
    for (int i = 0;i < n+1;++i) b[i] = cnt2[i]*i;
    for (int i = 0;i < n;++i) {
        cnt2[i+1] += cnt2[i];
        b[i+1] += b[i];
    }
    for (int i = 1;i < n+1;++i) {
        len[i] = (b[i]+(n-cnt2[i])*i)/i;
    }
    int j = n;
    for (int i = 1;i < n+1;++i) {
        while (j > 0 && len[j] < i) j--;
        cout << j << "\n";
    }
}

Measured memory_bytes: 5504
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
	char string[6][6],input[201];
	int i;
	for (i=0; i<26; i++) string[i/5][i%5]='a'+i;
	string[5][i++%5]='.',string[5][i++%5]='?';
	string[5][i++%5]='!',string[5][i++%5]=' ';
	while (scanf(" %s",input)!=EOF) {
		if (strlen(input)%2!=0) {
			cout<<"NA"<<endl;
			continue;
		}
		int i;
		for (i=0; i<strlen(input); i++) {
			if (i%2==0&&((input[i]-'0')<1||(input[i]-'0')>6)) {
				break;
			}
			if (i%2!=0&&((input[i]-'0')<1||(input[i]-'0')>5)) {
				break;
			}
		}
		if (i!=strlen(input)) {
			cout<<"NA"<<endl;
			continue;
		}
		
		for (int i=0; i<strlen(input); i+=2) {
			cout<<string[input[i]-1-'0'][input[i+1]-1-'0'];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1148
<?php
  
  //3をかけたところで２で割れるポテンシャルはかわらない。
  //なら、nこのそれぞれの数値が２で何回われるかみて、
  //それを足し合わせた値が操作数の最大値
  
fscanf(STDIN,"%d",$n);
$a_li=array();


$a_li=explode(" ",trim(fgets(STDIN)));
$c=0;

foreach($a_li as $a){
  while($a%2==0){
    $a /= 2;
    $c++;
  }
}



echo ($c)."\n";

Measured memory_bytes: 4604
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
 
using namespace std;
typedef long long ll;
int MOD = 1000000007;
int dp[110][4][4][4];
 
int main(){
 
    int S;
    cin >> S;
    //AGCT 0123
   
    //初期化
    dp[0][3][3][3] = 1;
 
    for(int i = 0; i < S; i++){
        //cout << i << endl;
        for(int c1 = 0; c1 < 4; c1++){
            for(int c2 = 0; c2 < 4; c2++){
                for(int c3 = 0; c3 < 4; c3++){
                    if(dp[i][c1][c2][c3] == 0) continue;
                    //新しく前に追加するものをループで回す
                    for(int a = 0; a < 4; a++){
                        //追加の仕方で違反するもの
						if (a == 2 && c1 == 1 && c2 == 0) continue;
						if (a == 2 && c1 == 0 && c2 == 1) continue;
						if (a == 1 && c1 == 2 && c2 == 0) continue;
						if (a == 2 && c1 == 1 && c3 == 0) continue;
						if (a == 2 && c2 == 1 && c3 == 0) continue;
 
                        //文字列が作れるのでdp[n+1]に何個くれたのかを記録する
						dp[i + 1][a][c1][c2] += dp[i][c1][c2][c3];
						dp[i + 1][a][c1][c2] %= MOD;
 
                    }
                    
                }
            }
        }
    }
 
    int ans = 0;
    for(int c1 = 0; c1 < 4; c1++){
        for(int c2 = 0; c2 < 4; c2++){
            for(int c3 = 0; c3 < 4; c3++){
                ans += dp[S][c1][c2][c3];
                ans %= MOD;
            }
        }
    }
 
    cout << ans << endl;
 
} 

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n + 1)
        self.size = [1] * (n + 1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def sizeof(self, x):
        return self.size[self.find(x)]


n, m, k = map(int, input().split())
uf = UnionFind(n)
f = [0] * n
bl = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    f[a - 1] += 1
    f[b - 1] += 1
    uf.unite(a - 1, b - 1)
for i in range(k):
    a, b = map(int, input().split())
    if uf.same_check(a - 1, b - 1):
        bl[a - 1] += 1
        bl[b - 1] += 1
ans = [0] * n
for i in range(n):
    ans[i] = uf.sizeof(i) - f[i] - bl[i] - 1
print(' '.join(map(str, ans)))


Measured memory_bytes: 21120
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;

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

	string s;
	cin >> s;
	rep(i, s.length()) {
		if (s[i] == '7') {
			cout << "Yes" << "\n";
			return 0;
		}
	}

	cout << "No" << "\n";

	return 0;
}


Measured memory_bytes: 3640
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{ min, max };

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();

    use std::collections::HashSet;
    let mut a = HashSet::new();
    a.insert('1');
    a.insert('9');
    a.insert('7');
    a.insert('4');
    let mut b = HashSet::new();
    for _ in 0..4 {
        let c = sc.cin::<String>().chars().collect::<Vec<char>>()[0];
        b.insert(c);
    }
    put!(if a==b { "YES" } else { "NO" });
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int N=100005;
typedef long long ll;
const ll mod=1e9+7;
inline void MOD(int &x) {if (x>=mod) x-=mod;}


int n;
ll S[N],A,B;
int dp[N][2],s[N][2];
int W(int id,int l,int r)
{
	if (l>r) return 0;
	if (!l) return s[r][id]+1;
	return (s[r][id]-s[l-1][id]+mod)%mod;
}
int main()
{
	scanf("%d",&n);
	scanf("%lld%lld",&A,&B);
	for (int i=1;i<=n;i++) scanf("%lld",&S[i]);
	
	s[1][0]=s[1][1]=dp[1][0]=dp[1][1]=1;
	int la=0,lb=0;
	int pa=0,pb=0;
	for (int i=2;i<=n-1;i++)
	{
		while (S[pa+1]+A<=S[i+1]&&pa+1<i) pa++;
		while (S[pb+1]+B<=S[i+1]&&pb+1<i) pb++;
		if (S[i]-S[i-1]<A) la=i-1;
		if (S[i]-S[i-1]<B) lb=i-1;
		
		dp[i][0]=W(1,la,pb);MOD(s[i][0]=s[i-1][0]+dp[i][0]);
		dp[i][1]=W(0,lb,pa);MOD(s[i][1]=s[i-1][1]+dp[i][1]);
	/*	printf("i=%d la=%d lb=%d pa=%d pb=%d dp0=%d dp1=%d\n"
		,i,la,lb,pa,pb,dp[i][0],dp[i][1]);*/
	}
	
	
	
	dp[0][0]=dp[0][1]=1;

	int ans=dp[n-1][0];
	for (int i=n-1;i>=1;i--) 
	{
		if (S[i+1]-S[i]<B) break;
		MOD(ans+=dp[i-1][0]);
	}
	MOD(ans+=dp[n-1][1]);
	for (int i=n-1;i>=1;i--) 
	{
		if (S[i+1]-S[i]<A) break;
		MOD(ans+=dp[i-1][1]);
	}
	printf("%d\n",ans);
	return 0;
}
/*
5 3 7
1 3 6 9 12
*/

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
	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;
	}
}

// 二項係数計算
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;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define inf 1e18 

using namespace std;
#define MAXN 1000001
// stores smallest prime factor for every number 
int spf[1000001]; 
  
// Calculating SPF (Smallest Prime Factor) for every 
// number till MAXN. 
// Time Complexity : O(nloglogn) 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
// A O(log n) function returning primefactorization 
// by dividing by smallest prime factor at every step 
vector<int> getFactorization(int x) 
{ 
    vector<int> ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 

signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif
    
    IOS;
    int n,i;
    cin>>n;
    sieve();
    int ans=0;
    for(i=1;i<=n-1;i++)
    {
        int x=n-i;
        map<int,int> m;
        while (x != 1) 
        { 
            m[spf[x]]++;
            x = x / spf[x]; 
        } 
        int prd=1;
        for(auto it=m.begin();it!=m.end();it++) prd*=it->S+1;
        ans+=prd;
    }
    cout<<ans;
}

Measured memory_bytes: 11408
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

enum EventType { ADD, REMOVE };

int main() {
    int n, q; cin >> n >> q;
    vector<tuple<int, EventType, int>> events;
    for (int i = 0; i < n; ++i) {
        int s, t, x; cin >> s >> t >> x;
        events.push_back(make_tuple(s - x, ADD, x));
        events.push_back(make_tuple(t - x, REMOVE, x));
    }
    sort(events.begin(), events.end());
    auto it = events.begin();
    multiset<int> obstacles;
    vector<int> ans(q, inf);
    for (int i = 0; i < q; ++i) {
        int d; cin >> d;
        while (it != events.end() && get<0>(*it) <= d) {
            if (get<1>(*it) == ADD) {
                obstacles.insert(get<2>(*it));
            }
            else {
                obstacles.erase(obstacles.lower_bound(get<2>(*it)));
            }
            ++it;
        }
        if (obstacles.size() > 0) ans[i] = *obstacles.begin();
        else ans[i] = -1;
    }
    for (int i = 0; i < q; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  int x,y,z;
  vector<int>a(n);
  vector<set<int> >s(n+1);
  int i;
  for(i=0;i<m;i++){
    cin >> x >> y >> z;
    s[x].insert(y);
    s[y].insert(x);
  }

  vector<bool> rikai(n+1);
  queue<int>q;

  int cnt = 0;
  int tmp;

  for(i=1;i<=n;i++){
    if(!rikai[i]){
      rikai[i] = true;
      cnt++;
      for(auto j:s[i]){
        if(!rikai[j])q.push(j);
      }
      while(!q.empty()){
        tmp = q.front();
        rikai[tmp]=true;
        q.pop();
        for(auto j:s[tmp]){
          if(!rikai[j])q.push(j);
        }
      }
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1e9+7;
typedef pair<int, int> P;

vector<P> prime_factorize(int N){
	vector<P> ans;
	for(int a = 2; a*a <= N; a++){
		if(N%a == 0){
			int ex = 0;
			while(N%a == 0){
				ex++;
				N /= a;
			}
			ans.push_back(P(a, ex));
		}
	}
	if(N != 1) ans.push_back(P(N, 1));
	return ans;
}

//ax = 1(modp) のｘをmodinv(a, p)で求める。ex modinv(4, 13) = 10
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        int t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

signed main(){
    int N; cin >> N;
    vector<int> a(N); vector<P> num1(1000000), num;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        vector<P> vec = prime_factorize(a[i]);
        for(int i = 0; i < vec.size(); i++){
            num1[vec[i].first].second = max(num1[vec[i].first].second, vec[i].second); 
        }
    }
    for(int i = 0; i < 1000000; i++){
        if(num1[i].second != 0) num.push_back(P(i, num1[i].second));
    }
    int g = 1;
    for(int i = 0; i < num.size(); i++) {
        g *= pow(num[i].first, num[i].second);
        g %= MOD;
    }  

    int ans = 0;
    for(int i = 0; i < N; i++){
        vector<P> vec = prime_factorize(a[i]);
        int x = 1;
        for(int i = 0; i < vec.size(); i++) x *= pow(vec[i].first, vec[i].second);
        int ans1 = modinv(x, MOD) * g;

        ans += ans1;
        ans %= MOD;
     }
    cout << ans << endl;
}

Measured memory_bytes: 16384
#include <stdio.h>
int main (void){
  int d;
  scanf("%d",&d);
  switch(d){
    case 22 : printf("Christmas Eve Eve Eve"); break;
    case 23 : printf("Christmas Eve Eve"); break;
    case 24 : printf("Christmas Eve"); break;
    case 25 : printf("Christmas"); break;
  }
  return 0;
}

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define N             (int)(1e6+5)
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    int m,n; cin>>m>>n;
    if(m*500>=n) cout<<"Yes";
    else cout<<"No";
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(lli = 0; i < n; ++i)
#define RFOR(n)			for(lli = n; i >= 0; --i)
#define FORR(start,end) for(lli = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
#define PI 3.141592
#define MOD 1e9+7
using namespace std;

ll snac(ll a, ll b, const ll pa, const ll pb) {
	if (a == b)
		return a;
	else if (a < b)
		return snac(a + pa, b, pa, pb);
	else
		return snac(a, b + pb, pa, pb);
}

void solve() {
	ll a, b;
	cin >> a >> b;
	cout << snac(a, b, a, b) << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256