akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
  int n;
  int tmp;
  int all;
  while(1){
    cin >> n;
    if(n == 0) break;
    int num[n];
    for(int i=0;i<n;i++) cin >> num[i];
    tmp = num[0];
    for(int i=0;i<n;i++){
      all = 0;
      for(int j=i;j<n;j++){
	all += num[j];
	if(tmp < all) tmp = all;
      }
    }
    cout << tmp << endl;
  }
}

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

int N, A, B;
int ans;

int main() {
	cin >> N >> A >> B;
	
	for(int i = 1; i <= N; ++i) {
		int tmp = 0;
		int ii = i;
		while(ii > 0) {
			tmp += ii % 10;
			ii /= 10;
		}
		if(tmp >= A && tmp <= B) {
			ans += i;
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a,b,c,k;
int main()
{
	scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
	if (k&1)
	{
		ll t=b-a;
		if (t>1e18) puts("Unfair");
		else printf("%lld\n",t);
	}
	else
	{
		ll t=a-b;
		if (t>1e18) puts("Unfair");
		else printf("%lld\n",t);
	}
	return 0;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n, m;
    cin >> n >> m;
    vint a(n), b(n), c(m), d(m);
    rep(i, n) cin >> a[i] >> b[i];
    rep(i, m) cin >> c[i] >> d[i];

    vint v(n, INF);
    vint ans(n, 0);
    rep(i, n)
    {
        rep(j, m)
        {
            int dist = abs(c[j] - a[i]) + abs(d[j] - b[i]);
            if (dist < v[i])
            {
                v[i] = dist;
                ans[i] = j + 1;
            }
        }
    }
    rep(i, n) cout << ans[i] << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100010];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n);
	long long ans=0;
	int fl=1,num=n-1;
	int l,r,i,tn=n,t1=3;
	l=r=a[1];
	while(num){
		if(num==1){
			if(fl) i=tn;
			else i=t1-1;
			ans+=max(abs(a[i]-l),abs(a[i]-r));
			break; 
		}
		if(fl) i=tn,tn-=2,fl=0;
		else i=t1,t1+=2,fl=1;
		int tmp1=abs(a[i]-l)+abs(a[i-1]-r);
		int tmp2=abs(a[i]-l)+abs(a[i-1]-r);
		if(tmp1>tmp2) l=a[i],r=a[i-1],ans+=tmp1;
		else l=a[i-1],r=a[i],ans+=tmp2;
		num-=2;
	}
	num=n-1;
	l=r=a[n],fl=0,t1=2,tn=n-1;
	long long tans=0;
	while(num){
		if(num==1){
			if(fl) i=tn;
			else i=t1-1;
			tans+=max(abs(a[i]-l),abs(a[i]-r));
			break; 
		}
		if(fl) i=tn,tn-=2,fl=0;
		else i=t1,t1+=2,fl=1;
		int tmp1=abs(a[i]-l)+abs(a[i-1]-r);
		int tmp2=abs(a[i]-l)+abs(a[i-1]-r);
		if(tmp1>tmp2) l=a[i],r=a[i-1],ans+=tmp1;
		else l=a[i-1],r=a[i],tans+=tmp2;
		num-=2;
	}
	ans=max(ans,tans);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    long long x, y;
    
    scanf("%lld %lld", &x, &y);
    
    if (x < y) swap(x, y);
    
    if (x - y <= 1) {
        puts("Brown");
    } else {
        puts("Alice");
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void){
    int x,y;
    while(1){
        scanf("%d %d",&x,&y);
        if(x == 0 && y == 0)break;
        else if(x <= y)
         printf("%d %d\n",x,y);
        else if(x > y)
         printf("%d %d\n",y,x);
    }
    return 0;
}


Measured memory_bytes: 2056
MOD = 10**9 + 7

N, K = gets.split.map{ |x| x.to_i }

len_x_count = []

p = Math.sqrt(N).floor

pairs = []
(1..p).each{ |x|
	pairs << [x, N/x]
}

$keys = pairs.flatten.sort.uniq

$multis = $keys.map.with_index{ |k, i| i >= 1 ? k - $keys[i - 1]: 1}

(1..K).each{ |len|
	len_x_count[len] = []

	if len == 1 then
		len_x_count[len] = Array.new($keys.size, 1)
	else
		add = 0
		(0 ... $keys.size).each{ |i|
			len_x_count[len].unshift(
				(len_x_count[len - 1][i] * $multis[i] + add) % MOD
			)

			add = len_x_count[len][0]
		}
	end
}

result = 0

(0 ... $keys.size).each{ |i|
	result += len_x_count[-1][i] * $multis[i]
}

puts result % MOD


Measured memory_bytes: 64680
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};
#define MAX 100000
int main(){
    int n,a,b,c,x;
    while(cin >> n >> a >> b >> c >> x,n|a|b|c|x){
        vector<int> y(n);
        rep(i,n) cin >> y[i];
        int cnt = 0;
        int frame = 0;
        while(1){
            if(frame > 10000) {
                cout << -1 << endl;
                break;
            }
            if(x==y[cnt]) cnt++;
            if(cnt == n) {
                cout << frame << endl;
                break;
            }
            x = (a*x+b)%c;
            frame++;
        }
    }
    return 0;
}


Measured memory_bytes: 3088
N, L = map(int, input().split())
al = sum(L + i for i in range(N))
ans = 0
m = None
for i in range(N):
    x = al - (L + i)
    y = abs(al - x)
    if m is None or y < m:
        m = y
        ans = x
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ALL(e) e.begin(), e.end()
#define RALL(e) e.rbegin(), e.rend()
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define dbg(x) (cerr << #x << ":" << x << endl)
#define mid (l + r) / 2
#define pii pair <int, int>
#define fi first
#define sc second
#define N 1000000009

using namespace std;

typedef long long int lli;

int main(){
	ios::sync_with_stdio(0);
	int n, k;
	cin >> n >> k;
	vector <int> ar(n);
	for(int &x: ar) cin >> x;
	cout << ceil((double)(n-1.0)/(double)(k-1.0))<< endl;
	return 0;
}

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

/*
 * クヌース・モリス・プラット法
 *
 * 単一パターン検索
 */
template<class T> class KMP{
    T pattern;
    vector<int> fail;
public:
    KMP(const T& pattern) : pattern(pattern){
        int pattern_len = (int) pattern.size();
        fail.assign(pattern_len + 1, -1);
        for(int i = 0, j = -1; i < pattern_len; ++i){
            while(j >= 0 && pattern[i] != pattern[j]){
                j = fail[j];
            }
            // 一致しなかった時、次どこから始めるかを格納
            fail[i + 1] = ++j;
        }
    }

    vector<int> match(const T& find){
        int find_len = (int) find.size();
        int pattern_len = (int) pattern.size();
        vector<int> res;
        for(int i = 0, k = 0; i < find_len; ++i){
            while(k >= 0 && find[i] != pattern[k]){
                k = fail[k];
            }
            ++k;
            if(k >= pattern_len){
                // 一致したらSの始まりのidxを格納
                res.push_back(i - pattern_len + 1);
                k = fail[k];
            }

        }
        return res;
    }
};

int main() {

    string find, pattren;
    cin >> find >> pattren;

    KMP<string> kmp(pattren);

    vector<int> ans = kmp.match(find);

    for(int x : ans){
        cout << x << endl;
    }
    return 0;
}



Measured memory_bytes: 8504
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  [n] <- readInts
  input <- readInts
  print $ solve n input

solve n (x:xs) = solveSub 1 x xs
  where
    solveSub i _ [] = i
    solveSub i highest (x:xs) =
      if highest <= x
        then solveSub (i + 1) x xs
        else solveSub i highest xs

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

Measured memory_bytes: 380
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long
set < ll> primes;
 
int n,m;

bool isvalid(int x,int y)
{
    return (x>=0 && x<n && y>=0 && y<m);
}
int dx[]={0,0,1,-1,-1,1,1,-1};
int dy[]={1,-1,0,0,-1,1,-1,1};
void Sieve(ll n) 
{ 
    bool prime[n+1];
	for(ll i=0;i<n+1;++i)
		prime[i]=true;
    for (ll p=2;p*p<=n;++p) 
    {
        if (prime[p] == true) 
        {  
            for (ll i=2*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }  
    for(ll p=2; p<=n; p++) 
       if (prime[p]) 
		primes.insert(p);  
}

ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
        return gcd(b % a, a); 
} 
ll powermod(ll x, ll y){
    if(y==0)
    return 1;
        
    if(y%2==0)
    return (powermod(x,y/2)*powermod(x,y/2))%mod;
    else
    return (((powermod(x,y/2)*powermod(x,y/2))%mod)*x)%mod;
}

void solve()
{
    int l,r,d;
    cin>>l>>r>>d;
    int ans=0;
    for(int i=l;i<=r;i++)ans+=(i%d==0);
    cout<<ans;
}
 
 

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    
	int t=1;
	//cin>>t;
	while(t--)solve();
	    
   
}

Measured memory_bytes: 3624
#include<iostream>
#include<fstream>
using namespace std;
#include<math.h>
#include<string.h>
#include<queue>
long long a[200000];
#define max 1000000000000000000
int main()
{
	//ifstream in("1.txt",ios::in);
	long long n,i;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(i=0;i<n;i++)
		if(a[i]==0){cout<<0<<endl;exit(0);}
	long long s=1;
	for(i=0;i<n;i++)
	{
		if(s>max/a[i]){cout<<-1<<endl;exit(0);}
		s*=a[i];
	}
	cout<<s<<endl;
	//in.close();
	return 0;
}


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define chmax(s, t) s=max(s,t);
#define chmin(s, t) s=min(s,t); 

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}

/*階乗*/
ll factorial(ll n){
    const ll FMOD = 1e9+7;
    ll ret = n;
    for(ll i=n-1;i>0;i--){
        ret*=i;
        ret%=FMOD;
    }
    return (ret?ret:1);
}


int main(){

    ll n, d; cin >> n >> d;

    cout << n/(2*d+1) + !!(n%(2*d+1)) << endl;

    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N;
    cin >> N;
    auto A = InputVec(N);
    ll oc = 0;
    ll ec = 0;
    for (int i = 0; i < A.size(); ++i) {
        if(A[i] % 2 == 0){
            ec++;
        }else{
            oc++;
        }
    }
    ec += oc / 2;
    oc = oc % 2;
    ec = 1;
    if(ec + oc == 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

int N;
vector<ll> a(3000);
// dp[i][j] = max{First - Second}
vector<vector<ll>> dp(3000, vector<ll>(3000, -1e15));

ll calc(int l, int r, int turn)
{
    if (dp[l][r] != -1e15)
    {
        return dp[l][r];
    }
    if (l == r)
    {
        if (turn == 0)
        {
            return dp[l][r] = a[l];
        }
        else
        {
            return dp[l][r] = -a[l];
        }
    }
    if (turn == 0)
    {
        dp[l][r] = max(a[l] + calc(l + 1, r, 1), calc(l, r - 1, 1) + a[r]);
    }
    else
    {
        dp[l][r] = min(-a[l] + calc(l + 1, r, 0), calc(l, r - 1, 0) - a[r]);
    }
    return dp[l][r];
}

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

    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> a[i];
    cout << calc(0, N - 1, 0) << endl;
}

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

void dec(string s){
    int a = 0, b = 0;
    for(int i = 1; i < s.length(); i++){
        if(s[i] == 'A')     a++;
        if(s[i] == 'B')     b++;
    }

    if(a > b)   a++;
    else        b++;
    
    cout << a << " " << b << endl;
}

int main(){
    while(1){
        string s;
        cin >> s;

        if(s == "0")    break;

        dec(s);
        for(int i = 0; i < 2; i++){
            cin >> s;
            dec(s);
        }
    }
    return 0;
}


Measured memory_bytes: 3188
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int P, Q, R;
  cin >> P >> Q >> R;
  cout << min(min(P + Q, Q + R), P + R) << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    A = map(int, input().split())

    a = list(filter(lambda x: (x%2 == 0), A))

    if all(x%3 == 0 or x%5 == 0 for x in a):
        print("APPROVED")
    else:
        print("DENIED")

main()

Measured memory_bytes: 2940
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;



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

int A = 0, B = 0, K = 0, T = 0, W = 0, N = 0, H = 0;
int n = 0;
double L = 0;
double S = 0;
double ar = 0, br = 0, cr = 0;
int answer = 0;

string C;
string sA, strB;
vector<vector<char>> map;
vector<double> num;
vector<string> str;

int sum = 0;

vector<int> value;
vector<int> weight;

int dp[110][10010];

int data_[210][2] = { -2 };

void input(void) {
	CI n;
	return;
}


int main(void) {
	input();
	long double money = 100000;
	
	for (int i = 0; i < n; i++) {
		money *= 1.05;
		if ((int)money % 1000 != 0) {
			money = money - ((int)(money) % 1000) + 1000;
		}
		
	}
	
	CO (int)money E
	

	return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long int;
int n;
unordered_map<int, int> odd, even;

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) {
        int v;
        cin >> v; 
        if(i % 2 == 0)
            even[v]++;
        else
            odd[v]++;
    }

    auto comp = [](P l, P r){ return l.second < r.second; };
    vector<P> ev(even.begin(), even.end());
    sort(ev.begin(), ev.end(), comp);
    reverse(ev.begin(), ev.end());
    ev.push_back({-1, 0});
    
    vector<P> ov(odd.begin(), odd.end());
    sort(ov.begin(), ov.end(), comp);
    reverse(ov.begin(), ov.end());
    ov.push_back({-1, 0});


    ll ans;
    if(ev[0].first != ov[0].first)
        ans = n - (ev[0].second + ov[0].second);
    else
        ans = n - max(ev[1].second + ov[0].second, ev[0].second + ov[1].second);

    cout << ans << endl;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

vector<int> vi[100001];
int cnt[100001];
int modCnt[100001];

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

  rep(i, N) {
    int X;
    cin >> X;
    cnt[X]++;
  }

  rep(i, 100001) if (cnt[i]) {
    modCnt[i % M] += cnt[i];
    vi[i % M].eb(cnt[i]);
  }

  int ans = 0;
  rep(i, M) {
    int j = (M - i) % M;
    if (i > j) break;

    int cnt1 = modCnt[i], cnt2 = modCnt[j];
    vector<int> v1 = vi[i], v2 = vi[j];
    sort(rall(v1));
    sort(rall(v2));

    if (cnt1 < cnt2) {
      swap(v1, v2);
      swap(cnt1, cnt2);
    }

    if (i == j) {
      ans += cnt1 / 2;
    } else {
      int idx = 0;
      while (1) {
        if (idx >= v1.size() || v1[idx] <= 1) break;

        if ((cnt1 - (v1[idx] / 2) * 2) < cnt2) {
          ans += (cnt1 - cnt2) / 2;
          break;
        }

        ans += v1[idx] / 2;
        cnt1 -= (v1[idx] / 2) * 2;
        idx++;
      }
      ans += cnt2;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 6528
def main():

    n, m = map(int, (input().split()))
    a = [list(map(int, list(input().split()))) for item in range(n)]
    b = [int(input()) for item in range(m)]

    c = [sum(a_im * b_m for (a_im, b_m) in zip(a_i, b)) for a_i in a]
    for c_i in c:
        print(c_i)


main()

Measured memory_bytes: 8052
from collections import deque
from typing import List, Any


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


def solve() -> Any:
    H, W = read_ints()
    S = []
    for _ in range(H):
        S.append(input().strip())
    Q = deque([(0, 0, 0)])
    INF = 10**9
    costs = [[INF]*W for _ in range(H)]
    costs[0][0] = 0
    while Q:
        i, j, cost = Q.popleft()
        for x, y in [(i-1, j), (i+1, j), (i, j-1), (i, j+1)]:
            if 0 <= x < H and 0 <= y < W and costs[x][y] == INF and S[x][y] == '.':
                costs[x][y] = cost+1
                Q.append((x, y, cost+1))
    if costs[H-1][W-1] == INF:
        return -1
    whites = sum(1 for row in S for c in row if c == '.')
    return whites-(costs[H-1][W-1]+1)


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 75792
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include<string>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);

constexpr int n = 27;
int d;
int c[27];
vector<vector<int>> sd;
vector<int> last_sche;
int a;

pair<int, int> max_minus_value_and_day(int day) {
	int ret_value = 0;
	int ret_type = 0;
	for (int i = 1; i < n; i++) {
		int tmp = c[i] * (day - last_sche[i]);
		if (tmp > ret_value) {
			ret_value = tmp;
			ret_type = i;
		}
	}
	return pair<int, int>(ret_value, ret_type);
}

int main(void) {
	cin >> d;
	sd = vector<vector<int>>(d + 1, vector<int>(n));
	last_sche = vector<int>(n, 0);
	for (int i = 1; i < n; i++) {
		cin >> c[i];
	}

	for (int i = 1; i < d + 1; i++) {
		for (int j = 1; j < n; j++) {
			cin >> sd[i][j];
		}
	}

	for (int i = 1; i < d + 1; i++) {
		auto itr = max_element(sd[i].begin(), sd[i].end());
		int plus_type = distance(sd[i].begin(), itr);
		int plus = *itr;
		pair<int, int> minus_pair = max_minus_value_and_day(i);
		if (plus > minus_pair.first) {
			cout << plus_type;
			//a += plus;
			last_sche[plus_type] = i;
		}
		else {
			cout << minus_pair.second;
			//a += sd[i][minus_pair.first];
			last_sche[minus_pair.second] = i;
		}
		//a -= compute_minus(i);
		if(i != d)
			cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3672
#!/usr/bin/env python3
import itertools as it
import numpy as np

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    f = lambda x: 0 if x=='.' else 1
    H, W, K = list(map(int, input().split()))

    mat = np.zeros((H, W))
    for i in range(H):
        row = [c for c  in input()]
        for j in range(W):
            mat[i,j] = f(row[j])

    
    # Failed to predict input format
    H_res = [0] * (H*W +1)
    W_res = [0] * (H*W+1)

    combs = list(range(H+W))
    count= 0
    for L in range(0, H+W+1):
        for subset in it.combinations(combs, L):
            subset = list(subset)
            row_idxs = [x for x in subset if x < H]
            col_idxs = [x-H for x in subset if x >= H]
            # if row_idxs == []:
            #     s = np.sum(mat[:,col_idxs])
            # elif col_idxs == []:
            #     s = np.sum(mat[row_idxs])
            # else:
            new_mat = mat[row_idxs][: , col_idxs]
            s = np.sum(new_mat)  
            if s == K:
                count += 1
    # count = 0
    # H_combs = list(range(H))
    # for L in range(0, len(H_combs)+1):
    #     for subset in it.combinations(H_combs, L):
    #         yokonutta = mat.copy()
    #         yokonutta[list(subset)] = 0
            
    #         _, idxs = np.where(yokonutta.sum(axis=0, keepdims=True)!=0)

    #         W_combs = idxs
    #         for L in range(0, len(W_combs)+1):
    #             for subset2 in it.combinations(W_combs, L):
    #                 tatenutta = yokonutta.copy()
    #                 tatenutta[:, list(subset2)] = 0

    #                 if tatenutta.sum() == K:
    #                     count+= 1

    # r = range(36)
    # count = 0
    # for i,j in it.product(r,r):
    #     if i+j==K:
    #         count += H_res[i] + W_res[j]

    print(count)
    pass

if __name__ == '__main__':
    main()


Measured memory_bytes: 26452
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll k,x;
    cin>>k>>x;
    if(k == 0)cout << x << endl;
    
    for(ll i =0; i < k*2-1; i++){
        cout << x-k+1+i << endl;
    }
    
    return 0;
}




Measured memory_bytes: 256
N = int(input())
P = list(map(float,input().split()))

#dp[i][j] : 最初のi枚のコインを投げた時に、表がj枚となる確率
dp = [[0]*(N+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    for j in range(N):
        dp[i+1][j+1] += dp[i][j]*P[i]
        dp[i+1][j] += dp[i][j]*(1-P[i])

ans = sum(dp[N][(N+1)//2:])
print(ans)


Measured memory_bytes: 252168
#define _DEBUG 1

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

bool comp(const tuple<string, ll, ll> &lh, const tuple<string, ll, ll> &rh) {
  return get<0>(lh) < get<0>(rh) ||
         (get<0>(lh) == get<0>(rh) && get<1>(lh) > get<1>(rh));
}

void solve(ll N, vector<tuple<string, ll, ll>> R) {
  sort(all(R), comp);
  for (auto r : R) {
    ll id;
    tie(ignore, ignore, id) = r;
    cout << id << endl;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  ll N;
  scanf("%lld", &N);
  vector<tuple<string, ll, ll>> R(N);
  for (int i = 0; i < N; i++) {
    string s;
    ll p;
    cin >> s >> p;
    R.at(i) = make_tuple(s, p, i + 1);
  }
  solve(N, R);
  return 0;
}


Measured memory_bytes: 256
import java.math.*;
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int N = sc.nextInt();
    int[] A = new int[N];
    int[] B = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
      B[i] = sc.nextInt();
    }
    sc.close();

    int ans = Integer.MAX_VALUE;
    int[] dp = new int[H];
    dp[0] = 1;

    for (int i = 0; i < N; i++) {
      for (int j = 0; j < H; j++) {
        if (dp[j] == 0) continue;
        int h = j + A[i];
        int c = dp[j] + B[i];
        if (h < H) {
          if (dp[h] == 0 || c < dp[h]) {
            dp[h] = c;
          }
        } else {
          ans = Math.min(ans, c);
        }
      }
    }
    System.out.println(ans - 1);
  }
}

Measured memory_bytes: 28016
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

int main() {
  int N;
  cin >> N;
  
  long long ans = 0;
  
  for (int C = 1; C < N; C++) {
    int n = N - C;
    for (int i = 1; i * i <= n; i++) {
      if (n % i) continue;
      
      if (i * i == n) ans += 1;
      else ans += 2;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

const int Mod = 1000000007;
class mll {
public:
	long long x;
	mll(long long x = 0) : x((x% Mod + Mod) % Mod) {};
	void operator += (const mll& a) {
		if ((x += a.x) >= Mod) x -= Mod;
	}
	void operator *= (const mll& a) {
		(x *= a.x) %= Mod;
	}
	mll operator * (const mll& a) const {
		mll ans = *this;
		ans *= a;
		return ans;
	}
	mll inv() {
		long long a = x, b = Mod, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= Mod;
		if (u < 0) u += Mod;
		a = u;
		return mll(a);
	}
};

map<int, int> Factorize(int A) {
	int a = A;
	map<int, int> Ans;
	for (int i = 2; i <= sqrt(A) + 1; i++) {
		while (a % i == 0) {
			Ans[i]++;
			a /= i;
		}
	}
	if (a > 1) Ans[a]++;
	return Ans;
}

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	map<int, int> FactorizedLCM;
	for (int i = 0; i < N; i++) {
		map<int, int> FactorizedA = Factorize(A[i]);
		for (auto p : FactorizedA) FactorizedLCM[p.first] = max(FactorizedLCM[p.first], p.second);
	}
	mll LCM = 1;
	for (auto p : FactorizedLCM) for (int i = 0; i < p.second; i++) LCM *= p.first;
	mll ans = 0;
	for (int i = 0; i < N; i++) {
		mll a = A[i];
		ans += LCM * a.inv();
	}
	cout << ans.x << endl;
}

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

void direction(char d, int dice[])
{
    int temp;
    switch(d)
    {
        case 'E': temp    = dice[1];
                  dice[1] = dice[4];
                  dice[4] = dice[6];
                  dice[6] = dice[3];
                  dice[3] = temp;
                  break;
        case 'S': temp    = dice[1];
                  dice[1] = dice[5];
                  dice[5] = dice[6];
                  dice[6] = dice[2];
                  dice[2] = temp;
                  break;
        case 'W': temp    = dice[1];
                  dice[1] = dice[3];
                  dice[3] = dice[6];
                  dice[6] = dice[4];
                  dice[4] = temp;
                  break;
        case 'N': temp    = dice[1];
                  dice[1] = dice[2];
                  dice[2] = dice[6];
                  dice[6] = dice[5];
                  dice[5] = temp;
                  break;
        case 'R': temp    = dice[2];
                  dice[2] = dice[3];
                  dice[3] = dice[5];
                  dice[5] = dice[4];
                  dice[4] = temp;
                  break;
    }
    return;
}

int main ()
{
    int n;
    cin >> n;
    
    int dice[n][7], same[n];
    for (int i = 0;i < n;i++) same[i] = true;
    
    for (int i = 0;i < n;i++)
    {
        for (int j = 1;j <= 6;j++)
        {
            cin >> dice[i][j];
        }
    }
    
    
    for (int i = 1;i < n;i++)
    {
        for(int j = 1;j <= 4;j++)
        {
            if (dice[i][1] != dice[0][1])
            {
                direction('N', dice[i]);
            }
            else break;
        }
        if (dice[i][1] != dice[0][1])
        {
            if (dice[i][3] == dice[0][1]) direction('W', dice[i]);
            else if (dice[i][4] == dice[0][1]) direction('E', dice[i]);
            else same[i] = false;
        }
        if (same[i])
        {
            for(int j = 1;j <= 4;j++)
            {
                if (dice[i][2] != dice[0][2])
                {
                    direction('R', dice[i]);
                }
                else break;
            }
            for(int j = 1;j <= 6;j++)
            {
                if (dice[i][j] != dice[0][j])
                {
                    same[i] = false;
                    break;
                }
            }
        }
    }
    
    int alldiff = true;
    for (int i = 1;i < n;i++)
    {
        if (same[i])
        {
            alldiff = false;
            break;
        }
    }
    
    if (alldiff) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}



Measured memory_bytes: 3108
#define _USE_MATH_DEFINES //M_PI, M_E
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int h,w,d;
	cin>>h>>w>>d;
	int a;
	ar<int,2> co[h*w];
	for(int i = 0; i<h; i++) for(int j = 0; j<w; j++){ cin>>a,--a; co[a] = {i,j};}
	int q;
	cin>>q;
	int v[h*w]={0};
	for(int i = 0; i+d<h*w; i++)
	{
		v[i+d] = abs(co[i+d][0]-co[i][0])+abs(co[i+d][1]-co[i][1])+v[i];
	}
	while(q--)
	{
		int b,c;
		cin>>b>>c;
		--b,--c;
		int ans = v[c]-v[b];
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 2176
program main;
var
	num, c1, c2, c3, c4, i : integer;
	result : string;
begin
	readln(num);
    c1 := 0;
    c2 := 0;
    c3 := 0;
    c4 := 0;
    for i := 1 to num do begin
    	readln(result);
        if result = 'AC'
        	then c1 := c1 + 1;
        if result = 'WA'
        	then c2 := c2 + 1;
        if result = 'TLE'
        	then c3 := c3 + 1;
        if result = 'RE'
        	then c4 := c4 + 1;
         end;
	writeln('AC x ',c1);
    writeln('WA x ',c2);
    writeln('TLE x ',c3);
    writeln('RE x ',c4);
end.

Measured memory_bytes: 1380
H, W = map(int, input().split())
a = [list(input()) for _ in range(H)]

for i in range(-1, H+1):
    if i == -1 or i == H:
        print("#" * (W+2))
    else:
        tmp = ["#"] + a[i] + ["#"]
        print("".join(tmp))

Measured memory_bytes: 3060
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		n: usize,
	}

	let mut p = 1;
	loop {
		if p*2 > n {
			break;
		}
		p *= 2; 
	}
	println!("{}", p);
}



Measured memory_bytes: 2172
#include <bits/stdc++.h>
/* Karen {{{
  ___  ____
 |_  ||_  _|
   | |_/ /    ,--.   _ .--.  .---.  _ .--.
   |  __'.   `'_\ : [ `/'`\]/ /__\\[ `.-. |
  _| |  \ \_ // | |, | |    | \__., | | | |
 |____||____|\'-;__/[___]    '.__.'[___||__]
}}} */
/* cpp template {{{*/
using namespace std;

#define endl '\n'

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()

typedef double D;
typedef long long ll;
typedef long double lb;
typedef complex<D> P;
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);}
inline int in() {int x; std::cin >> x; return x;}

template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
/* }}} */
/* 定数 {{{*/
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS  = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
/* }}} */

int s;

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

  string s;
  cin >> s;

  int g = 0;
  REP(i, s.size()){
    if (s[i] == 'g'){
      g++;
    }
  }
  cout << (s.size() / 2 + g - s.size())  << endl;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
	long a,min,max,d=0;
	cin>>a;
	int b[10000];
	cin>>b[0];
	min=b[0];
	max=b[0];
	d=b[0];
	for(int i=1;i<a;i++){
		cin>>b[i];
		if(min>b[i])min=b[i];
		if(max<b[i])max=b[i];
		d=d+b[i];
	}
	cout<<min<<" "<<max<<" "<<d<<endl;
}

Measured memory_bytes: 1200
#include <cstdio>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> pi;

int n;
int a[100005], b[100005], c[100005], d[100005];
int dp[100005];

struct seg{int a,b,p,i;}st[200005];
bool cmp(seg a, seg b){return a.a < b.a;}

struct rmq{
    int lim, tree[530000];
    void init(int n){
        for(lim = 1; lim <= n; lim <<= 1);
    }
    void ins(int s, int v){
        s += lim;
        tree[s] = v;
        while(s>1){
            s >>= 1;
            tree[s] = max(tree[2*s],tree[2*s+1]);
        }
    }
    int q(int s, int e){
        s += lim;
        e += lim;
        int r = 0;
        while(s<e){
            if(s%2 == 1) r = max(r,tree[s++]);
            if(e%2 == 0) r = max(r,tree[e--]);
            s >>= 1;
            e >>= 1;
        }
        if(s == e) r = max(r,tree[s]);
        return r;
    }
}rmq;

void input(){
    vector<int> vu, vd;
    scanf("%d",&n);
    rmq.init(2*n);
    for (int i=0; i<n; i++) {
        scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
        vu.push_back(a[i]);
        vu.push_back(b[i]);
        vd.push_back(c[i]);
        vd.push_back(d[i]);
    }
    sort(vu.begin(),vu.end());
    sort(vd.begin(),vd.end());
    for (int i=0; i<n; i++) {
        a[i] = (int)(lower_bound(vu.begin(),vu.end(),a[i]) - vu.begin());
        b[i] = (int)(lower_bound(vu.begin(),vu.end(),b[i]) - vu.begin());
        c[i] = (int)(lower_bound(vd.begin(),vd.end(),c[i]) - vd.begin());
        d[i] = (int)(lower_bound(vd.begin(),vd.end(),d[i]) - vd.begin());
        st[2*i] = {a[i],c[i],0,i};
        st[2*i+1] = {b[i],d[i],1,i};
    }
    sort(st,st+2*n,cmp);
}

vector<pi> v;

int main(){
    input();
    for (int i=0; i<2*n; i++) {
        if(st[i].p == 0){
            dp[st[i].i] = rmq.q(0,st[i].b) + 1;
        }
        else{
            rmq.ins(st[i].b,dp[st[i].i]);
        }
    }
    int mcnt = *max_element(dp,dp+n);
    printf("%d\n",mcnt);
}

Measured memory_bytes: 7876
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int n;
    cin >> n;
    long long a[100000];
    for (int i = 0; i < n; i++) cin >> a[i];
    long long constant = a[0] * 2;
    for (int i = 1; i < n; i++) {
        constant = a[i] * 2 - constant;
    }
    long long ans[100000];
    ans[0] = constant / 2;
    for (int i = 1; i < n; i++) {
        ans[i] = a[i - 1] * 2 - ans[i - 1];
    }
    for (int i = 0; i < n; i++) cout << ans[i] << " ";
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;

#define endl "\n"

const int MOD = 1000000007;


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

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

int main() {
  int N, A, ans;
  cin >> N;
  cin >> ans;
  for (int i = 1; i < N; i++) {
    cin >> A;
    ans = __gcd(ans, A);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter

R = lambda: map(int, input().split())
R()
d = Counter(R())
s = sum(d.elements())
q, = R()
for _ in range(q):
  b, c = R()
  s += (c - b) * d[b]
  print(s)
  d[c]+=d[b]
  d[b] = 0


Measured memory_bytes: 22132
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
    int k;
    char s[105];
    scanf("%d",&k);
    scanf("%s",s);
    int l=strlen(s);
    if(l<=k)
    puts(s);
    else
    {
        for(int i=0;i<k;i++)
        printf("%c",s[i]);
        printf("...");
    }
}

Measured memory_bytes: 1616
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> PII;
#define MOD (1000000007ll)

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


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

#define db(x) cerr << #x ": " << (x) << '\n';

#define int long long

using namespace std;

typedef long long ll;

typedef long double ld;

const int oo = 1e18;

const int MAXN = 2e5 + 100;

const int MOD = 1e9+7;

int qpow(int a, int b)
{
    int res = 1;
    while(b)
    {
        if(b&1)res = res*a%MOD;
        a = a*a%MOD;
        b /= 2;
    }
    return res;
}

int inv(int x)
{
    return qpow(x,MOD-2);
}

int N;

int fact[MAXN];

int sz[MAXN];

int cc[MAXN];

int dp[MAXN];

vector<int> L[MAXN];

void precal(int nodo, int padre)
{
    sz[nodo] = 1;
    for(auto v : L[nodo])
    {
        if(v != padre)
        {
            precal(v,nodo);
            sz[nodo] += sz[v];
        }
    }
    cc[nodo] = fact[sz[nodo]-1];
    for(auto v : L[nodo])
    {
        if(v != padre)
        {
            cc[nodo] = (cc[nodo]*cc[v]%MOD)*inv(fact[sz[v]])%MOD;
        }
    }
}


void DFS(int nodo, int padre, int tp, int ss)
{
    dp[nodo] = fact[sz[nodo]-1+ss];
    for(auto v : L[nodo])
    {
        if(v != padre)
        {
            dp[nodo] = (dp[nodo]*cc[v]%MOD)*inv(fact[sz[v]])%MOD;
        }
    }

    dp[nodo] = (dp[nodo]*tp%MOD)*inv(fact[ss])%MOD;

    for(auto v : L[nodo])
    {
        if(v != padre)
        {
            int temp = dp[nodo];
            temp = temp*inv(fact[N-1])%MOD;
            temp = temp*fact[N-1-sz[v]]%MOD;
            temp = temp*inv(cc[v])%MOD;
            temp = temp*fact[sz[v]]%MOD;
            DFS(v,nodo,temp,N-sz[v]);
        }
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    fact[0] = 1;
    for(int i = 1 ; i < MAXN ; i++)fact[i] = fact[i-1]*i%MOD;

    cin >> N;

    for(int i = 1 ; i <= N-1 ; i++)
    {
        int a, b;
        cin >> a >> b;
        L[a].push_back(b);
        L[b].push_back(a);
    }

    precal(1,-1);

    dp[1] = cc[1];
    DFS(1,-1,1,0);

    for(int i = 1 ; i <= N ; i++)cout << dp[i] << '\n';

    return 0;
}


Measured memory_bytes: 20976
import qualified Data.Vector.Unboxed as V
import Data.Array.IArray (listArray, accumArray, (!))
import Data.Array.MArray
import Data.Array.ST (STUArray, runSTUArray)
import Data.Array.Unboxed (UArray)
import Data.List (sortOn, sortBy, unfoldr, partition)
import Data.Char (isSpace)
import Control.Monad.ST (ST)
import Control.Monad.Trans.State (StateT(..))
import qualified Data.ByteString.Char8 as B

-- utility functions

--   Input functions
readInt = B.readInt . B.dropWhile isSpace

readInts :: Int -> B.ByteString -> [Int]
readInts n = take n . unfoldr readInt

readIntsV :: Int -> B.ByteString -> V.Vector Int
readIntsV n = V.unfoldrN n readInt

readIntsA :: Int -> B.ByteString -> UArray Int Int
readIntsA n bs = runSTUArray $ do
  arr <- newArray_ (0,n-1)
  go arr 0 bs
  return arr
  where
    go :: STUArray s Int Int -> Int -> B.ByteString -> ST s ()
    go arr i bs
      | i==n = return ()
      | otherwise = do
        let Just (x,bs') = readInt bs
        writeArray arr i x
        go arr (i+1) bs'

readTsV :: Int -> B.ByteString -> V.Vector (Int,Int)
readTsV n = V.unfoldrN n $ runStateT ((,) <$> StateT readInt <*> StateT readInt)

readTs :: Int -> B.ByteString -> [(Int,Int)]
readTs n = take n . unfoldr readT where
  readT = runStateT ((,) <$> StateT readInt <*> StateT readInt)

-- main

solv n s k = B.map rep s where
  t = B.index s (k-1)
  rep c
    | c/=t = '*'
    | otherwise = c

main = do
  n <- read <$> getLine :: IO Int
  s <- B.getLine
  k <- read <$> getLine
  B.putStrLn $ solv n s k


Measured memory_bytes: 508