akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}


vector<ll> enum_div(int n){//yakusu
  vector<ll> ret;
  for(ll i=1 ; i*i<=n ; ++i){
      if(n%i == 0){
        ret.push_back(i);
        if(i*i!=n)ret.push_back(n/i);
      }
  }
  return ret;
}

int main(){
  ll N,K,S=0;
  cin >> N >> K;
  vector<ll> A(N);
  for(auto &&a:A){
    cin >> a;
    S += a;
  }

  ll ans = 1;
  for(auto e:enum_div(S)){
    vector<ll> d;
    for(auto a:A)if(a%e)d.push_back(a%e);
    sort(d.begin(), d.end());
    ll pnum = 0;
    ll mnum = 0;
    for(auto a:d)mnum+=(e-a);
    if(mnum <= K  &&  abs(pnum-mnum)%e==0){
      ans = max(ans,e);
    }
    for(auto a:d){
      pnum += a;
      mnum -= (e-a);
      if(max(pnum,mnum) <= K && abs(pnum-mnum)%e==0){
        ans = max(ans,e);
      }
    }
  }
  cout << ans << endl;
}


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

int main(){
    long long N;
    vector<string> s;
    vector<long long> res(4,0);
    cin>>N;
    for (long long i=0;i<N;i++){
        string line;
        cin>>line;
        s.emplace_back(line);
    }
    for(int i=0;i<N;i++) {
        if(s[i]=="AC"){
            res[0]+=1;
        }else if(s[i]=="WA"){
            res[1]+=1;
        }else if(s[i]=="TLE"){
            res[2]+=1;
        }else if(s[i]=="RE"){
            res[3]+=1;
        }
    }
    cout<< "AC" << " x " << to_string(res[0]) <<endl;
    cout<< "WA" << " x " << to_string(res[1]) <<endl;
    cout<< "TLE" << " x " << to_string(res[2]) <<endl;
    cout<< "RE" << " x " << to_string(res[3]) <<endl;
}    

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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second

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

const int MOD = 1e9+7;

int main() {

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

	int n,x,t;
	cin >> n >> x >> t;
	cout << (1+(n-1)/x)*t;
}

Measured memory_bytes: 3576
#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> d;
    for(int i=0; i<N; i++){
        int tmp;
        cin >> tmp;
        d.push_back(tmp);
    }
    std::sort(d.begin(), d.end());

    int median = d[N/2-1];
    int median_next = d[N/2];

    cout<<median_next-median<<endl;

    return 0;

}

Measured memory_bytes: 892
n, d, x = map(int, raw_input().split())
ans = (d + d + x + d + 2 *(n - 1) * x + d + (2 * (n - 1) + 1) * x) / 4.0
s = 0.5 * n
for i in xrange(1, n):
    s += 0.5 / (i + 1) * (n - i)
print "%.12f" %  (ans * s * 2)


Measured memory_bytes: 2568
#include<stdio.h>
int main(){
int i,n,x;
fscanf(stdin,"%d",&n);
for(i=1;i<=n;i++){
x=i;
if(x%3==0){
printf(" %d",i);
continue;
}
do{
if(x%10==3){
printf(" %d",i);
break;
}
x/=10;
}while(x);
}
printf("\n");
return 0;
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    string s;
    cin >> s;
    ll n=s.size();
    ll ans=n;
    vector<string>str(n+1,".");
    for(ll i=0;i<n;i++){
        str[i]=s[i];
    }
    for(ll i=0;i<n-1;i++){
        if(str[i]==str[i+1]){
            str[i+1]=str[i]+str[i+1];
            ans--;
            str[i+2]="XXX";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9668
import sys
sys.setrecursionlimit(10**5)

N, Q = map(int,input().split())
G = [[] for _ in range(N)]
counter = [0] * N

for _ in range(N-1):
    a, b = map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

for _ in range(Q):
    p, x = map(int,input().split())
    counter[p-1] += x

stack, seen = [0], [False]*N
while stack:
    v = stack.pop()
    seen[v] = True

    for u in G[v]:
        if not seen[u]:
            stack.append(u)
            counter[u] += counter[v]

for c in counter:
    print(c, end = " ")
print("")

Measured memory_bytes: 124880
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int  long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
using namespace std;
/// age ye mosh dp ro baze dashti dp tedad baz shodeye baste nashode yadet nare !!
const int N=1e5+100;
vector <pii> a;
ll par[N];
ll rap[N];
int32_t main(){
    sync;
    ll n;
    cin >> n;
    ll ans=0;
    for (int i=0;i<n;i++){
        ll u,v;
        cin >> u >> v;
        ans=max(ans,v-u+1);
        a.pb({u,v});
    }
    sort(a.begin(),a.end());
    for (int i=1;i<a.size();i++){
        if (a[i].S-a[i].F==ans-1){
            ll l=0,r=1e9+100;
            for (int j=0;j<n;j++){
                if (j==i){
                    continue;
                }
                l=max(l,a[j].F);
                r=min(r,a[j].S);
            }
            ans=max(ans,ans+r-l+1);
            break;
        }
    }
    ll l=0,r=1e9+100;
    for (int i=0;i<n;i++){
        l=max(l,a[i].F);
        r=min(r,a[i].S);
        par[i]=max((ll)0,r-l+1);
    }
    l=0,r=1e9+100;
    for (int i=n-1;i>-1;i--){
        l=max(l,a[i].F);
        r=min(r,a[i].S);
        rap[i]=max((ll)0,r-l+1);
    }
    for (int i=0;i<n;i++){
        ans=max(ans,par[i]+rap[i+1]);
    }
    cout << ans;
}













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



signed main() {
	int n;
	cin >> n;
	int val[n][3];
	for(int i=0;i<n;i++){
		cin >> val[i][0] >> val[i][1] >> val[i][2];
	}
	int dp[n][3];
	for(int i=0;i<3;i++){
		dp[0][i]=val[0][i];
	}
	for(int i=1;i<n;i++){
		for(int j=0;j<=2;j++){
			dp[i][j]=dp[i-1][(j+1)%3]+val[i][j];
			dp[i][j]=max(dp[i][j],dp[i-1][(j+2)%3]+val[i][j]);
		}
	}
	cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	// your code goes here
	return 0;
}

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


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

  int tmp_max = 0;
  int tmp_min = 1000000000;
  for (int i = 0; i < d; i++){
    tmp_max = max(tmp_max, a[i]);
    tmp_min = min(tmp_min, a[i]);
  }
  cout << tmp_max - tmp_min << endl;

}



  
    

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(void) {
 
	int a, a2;
  
  	cin >> a;
  	a2 = a * a;
  
  	int ans = a + a2 + a * a2;
  
  	cout << ans << '\n';
  
  	return 0;
}

Measured memory_bytes: 3132
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(x,y) lower_bound(ALL(x), y) - x.begin() - 1;
#define INF 9223372036854775807
#define MOD 1000000007
#define pb push_back
#define F first 
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0;
string s;
bool flag;
#pragma endregion
#define MAX 111111



int main(void) {
  cin >> n >> m;
  FOR(i, 0, n + 1) {
	FOR(j, 0, n + 1 - i) {
	  if (10000 * i + 5000 * j + 1000 * (n - i - j) == m) {
		cout << i << " " << j << " " << n - i - j << endl;
		return 0;
	  }
	}
  }
  cout << "-1 -1 -1" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	for(int i=0;i<10;i++)for(int j=0;j<10;j++){
		int t = i*j;
		if(t==N){
			cout <<"Yes"<<endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


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



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

vector<vector<pair<int, int>>> G;

void dfs(int current, int parent, int id, vector<bool> &visited) {
  visited.at(current) = true;
  for (auto tovisit : G.at(current)) {
    if (tovisit.first == parent) continue;
    if (visited.at(tovisit.first)) continue;
    if (tovisit.second == id) continue;
    dfs(tovisit.first, current, id, visited);
  }
}

int main() {
  int N, M; cin >> N >> M;
  G.resize(N);
  for (int i = 0; i < M; i++) {
    int a, b; cin >> a >> b;
    a--; b--;
    G.at(a).push_back(make_pair(b, i));
    G.at(b).push_back(make_pair(a, i));
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    vector<bool> visited(N);
    dfs(0, -1, i, visited);
    for (int i = 0; i < N; i++) {
      if (!visited.at(i)) { ans++; break; }
    }
  }
  cout << ans << endl;
}

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

int main() {
    string s;
    std::cin >> s;
    if(s[0]=='7'||s[1]=='7'||s[2]=='7'){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 1e5+7;

ll dp[N][5];
int n;
ll a[N][5];


int main()
{
    //ios::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);

    scanf("%d",&n);
    REP(i,0,n-1) scanf("%lld %lld %lld",&a[i][0], &a[i][1], &a[i][2]);

    REP(j,0,2) dp[0][j] = a[0][j];

    REP(i,1,n-1)
    {
        REP(j,0,2)
        {
            REP(k,0,2)
            {
                if (k==j) continue;
                dp[i][j] = max(dp[i][j],dp[i-1][k]+a[i][j]);
            }
        }
    }
    ll ans = 0;
    REP(i,0,2) ans = max(ans,dp[n-1][i]);
    printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 8192
//
// Projction and Reflection
//
// verified:
//   AOJ Course CGL_1_A: Projection
//   AOJ Course CGL_1_B: Reflection
//

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

/* Point */
using DD = double;
const DD INF = 1LL<<60;      // to be set appropriately
const DD EPS = 1e-10;        // to be set appropriately
const DD PI = acos(-1.0);
DD torad(int deg) {return (DD)(deg) * PI / 180;}
DD todeg(DD ang) {return ang * 180 / PI;}

struct Point {
    DD x, y;
    Point(DD x = 0.0, DD y = 0.0) : x(x), y(y) {}
    friend ostream& operator << (ostream &s, const Point &p) {return s << '(' << p.x << ", " << p.y << ')';}
};

inline Point operator + (const Point &p, const Point &q) {return Point(p.x + q.x, p.y + q.y);}
inline Point operator - (const Point &p, const Point &q) {return Point(p.x - q.x, p.y - q.y);}
inline Point operator * (const Point &p, DD a) {return Point(p.x * a, p.y * a);}
inline Point operator * (DD a, const Point &p) {return Point(a * p.x, a * p.y);}
inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);}
inline Point operator / (const Point &p, DD a) {return Point(p.x / a, p.y / a);}
inline Point conj(const Point &p) {return Point(p.x, -p.y);}
inline Point rot(const Point &p, DD ang) {return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);}
inline Point rot90(const Point &p) {return Point(-p.y, p.x);}
inline DD cross(const Point &p, const Point &q) {return p.x * q.y - p.y * q.x;}
inline DD dot(const Point &p, const Point &q) {return p.x * q.x + p.y * q.y;}
inline DD norm(const Point &p) {return dot(p, p);}
inline DD abs(const Point &p) {return sqrt(dot(p, p));}
inline DD amp(const Point &p) {DD res = atan2(p.y, p.x); if (res < 0) res += PI*2; return res;}
inline bool eq(const Point &p, const Point &q) {return abs(p - q) < EPS;}
inline bool operator < (const Point &p, const Point &q) {return (abs(p.x - q.x) > EPS ? p.x < q.x : p.y < q.y);}
inline bool operator > (const Point &p, const Point &q) {return (abs(p.x - q.x) > EPS ? p.x > q.x : p.y > q.y);}
inline Point operator / (const Point &p, const Point &q) {return p * conj(q) / norm(q);}

/* Line */
struct Line : vector<Point> {
    Line(Point a = Point(0.0, 0.0), Point b = Point(0.0, 0.0)) {
        this->push_back(a);
        this->push_back(b);
    }
    friend ostream& operator << (ostream &s, const Line &l) {return s << '{' << l[0] << ", " << l[1] << '}';}
};

/* Projection */
Point proj(const Point &p, const Line &l) {
    DD t = dot(p - l[0], l[1] - l[0]) / norm(l[1] - l[0]);
    return l[0] + (l[1] - l[0]) * t;
}
Point refl(const Point &p, const Line &l) {
    return p + (proj(p, l) - p) * 2;
}


int main() {
    DD xp1, yp1, xp2, yp2; cin >> xp1 >> yp1 >> xp2 >> yp2;
    Line l(Point(xp1, yp1), Point(xp2, yp2));
    int Q; cin >> Q;
    for (int qu = 0; qu < Q; ++qu) {
        DD x, y; cin >> x >> y;
        Point p(x, y);
        Point res = refl(p, l);
        cout << fixed << setprecision(10) << res.x << " " << res.y << endl;
    }
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

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

Measured memory_bytes: 3636
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int f(vector<pair<int, vi>> &data, vi &p, vb &bit, int n) {
    if (n == 0) {
        int M = p.size();
        for (int i = 0; i < M; i++) {
            int on = 0;
            for (int j = 0; j < data[i].first; j++) {
                if (bit[data[i].second[j] - 1]) {
                    on++;
                    on %= 2;
                }
            }
            if (on != p[i]) {
                return 0;
            }
        }
        return 1;
    }
    int N = bit.size();
    bit[N - n] = true;
    int anst = f(data, p, bit, n - 1);
    bit[N - n] = false;
    int ansf = f(data, p, bit, n - 1);
    return anst + ansf;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, vi>> data(M);
    for (int i = 0; i < M; i++) {
        pair<int, vi> p;
        int k;
        cin >> k;
        vi s(k);
        for (int j = 0; j < k; j++) {
            cin >> s[j];
        }
        p = make_pair(k, s);
        data[i] = p;
    }
    vi p(M);
    for (int i = 0; i < M; i++) {
        cin >> p[i];
    }
    vb bit(N, true);
    int ans = f(data, p, bit, N);
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int n, t, a;
    cin >> n >> t >> a;
    int h0 = (t - a) * 1000;

    int d1 = 1 << 30, i1 = 0;
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;
        h *= 6;
        int d = abs(h - h0);
        if (d < d1) {
            d1 = d;
            i1 = i;
        }
    }

    cout << i1 + 1 << endl;

    return 0;
}

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

void call(int n);

int main(){
    int a;
    cin >> a;
    call(a);
    return 0;
}

void call(int n){
    int i=1;
    do{
        int x=i;
        if(x%3==0){
            cout << " " << i;
        }
        else{
            while(1){
                if ( x % 10 == 3 ){
                cout << " " << i;
                break;
                }
                x /= 10;
                if(!x) break;
            }
        }
        
    }while(++i <= n);
    
    cout << endl;
}


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, k;
  cin >> n >> k;
  ll m = 1e5;
  vector<ll> cnt(m + 1, 0);
  REP(i, n) {
    ll a, b;
    cin >> a >> b;
    cnt[a] += b;
  }
  ll sum = 0;
  REP(i, m + 1) {
    if (sum + cnt[i] >= k) {
      cout << i << endl;
      return 0;
    }
    sum += cnt[i];
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
//cout << std::fixed << std::setprecision(15);
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e9;
const long long MOD = 1e9+7;
signed main(){
    string s,t; cin >> s >> t;
    int a,b; cin >> a >> b;
    string u; cin >> u;
    /*
    if(s==u) cout<<a-1<<' '<<b<<endl;
    else cout<<a<<' '<<b-1<<endl;
    */
   (s==u)?a--:b--;
   cout<<a<<' '<<b<<endl;
    
}

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

int val[MAX];

int main()
{
    for( int x = 1; x <= 100; x++ ){
        for( int y = 1; y <= 100; y++){
            for( int z = 1; z <= 100; z++ ){
                int num = x * x + y * y + z * z + x * y + x * z + y * z;
                if(num <= MAX)
                    val[num]++;
            }
        }
    }
    int n;
    cin >> n;
    for( int i = 1; i <= n; i++ )
        cout << val[i] << endl;
    return 0;
}

Measured memory_bytes: 3604
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll a,b,c;cin>>a>>b>>c;
    ll cap=a-b;
    cout<<max(0LL,c-cap)<<endl;
}

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

int main(){
    string s;
    cin >>s;
    if(s == "AAA" || s == "BBB"){
        cout <<"No" <<endl;
        return 0;
    }
    else{
        cout <<"Yes" <<endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	string number;
		while(1){ 
            cin >> number;
			if( number == "0"){
				break;
			}
			int x = 0;
		    for(int i = 0;i<number.size();i++){
				int num = number[i] -'0';
				x +=num;
			
			}
			cout << x << endl;
		}

	return 0;
} 

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

const int maxn=55;
int a[maxn],n;
double tmp;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",a+i);
	sort(a+1,a+n+1);
	tmp=a[1];
	for(int i=2;i<=n;++i) {
		tmp=(tmp+a[i])/2.0;
	}
	cout<<tmp;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5 + 10;

int main() {
    string s;
    cin >> s;
    if(s.length()==2 && s[0] == s[1]) {
        cout << "1 2" << endl;
        return 0;
    }
    for(int i = 2; i < s.length(); i++) {
        if(s[i- 2] == s[i] || s[i-1] == s[i] || s[i-2] == s[i-1]) {
            cout << i-1 << " " << i+1 << endl;
            return 0;
        }
    }
    cout << "-1 -1\n";
    return 0;
}

Measured memory_bytes: 512
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n, m;
    long long K;
    cin >> n >> m >> K;

    vector<long long> A(n);
    vector<long long> B(m);

    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> B[i];
    }

    vector<long long> sumA(n + 1, 0);
    vector<long long> sumB(m + 1, 0);

    for (int i = 0; i < n; ++i) {
        sumA[i + 1] = sumA[i] + A[i];
    }
    for (int i = 0; i < m; ++i) {
        sumB[i + 1] = sumB[i] + B[i];
    }

    auto ok = [&](int x) {

        for (int i = 0; i <= n && i <= x; ++i) {
            int j = x - i;
            if (j <= m && j >= 0) {
                if (sumA[i] + sumB[j] <= K) {
                    return true;
                }
            }
        }

        return false;
    };

    int lo = 0, hi = n + m;
    while (lo < hi) {
        auto mi = (lo + hi + 1) / 2;
        if (ok(mi)) {
            lo = mi;
        } else {
            hi = mi - 1;
        }
    }

    cout << lo << '\n';


    return 0;
}

Measured memory_bytes: 9536
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
inline void print() { cout << endl; }
template <class Head, class... Tail> inline void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...);}
template <class T> inline void print(vector<T>& vec) { for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " "; } cout << endl;}
template <class T> inline void print(vector<vector<T>>& df) { for (auto& vec : df) { print(vec); }}
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;

long double mlog(ll base, ll val) {
    if(val==0) return 0;
    return logl(val) / log(base);
}

int main() { 
    string S; cin >> S;
    ll K; cin >> K;
    ll T = 5e15;
    ll ct = 0;
    // print(S, K);
    REP(i, S.size()) {
        ll base = S[i]-'0';
        // print("base=", base, "ct=", ct);
        // print(mlog(base, ct) + T , mlog(base, K));
        if(base == 1) {
            ct += 1;
        } else if(mlog(base, ct) + T >= mlog(base, K)) {
            print(base);
            return 0;
        } else {
            ct += powl(base, T);
        }

        if(ct == K) {
            print(base);
            return 0;
        }
        // if(mlog(i, ))
        // print(i, ct);
        // if(ct >= K) {
        //     print(S[i]);
        //     break;
        // }
    }
    print(S[0]-'0');
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void open(const char *s)
{
#ifdef DEBUG
	char str[100];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
	sprintf(str,"%s.out",s);
	freopen(str,"w",stdout);
#endif
}
int ch[140010][2];
int d[140010];
int n;
int w[140010];
ll lim;
vector<pll> c[140010];
void dfs(int x)
{
	vector<pll> e;
	if(!d[x])
		e.push_back(pll(0,0));
	else
	{
		int v1=ch[x][0],v2=ch[x][1];
		dfs(v1);
		dfs(v2);
		if(!c[v1].size()||!c[v2].size())
		{
			c[v1].resize(0);
			c[v2].resize(0);
			return;
		}
		if(c[v1].size()>c[v2].size())
			swap(v1,v2);
		vector<pll>::iterator p2=c[v2].begin();
		vector<pll> e1,e2;
		for(auto s1:c[v1])
		{
			while(p2!=c[v2].end()&&s1.second+p2->first<=lim)
				p2++;
			if(p2==c[v2].begin())
				continue;
			p2--;
			e1.push_back(pll(s1.first,p2->second));
		}
		vector<pll>::iterator p1=c[v2].begin();
		for(auto s2:c[v1])
		{
			while(p1!=c[v2].end()&&s2.first+p1->second>lim)
				p1++;
			if(p1!=c[v2].end())
				e2.push_back(pll(p1->first,s2.second));
		}
		e.resize(e1.size()+e2.size());
		merge(e1.begin(),e1.end(),e2.begin(),e2.end(),e.begin());
		c[v1].resize(0);
		c[v2].resize(0);
	}
	for(auto v:e)
	{
		v.first+=w[x];
		v.second+=w[x];
		if(c[x].size()&&v.second>=c[x].back().second)
			continue;
		c[x].push_back(v);
	}
}
int check()
{
	dfs(1);
	int res=c[1].size();
	c[1].resize(0);
	return res;
}
int main()
{
	open("c");
	scanf("%d",&n);
	int i,x;
	for(i=1;i<=n-1;i++)
	{
		scanf("%d%d",&x,&w[i+1]);
		ch[x][d[x]++]=i+1;
	}
	ll l=0,r=10000000000000ll;
	while(l<r)
	{
		lim=(l+r)>>1;
		if(check())
			r=lim;
		else
			l=lim+1;
	}
	printf("%lld\n",l);
	return 0;
}

Measured memory_bytes: 31400
N,M = map(int,input().split())

A = [list(map(int, input().split()))  for i in range(M)]

graph_data = [[0] * N for i in range(N)]

for i in range(M):
    if A[i][0] > A[i][1]: A[i][0], A[i][1] = A[i][1], A[i][0]
    graph_data[A[i][0]-1][A[i][1]-1] = graph_data[A[i][1]-1][A[i][0]-1] = 1
    
visited = [False] * N

def dfs(now, depth):
    if visited[now]:
        return 0
    if depth == N - 1:
        return 1
    
    visited[now] = True
    total_path = 0
    for i in range(0,N):
        if graph_data[now][i] == 1: 
            total_path +=  dfs(i, depth + 1)
    visited[now] = False
    
    return total_path

print(dfs(0,0))

Measured memory_bytes: 3064
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();

    for i in 1..=n {
        let mut ans = 0;
        for x in 1..=i {
            if x * x > i {
                break;
            }
            for y in 1..=i {
                if x * x + y * y + x * y > i {
                    break;
                }
                for z in 1..=i {
                    if x * x + y * y + z * z + x * y + y * z + z * x > i {
                        break;
                    }
                    if x * x + y * y + z * z + x * y + y * z + z * x == i {
                        ans += 1;
                    }
                }
            }
        }
        println!("{}", ans);
    }
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if( a*b%2 == 0 ){
    cout << "Even" << endl;
  }else{
    cout << "Odd" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())
def TI(): return tuple(Is())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(S())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

def compress(A):
    return {element: i+1 for i, element in enumerate(sorted(set(A)))}

n, m = Is()
PY = TIR(m)
A = [list() for _ in range(n+1)]
for p, y in PY:
    A[p].append(y)
B = [compress(a) for a in A]

for p, y in PY:
    ans = str(p).zfill(6) + str(B[p][y]).zfill(6)
    print(ans)


Measured memory_bytes: 122584
#include <iostream>

using namespace std;

int val[110],weight[10010];
int res[110][10010];

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

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

	//res[number][weight]
	for (int i=0;i<N+1;i++) {
		res[i][0] = 0;
	}
	for (int i=0;i<W+1;i++) {
		res[0][i] = 0;
	}

	for(int i=1;i<N+1;i++) {
		for(int j=1;j<W+1;j++) {

			if (weight[i-1] > j) {

				res[i][j] = res[i-1][j];

			} else {
				res[i][j] = max(res[i-1][j],val[i-1]+res[i][j-weight[i-1]]);
			}
		}
	}
	//for(int j=1;j<W+1;j++) {
	//	cout << endl;
	//	for(int i=1;i<N+1;i++) {
	//		cout << res[i][j] << " ";
	//	}
	//}


	cout << res[N][W] << endl;
	return 0;
}

Measured memory_bytes: 7028
#include<bits/stdc++.h>
using namespace std;
int mp[200010],mp2[200010];
int main()
{
    int n,p=0,a,b;
    cin>>n;
    int t=n/2;
    for(int i=1;i<=n;i++)
     {
         cin>>mp[i];
         mp2[i]=mp[i];
     }
    sort(mp+1,mp+n+1);
     a=mp[t],b=mp[t+1];
    for(int i=1;i<=n;i++)
    {
        if(mp2[i]<=a)
            printf("%d",b);
        else
            printf("%d",a);
            if(i<n)
                printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main(){
	char s;cin>>s;
	if(s=='A'){
		cout<<"T"<<endl;
	}else if(s=='T'){
		cout<<"A"<<endl;
	}else if(s=='G'){
		cout<<"C"<<endl;
	}else{
		cout<<"G"<<endl;
	}
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect()
}

fn gcd(a: u32, b: u32) -> u32 {
    let mut x = a;
    let mut y = b;
    while y != 0 {
        let tmp = x;
        x = y;
        y = tmp % y;
    }
    x
}

fn main() {
    let (_n, k) = {
        let v: Vec<u32> = read();
        (v[0], v[1])
    };
    let a: Vec<u32> = read();
    let gcd = a.iter().fold(a[0], |x, &y| gcd(x, y));
    let max = a.into_iter().max().unwrap();

    if k % gcd == 0 && k <= max {
        println!("POSSIBLE",);
    } else {
        println!("IMPOSSIBLE");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=5010;
int a[N],b[N],v[N],id[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline bool cmp(const int &x,const int &y) {return b[x]+a[x]<b[y]+a[y];}
int main() {
    int n,tp=0;
    cin>>n;
    for(int i=1;i<=n;i++) a[i]=gi(),b[i]=gi(),id[i]=i;
    sort(id+1,id+1+n,cmp);
    for(int i=1;i<=n;i++) {
	int t=id[i];
	if(v[tp]<=a[t]) ++tp,v[tp]=v[tp-1]+b[t];
	for(int j=tp;~j;j--)
	    if(v[j]<=a[t]) v[j+1]=min(v[j+1],v[j]+b[t]);
	if(v[tp+1]) ++tp;
    }
    cout<<tp;
    return 0;
}

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

int main(){
  int n;
  string Taro, Hanako;
  int T = 0, H = 0;

  cin >> n;

  for ( int i = 0; i < n; i++ ){
    cin >> Taro >> Hanako;
    if ( Taro > Hanako ) T += 3;
    else if ( Hanako > Taro ) H += 3;
    else { T += 1; H += 1; }
  }

  cout << T << " " << H << endl;

  return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N; cin >> N;
    map<int,int> m; int cnt=0;
    rep(i,N){
        int a; cin >> a; 
        if(a>=1 && a<=399) m[0]++;
        else if(a>=400 && a<=799) m[1]++;
        else if(a>=800 && a<=1199) m[2]++;
        else if(a>=1200 && a<=1599) m[3]++;
        else if(a>=1600 && a<=1999) m[4]++;
        else if(a>=2000 && a<=2399) m[5]++;
        else if(a>=2400 && a<=2799) m[6]++;
        else if(a>=2800 && a<=3199) m[7]++;
        else cnt++; 
    }
    if(m.size()<1 && cnt>0) cout << 1 << " " << cnt << endl;  
    else if(cnt>0) cout << m.size() << " " << m.size()+cnt << endl;
    else  cout << m.size() << " " << m.size() << endl; 

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

LL n, a[100000];

LL f() {
	int c = 0;
	dec(j, 60) {
		int p = -1;
		incID(i, c, n) {
			if(bit(a[i], j) == 1) { p = i; break; }
		}
		if(p == -1) { continue; }
		inc(i, n) {
			if(i == p) { continue; }
			if(bit(a[i], j)) { a[i] ^= a[p]; }
		}
		swap(a[c++], a[p]);
	}
	LL x = 0;
	inc(i, n) { x ^= a[i]; }
	return x;
}

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	LL ans = 0;
	inc(i, n) { ans ^= a[i]; }
	inc(i, n) { a[i] &= ~ans; }
	
	ans += f() * 2;
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a = 0;
  int b = 0;
  cin >> a;
  for(int i = 0; i<3; i++){
    b += a % 2;
    a /= 2;
  }
  cout << b << endl;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<string> v(h);
  rep(i, h) cin >> v[i];

  queue<pair<p, int>> q;
  q.push({{0, 0}, v[0][0] == '.' ? 0 : 1});
  vector<vector<int>> dp(h, vector<int>(w, INT_MAX));
  // dp[0][0] = (v[0][0] == '.') ? 0 : 1;

  while(!q.empty()){
    int y = q.front().first.first;
    int x = q.front().first.second;
    int num = q.front().second;
    q.pop();
    // cout << y << ' ' << x << endl;
    if(dp[y][x] <= num){
      continue;
    }
    chmin(dp[y][x], num);

    if(y+1 < h) {
      q.push({{y+1, x}, v[y][x] == '.' && v[y+1][x] == '#' ? num+1 : num});
    }
    if(x+1 < w){
      q.push({{y, x+1}, v[y][x] == '.' && v[y][x+1] == '#' ? num+1 : num});
    }
  }
  cout << dp[h-1][w-1] << endl;
  // print(dp);
}


Measured memory_bytes: 512
def maybe_prime(d,s,n):
    for a in (2,3,5,7):
        p = False
        x = pow(a,d,n)
        if x==1 or x==n-1:
            continue
        for i in range(1,s):
            x = x*x%n
            if x==1: return False
            elif x == n-1:
                p = True
                break
        if not p: return False
    return True

def is_prime(n):
    if n in (2,3,5,7,11): return True
    elif 0 in (n%2,n%3,n%5,n%7,n%11): return False
    else:
        d,s = n-1, 0
        while not d%2:
            d,s = d>>1,s+1
        return maybe_prime(d,s,n)
cnt = 0
n = int(input())
for i in range(n):
  n = int(input())
  if is_prime(n): cnt+=1

print(cnt)

Measured memory_bytes: 7716
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;

/////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

////////////////////////////////

#define int long long

void solve(){
	
	int n;
	cin>>n;
	map<string,int> mp;
	int mx = 0;
	while(n--){

		string x;
		cin>>x;
		mp[x]++;

		mx = max(mx , mp[x]);

	}

	for(auto it : mp){

		if(it.ss==mx)
			cout<<it.ff<<endl;
	}
}

signed main(){

    fast;
    int t = 1;
    //cin>>t;
    for(int i = 1 ; i <= t; ++i){

    	solve();
    }
}


Measured memory_bytes: 23808
h, w, k = map(int, input().split())
s = [input() for _ in range(h)]
res = 1000000
for i in range(2 ** (h - 1)):
    l = [0]
    cnt = 0
    for j in range(h - 1):
        if (i >> j) & 1:
            l.append(j + 1)
            cnt += 1
    l.append(h)
    li = [0] * (cnt + 1)
    j = 0
    ans = cnt
    f = 0
    while j < w:
        sm = 0
        idx = 0
        for i in range(h):
            if l[idx + 1] <= i:
                if sm > k:
                    f = 1
                    break
                sm = 0
                if li[idx] > k:
                    ans += 1
                    break
                idx += 1
            if s[i][j] == '1':
                sm += 1
                li[idx] += 1
        else:
            if li[idx] > k:
                if sm > k:
                    f = 1
                    break
                ans += 1
                li = [0] * (cnt + 1)
                continue
            j += 1
            continue
        if f:
            break
        li = [0] * (cnt + 1)
    if not f:
        res = min(res, ans)
print(res)


Measured memory_bytes: 44508
<?PHP
fscanf(STDIN, "%d", $n);
$array = array_map('intval', explode(' ', trim(fgets(STDIN))));
if (in_array('0', $array)){
  echo 0;
  return;
}
$sum = $array[0];
for($i = 1; $i < $n; $i++){
  $sum = $sum * $array[$i];
  if($sum > 1000000000000000000){
   echo -1;
   return;
  }
}
 
 echo $sum;

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

int main(){
    char a,b;
    cin >> a >> b;
    if(a=='H' && b=='H'){
        cout << 'H' << endl;
    }
    else if(a=='H' && b=='D'){
        cout << 'D' << endl;
    }
    else if(a=='D' && b=='H'){
        cout << 'D' << endl;
    }
    else if(a=='D' && b=='D'){
        cout << 'H' << endl;
    }
    
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] h = new int[N];
    for (int i = 0; i < N; i++) {
      h[i] = sc.nextInt();
    }
    int[] dp = new int[N];
    for (int i = 0; i < N; i++) {
      dp[i] = Integer.MAX_VALUE;
    }
    dp[0] = 0;
    for (int i = 0; i < N - 1; i++) {
      dp[i+1] = Math.min(dp[i+1], dp[i] + Math.abs(h[i+1]-h[i]));
      if (i + 2 < N) {
        dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(h[i+2]-h[i]));
      }
    }
    System.out.println(dp[N-1]);
  }
}

Measured memory_bytes: 50456
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int n, m, x, y;
  scanf("%d %d %d %d", &n, &m, &x, &y);
  int max = x;
  int min = y;
  rep(i, 0, n) {
    scanf("%d", &x);
    max = max(max, x);
  }
  rep(i, 0, m) {
    scanf("%d", &y);
    min = min(min, y);
  }
  if (min > max) 
    printf("No War\n");
  else
    printf("War\n");
  return 0;
}


Measured memory_bytes: 128