akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	string s; cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '?') s[i] = 'D';
	}
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 3768
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	x,y = map(int,input().split())	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

def inpl(): return list(map(int, input().split()))

#### START
S = input()

new_S = ""
for s in S:
  if s == "9":
    new_S = new_S + "1"
  elif s == "1":
    new_S = new_S + "9"
  else:
    new_S = new_S + s

print(new_S)

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

vector<int> dignum(int X){
    if(X == 0) return {0};
    vector<int> res;
    while(X){
        res.push_back(X%10);
        X /= 10;
    }
    reverse(res.begin(), res.end());
    return res;
}

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> S(M), C(M);
    for(int i=0; i<M; i++){
        cin >> S[i] >> C[i];
        S[i]--;
    }

    for(int x=0; x<1000; x++){
        auto v = dignum(x);
        if(v.size() != N) continue;
        bool ok = true;
        for(int i=0; i<M; i++) if(v[S[i]] != C[i]) ok = false;
        if(ok){
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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

int main()
{
  int a, b, c;
  std::cin >> a >> b >> c;

  if (a < b && b < c)
  {
    std::cout << "Yes" << std::endl;
  }
  else
  {
    std::cout << "No" << std::endl;
  }

  return 0;
}



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

namespace Atcoder
{
    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int x = int.Parse(input[0]);int a = int.Parse(input[1]);int b = int.Parse(input[2]);

            if (Math.Abs(x - a) > Math.Abs(x - b)){
                Console.WriteLine("B");
            }else{
                Console.WriteLine("A");
            }

        }
    }
}


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

int main()
{
  int k,n;
  int l = 0;
  int* pT;

  cin >> k >> n;

  pT = new int[n];

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

  for(int j=0; j < n-1; j++){
    if(l < pT[j+1] - pT[j]){
      l = pT[j+1] - pT[j];
    }
  }

  if(l < k + pT[0] - pT[n-1])
    l = k + pT[0] - pT[n-1];

  cout << k-l << '\n';

  delete[] pT;

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

long long bin_search(long long l, long long r, long long x, vector<long long> &A){
    long long mid=(l+r)/2;
    if(mid==l){
        return mid+1;
    }else if(r==0){
        return 0;
    }
    //cout << mid << endl;
    if(A[mid]>=x){
        return bin_search(mid, r, x, A);
    }else{
        return bin_search(l, mid, x, A);
    }

}

long long N, M;
long long bin_search2(long long l, long long r, vector<long long> &A){
    long long mid=(l+r)/2;
    if(mid==l){
        return mid;
    }

    long long cnt =0;
    for(int i=0; i<N; i++){
        cnt+=bin_search(-1, N, mid-A[i], A);
    }

    if(cnt>=M){
        return bin_search2(mid, r, A);
    }else{
        return bin_search2(l, mid, A);
    }
}

int main(){
    cin >> N >> M;
    vector<long long> A(N,0);
    vector<long long> accA(N+1,0);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A.rbegin(), A.rend());
    for(int i=0; i<N; i++){
        accA[i+1]=accA[i]+A[i];
    }
    //cout_vec(A);

    long long x = bin_search2(0,MOD, A);
    long long cnt =0;
    //cout << x << endl;
    long long ans=0;
    for(int i=0; i<N; i++){
        long long k = bin_search(-1,N,x-A[i],A);
        ans+=A[i]*k+accA[k];
        cnt+=k;
        //cout << k << endl;
    }
    ans-=(cnt-M)*x;
    cout << ans << endl;
}

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

int h, w, m;
vector<int> x, y;

int main() {
    cin >> h >> w >> m;
    x.resize(m);
    y.resize(m);
    for (int i = 0; i < m; i++) {
        cin >> x[i] >> y[i];
        x[i]--, y[i]--;
    }
    vector<int> x_eq(h), y_eq(w);
    for (int i = 0; i < m; i++) {
        x_eq[x[i]]++;
        y_eq[y[i]]++;
    }
    int x_max = *max_element(x_eq.begin(), x_eq.end());
    int y_max = *max_element(y_eq.begin(), y_eq.end());
    lint x_num = 0;
    for (int i = 0; i < h; i++) {
        if (x_eq[i] == x_max) {
            x_num++;
        }
    }
    lint y_num = 0;
    for (int i = 0; i < w; i++) {
        if (y_eq[i] == y_max) {
            y_num++;
        }
    }
    lint pattern = x_num * y_num;
    lint bomb_pattern = 0;
    lint max_obj = x_max + y_max;
    for (int i = 0; i < m; i++) {
        if (x_eq[x[i]] + y_eq[y[i]] == max_obj) {
            bomb_pattern++;
        }
    }
    lint ans = x_max + y_max;
    if (pattern <= bomb_pattern) {
        ans--;
    }
    cout << ans << endl;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    map<int,int> mp;
    rep(i,k) {
        int d;
        cin >> d;
        rep(i,d) {
            int a;
            cin >> a;
            mp[a]++;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (mp[i] == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    string T, S;

    cin >> S;
    cin >> T;

    int count = 0;

    for (int i = 0; i < S.size(); i++){
        if (S[i] != T[i]){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3852
// https://atcoder.jp/contests/arc067/tasks/arc067_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    int n, x;
    cin >> n >> x;
    ll a, b, sum = 0;
    REP(i, n) {
        cin >> a;
        if (i > 0) {
            ll t = a + b - x;
            if (t > 0) {
                sum += max(0LL, t);
                b = max(0LL, a - t);
            } else {
                b = a;
            }
        } else {
            b = a;
        }
    }
    cout << sum << endl;
    return 0;
}


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

using namespace std;

#define endl            "\n"

#define sz(x)          (int) (x.size())

#define all(v)          v.begin(), v.end()

#define isOdd(n)       (n&1)

#define pow(n, m)      (ll)powl(n, m)

#define clr(x, val)     memset(x, val, sizeof(x))

typedef long long ll;

typedef long double ld;

typedef pair<int, int> pii;

typedef vector<int> vi;

const int N = 1e6 + 5;

int mp[N];

vector<int> sieve(N, 0);

int main()

{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, mx = 0; cin >> n;

    int a[n];

    for(auto &i: a){

            cin >> i, mp[i]++;

            if(i != 1) mx = max(mx, mp[i]);

    }

    if(!mx) return cout << "pairwise coprime", 0;

    int g = 0, p = 1;

    for(ll i = 2; i < N && p; i++){

        if(!sieve[i]){

            ll k = i, c = 0;

            while(k < N){

                sieve[k] = 1;

                c += mp[k];

                if(c > 1){

                    p = 0;

                    goto EmergencyGate;

                }

                k += i;

            }

        }

    }

    EmergencyGate:;

    if(p) return cout << "pairwise coprime", 0;

    for(int i = 0; i < n; i++) g = __gcd(g, a[i]);

    if(g == 1) return cout << "setwise coprime", 0;

    cout << "not coprime";

    return 0;

}



Measured memory_bytes: 14756
#include<cstdio>
#include<iostream>

#define NMAX 500000
#define SENTINEL 1000000001

int cnt=0;

using namespace std;

void merge(int A[],int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	int L[NMAX],R[NMAX];
	for(int i=0;i<=n1-1;i++){
		L[i]=A[left+i];
	}
	for(int i=0;i<=n2-1;i++){
		R[i]=A[mid+i];
	}
	L[n1]=SENTINEL;
	R[n2]=SENTINEL;
	int i=0,j=0;
	for(int k=left;k<=right-1;k++){
		cnt++;
		if(L[i]<=R[j]){
			A[k]=L[i];
			i++;
		}
		else{
			A[k]=R[j];
			j++;
		}
	}
}

void merge_sort(int A[],int left,int right){
	if(left+1<right){
		int mid=(left+right)/2;
		merge_sort(A,left,mid);
		merge_sort(A,mid,right);
		merge(A,left,mid,right);
	}
}

int main(void){

	int n;
	int A[NMAX];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>A[i];
	}
	merge_sort(A,0,n);
	for(int i=0;i<n-1;i++){
		cout<<A[i]<<" ";
	}
	cout<<A[n-1]<<endl;
	cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}

ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
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;

void solve(){
  int n;
  double m;
  cin>>n>>m;
  vector<double>a(n);
  double sum=0;
  rep(i,n)cin>>a[i],sum+=a[i];
  sort(rall(a));
  int cnt=0;
  rep(i,n){
    if(a[i]>=sum/(4.0*m))++cnt;
  }
  if(cnt>=m)cout<<"Yes";
  else cout<<"No";
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}


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


int main()
{
   int n,x ;
   cin >> n >> x ;
   int l[n] ;
   for(int i=0;i<n;++i) cin >> l[i] ;

   int ans = 1;
   int d = 0 ;
   for(int i=0;i<n;++i)
   {
       int tmp = d + l[i] ;
       d = d + l[i] ;
       //cout << d << endl ;
       if(tmp<=x) ans++ ;
   }

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



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

bool is_atari(string my, string ru) {
    for (int i=0; i<8; i++) {
        if ((ru[i] != '*')&&(my[i] != ru[i])) return false;
    }
    return true;
}

int main() {
    int i, j, n, m, atari_value;
    string atari_rule;
    string my_num;

    while (cin >> n >> m) {
        if ((n == 0) && (m == 0)) {
            break;
        }

        vector<string> atari_rules;
        vector<int> atari_values;
        int tousenkin = 0;
        for (i=0; i<n; i++) {
            cin >> atari_rule >> atari_value;
            atari_rules.push_back(atari_rule);
            atari_values.push_back(atari_value);
        }

        for (i=0; i<m; i++) {
            cin >> my_num;
            for (j=0; j<n; j++) {
                if (is_atari(my_num, atari_rules[j])) {
                    tousenkin += atari_values[j];
                }
            }
        }
        cout << tousenkin << endl;
    }
    return 0;
}

Measured memory_bytes: 1240
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n) cout<<fixed<<setprecision(n);
#define rep(i,n)   for (int i = 0; i < (n); ++i)
#define sort(a)    sort((a).begin(), (a).end());
#define uniq(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define reverse(a) reverse((a).begin(), (a).end());
#define out(d) cout << (d);
#define outl(d) std::cout<<(d)<<"\n";
#define Yes() printf("Yes\n");
#define No() printf("No\n");
#define YES() printf("YES\n");
#define NO() printf("NO\n");
#define ceil(x, y) ((x + y - 1) / (y))

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12)

  ll a, b; cin >> a >> b;
  if (a == b)
    outl("Draw")
  else if (a == 1 && b != 1)
    outl("Alice")
  else if (a != 1 && b == 1)
    outl("Bob")
  else if (a > b)
    outl("Alice")
  else
    outl("Bob")
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
ll i,n,m,a,b;
ll deg[N],p[N];
vector<vi> adj(N);
stack<ll> s;
bool visit[N];
void dfs(ll v)
{
    visit[v] = 1;
    for(auto it: adj[v]) if(!visit[it])
        dfs(it);
    s.push(v);
}
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>m;
    rep(i,0,n - 1 + m){
        cin>>a>>b;
        adj[a].pb(b);
        deg[b] += 1;
    }
    rep(i,1,n + 1) if(deg[i] == 0)
        dfs(i);
    while(!s.empty()){
        a = s.top();
        s.pop();
        for(auto it: adj[a])
            p[it] = a;
    }
    rep(i,1,n + 1) cout<<p[i]<<endl;
    return 0;
}

Measured memory_bytes: 12700
#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(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int 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 inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(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 PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

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; } }
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; }

// ---- ----

int n, m, x[101], y[101];

int main() {
	cin >> n >> m >> x[0] >> y[0];
	inc1(i, n) { cin >> x[i]; }
	inc1(i, m) { cin >> y[i]; }
	
	sort(x, x + n + 1, greater<int>());
	sort(y, y + m + 1,    less<int>());
	
	// inc(i, n + 1) { cout << x[i] << " "; } cout << endl;
	// inc(i, m + 1) { cout << y[i] << " "; } cout << endl;
	
	cout << (x[0] < y[0] ? "No War" : "War") << endl;
	
	return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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; }


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

void func(std::string S, std::string T){

    if(S== T.substr(0,S.size())){
        cout<<YES<<endl;
    }
    else{
        cout<<NO<<endl;
    }

}

int main(){
    // cout << fixed << setprecision(5);

    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    func(S, T);
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define vll vector<pair<ll, ll>
using namespace std;


int main(){
    ios_base::sync_with_stdio(true);
    cin.tie(NULL);
    ll n, ans = 0;
    cin >> n;
    string s;
    cin >> s;
    
    for(ll i=0; i<n-2; i++){
        if (s.substr(i, 3) == "ABC"){
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
//abc057_a.cpp
//Fri Oct 19 23:17:02 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n,m;
	cin >> n >> m;
	cout << (n+m)%24 << endl;
}

Measured memory_bytes: 256
'use strict'

const main = (INPUT) => {
  const input = INPUT.split('\n')
  const n = Number(input[0])
  const p = input[1].split(' ').map(n => Number(n))
  let ans = 0
  for (let i = 1; i < p.length - 1; i++) {
    if (p[i - 1] <= p[i] && p[i] <= p[i + 1] || p[i - 1] >= p[i] && p[i] >= p[i + 1]) {
      ans++
    }
  }
  console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 21064
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

inline double add(double a, double b){
    return abs(a+b)<(1e-10)*(abs(a)+abs(b)) ? 0.0 : a+b;
}

struct vec{
    double x,y;
    vec operator-(vec b){
        return (vec){add(x,-b.x),add(y,-b.y)};
    }
    vec operator+(vec b){
        return (vec){add(x,b.x),add(y,b.y)};
    }
    vec operator*(double d){
        return (vec){x*d,y*d};
    }
    double dot(vec v){
        return add(x*v.x,y*v.y);
    }
    double cross(vec v){
        return add(x*v.y,-y*v.x);
    }
    double norm(){
        return sqrt(x*x+y*y);
    }
};

int ccw(vec& a, vec& b, vec& c){
    vec ab = b-a, ac = c-a;
    double o = ab.cross(ac);
    if(o>0) return 1; //CCW
    if(o<0) return -1; //CW
    if(ab.dot(ac)<0){
        return 2; //C-A-B
    }else{
        if(ab.dot(ab)<ac.dot(ac)){
            return -2; //A-B-C
        }else{
            return 0; //A-C-B
        }
    }
}

vector<vec> convex_hull(vector<vec>& V){
    vector<vec> C;
    vector<vec>::iterator ite;
    sort(V.begin(),V.end(),[](const vec& a, const vec& b){return a.y==b.y ? a.x < b.x : a.y< b.y;});
    C.push_back(V[0]),C.push_back(V[1]);
    for(auto i=V.begin()+2; i!=V.end(); ++i){
        C.push_back(*i);        
        while(ite=C.end()-1, C.size()>2&&ccw(*(ite-2),*(ite-1),*ite)==-1){
            C.erase(ite-1);
        }
    }
    sort(V.begin(),V.end(),[](const vec& a, const vec& b){return a.y==b.y ? a.x > b.x : a.y>b.y;});
    for(auto i=V.begin()+1; i!=V.end(); ++i){
        C.push_back(*i);
        while(ite=C.end()-1, C.size()>2&&ccw(*(ite-2),*(ite-1),*ite)==-1){
            C.erase(ite-1);
        }
    }
    C.pop_back();
    return C;
}

int main(){
    int n;
    cin >> n;
    vec v;
    vector<vec> V,C;
    while(n--){
        cin >> v.x >> v.y;
        V.push_back(v);
    }
    C=convex_hull(V);
    cout << C.size() << endl;
    for(auto& i : C) cout << i.x << " " << i.y << endl;
    return 0;
}

Measured memory_bytes: 7260
#!/usr/bin/env python3
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

counters = Counter(A).items()

if N % 2 == 1:
    for k, v in counters:
        if k == 0:
            if v != 1:
                print(0)
                break
        else:
            if k % 2 != 0 or v != 2:
                print(0)
                break
    else:
        ans = pow(2, N // 2, mod)
        print(ans)
else:
    for k, v in counters:
        if k % 2 != 1 or v != 2:
            print(0)
            break
    else:
        ans = pow(2, N // 2, mod)
        print(ans)

Measured memory_bytes: 14820
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	string s,p;
	cin >> s >> p;
	int k,f;
	for (int i = 0; i < s.size(); ++i)
	{
		k = i;
		for (int j = 0; j < p.size(); ++j)
		{
			if (s[k] == p[j])
			{
				k++;
				if (k == s.size())
				{
					k = 0;
				}
			}else{
				f = 1;
				break;
			}
		}
		if (f == 1)
		{
			f = 0;
		}else{
			f = 2;
			break;
		}
	}
	if(f == 0){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 1184
#ifdef DEBUG
#include "debug.h"
#else
#define debug(...) 42
#endif
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> str(h);
  for(auto &x: str) cin >> x;
  int res = 1.01e9;
  for(int cuts = 0; cuts <= (1 << (h - 1)); ++cuts) {
    vector<int> area;
    area.push_back(0);
    for(int i = 0; i < h - 1; ++i) {
      if((cuts >> i) & 1) area.push_back(i + 1);
    }
    area.push_back(h);
    int here = 0;
    vector<vector<int>> v(area.size() - 1);
    for(int i = 0; i < (int) area.size() - 1; ++i) {
      int s = area[i], e = area[i + 1];
      for(int j = 0; j < w; ++j) {
        int hr = 0;
        for(int x = s; x < e; ++x) {
          hr += int(str[x][j] == '1');
        }
        if(hr > k) here = 1.01e9;
        v[i].push_back(hr);
      }
    }
    vector<int> count(area.size() - 1);
    if(here >= int(1.01e9)) continue;
    for(int i = 0; i < w; ++i) {
      int mx = 0;
      for(int j = 0; j < (int) area.size() - 1; ++j) {
        count[j] += v[j][i];
        mx = max(mx, count[j]);
      }
      debug(mx, k, i);
      if(mx > k) {
        here++;
        for(int j = 0; j < (int) area.size() - 1; ++j) {
          count[j] = v[j][i]; 
        }
      }
    }
    debug(area);
    debug(v);
    res = min(res, here + (int) area.size() - 2);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>

using namespace std;

int main() { 
    string s;
    cin >> s;
    if(s[2] == s[3] and s[4] == s[5]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
#define pb push_back
#define PI 3.14159265
int M = 998244353;
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int a[n];
  unordered_map<int, int> m;
  bool e = false;
  for (int i = 0; i < n; ++i)
  {
    cin >> a[i];
    if (a[i] == 1)
      e = true;
    m[a[i]]++;
  }
  if (e)
  {
    if (m[1] > 1)
      cout << "0";
    else
      cout << "1";
    exit(0);
  }
  int ans = n;
  for (int i = 0; i < n; ++i)
  {
    bool flag = false;
    if (m[a[i]] > 1)
    {
      ans--;
      continue;
    }
    for (int j = 2; j * j <= a[i]; ++j)
    {
      if (a[i] % j == 0)
      {
        int f = j;
        int s = a[i] / j;
        if (m[f] > 0)
        {
          flag = true;
          break;
        }
        if (m[s] > 0)
        {
          flag = true;
          break;
        }
      }
    }
    if (flag)
      ans--;
  }
  cout << ans;


}


Measured memory_bytes: 33304
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>



void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}

int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }

  if(b==0){
    return a;
  }

  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }

  return b;
}

/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}


long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int n,x,t;
  scanf("%d%d%d",&n,&x,&t);

  int count=(n+(x-1))/x; //何回焼くか
  count=!!(n%x)+n/x;  

  printf("%d\n",t*count);

  return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> X;
    for (int i = 0; i < N; ++i)
    {
        int temp;
        cin >> temp;
        X.push_back(temp);
    }

    int ans = 1 << 30;
    for (int i = 1; i <= 100; ++i)
    {
        int sum = 0;
        for (int j = 0; j < N; ++j)
        {
            sum += (i - X[j]) * (i - X[j]);
        }
        ans = std::min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(void)
{
    long long n,i,m;
    cin >> n;
//    for(i=(long long)sqrt(n);i>=1;i--)
    for(i=1;i*i<=n;i++)
        if(n%i==0)
        {
            m=i;
        }
    cout << n/m+m-2;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int,input().split())
min = 1
max = n
for var in range(0, m):
  a, b= map(int, input().split())
  if min < a:
    min = a

  if max > b:
    max = b
if(max-min < 0):
  print(0)
else:
  print(max-min+1)

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

const int maxn = 1e6 + 1;

inline int read()
{
	register int x = 0, ch = getchar(), f = 1;
	while(!isdigit(ch)) {if(ch == '-') f = -1; ch = getchar();}
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	return x * f;
}

int n;

int main()
{
	n = read();
	printf("%d", n * n * n);
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = Counter(map(int, input().split()))
c = []
for k,v in a.items():
    if v >= 2:
        c.append(k)
    if v >= 4:
        c.append(k)

c.sort()
c = c[::-1]
if len(c) < 2:
    print(0)
else:
    print(c[0] * c[1])

Measured memory_bytes: 24224
N = input()

cnt = 0
strdit = {}
for i in input().split():
    i = int(i)
    if i not in strdit.keys():
        strdit[i] = 0
    strdit[i] += 1

for i in strdit.keys():
    if i > strdit[i]:
        cnt += strdit[i]
    else:
        cnt += strdit[i] - i

print(cnt)



Measured memory_bytes: 23284
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {
  public static void main(final String[] args) throws Exception {
    try (BufferedReader r = new BufferedReader(new InputStreamReader(System.in))) {
      String l = r.readLine();
      int n = Integer.parseInt(l);
      Set<String> s = new HashSet<String>();
      for (int i = 0; i < n; i++) {
        l = r.readLine();
        s.add(l);
      }
      System.out.println(s.size());
    }
  }
}

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

int main(){
    long long a, b;
    cin >> a >> b;

    double k = (a +b)  / double(2);

    if(ceil(k) == floor(k)){
        cout << int(k) << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    char s[3];
    int n=0;
    cin >> s;
    for(int i=0;i<3;i++){
        if(s[i] == 'o') n++;
    }
    cout << 700 + 100 * n << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
const int N=1e5+10;
int main(){
int n,ans=0,temp;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d",&temp);
while(temp%2==0){
temp/=2;
ans++;
}
}
printf("%d\n",ans);
}

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

int main(){
    int H,W,i,j;
    int count=0;
    string  S[50];

    const int di[8]={-1,-1,-1,0,0,1,1,1};
    const int dj[8]={-1,0,1,-1,1,-1,0,1};
    int ki,kj;
    cin >> H >> W;

    for(i=0;i<H;i++){
        cin >> S[i];
    }

    for(i=0;i<H;++i){
        for(j=0;j<W;++j){
            if(S[i][j]=='#') continue;

            count=0;
            for(int d=0;d<8;++d){
                const int ki=i+di[d];
                const int kj=j+dj[d];

                if(ki<0 || ki>=H) continue;
                if(kj<0 || kj>=W) continue;
                if(S[ki][kj]=='#') count ++;
            }

            S[i][j]=char(count+'0');
        }
    }

    for(i=0;i<H;++i) cout << S[i] << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll INF=1e15+4;
const int Nmax=2e5+1;
const int Nd=61;



int main(){
  ll x,k,d; cin>>x>>k>>d;
  long double lx,lk,ld;
  lx=log(abs(x));lk=log(abs(k)); ld=log(abs(d));
  ll ans=INF;


  ll k2=x/d;
  if(abs(k2)>k){
    cout<<min(abs(x-k*d),abs(x+k*d));
    return 0;
  }

  if(abs(k2)%2==k%2){
    cout<<abs(x-k2*d);
    return 0;
  }else{
    ans=min(abs(x-(k2-1)*d),abs(x-(k2+1)*d));
  }
  cout<<ans<<endl;





}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define LONGLONGMAX 9223372036854775807
#define LONGLONGMIN -9223372036854775807
#define INTMAX 32767
#define INTMIN -32767
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
string n; int ans;
int main(){
  cin >> n;
  for (size_t i = 0; i < n.length(); i++) {
    if(n[i] == '2') ans++;
  }
  cout << ans; 
}


Measured memory_bytes: 256
n,x=map(int,input().split())
a=list(map(int,input().split()))
count=0
keeper=0
for i in range(n):
  if a[i]+keeper<=x:
    keeper=a[i]
  else:
    counter=a[i]+keeper-x
    if a[i]-counter>0:
      keeper=a[i]-counter
    else:
      keeper=0
    count+=counter
print(count)

Measured memory_bytes: 14252
#include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <math.h>
    #include <ctype.h>
    #include <limits.h>	
    #define inf (INT_MAX-1)
    #define INF 9223372036854775807
    #define sq(n) ((n)*(n))
    #define rep(i,n) for(i=0;i<n;i++)
    #define rev(i,n) for(i=n-1;i>=0;i--)
    const int mod=(int)1e09+7;
     
    int in(void){
    	int i;scanf("%d",&i);
    	return i;
    }
    long long llin(void){
    	long long i;scanf("%lld",&i);
    	return i;
    }
    double din(void){
    	double i;scanf("%lf",&i);
    	return i;
    }
    void chin(char s[]){
    	scanf("%s",s);
    }
    void print(int a){
    	printf("%d\n",a);
    }
    void llprint(long long a){
    	printf("%lld\n",a);
    }
    void dprint(double a){
    	printf("%.10f\n",a);
    }
    void print2(int a,int b){
    	printf("%d %d\n",a,b);
    }
    long long max(long long a,long long b){
    	return a>b?a:b;
    }
    long long min(long long a,long long b){
    	return a<b?a:b;
    }
    double dmax(double a,double b){
    	return a>b?a:b;
    }
    int cmp(const void *a,const void *b){
    	return *(long long *)b-*(long long *)a;
    }
     
    int main(void){
    	int n=in(),k=in(),i,l[50],ans=0;
    	rep(i,n){
    		l[i]=in();
    	}
    	qsort(l,n,sizeof(int),cmp);
    	rep(i,k){
    		ans+=l[i];
    	}
    	print(ans);
    	return 0;
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
// nichijou
#define REP(i,a,b) for (int i(a), _B(b); i < _B; ++i)
#define RP(i,n) REP(i,0,n)
#define PER(i,a,b) for(int i((a)-1), _B(b); i >= _B; --i)
#define PR(i,n) PER(i,n,0)
#define REP1(i,a,b) REP(i,a,(b)+1)
#define RP1(i,n) REP1(i,1,n)
#define PER1(i,a,b) PER(i,(a)+1,b)
#define PR1(i,n) PER1(i,n,1)
#define DO(n) REP(__i,0,n)
template<typename T>
void cmax(T & a, T b) {a = max(a, b);}
template<typename T>
void cmin(T & a, T b) {a = min(a, b);}

// data type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second

// STL container
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define CLR(a) a.clear()
#define BK(a) (a.back())
#define FT(a) (a.front())
#define DB(a) a.pop_back()
#define DF(a) a.pop_front()
#define PB push_back
#define EB emplace_back

/* I gave you my heart and then you turned around. */
void _BG(const char * s) {}
template<typename T, typename ... TT>
void _BG(const char * s,T a, TT...b)
{
	for (int c = 0; *s && (c || *s != ','); ++s) {
		cerr<<*s;
		switch (*s) {
		case '(':
		case '[':
		case '{':
			++c;
			break;
		case ')':
		case ']':
		case '}':
			--c;
			break;
		}
	}
	cerr<<" = "<<a;
	if (*s) {
		cerr<<", ";
		_BG(++s,b...);
	} else
		cerr<<endl;
}
#define BG(...) do { \
	cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
	_BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)

/* Reading input is now 20% cooler! */
bool RD(void) {return true;}
bool RD(char & a) {return scanf(" %c", &a) == 1;}
bool RD(char * a) {return scanf("%s", a) == 1;}
bool RD(double & a) {return scanf("%lf", &a) == 1;}
bool RD(int & a) {return scanf("%d", &a) == 1;}
bool RD(ll & a) {return scanf("%lld", &a) == 1;}

template<typename T, typename ... TT>
bool RD(T & a, TT & ...  b) {return RD(a) && RD(b...);}

/* Do princesses dream of magic sheep? */
#define RI(a) int a; RD(a)
#define RII(a,b) RI(a); RI(b)
#define RIII(a,b,c) RI(a); RII(b,c)
#define RIIII(a,b,c,d) RI(a); RIII(b,c,d)

/* For it's time for you to fulfill your output. */
void PT(const char a) {putchar(a);}
void PT(const char * a) {fputs(a, stdout);}
void PT(char * a) {fputs(a, stdout);}
void PT(const double a) {printf("%.16f", a);}
void PT(const int a) {printf("%d", a);}
void PT(const ll a) {printf("%lld", a);}

/* The line will last forever! */
template<char sep = ' ',char end = '\n'>
void PL(void) {if (end) PT(end);}
template<char sep = ' ',char end = '\n',typename T, typename ... TT>
void PL(const T a, const TT ...  b) {PT(a); if (sizeof...(b) && sep) PT(sep); PL<sep,end>(b...);}

/* Good Luck && Have Fun ! */
const int N = 50;
int main()
{
	ll k;
	RD(k);
	ll q = k/N, r = k%N;
	PL(N);
	int i;
	for (i = 0; i < N - r; ++i)
		printf("%lld%c",N-1+q-r," \n"[i == N - 1]);
	for (; i < N; ++i)
		printf("%lld%c",N-1+q-r+1+N," \n"[i == N - 1]);
}


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>;

const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<P> s(n);
    rep(i,k) cin >> s[i].first >> s[i].second;
    vector<mint> sum(n+1);
    sum[1] = 1;
    for(int i = 1; i < n; i++){
        rep(j,k){
            if(i+s[j].first <= n) sum[i+s[j].first] += sum[i];
            if(i+s[j].second+1 <= n) sum[i+s[j].second+1] -= sum[i];
        }
        if(i != 1) sum[i+1] += sum[i];
    }
    cout << sum[n] << endl;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	string s1, s2; read(s1, s2);
	vector<vi> dp(3001, vi(3001, 0));
	vector<vector<pii>> bt(3001, vector<pii>(3001));
	vector<vector<char>> ap(3001, vector<char>(3001, 0));
	int n = sz(s1), m = sz(s2);
	s1 = ' ' + s1, s2 = ' ' + s2;
	rep(i, 1, n + 1) rep(j, 1, m + 1) {
		if (chmax(dp[i][j], dp[i - 1][j])) bt[i][j] = {i - 1, j};
		if (chmax(dp[i][j], dp[i][j - 1])) bt[i][j] = {i, j - 1};
		if (s1[i] == s2[j] && chmax(dp[i][j], dp[i - 1][j - 1] + (s1[i] == s2[j]))) bt[i][j] = {i - 1, j - 1}, ap[i][j] = s1[i];
	}

	pii st = {n, m};
	string b;

	while (st != pii {0, 0}) {
		int x1, y1, x2, y2;
		tie(x1, y1) = st;
		tie(x2, y2) = bt[x1][y1];
		if (ap[x1][y1]) b.push_back(ap[x1][y1]);
		st = {x2, y2};
	}

	reverse(all(b));
	die(b);
}


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

using namespace std;
const int N = 100010;
int _w;

int n, m, eu[N], ev[N], flip[N], deg[N];

namespace G {
	int head[N], nxt[N*2], to[N*2], id[N*2], eid;
	void init() {
		eid = 0;
		memset(head, -1, sizeof head);
	}
	void link( int u, int v, int w ) {
		to[eid] = v, id[eid] = w, nxt[eid] = head[u], head[u] = eid++;
		to[eid] = u, id[eid] = w, nxt[eid] = head[v], head[v] = eid++;
	}
}

namespace DSU {
	int pa[N];
	void init() {
		for( int i = 0; i < N; ++i )
			pa[i] = i;
	}
	int find( int u ) {
		return u == pa[u] ? u : pa[u] = find( pa[u] );
	}
	bool link( int u, int v ) {
		u = find(u), v = find(v);
		if( u == v ) return false;
		return pa[u] = v, true;
	}
}

void dfs( int u, int fa, int w ) {
	using namespace G;
	for( int i = head[u]; ~i; i = nxt[i] ) {
		int v = to[i];
		if( v == fa ) continue;
		dfs(v, u, id[i]);
	}
	if( deg[u] % 2 == 1 ) {
		flip[w] ^= 1;
		++deg[u], ++deg[fa];
	}
}

int main() {
	_w = scanf( "%d%d", &n, &m );
	for( int i = 1; i <= m; ++i ) {
		_w = scanf( "%d%d", eu+i, ev+i );
		flip[i] = 0;
		++deg[eu[i]];
	}
	G::init();
	DSU::init();
	for( int i = 1; i <= m; ++i ) {
		int u = eu[i], v = ev[i];
		if( DSU::link(u, v) ) {
			G::link(u, v, i);
		}
	}
	int cnt_odd = 0;
	for( int i = 1; i <= n; ++i )
		if( deg[i] % 2 == 1 )
			++cnt_odd;
	if( cnt_odd % 2 == 1 ) {
		puts("-1");
		return 0;
	}
	dfs(1, 0, 0);
	for( int i = 1; i <= m; ++i ) {
		if( flip[i] ) swap( eu[i], ev[i] );
		printf( "%d %d\n", eu[i], ev[i] );
	}
	return 0;
}


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

int main(){
  int x , y ;
  cin >> x >> y ;
  bool ans = false;
  for(int i=0;i<=x;i++){
      if((2*i+(x-i)*4)==y) ans = true;
  }
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

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

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

int H, W;
vector<vector<int>> islands;

vector<vector<bool>> seen;
void dfs(int h, int w) {
  seen[h][w] = true;

  for (int dir = 0; dir < 8; dir++) {
    int nh = h + dx[dir];
    int nw = w + dy[dir];

    if (nh < 0 || nh >= H || nw < 0 || nw >= W) {
      continue;
    } else if (islands.at(nh).at(nw) == 0 || seen.at(nh).at(nw)) {
      continue;
    } else {
      dfs(nh, nw);
    }
  }
}

int main() {
  while (true) {
    cin >> W >> H;
    if (H == 0 && W == 0) break;
    islands.assign(H, vector<int>(W, 0));
    rep(h, H) {
      rep(w, W) { cin >> islands.at(h).at(w); }
    }

    int count = 0;
    seen.assign(H, vector<bool>(W, false));
    rep(h, H) {
      rep(w, W) {
        if (!seen.at(h).at(w) && islands.at(h).at(w) == 1) {
          dfs(h, w);
          count++;
        }
      }
    }

    cout << count << endl;
  }
  return 0;
}


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


main()
{
	int n;
	cin >> n;
	priority_queue<int>Q;
	for(int i=0;i<n;i++)
	{
		int a;
		cin >> a;
		Q.push(a);
	}
	int s1=0,s2=0;
	for(int i=0;i<n;i++)
	{
		if(i%2==0)
		{
			s1+=Q.top();
		}
		else
		{
			s2+=Q.top();
		}
		Q.pop();
	}
	cout << abs(s1-s2);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n], x = 0, ans = 0;
    for (int i = 0; i < n; i++) { cin >> a[i]; x ^= a[i]; }
    bool used[n] = {};
    while (x != 0) {
        int e = 0;
        while (x >= 2 << e) e++;
        for (int i = 0; i < n; i++) if (a[i] % (2<<e) == 1<<e && !used[i]) { x ^= a[i] ^ (a[i]-1); a[i]--; used[i] = true; ans++; break; }
        if (x >= (1 << e)) { cout << "-1\n"; return 0; }
    }
    cout << ans << endl;
}


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

int main() {
  
  int n;
  cin >> n;
  
  int a, sum = 0, m = 0;
  REP(i,n) {
    cin >> a;
    sum += a;
    m = max(m,a);
  }
  
  cout << sum - m / 2 << endl;
  
}     

Measured memory_bytes: 3544
#ABC-126-C
N, K = map(int, input().split())
possibility = 0

def check_double(n, K):
    count = 0
    while n < K:
        n *= 2
        count += 1
    return count

for i in range(1, N+1):
    possibility += (1/N) * (0.5 ** check_double(i, K))

print(possibility)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>

using namespace std;

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

  int t,a;
  cin >> t >> a;

  int h;
  cin >> h;

  double min = abs(a - (t - h * 0.006));
  int id = 0;

  for(int i = 1;i < n;i++){
    cin >> h;
    double tmp = abs(a - (t - h * 0.006));
    if(min > tmp){
      min = tmp;
      id = i;
    }
  }

  cout << id+1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int                     long long   
#define double                  long double
#define endl                    "\n"
#define pb                      push_back
#define PI                      3.1415926535897932384626433832795l
#define F                       first
#define S                       second
#define mp                      make_pair
#define f(i,n)                  for(int i=0;i<n;i++)
#define fastio                  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)                  (v).begin(),(v).end()
#define rall(v)                 (v).rbegin(),(v).rend()
#define gcd(a,b)                __gcd((a),(b))
#define fill(a,value)           memset(a,value,sizeof(a));
#define minn(v)                 *min_element(v.begin(), v.end());
#define maxx(v)                 *max_element(v.begin(), v.end());
#define print(x)                cout<<(x)<<endl;
#define sum(v)+x                accumulate(v.begin(), v.end(),x);
#define debug(x)                cout<<#x<<'='<<(x)<<endl;
typedef pair<int,int>           pii;
typedef vector<int>             vi;
signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int x=0,y=0,z=0;
    f(i,n)
    {
        if(s[i]=='R')x++;
        else if(s[i]=='G')y++;
        else z++;
    }
    int ans=x*y*z;
    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            int k=2*j-i;
            if(k>=n)break;
            if(s[i]!=s[k] and s[i]!=s[j] and s[j]!=s[k])ans--;
        }
    }
    print(ans)
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 3596