akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

    
const int MAX = 10000001;
const int MOD = 998244353;

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

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}

// 負の数にも対応した mod (a = -11 とかでも OK) 
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

// 逆元計算 (ここでは a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll MOD = 998244353;
    COMinit();
    ll n;
    cin>>n;
    ll f = n/2 + 1;

    vector<ll> v2(n);
    v2[0] = 1;
    FOR(i,1,n){
        v2[i] = (v2[i-1]*2)%MOD;
    }
    ll x = 3;
    FOR(i,1,n) x = (x*3)%MOD;
    ll res = 0;
    FOR(i,f,n+1){
        //cout<<"n = "<<n<<" i = "<<i<<" "<<COM(n,i)<<" "<<v2[n-i]<<endl;
        //cout<<COM(n,i) * v2[n-i]<<endl;
    
        res += mod(COM(n,i) * v2[n-i],MOD);
        if(res<0)cout<<res<<endl;
    }
    //cout<<endl;
    //cout<<x<<endl;
    x = mod(x-2*res,MOD);
    cout<<x<<endl;

}

Measured memory_bytes: 312704
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int K, X; cin >> K >> X;
  printf("%s", 500*K>=X?"Yes":"No");
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b;
    char s[20];
    scanf("%d%d%s",&a,&b,s);
    int i,l,k,m;
    k=0;l=0;m=0;
    for(i=0;i<(a+b+1);i++)
    {
        k++;
        if(s[i]=='-')
        {
            l=l+10;
            m++;
        }
        if(l<10)
        {
            l++;
        }
    }
    l=l-10;
    if(l==a&&(k-l-1)==b&&m==1)
        printf("Yes");
    else
        printf("No");
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,Q;
    string s;
    cin>>n>>s>>Q;
    while(Q--){
        ll k;
        cin>>k;
        ll ans=0;
        ll cd=0,cm=0,cdm=0;
        rep(i,n){
            if(s[i]=='D') cd++;
            else if(s[i]=='M'){
                cm++;
                cdm+=cd;
            }
            else if(s[i]=='C'){
                ans+=cdm;
            }
            if(i-k+1>=0){
                if(s[i-k+1]=='D'){
                    cd--;
                    cdm-=cm;
                }else if(s[i-k+1]=='M'){
                    cm--;
                }
            }
            
        }
        cout<<ans<<'\n';
    }
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    string S;
    cin >> S;

    cout << S[0] << S[1] << S[2] << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int m; cin >> m;
  while (m--) {
    string s; cin >> s;
    int n = s.size();
    set<string> se;
    for (int i = 1; i < n; ++i) {
      string l = s.substr(0, i), r = s.substr(i, n - i);
      se.insert(l + r), se.insert(r + l);
      reverse(begin(l), end(l));
      se.insert(l + r), se.insert(r + l);
      reverse(begin(r), end(r));
      se.insert(l + r), se.insert(r + l);
      reverse(begin(l), end(l));
      se.insert(l + r), se.insert(r + l);
    }
    cout << se.size() << '\n';
  }
}


Measured memory_bytes: 3200
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,k = LI()
    a = LI()

    for kk in range(k):
        r = [0] * (n+1)
        for i in range(n):
            c = a[i]
            r[max(0, i - c)] += 1
            r[min(n, i + c + 1)] -= 1

        if r[0] == n and r[n] == -n:
            a = [n] * n
            break

        t = 0
        for i in range(n):
            t += r[i]
            a[i] = t

    return JA(a, " ")


print(main())




Measured memory_bytes: 168600
import sys

def main(inp):
    A=[inp]
    s=inp
    while True:
        if(s%2==0): s=s/2
        else: s=3*s+1
            
        for i in range(len(A)):
            if(s==A[i]):
                return len(A)+1
                break
        
        A.append(s)

print(main(int(next(sys.stdin))))

Measured memory_bytes: 3060
import collections

n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
d = collections.Counter(s)

for k in t:
    if k in d:
        d[k]-=1
print(d.most_common()[0][1] if d.most_common()[0][1]>=0 else 0)

Measured memory_bytes: 3316
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(n):
    answer = 1110 - n
    return answer

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    return int(line)

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXM = 32768, N = 3, MOD = 1e9 + 7;
struct Mat {
	LL a[N][N];
	Mat() { memset(a, 0, sizeof(a)); }
	LL* operator[](int x) { return a[x]; }
	const LL* operator[](int x) const { return a[x]; }
	
	Mat operator*(const Mat &b) const {
		Mat res;
		for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++) if (a[i][j])
		for (int k = 0; k < N; k++)
			res[i][k] += a[i][j] * b[j][k];
		for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++) res[i][j] %= MOD;
		return res;
	}
} m1, m2, pw1[MAXM], pw2[MAXM];

struct Vec {
	LL a[N];
	Vec() { memset(a, 0, sizeof(a)); }
	LL& operator[](int x) { return a[x]; }
	const LL& operator[](int x) const { return a[x]; }
	
	Vec& operator*=(const Mat &b) {
		static LL res[3];
		memset(res, 0, sizeof(res));
		for (int i = 0; i < N; i++) if (a[i])
		for (int j = 0; j < N; j++)
			res[j] += a[i] * b[i][j];
		for (int i = 0; i < N; i++) a[i] = res[i] % MOD;
		return *this;
	}
};
int n, m;

void init() {
	const int a[3][3] = {{ 2, 2, 1 }, { 1, 1, 1 }, { 1, 0, 1 }};
	const int b[3][3] = {{ 1, 2, 1 }, { 0, 1, 1 }, { 0, 0, 1 }};
	for (int i = 0; i < N; i++)
	for (int j = 0; j < N; j++)
		m1[i][j] = a[i][j], m2[i][j] = b[i][j];
	for (int i = 0; i < N; i++) pw1[0][i][i] = pw2[0][i][i] = 1;
	for (int i = 1; i < MAXM; i++) pw1[i] = pw1[i - 1] * m1;
	Mat t = pw1[MAXM - 1] * m1;
	for (int i = 1; i < MAXM; i++) pw2[i] = pw2[i - 1] * t;
}

int main() {
	init();
	scanf("%d%d", &n, &m);
	Vec res; res[0] = 1;
	int lst = 1;
	for (int i = 1; i <= m; i++) {
		int x; scanf("%d", &x);
		if (x > lst) {
			res *= pw1[(x - lst) % MAXM];
			res *= pw2[(x - lst) / MAXM];
		}
		res *= m2;
		lst = x + 1;
	}
	if (n > lst) {
		res *= pw1[(n - lst) % MAXM];
		res *= pw2[(n - lst) / MAXM];
	}
	res *= m2;
	printf("%lld\n", res[2]);
	return 0;
}

Measured memory_bytes: 4864
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))

ans = 0
mod = 10**9+7

for n in range(N):
    for i in range(N):
        if A[n] > A[i]:
            if n<i:ans += (K*(K+1)//2)%mod
            else:ans+=(K*(K-1)//2)%mod

print(ans%mod)


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

using namespace std;

int a, b, c;

int main() {
	int ans;

	cin >> a >> b >> c;
	
	if (max({ a, b, c }) == a) {
		ans = b + c;
	}
	else if (max({ a, b, c }) == b) {
		ans = a + c;
	}
	else {
		ans = a + b;
	}

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

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int N;
int C[555], S[555], F[555];

int main() {
   cin >> N;
   rep (i, N-1) {
      cin >> C[i] >> S[i] >> F[i];
   }

   rep (i, N) { // スタート
      int t = 0; // 今の時間
      repp (j, i, N-1) {
         int k = max(0, (t - S[j] + F[j] - 1) / F[j]);
         t = S[j] + F[j]*k;
         t += C[j];
         // debug2(k, t)
         // if (j == i) t += S[j];
         // int k = 0;
         // for ( ; ; k++) {
         //    if ((S[j] + F[j]*k) >= t) break;
         // }
         // t = S[j] + F[j]*k;
         // t += C[j];
      }
      cout << t << endl;
      // line()
   }

   return 0;
}

Measured memory_bytes: 256
/*
AUTHOR : Chandan Agrawal
College : Poornima College of Engg. jaipur, Raj
Mail : chandanagrawal23@gmail.com
*/

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX 100050

#define ll long long
#define ld long double
#define lli long long int

#define pb emplace_back
#define INF 1000000000
#define mod 1000000007

// trignometric function always give value in Radians only
#define PI acos(-1) //3.1415926535897932384626433832795028
#define dsin(degree) sin(degree*(PI/180.0))
#define dcos(degree) cos(degree*(PI/180.0))
#define dtan(degree) tan(degree*(PI/180.0))

#define rsin(radian) sin(radian)
#define rcos(radian) cos(radian)
#define rtan(radian) tan(radian)

#define loop(i,n) for (lli i = 0; i < n; i++)
#define loopitr(xt,vec) for (auto xt : vec)
#define FOR(i,a,b) for (lli i = a; i < b; i+=1)
#define loop_rev(i,n) for (lli i = n-1; i >= 0; i--)
#define FOR_REV(i,a,b) for (lli i = a; i >= b; i--)
#define itr :: iterator it
#define WL(t) while(t --)

#define all(v) v.begin(),v.end()
#define sz(x) int(x.size())
#define F first
#define S second

#define mii map<lli,lli>
#define vi vector<lli>
#define seti set<lli>
#define pii pair<lli,lli>

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a/gcd(a,b))*b
#define abs(x) ((x < 0)?-(x):x)

template <typename T>
void print(T x){cout<<x<<endl;}
template <typename T1, typename T2>
void print2(T1 x,T2 y){cout<<x<<" "<<y<<endl;}
template <typename T1, typename T2,typename T3>
void print3(T1 x, T2 y,T3 z){cout<<x<<" "<<y<<" "<<z<<endl;}

#define scanarr(a,n) for(lli i=0;i<n;i++)    cin>>a[i];
#define scanvector(a,n) for(lli i=0;i<n;i++){ lli x ; cin>>x; a.pb(x);}

#define printarr(a,n) for(lli i=0;i<n;i++)   cout<<a[i]<<" "; cout<<endl;
#define printvector(vec) for(auto xt : vec) cout<<xt<<" ";    cout<<"\n";
#define printset(st) for(auto xt : st) cout<<xt<<" ";    cout<<"\n";

#define FD(N) fixed<<setprecision(N)

#define endl '\n'

#define deb(x) cout<<#x<<" "<<x<<endl;

// chandan1,2
void chandan1(){int y=1;return;}
void chandan2(){
        loop(i,10){
        lli x=1;
    }
    return(chandan1());
}

ll modmul(ll a, ll b) {
    return ((a%mod) * (b%mod)) % mod;
}

ll modadd(ll a , ll b){
    return((a%mod)+(b%mod)+mod)%mod;
}

ll modsub(ll a , ll b){
    return((a%mod) - (b%mod) + mod)%mod;
}

lli fastexpo(lli a,lli b ,lli MOD = mod){
    a = a%MOD;
    //b = b%(mod-1); // if mod is prime then only
    lli ans=1;
    while(b){
        if(b&1)
            ans=(ans*1ll*a)%MOD;
        a=(a*1ll*a)%MOD;
        b=b/2;
        }
    return ans;
 }
 

int main(){
fastio
lli t=1;
//cin>>t;
chandan2();
while(t--) {
    lli n,b,c;
    string s;
    cin>>n;
    lli a[n];
    scanarr(a,n);
    lli cnt=0;
    loop(i,n)
        if(i%2==0 and a[i]%2==1)
            cnt++;
    print(cnt);
    
  }
return 0;
}

Measured memory_bytes: 3612
from sys import stdin
input = stdin.readline

N = int(input())
A = list(map(int, input().split()))


def p(N):
    for i in range(len(N)):
        if i == len(N) - 1:
            print(N[i])
        else:
            print(N[i], end=" ")


flag = True
ans = 0

while flag:
    flag = False
    for i in range(N - 1, 0, -1):
        if A[i] < A[i - 1]:
            A[i], A[i - 1] = A[i - 1], A[i]
            ans += 1
            flag = True

p(A)
print(ans)



Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
int main(){
    int n,c[21],v[21],ans=0;
    cin>>n;
    REP(i,n)cin>>v[i];
    REP(i,n)cin>>c[i];
    REP(i,n){
        if(v[i]-c[i]>0) ans+=v[i]-c[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

	int a, b, n;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &n);
	
	int sum;
	if (a>=b){
		if(n%a==0){
			sum=n/a;
		}
		else{
			sum=(n/a)+1;
		}
	}
	
	else if(b>a){
		if(n%b==0){
			sum=n/b;
		}
		else{
			sum=(n/b)+1;
		}
	}

	printf("%d\n", sum);
	
    return 0;
}

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

/*
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);}
void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
template<class T> void writerLn(T x){writer(x,'\n');}
*/

#define incID(i, l, r) for(int i = (l); i < (r); i++)
#define inc(i, n) incID(i, 0, n)
template<typename T> bool setmin(T &a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T &a, T b) { if(b <= a) { return false; } else { a = b; return true; } }


// ---- ----

int n, k;
vector<int> vec[100000];
bool has[100000];
int mi[100000];
int ma[100000];

void prod(int x, int y) {
	if(has[y]) {
		bool flag = true;
		if(has[x] && (mi[x] - mi[y]) % 2 == 0) { flag = false; }
		setmax(mi[x], mi[y] - 1);
		setmin(ma[x], ma[y] + 1);
		has[x] = true;
		if(mi[x] > ma[x]) { flag = false; }
		if(! flag) {
			cout << "No" << endl;
			exit(0);
		}
	}
}

bool dfs(int node, int pre) {
	if(pre != -1) { prod(node, pre); }
	for(auto && e : vec[node]) {
		if(e != pre) {
			dfs(e, node);
			prod(node, e);
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> n;
	inc(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	fill(mi, mi + n, -1000000);
	fill(ma, ma + n,  2000000);
	cin >> k;
	inc(j, k) {
		int v, p;
		cin >> v >> p;
		v--;
		mi[v] = p;
		ma[v] = p;
		has[v] = true;
	}
	
	dfs(0, -1);
	dfs(0, -1);
	
	cout << "Yes" << endl;
	inc(i, n) { cout << mi[i] << endl; }
	
	return 0;
}


Measured memory_bytes: 12032
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000

const double EPS = 1e-10;
const double PI  = acos(-1.0);
////////////////////////////////////////////////
int a[100][100],n,judge,s[100],d[101],p[100];

int main()
{
	cin>>n;
	REP(i,n)
	{
		REP(j,n)a[i][j]=INF;
	}
	REP(i,n)
	{
		int node,m;cin>>node>>m;
		REP(j,m)
		{
			int x,cost;cin>>x>>cost;
			a[node][x]=cost;
		}
	}
	
	REP(i,n+1)d[i]=INF;
	d[0]=0;
	for(;;)
	{
		int u=n;
		REP(i,n)
		{
			if(s[i]==0&&d[u]>d[i])u=i;
		}
		s[u]=1;
		if(d[u]==INF)break;
		REP(i,n)
		{
			if(d[u]+a[u][i]<d[i]&&s[i]==0)
			{
				d[i]=d[u]+a[u][i];
				p[i]=u;
			}
		}
	}
	REP(i,n)cout<<i<<" "<<d[i]<<endl;
	return 0;
}

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

 int main() {
   int D;
   cin >> D;
   if(D == 25){
     cout << "Christmas" << endl;
   }else if(D == 24){
     cout << "Christmas Eve" << endl;
   }else if(D == 23){
     cout << "Christmas Eve Eve" << endl;
   }else if(D == 22){
     cout << "Christmas Eve Eve Eve" << endl; 
   }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys

INF = float('inf')


def solve(S: str, T: str):
    return len(T) - max(sum(s == t for s, t in zip(S[i:], T)) for i in range(len(S) - len(T) + 1))


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    print(f'{solve(S, T)}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 75760
//2706 石井夏鈴 問3
import java.util.Scanner;
public class Main{
	int x,y,b,p,a;
	int a1=0;
	
	public void solve(){
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		for(int i=1;i<=N;i++){
			x=sc.nextInt();
			y=sc.nextInt();
			b=sc.nextInt();
			p=sc.nextInt();
			a=(x*b+y*p);
			
			if(b>=5&&p>=2){
				a1=(x*b+y*p)*4/5;
			}else{
				if(b<5){
					b=5;
				}
				if(p<2){
					p=2;
				}
				a1=(x*b+y*p)*4/5;
			}
			if(a>a1){
				a=a1;
			}
			System.out.println(a);
		}
	}
	
	public static void main(String[]args){
		Main obj=new Main();
		obj.solve();
	}
}

Measured memory_bytes: 23468
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000 //1e16
 
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}


 
void solve()
{
    int n,m,t,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U; 
    // int a,b;
    cin>>n;
    n-=400;
    n/=200;
    cout<<8-n;
}
 
 
signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        // if(t)cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main() {
    string s; cin >> s;
    string t = "ATCG";
    int ans = 0, now = 0;

    for(int i = 0; i < s.size(); i++) {
        bool flag = false;
        for(int j = 0; j < s.size(); j++) {
            if((int)t.find(s[i]) != -1) flag = true;
        }
        if(flag) {
            now++;
            ans = max(ans, now);
        } else {
            now = 0;
        }
    }
    cout << ans << endl;
}


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

class program
{
    public static void Main()
    {
        // System.Text.RegularExpressions.Regex.IsMatch(str, @"[0-9]+"))
        while (true)
        {
            var str = Console.ReadLine();

            if (str.Equals("-")) break;

            int m = int.Parse(Console.ReadLine());

            for (int i = 0; i < m; i++)
            {
                int h = int.Parse(Console.ReadLine());
                string foward = str.Substring(0, h);
                string backward = str.Substring(h, str.Length - h);
                str = backward + foward;
            }

            Console.WriteLine(str);
        }
    }
}

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

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    long long ans = 1000000000000000000;
    for (long long i = 0; i <= max(x, y); i++) {
        long long p = max(0LL, x - i) * a + max(0LL, y - i) * b + i * c * 2;
        ans = min(ans, p);
    }
    cout << ans << endl;
    return 0;
}

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();
		String s = sc.next();
		int[] w = new int[n];
		int[] e = new int[n];
		if(s.charAt(0) == 'W') {
			w[0] = 1;
		} else {
			e[0] = 1;
		}
		for(int i = 1; i < n; i++) {
			if(s.charAt(i) == 'W') {
				w[i] = w[i - 1] + 1;
				e[i] = e[i - 1];
			} else {
				w[i] = w[i - 1];
				e[i] = e[i - 1] + 1;
			}
		}
		int ans = e[n - 1] - e[0];
		for(int i = 1; i < n; i++) {
			ans = Math.min(ans, w[i - 1] + e[n - 1] - e[i]);
		}
		ans = Math.min(ans, w[n - 2]);
		System.out.println(ans);
	}
}

Measured memory_bytes: 30908
#!/usr/bin/perl

use strict;
use warnings;

my ($n, $k);
{
    my $in = <STDIN>;
    ($n, $k) = split(" ", $in);
}
my @p;
{
    my $in = <STDIN>;
    @p = split(" ", $in);
}
my $sum = 0;
for (my $i=0; $i<$k; $i++)
{
    $sum += $p[$i];
}
my $max = $sum;
if ($n>$k)
{
    for (my $i=0; $i<$n-$k; $i++)
    {
        $sum = $sum - $p[$i] + $p[$i+$k];
        if ($max<$sum)
        {
            $max = $sum;
        }    
    }
}
$max = ($max+$k)/2;
print "$max\n";

Measured memory_bytes: 33060
import sys
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

# A以上B以下にXの倍数が幾つあるか？ 1 <= A <= B
def check(A, B, X):
    x = (A-1) // X
    y = (B-0) // X
    return y - x

import fractions

def main():
    A, B, C, D = i2nn()
    # A以上B以下の数
    n = B - A + 1
    # Cの倍数
    n -= check(A, B, C)
    # Dの倍数
    n -= check(A, B, D)
    # GCD(C, D)の倍数
    E = C * D // fractions.gcd(C, D)
    n += check(A, B, E)
    n = int(n)
    print(n)

main()


Measured memory_bytes: 66028
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <queue>
#include <stack>
using namespace std;
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> P;
int n,u[105],s[105];
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>u[i];
        if(i!=0)u[i]+=u[i-1];
    }
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=n-2;i>=0;i--){
        s[i]+=s[i+1];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        ans=max(ans,u[i]+s[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%lld\n",n)
#define PRF(f) printf("%.10lf\n",f)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
typedef long long int ll;
int main(void){
  int n;
  scanf("%d",&n);
  ll a[n],b[n],sum=0,cnt=0;
  FOR(n){
    scanf("%lld %lld",&a[i],&b[i]);
    sum+=b[i];
  }
  for(int i=n-1;i>=0;i--){
    a[i]+=cnt;
    if(a[i]){
      ll x=a[i]%b[i];
      if(x){
        sum-=x;
        cnt+=b[i]-x;
      }else{
        sum-=b[i];
      }
    }else{
      sum-=b[i];
    }
  }
  PRN(sum);
  return 0;
}


Measured memory_bytes: 1792
package main

import "fmt"

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

	if a < c && c < b {
		fmt.Println("Yes")
	} else if b < c && c < a {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
def main():
    N = int(input())
    S = str(input())

    if N % 2 == 1:
        print('No')
        return 0

    s_start = S[:N//2]
    s_end = S[N//2:]

    if s_start == s_end:
        print('Yes')
    else:
        print('No')
    return 0


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#!/usr/bin/env python3
n = int(input())
list_5 = []
a = 0
b = 0
for _ in range(-200,200):
    list_5.append(_**5)
for i in range(-200,200):
    if (n + list_5[i]) in list_5:
        b = i  
        a = list_5.index(n + list_5[i])
print(a-200, b-200)




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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll W,H,X,Y;
ll i, j, k;
double ans;
int main(){
    scanf("%lld%lld%lld%lld", &W,&H,&X,&Y);
    printf("%.12lf ", (double)W * H / 2);
    if(X*2==W&&Y*2==H){
        printf("1");
    }else{
        printf("0");
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

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

    int ai, a, _a, ma=0;

    int i;
    scanf("%d", &ai);
    _a = ai;
    for (i=1; i<n; i++) {
        scanf("%d", &a);
        if (a - _a > ma) {
            ma = a - _a;
        }
        _a = a;
    }

    if (ma < k - (a-ai)) {
        ma = k - (a-ai);
    }

    printf("%d\n", k-ma);

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int min(int a, int b) {
  return a < b ? a : b;
}

int main(void) {
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  printf("%d", min(a, b) + min(c, d));
  return 0;
}

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

int bit0[1000000],bit1[1000000];
int sum(int *b,int i){
  int res=0;
  while(i){
    res+=b[i];
    i-=i&-i;
  }
  return res;
}
void fadd(int *b,int i,int v){
  while(i<=N){
    b[i]+=v;
    i+=i&-i;
  }
}
void add(int l,int r){
  fadd(bit0,l,-1*(l-1));
  fadd(bit1,l,1);
  fadd(bit0,r+1,1*r);
  fadd(bit1,r+1,-1);
}

signed main(){
  int n,M;cin>>n>>M;
  while(n>N)N*=2;
  memset(bit0,0,sizeof(bit0));
  memset(bit1,0,sizeof(bit1));
  for(int i=0;i<M;i++){
    int l,r;cin>>l>>r;r--;
    add(l,r);
  }
  //return 0;
  for(int i=1;i<=N;i++){
    int res=0;
    res+=sum(bit0,i)+sum(bit1,i)*i;
    res-=sum(bit0,i-1)+sum(bit1,i-1)*(i-1);
    if(res%2){cout<<"NO"<<endl;return 0;}
  }
  cout<<"YES"<<endl;
}


Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <functional>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,f,t) for(int i=f;i<t;i++)
int main()
{
    int N, A, B; cin >> N >> A >> B;
    vector<int> H(N); REP(i, N) cin >> H[i];
    sort(H.rbegin(), H.rend());
    int lo = 0, hi = (H[0] + B - 1) / B;
    while (lo + 1 != hi) {
        int mid = (lo + hi) / 2;
        bool res = true;
        int cnt = 0;
        for (int i = 0; i < H.size(); i++) {
            int k = H[i] - mid * B;
            if (k <= 0) break;
            cnt += (k + A - B - 1) / (A - B);
            if (cnt > mid) { res = false; break; }
        }
        if (res) hi = mid; else lo = mid;
    }
    cout << hi << endl;
    return 0;
}

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

namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            string input;
            List<int> count = new List<int>();
            List<int> cards = new List<int>();
            List<Func<string>> check = new List<Func<string>> {
                new Func<string>(() => count.Contains(4)                      ? "four card"  : string.Empty),
                new Func<string>(() => count.Contains(3) && count.Contains(2) ? "full house" : string.Empty),
                new Func<string>(() => StraightCheck(cards)                   ? "straight"   : string.Empty),
                new Func<string>(() => count.Contains(3)                      ? "three card" : string.Empty),
                new Func<string>(() => count.Count(i => i == 2) == 2          ? "two pair"   : string.Empty),
                new Func<string>(() => count.Count(i => i == 2) == 1          ? "one pair"   : string.Empty),
                new Func<string>(() =>                                          "null"                     )
            };
            while((input = Console.ReadLine()) != null) {
                cards.Clear();
                count.Clear();
                cards.AddRange(input.Split(',').Select(q => int.Parse(q)).OrderBy(p => p));
                for(int i=0; i < cards.Count; ++i) {
                    if(i != 0 && cards[i - 1] == cards[i]) {
                        ++count[count.Count - 1];
                    }
                    else {
                        count.Add(1);
                    }
                }
                foreach(Func<string> item in check) {
                    string result = item();
                    if(result != string.Empty) {
                        Console.WriteLine(result);
                        break;
                    }
                }
            }
        }
        static bool StraightCheck(List<int> cards)
        {
            if(cards.SequenceEqual(new[] { 1, 10, 11, 12, 13 })) {
                return true;
            }
            return cards.SequenceEqual(Enumerable.Range(cards[0], 5));
        }
    }
}

Measured memory_bytes: 6324
#include <iostream>

int main(void) {
	int N;
	int i;

	std::cin >> N;
	int* pn = new int[N];
	for (i = 0; i < N; i++) {
		std::cin >> pn[i];
	}
	int current = 0;
	for (i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			current = std::max(std::abs(pn[j] - pn[i]), current);
		}
	}

	delete[] pn;

	std::cout << current << std::endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int n;
    cin >> n;
    map<string,int> a;
    rep(i,n){
        string c;
        cin >> c;
        a[c]++;
    }
    int m;
    cin >> m;
    map<string,int> b;
    rep(i,m){
        string c;
        cin >> c;
        b[c]++;
    }
    int ans = 0;
    for(auto i:a){
        int cnt = a[i.first]-b[i.first];
        ans = max(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;

    int64_t a[3*N];
    for (int i = 0; i < 3 * N; i++)
    {
        cin >> a[i];
    }
    sort(a, a + 3 * N);
    int64_t ans = 0;
    for (int i = N; i < 3*N; i+=2)
    {
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define endl '\n'
#define lose {printf("NO\n");return;}
#define win {printf("YES\n");return;}
#define all(A) (A).begin(),(A).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define PER(I, A, B) for (int I = (A); I >= (B); --I)
#define DB(A) cout<<(A)<<endl 
#define lson k*2
#define rson k*2+1
#define fi first
#define se second
#define PB push_back
#define Pair pair<int,int>
#define MP make_pair
#define LL long long
#define ull unsigned long long
#define int LL
using namespace std;
#define DB1(args...) do { cout << #args << " : "; dbg(args); } while (0)
void dbg() { std::cout << "  #\n"; }
template<typename T, typename...Args>
void dbg(T a, Args...args) { std::cout << a << ' '; dbg(args...); }
//var
const int maxn=6e5+10;
const int MAX=6e5;
const int inf=0x3f3f3f3f;   
const int mod=1e9+7;
//head
int n,m;
vector<int>a[maxn];


LL fac[maxn];
LL inv[maxn];
//LL facinv[maxn];
void fac_init()//reload fac, inv, facinv
{
    fac[0]=fac[1]=1;//both 0 1 initiate
    for (int i=1;i<=MAX;i++) fac[i]=(fac[i-1]*(i%mod))%mod;
    inv[0]=inv[1]=1;    
    for(int i=2;i<=MAX;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
    
//	facinv[0]=facinv[1]=1;
//	for(int i=2;i<=MAX;i++) facinv[i]=inv[i];    
//  for(int i=2;i<=MAX;i++) facinv[i]=facinv[i]*facinv[i-1]%mod;
}
LL fpow(LL x, LL power, LL mod) 
{
    x %= mod;
    LL ans = 1;
    for (; power; power >>= 1, (x *= x) %= mod)
        if(power & 1) (ans *= x) %= mod;
    return ans;
}
LL qinv(LL a)
{
    LL x = fpow(a, mod - 2, mod);
    return x;
}
LL C(LL i,LL j)
{
	if (i<j) return 0;
	if (i<0||j<0) return 0;
//  return fac[i]*facinv[i-j]%mod*facinv[j]%mod;    
    return fac[i]*qinv(fac[i-j])%mod*qinv(fac[j])%mod;
}

int ans[maxn];
int son[maxn];
int mul[maxn];
int dp[maxn];

void dfs1(int now,int fa)
{
	son[now]=1;
	mul[now]=1;
	
	for (auto to:a[now])
	{
		if (to==fa) continue;
		dfs1(to,now);
		son[now]+=son[to];
		son[now]%=mod;
		mul[now]*=mul[to];
		mul[now]%=mod;
	}
	//DB1(now,son[now],mul[now]);
	mul[now]*=son[now];
	mul[now]%=mod;
	dp[now]=fac[son[now]]*qinv(mul[now])%mod;
	return;
}

void dfs2(int now,int fa)
{
	for (auto to:a[now])
	{
		if (to==fa) continue;
		dp[to]=dp[now]*son[to]%mod*qinv(n-son[to])%mod;
		ans[to]=dp[to];
		dfs2(to,now);	
	}
}

void solve()
{
	fac_init();
	cin>>n;
	FOR(i,1,n-1)
	{		
	int x,y;
		cin>>x>>y;
		a[x].PB(y);
		a[y].PB(x);
	}      
	dfs1(1,0);
	DB(dp[1]);
	dfs2(1,0);
	FOR(i,2,n) DB(ans[i]);
} 
signed main()
{
	SIS;
	int T=1;
//	cin>>T;
	while (T--)
	{
		solve();
	}
	  
}

Measured memory_bytes: 47600
#include<stdio.h>
    int main(){
        int A, B, C, D, E, F;
            scanf("%d", &A);
            scanf("%d", &B);
            scanf("%d", &C);
            scanf("%d", &D);            
                if(A < B){
                    E = A;
                }
                    else{
                        E = B;
                    }
                if(C < D){
                    F = C;
                }
                    else{
                        F = D;
                    }
        printf("%d", E + F);
    return 0;
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define srt(x) sort((x).begin(), (x).end())
#define rsrt(x) sort((x).rbegin(), (x).rend())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vc = vector<char>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
template<class T>void print(T x) { cout << '\n' << "== " << x << " ==" << '\n'; }
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T>void precise(T x) { cout << setprecision(21) << x << '\n'; }
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, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long double doublepi = M_PI * 2.0;
const long double halfpi = M_PI / 2.0;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long MOD = 1e9 + 7;



int main()
{
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll ans = B - A + 1;
    ans -= B/C - (A-1)/C;
    ans -= B/D - (A-1)/D;
    ans += B/l(C, D) - (A-1)/l(C, D);
    cout << ans << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

vector<int> vi;
vector<int> vj;

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

    vi.resize(N);

    REP(i, N) cin >> vi[i];

    vj = vi;

    ALL(sort, vi);
    ALL(reverse, vi);

    REP(i, N)
    {
        if (vi[(N + 1) / 2 - 1] <= vj[i]) cout << vi[(N + 1) / 2] << endl;
        else cout << vi[(N + 1) / 2 - 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 3712
import java.util.Scanner;

public class Main{

	public static void main (String[] args) {

		Scanner sc = new Scanner (System.in);

		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long D = sc.nextLong();

		long first = B/C;
		long second = (A-1)/C;
		long third = B/D;
		long fourth = (A-1)/D;
		long lc = lcm (C,D);
		long fifth = B/(lc);
		long sixth = (A-1)/(lc);

		long oneans = first - second;
		long secans = third - fourth;
		long thians = fifth - sixth;

		long answer = (B-A+1)-oneans-secans+thians;

		System.out.println(answer);
	}

	private static long lcm(long m, long n) {
	    return m * n / gcd(m, n);
	}

	private static long gcd(long m, long n) {
	    if(m < n) return gcd(n, m);
	    if(n == 0) return m;
	    return gcd(n, m % n);
	}
}

Measured memory_bytes: 22100
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;

static class HitAndBlow
{
    static void Main()
    {
        var input = new StreamReader( Console.OpenStandardInput() ).ReadToEnd()
            .Where( x => '0' <= x && x <= '9' )
            .GroupSpan( 3 )
            .Select( x => x.GroupSpan( 2 ) )
            .Select( x => x.Select( y => y.ToArray() ) )
            .Select( x => x.ToArray() );
        var q =
            from x in input
            let nohit = Enumerable.Range( 0, 4 )
                .Where( y => x[0][y] != x[1][y] )
                .Select( y => new { a = x[0][y], b = x[1][y] } )
                .ToArray()

            let h = 4 - nohit.Length
            let b = nohit.Select( y => y.b )
                .Count( y => nohit.Select( z => z.a ).Contains( y ) )
            select h + " " + b;
        q.ToList().ForEach( Console.WriteLine );
    }

    static IEnumerable<IEnumerable<TSource>>
    GroupSpan<TSource>
    (this IEnumerable<TSource> source, int span)
    {
        return source
            .Select( (v, i) => new { v, k = i >> span } )
            .GroupBy( x => x.k, x => x.v )
            .Select( x => x as IEnumerable<TSource> );
    }
}

Measured memory_bytes: 6796
import std;

auto input()
{
    return readln().chomp();
}

alias sread = () => readln.chomp();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    string s;
    s = input();
    // writeln(s);
    // writeln(s[0 .. (s.length - 1) / 2]);
    // writeln(s[((s.length + 3) / 2) - 1 .. $]);
    if (s[0 .. (s.length - 1) / 2] == s[((s.length + 3) / 2) - 1 .. $])
    {
        writeln("Yes");
    }
    else
    {
        writeln("No");
    }

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}


Measured memory_bytes: 3576
#pragma warning (disable:4996)
#include"bits/stdc++.h"
#include<cassert>
#define int long long
#define MRE assert(0);
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const long long mod = 1000000007;
const long long inf = 1ll<<61;
typedef pair<int, int> P;
typedef pair<int, P > PP;

signed main() {
	int n, a, b; cin >> n >> a >> b;
	int ab = n / (a + b), c = n % (a + b);
	int res = ab*a + min(a, c);
	cout << res << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  string h[7] = {"fri", "sat", "sun", "mon", "tue", "wed", "thu"};
  int x;
  cin >> x;
  x--;
  cout << h[x % 7] << endl;
}



Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll,ll> 
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=0;cin>>n;
  string name;
  map<char,ll> mp;
  rep(i,n) {
    cin>>name;
    mp[name[0]]++;
  }
  ans+=mp['M']*mp['A']*mp['R'];
  ans+=mp['M']*mp['A']*mp['C'];
  ans+=mp['M']*mp['A']*mp['H'];
  ans+=mp['M']*mp['R']*mp['C'];
  ans+=mp['M']*mp['R']*mp['H'];
  ans+=mp['M']*mp['C']*mp['H'];
  ans+=mp['A']*mp['R']*mp['C'];
  ans+=mp['A']*mp['R']*mp['H'];
  ans+=mp['A']*mp['C']*mp['H'];
  ans+=mp['R']*mp['C']*mp['H'];
  print(ans);
  return 0;
}

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

int main() {
 int a;
 cin >> a;
 int b;
 cin >> b;
 if (a + b > a - b) {
  if (a + b > a * b) {
   cout << a + b << endl;
  }
  else {
   cout << a * b << endl;
  }
 }
 else {
  if (a - b > a * b) {
   cout << a - b << endl;
  }
  else {
   cout << a * b << endl;
  }
 }
}

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

int main(void) {
	int n;
	int a[200001] = { 0 };
	int b[200001] = { 0 };
	int cnt = 0;
	int temp = 0;

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		if (i > n / 2 && a[i] == 1)b[i] = 1;
	}

	for (int i = n/2; i >= 1; i--) {
		temp = 0;
		for (int j = 2; i * j <= n; j++) {
			if (b[i * j] == 1)temp++;
		}
		if (temp % 2 != a[i])b[i] = 1;
	}
	for (int i = 1; i <= n; i++)cnt += b[i];
	printf("%d\n", cnt);
	for (int i = 1; i <= n; i++) {
		if (b[i])printf("%d ", i);
	}
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(),a.end());
  
  int ans = 0;
  
  for(int i = 0; i < 2; i++){
    ans += abs(a[i+1]-a[i]);
  }
  
  cout << ans << endl; return 0;}

Measured memory_bytes: 256