akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
struct LazySegmentTreeAddSum {
    int n;
    std::vector<long long> node, lazy;
    LazySegmentTreeAddSum(std::vector<long long> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);
        for(int i=0;i<sz;++i) {
            node[i+n-1] = v[i];
        }
        for(int i=n-2;i>=0;--i) {
            node[i] = node[i*2+1] + node[i*2+2];
        }
    }
    void eval(int k, int l, int r) {
        if(lazy[k] != 0) {
            node[k] += lazy[k];
            if(r - l > 1) {
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }
    void add(int a, int b, long long x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
            return;
        }
        add(a, b, x, 2*k+1, l, (l+r)/2);
        add(a, b, x, 2*k+2, (l+r)/2, r);
        node[k] = node[2*k+1] + node[2*k+2];
    }
    long long getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(b <= l || r <= a) return 0;
        eval(k, l, r);
        if(a <= l && r <= b) return node[k];
        long long vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        long long vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n, m; cin >> n >> m;
  vector<vector<P>> v(m+1);
  for(int i=0;i<n;++i) {
    int l, r; cin >> l >> r;
    v[r-l+1].push_back({l, r});
  }
  LazySegmentTreeAddSum st(vll(m+1));
  ll su = n;
  for(int i=1;i<=m;++i) {
    for(int j=0;j<(int)(v[i].size());++j) {
      su--;
      st.add(v[i][j].first, v[i][j].second + 1, 1);
    }
    int pos = 0;
    int ans = su;
    while(pos <= m) {
      ans += st.getsum(pos, pos+1);
      pos += i;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 11904
public class Main {
	public static void main(String[] args) {
		for(java.util.Scanner scan:new java.util.Scanner[] {new java.util.Scanner(System.in)}) {
			for(int a:new int[]{scan.nextInt()}) { 
				for(int b:new int[]{scan.nextInt()}) { 
					for(int c:new int[]{scan.nextInt()}) { 
						if(a==5&&b==5&&c==7||a==5&&b==7&&c==5||a==7&&b==5&&c==5) {
							if(System.out.printf("%s","YES")==null) {}
						}
						else {
							if(System.out.printf("%s","NO")==null) {}
						}
					}
				}
			}
		}
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    cin >> a >> s;

    if (a>=3200)
    {
        cout << s << endl;
    }
    else
    {
        cout << "red" << endl;
    }
    
}


Measured memory_bytes: 256
import sys
inp=[i.strip() for i in sys.stdin.readlines()]
if len(inp)==1:
    if len(inp[0].split())==2:
        A,B=map(int,inp[0].split())
        print(max(2*A-1,2*B-1,A+B))
    else:
        S=inp[0]
        N=len(S)
        X=""
        Y=""
        for i in range(N):
            if i%2==0:
                X=X+"0"
                Y=Y+"1"
            else:
                X=X+"1"
                Y=Y+"0"
        A=0
        B=0
        for i in range(N):
            if X[i]!=S[i]:
                A+=1
            if Y[i]!=S[i]:
                B+=1
        print(min(A,B))
else:
    if len(inp[0].split())==1:
        N=int(inp[0])
        H=[int(i) for i in inp[1].split()]
        ans=1
        for i in range(1,N):
            flag=1
            for j in range(i):
                if H[j]>H[i]:
                    flag=0
                    break
            if flag==1:
                ans+=1
        print(ans)
    else:
        N,K=map(int,inp[0].split())
        S=inp[1]
        L=[0]
        tmp="1"
        for i in range(N):
            if tmp!=S[i]:
                L.append(1)
            else:
                L[-1]+=1
            tmp=S[i]
        if tmp=="0":
            L.append(0)
        M=len(L)
        if M<=2*K+1:
            print(N)
            exit()
        X=[0 for i in range(M+1)]
        for i in range(M):
            X[i+1]=L[i]+X[i]
        ans=0
        for i in range(0,M-2*K,2):
            ans=max(ans,X[i+2*K+1]-X[i])
        print(ans)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 1;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans %= mod;
        ans *= power(i + 1, mod - 2);
        ans %= mod;
    }
    return ans;
}

int main(){
    ll n,m;
    cin >> n >> m;
    rrep1(i, m / n){
        if(m % i == 0){
            pf(i);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import numpy as np

D = int(input())
c = np.array(list(map(int, input().split())))
s = np.array([list(map(int, input().split())) for _ in range(D)])


def s6(c, s, last_date, di, i):
    score = s[di - 1][i]
    score += 500 * c[i] * (di - last_date[i])
    return score


def f6(D, c, s):
    last_date = np.zeros(26)

    t = []
    for di in range(1, D + 1):
        score_list = []
        for i in range(26):
            score_list.append(s6(c, s, last_date, di, i))

        select_index = score_list.index(max(score_list))
        t.append(select_index)
        last_date[select_index] = di

    return t


for ti in f6(D, c, s):
    print(ti + 1)

Measured memory_bytes: 27404
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

alis=[]
time=0
for i in range(n):
  time+=a[i]
  alis.append(time)
blis=[]
time=0
for i in range(m):
  time+=b[i]
  blis.append(time)
  
import bisect
nowtop=0
for i in range(0,n+1):
  if i==0:
    aldtime=0
    books=0
  else:
    aldtime=alis[i-1]
    books=i
  if aldtime>k:
    break
  else:
    nokoritime=k-aldtime
    books+=bisect.bisect_right(blis,nokoritime)
    if books>nowtop:
      nowtop=books
print(nowtop)
  

Measured memory_bytes: 47464
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,q;
  int a[100005],b[100005]={};
  cin>>n>>k>>q;
  for(int i=0;i<q;i++){
    cin>>a[i];
    b[a[i]-1]++;
  }
  for(int i=0;i<n;i++){
    b[i]-=q;
    if(b[i]>-k){
      cout<<"Yes"<<"\n";
    }else{
      cout<<"No"<<"\n";
    }
  }
  return 0;
}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,pre[N],suf[N],a[N],b[N];
char s[N],t[N],*S,*T;
bool flip[N];
int calc(){
    static pair<int,int> p[N];
    static int Max[N];
    for (int i=1;i<=n;i++) p[i]=make_pair(a[i],b[i]);
    sort(p+1,p+n+1);
    for (int i=n;i;i--) Max[i]=max(Max[i+1],p[i].second);
    int ans=Max[1];
    for (int i=1;i<=n;i++) ans=min(ans,p[i].first+Max[i+1]);
    return min(ans*2,n);
}
int main()
{
    scanf("%s%s",s+1,t+1);
    n=strlen(s+1);
    if (!strcmp(s+1,t+1)) return puts("0"),0;
    for (int i=1;i<=n;i++) s[i]-='0',t[i]-='0';
    bool no=1;
    for (int i=1;i<=n;i++) if (t[i]) no=0;
    if (no) return puts("-1"),0;
    for (int i=1;i<=n;i++) s[n+n+i]=s[n+i]=s[i],t[n+n+i]=t[n+i]=t[i];
    T=t+n;
    for (int i=1;i<=n;i++){
        while (!T[i-pre[i]]) pre[i]++;
        while (!T[i+suf[i]]) suf[i]++;
    }
    int ans=1e9;
    for (S=s;S<s+n;S++){
        for (int i=1;i<=n;i++) flip[i]=(S[i]!=t[i]);
        int L=S-s,R=(n-L)%n;
        int cnt=L;
        for (int i=1;i<=n;i++)
        if (flip[i]) cnt++,a[i]=pre[i],b[i]=max(suf[i]-L,0);
            else a[i]=b[i]=0;
        ans=min(ans,cnt+calc());
        cnt=R;
        for (int i=1;i<=n;i++)
        if (flip[i]) cnt++,a[i]=max(pre[i]-R,0),b[i]=suf[i];
            else a[i]=b[i]=0;
        ans=min(ans,cnt+calc());
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 384
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on
void main()
{
    long N = lread();
    auto S = sread();
    auto R = new long[](N + 1);
    auto W = new long[](N + 1);
    foreach (i; 0 .. N)
    {
        R[i + 1] = R[i] + (S[i] == 'R');
        W[i + 1] = W[i] + (S[i] == 'W');
    }
    long ans = long.max;
    foreach (i; 0 .. N + 1)
    {
        long r = R[$ - 1] - R[i];
        long w = W[i];
        long a = min(r, w) + abs(r - w);
        ans = ans.min(a);
    }
    writeln(ans);
}


Measured memory_bytes: 7144
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m, sum = 0;
    cin >> n >> m;
    if(n > 1)
        sum += (n*(n-1))/2;
    if(m > 1)
        sum += (m*(m-1))/2;
    cout << sum << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define MAX 1000007
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
void solve() {
	int n;
	cin >> n;
	vector <char> v1(n+1), v2(n+1);
	int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
	string s1 = "";
	string s2 = "";
	for(int i=0;i<n;i++) {
		cin >> v1[i];
		s1 += (v1[i]);
	}
	for(int i=0;i<n;i++) {
		cin >> v2[i];
		s2 += char(v2[i]);
	}
	if(s1 == s2)
		cout << '0' << endl;
	else {
		int c = 0;
		if(s1[0] - '0' > s2[0] - '0')
			swap(s1, s2);
		while(next_permutation(s1.begin(), s1.end())) {
			c++;
			if(s1 == s2)
				break;
		}
		cout << c;
	}
	return ;
}
int32_t main() {
    FO;
    solve();
    return 0;
}


Measured memory_bytes: 256
/* https://probgate.org/viewanalysis.php?pid=978 */
#include <stdio.h>
#include <string.h>

#define N	4000
#define L	62
#define K	((N + L - 1) / L)
#define MD	998244353

void shift(long long *aa, long long *bb, int s) {
	int h, q, r;

	memset(bb, 0, K * sizeof *bb);
	q = s / L, r = s % L;
	for (h = 0; h + q < K; h++) {
		bb[h + q] |= (aa[h] & (1LL << L - r) - 1) << r;
		if (h + q + 1 < K && r > 0)
			bb[h + q + 1] |= aa[h] >> L - r;
	}
}

void xor(long long *aa, long long *bb) {
	int h;

	for (h = 0; h < K; h++)
		aa[h] ^= bb[h];
}

int main() {
	static char s[N + 1];
	static long long aa[K], bb_[K], cc[K], dd_[K], *bb = bb_, *dd = dd_;
	static int p2[N];
	int m, n, l, i, j, p, ans;

	scanf("%d%s", &m, s), n = strlen(s);
	for (i = 0; i < n; i++)
		if (s[i] == '1')
			aa[(n - 1 - i) / L] |= 1LL << (n - 1 - i) % L;
	while (m--) {
		scanf("%s", s), l = strlen(s);
		memset(bb, 0, K * sizeof *bb);
		for (i = 0; i < l; i++)
			if (s[i] == '1')
				bb[(l - 1 - i) / L] |= 1LL << (l - 1 - i) % L;
		i = j = N - 1;
		while (1) {
			long long *tt;
			int tmp;

			while (i >= 0 && (dd[i / L] & 1LL << i % L) == 0)
				i--;
			while (j >= 0 && (bb[j / L] & 1LL << j % L) == 0)
				j--;
			if (i < j)
				tt = dd, dd = bb, bb = tt, tmp = i, i = j, j = tmp;
			if (j < 0)
				break;
			shift(bb, cc, i - j);
			xor(dd, cc);
		}
	}
	l = N;
	while (l > 0 && (dd[(l - 1) / L] & 1LL << (l - 1) % L) == 0)
		l--;
	p = 1;
	for (i = 0; i < n; i++) {
		p2[i] = p;
		p = p * 2 % MD;
	}
	memset(bb, 0, K * sizeof *bb);
	ans = 0;
	for (i = n - 1; i >= 0; i--) {
		int x = aa[i / L] >> i % L & 1, y = bb[i / L] >> i % L & 1;

		if (i >= l - 1 && x == 1)
			ans = (ans + p2[i - l + 1]) % MD;
		if (x != y) {
			if (i >= l - 1) {
				shift(dd, cc, i - l + 1);
				xor(bb, cc);
			} else {
				if (x > y)
					ans = (ans + 1) % MD;
				break;
			}
		}
	}
	if (i < 0)
		ans = (ans + 1) % MD;
	printf("%d\n", ans);
	return 0;
}

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

string S;

int main() {
    cin >> S;
 
    int a = 0;
    for (int i = 0; i < 3; i++) {
        if (S[i] == 'A') {
            a++;
        }
    }
 
    cout << ((a == 1 || a == 2) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int j = 0;
    while(1)
    {
        if(a<=0){
            cout<<"No\n";
            return 0;
        }
        if(c<=0){
            cout<<"Yes\n";
            return 0;
        }
        if(j%2==0)
        {
            c-=b;
        }
        else
            a-=d;
        j++;

    }
    return 0;
}


Measured memory_bytes: 3568
#include <cstdio>
using namespace std;

int main() {
	int n;
	int answer = 0;
	char c;
	int counts[4] = {};
	scanf("%d\n", &n);
	for (int i = 0; i < n; i++) {
		if (i < n-1) {
			scanf("%c ", &c);
		} else {
			scanf("%c", &c);
		}
		if (c == 'P') {
			counts[0]++;
		} else if (c == 'W') {
			counts[1]++;
		} else if (c == 'G') {
			counts[2]++;
		} else if (c == 'Y') {
			counts[3]++;
		}
	}
	for (int j = 0; j < 4; j++) {
		if (counts[j] > 0) {
			answer++;
		}
	}
	if (answer == 1) {
		printf("One\n");
	} else if (answer == 2) {
		printf("Two\n");
	} else if (answer == 3) {
		printf("Three\n");
	} else if (answer == 4) {
		printf("Four\n");
	}
	fflush(stdout);
}

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

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    int N, W, maxi = 0;
    cin >> N >> W;
    vector<pair<int, int>> weights(N+1);
    for (int i=1; i<=N; i++)
        cin >> weights[i].first >> weights[i].second, maxi += weights[i].second;
    vector<vector<long long>> dp(2, vector<long long >(maxi+1, 1e11));
    dp[0][0] = dp[1][0] = 0;
    for (int i=1; i<=N; i++){
        int t = i&1;
        for (int j=1; j<=maxi; j++) {
            dp[t][j] = dp[1 - t][j];
            if (j>=weights[i].second && dp[1-t][j-weights[i].second]+weights[i].first<=W)
                dp[t][j] = min(dp[t][j], dp[1-t][j-weights[i].second]+weights[i].first);
        }
    }
    int ans = 0, t = N&1;
    for (int i=maxi; i>=0; i--)
        if (dp[t][i]<=W){
            ans = i;
            break;
        }
    cout << ans << "\n";
}

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

int main(){
    int S, h, m, s;
    cin >> S;
    h = S / 3600;
    m = (S % 3600) / 60;
    s = (S % 3600) % 60;
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}


Measured memory_bytes: 3100
S = input()
acgt = {'A', 'C', 'G', 'T'}
length = len(S)
start = 0
ans = 0
while start < length:
  while start < length and S[start] not in acgt:
    start += 1
  right = start
  while right < length and S[right] in acgt:
    right += 1
  ans = max(ans, right - start)
  start = right
print(ans)

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

int main()
{
  enum {A, C, G, T};
  const int mod = 1000000007;
  int dp[101][4][4][4] {};
  uint64_t n;
  cin >> n;
  dp[0][3][3][3] = 1;
  for (int l = 0; l < n; l++) {
    for (int c1 = 0; c1 < 4; c1++) {
      for (int c2 = 0; c2 < 4; c2++) {
        for (int c3 = 0; c3 < 4; c3++) {
          if (dp[l][c1][c2][c3] == 0) continue;
          for (int nc = 0; nc < 4; nc++) {
            if (c2 == A && c1 == G && nc == C) continue;
            if (c2 == A && c1 == C && nc == G) continue;
            if (c2 == G && c1 == A && nc == C) continue;
            if (c3 == A && c1 == G && nc == C) continue;
            if (c3 == A && c2 == G && nc == C) continue;
            dp[l + 1][nc][c1][c2] += dp[l][c1][c2][c3];
            dp[l + 1][nc][c1][c2] %= mod;
          }
        }
      }
    }
  }
  int ans = 0;
  for (int c1 = 0; c1 < 4; c1++) {
    for (int c2 = 0; c2 < 4; c2++) {
      for (int c3 = 0; c3 < 4; c3++) {
        ans += dp[n][c1][c2][c3];
        ans %= mod;
      }
    }
  }
  cout << ans << endl;
}


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

int main(){
    string s;
    cin>>s;
    int m=0,c=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T') c++;
        else c=0;
        m=max(m,c);
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
	int N;
	int A[200];
	scanf("%d\n", &N);
	for(int i=0; i<N; i++){
		scanf("%d", &A[i]);
	}
	for(int i=N-1; i>=0; i=i-1){
			if(i==0){
				printf("%d\n", A[0]);
			}
			else{
				printf("%d ", A[i]);
			}
	}
	return 0;
}

Measured memory_bytes: 2692
#include <iostream>
#include <fstream>
using namespace std;
const int nmax=200005;
int v[nmax];
long long pond[nmax];
long long tot;
int n,s,x,i,j,nr;
int main()
{
   // freopen("data.in","r",stdin);
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        if(x==0) pond[nr]++;
        else v[++nr]=x;
    }
    for(i=0;i<=nr;i++)
    {
        tot+=(1LL*pond[i]*(pond[i]+1))/2;
    }
    for(i=1;i<=nr;i++)
    {
        s=x=0;
        for(j=i;j<=min(nr,i+19);j++)
       {
           s+=v[j],x^=v[j];
           tot+=1LL*(s==x)*(pond[i-1]+1)*(pond[j]+1);
       }
    }
    cout<<tot;
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int r, g, b, n; cin >> r >> g >> b >> n;
	int ans = 0;
	for( int x = 0; x <= n/r; ++x ){
		for( int y = 0; y <= n/g; ++y ){
			int m = r*x+g*y-n;
			if( m % b == 0 && 0 <= -(m/b) ){
				++ans;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import Data.Char
import Data.List

decToBin :: Int -> String
decToBin 0 = "0"
decToBin 1 = "1"
decToBin n = decToBin (n`div`2) ++ show (n`mod`2)

chrToDig ch = if isDigit ch then ord ch - ord '0' else 0

delZero s = if elem 0 s then delZero (delete 0 s) else s

main=getContents>>=mapM_ putStrLn.map(unwords.(map show).delZero.zipWith(*)(iterate(*2)1).(reverse.map chrToDig).decToBin.read).lines

Measured memory_bytes: 3912
import sys
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))
H, W, K = inpl()
a = [input() for _ in range(H)]
strawberry = [[] for _ in range(H)]
for h in range(H):
    for w in range(W):
        if a[h][w] == '#':
            strawberry[h].append(w)
empty = []
ans = [[0]*W for _ in range(H)]
s = 1
for h in range(H):
    if len(strawberry[h]) == 0:
        empty.append(h)
        continue
    strawberry[h][-1] = W-1
    i = 0
    for w in range(W):
        ans[h][w] = s
        if w == strawberry[h][i]:
            s += 1
            i += 1

j = 0
while len(empty) > j and empty[j] == j:
    j += 1
for k in range(j):
    ans[k] = ans[j]
for e in range(j, len(empty)):
    k = empty[e]
    ans[k] = ans[k-1]

for h in range(H):
    print(' '.join(list(map(str, ans[h]))))


Measured memory_bytes: 45148
#include <stdio.h>

int main(){
    char number[1001];
    int i, sum;
    while(1){
        scanf("%s", number);
        if(number[0]=='0')break;
        sum=0;
        for(i=0;number[i]!='\0';i++){
            sum+=number[i]-'0';
        }
        printf("%d\n", sum);
    }

    return 0;
}


Measured memory_bytes: 2096
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int W,H,N,x,y,nx,ny,dx,dy,sum;
  cin>>W>>H>>N;
  cin>>nx>>ny;
  sum=0;
  for(int i=0;i<N-1;i++){
    cin>>x>>y;
    dx=abs(nx-x);
    dy=abs(ny-y);
    //cout<<sum<<' ';
    if((nx-x)*(ny-y)>0)sum+=max(dx,dy);
    else sum+=dx+dy;
    ny=y;nx=x;
    //if(dx>=0&&dy>=0)sum+=max(dx,dy);
    //else if(dx<0&&dy<0)sum+=dx+dy;
    //cout<<sum<<endl;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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 long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    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;
    }
}
 
 
#define comuse Comuse()
 
ll combi(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;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  FOR(i,0,1700000000){
    if(i%2==0){
      n*=3;
    }
    else{
      n/=3;
    }
  }
  co(3*n*n)
}


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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  int n;
  cin >> n;
  int odd[100002]={}, even[100002]={};
  int omax=0, emax=0, io, ie;
  for(int i=0; i<n; i++){
    int a;
    cin >> a;
    if(i%2==0){
      odd[a]++;
      if(odd[a]>omax){
        omax = odd[a];
        io = a;
      }
    }else{
      even[a]++;
      if(even[a]>emax){
        emax = even[a];
        ie = a;
      }
    }
  }
  sort(odd, odd+100000, greater<int>());
  sort(even, even+100000, greater<int>());
  int ans;
  if(io!=ie) ans = n - omax - emax;
  else ans = n - max(omax+even[1], odd[1]+emax);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int main() {
    string t, s, f;
    int n, a, b;
    cin >> s;
    cin >> n;

    for(int i=0;i<n;i++){
        cin >> f;

        if (f=="replace") {
            cin >> a >> b >> t;
            s = s.substr(0, a) + t + s.substr(b+1, s.length());
        }
        if (f=="reverse") {
            cin >> a >> b;
            t = s.substr(a, b+1 - a);
            reverse(t.begin(), t.end());
            s = s.substr(0, a) + t + s.substr(b+1, s.length());
        }
        if (f=="print") {
            cin >> a >> b;
            cout << s.substr(a, b+1 - a) << endl;
        }
    }
}


Measured memory_bytes: 3224
#include<iostream>
#include<map>
using namespace std;
const int mod=1000000007;
int n;
map<string,long> dp[101];

bool ok(string s){
	for(int i=0;i<4;i++){
		string s4=s;
		if(i!=0){
			char tmp=s4[i];
			s4[i]=s4[i-1];
			s4[i-1]=tmp;
		}
		if(s4.substr(0,3)=="AGC" || s4.substr(1)=="AGC") return false;
	}
	return true;
}

string ss="ACGT";
long dfs(int cur,string s3){
	if(dp[cur].count(s3)) return dp[cur][s3];
	if(cur==n) return 1;
	long res=0;
	for(char c:ss){
		if(ok(s3+c)) res+=dfs(cur+1,s3.substr(1)+c);
	}
	return dp[cur][s3]=res%mod;
}

int main(){
	cin >> n;
	cout << dfs(0,"TTT") << endl;
	return 0;
}


Measured memory_bytes: 896
import math
from collections import Counter
a, b = map(int, input().split())
x = math.gcd(a, b)

Nso = []
Nruto = math.sqrt(x)
Nruto = math.floor(Nruto)

for i in range(2, Nruto+1):
    while x % i == 0:
        x = x//i
        Nso.append(i)
    if x == 1:
        break
    Nruto = math.sqrt(x)
    Nruto = math.floor(Nruto)

Nso.append(x)
Nso.append(1)
Nso = Counter(Nso)
print(len(Nso))


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

#define int long long

using namespace std;

void solve()
{
    int nbr; cin >> nbr;
    vector<int> v(nbr);
    for (int i = 0; i < nbr; i++) {cin >> v[i];}

    int ans = 0;

    for (int i = 1; i < nbr; i++) {
        if (v[i] < v[i-1]) {
            ans += v[i-1] - v[i];
            v[i] = v[i-1];
        }
    }
    cout << ans << endl;
}

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

    //int TT;
    //cin >> TT;

    //for (int T = 0; T < TT; T++) {
        solve();
    //}
    return 0;
}

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

inline int toInt(string s) {
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x) {
    ostringstream sout;
    sout << x;
    return sout.str();
}

#define reps(i, k, n) for (ll(i) = (k); (i) < (n); ++(i))
#define rep(i, n) reps(i, 0, n)
#define debug(x) cerr << x << " (L:" << __LINE__ << ")" << '\n';

#define pb push_back
#define mp make_pair
#define ALL(o) (o).begin(), (o).end()
#define sz(a) (int)((a).size())

#define ll long long
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vs = vector<string>;

const ll MAX = (ll)0x3f0000003f000000;
const int MOD = 1000000007;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
          dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

void solve();
ll ans = 0;

void setup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
}

int main() {
    setup();

    solve();
}

void solve() {
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (s == u) a--;
    if (t == u) b--;
    cout << a << " " << b;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

ll N, K;
vector<vector<int>> adj;
vector<ll> p1, p2;

void input() {
    cin >> N >> K;
    adj.resize(N);
    p1.resize(K);
    p2.resize(K);
    rep(i, N-1) {
        int a, b; cin >> a >> b; --a; --b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    p1[0] = 1; p2[0] = 1;
    repr(i, 1, K) {
        p1[i] = p1[i-1] * (K-i);
        chmod(p1[i]);
    }
    repr(i, 1, K-1) {
        p2[i] = p2[i-1] * (K-1-i);
        chmod(p2[i]);
    }
}

ll dfs(int now, int from) {
    int chi = adj[now].size();
    if (now!=0) --chi;

    ll res;
    ll use = (now==0? K-1:K-2);
    if (use < chi) return 0;
    else res = (use==K-1? p1[chi]:p2[chi]);

    for(auto to: adj[now]) if (to!=from) {
        res *= dfs(to, now);
        chmod(res);
    }
    return res;
}

void solve() {
    ll ans = K * dfs(0, -1);
    chmod(ans);
    cout << ans << endl;
}

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

    input();
    solve();
    
    return 0;
}


Measured memory_bytes: 10368
import sys
from collections import defaultdict
import heapq

class Dijkstra():
    def __init__(self):
        self.edges = defaultdict(list)
    
    def add_edge(self, a, b, cost, directed=False):
        self.edges[a].append((b,cost))
        if not directed:
            self.edges[b].append((a,cost))
        
    def delete_edge(self, a, b):
        self.edges[a] = [item for item in self.edges[a] if item[0] != b]
        self.edges[b] = [item for item in self.edges[a] if item[0] != a]

    def Dijkstra_search(self, start=0):
        '''
        Returns min distances to every node from start node(input).
        '''

        # defaultdict to store minimum cost to visit each node
        distances = defaultdict(lambda: float('inf'))
        distances[start] = 0 # start node is zero-cost

        # initialize a priorit queue with heapq
        q = []
        heapq.heappush(q, (0, start))

        # store flags for each node to mark if the node has been visited
        if_visited = defaultdict(bool)

        while q:
            # search from a new node whose cost is known to be minimum among items in queue 
            cost_current, node_current = heapq.heappop(q)
            
            # skip if the node has already been visited
            if if_visited[node_current]:
                continue
            
            else:
                if_visited[node_current] = True

                # visit adjacent nodes
                for node_visiting, cost_visiting in self.edges[node_current]:

                    if if_visited[node_visiting]: # check if already visited
                        continue
                    
                    cost_cumulative = cost_current + cost_visiting

                    if cost_cumulative < distances[node_visiting]: # check if current path is worthy updating
                        distances[node_visiting] = cost_cumulative
                        heapq.heappush(q, (cost_cumulative, node_visiting))

        return distances


input = sys.stdin.readline
N = int(input())
g = Dijkstra()

while True:
    s = input()
    if s == '':
        break
    
    a, b, c = map(int, s.rstrip().split())
    a -= 1
    b -= 1
    g.add_edge(a,b,c)

distance = g.Dijkstra_search()

for x in distance:
    if distance[x] % 2 == 0:
        print(0)
    else:
        print(1)

Measured memory_bytes: 67488
#include<bits/stdc++.h>
using namespace std;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int five = 0;
   int seven = 0;
   int a, b, c;
   cin >> a >> b >> c;
   if(a==5) {
       five++;
   } else if(a==7) {
       seven++;
   }
   if(b==5) {
       five++;
   } else if(b==7) {
       seven++;
   }
   if(c==5) {
       five++;
   } else if(c==7) {
       seven++;
   }
   if(five==2&&seven==1) {
       cout << "YES" << endl;
   } else {
       cout << "NO" << endl;
   }
}

Measured memory_bytes: 256
import sys
from collections import deque

input = sys.stdin.readline


def main():
    H, W = map(int, input().split())
    S = [None] * (H + 2)
    S[0] = S[-1] = "x" * (W + 2)
    for i in range(1, H + 1):
        S[i] = "".join(["x", input().rstrip(), "x"])

    group = []
    visited = [[True] + [False] * W + [True] for _ in range(H + 2)]
    visited[0] = visited[-1] = [True] * (W + 2)
    for h in range(1, H + 1):
        for w in range(1, W + 1):
            if visited[h][w]:
                continue
            queue = deque([(h, w, S[h][w])])
            group.append({"#": 0, ".": 0})
            while queue:
                y, x, s = queue.popleft()
                if visited[y][x]:
                    continue
                visited[y][x] = True
                group[-1][s] += 1
                for i, j in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
                    yy, xx = y + i, x + j
                    if visited[yy][xx]:
                        continue
                    if s == "#" and S[yy][xx] == ".":
                        queue.append((yy, xx, "."))
                    elif s == "." and S[yy][xx] == "#":
                        queue.append((yy, xx, "#"))

    ans = 0
    for g in group:
        ans += g["#"] * g["."]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 44544
/*
for:
Hussien , Ayman , Emad
Abanob , George , Genawy
Ka8eem , Mosta7il , Stawro
Shahat , Omar
ICPC DREAM
*/
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<bits/stdc++.h>
#include<chrono>
#include<unordered_map>
#include <random>
#include <complex> 
using namespace std;
#define ll long long
#define ld double
#define ull unsigned ll 
#define endl '\n'
#define mk make_pair
#define holla(x,y) cout <<"# holla "<<y<<" "<< #x << " is " << x << endl;
typedef complex<long double> point;
#define sz(a) ((int)(a).size())
#define all(n) (n).begin(), (n).end()
#define EPS 1e-9
#define OO 1e9
#define X real()
#define Y imag()
#define vec(a,b) ((b)-(a))
#define polar(r,t) ((r)*exp(point(0,(t))))
#define angle(v) (atan2((v).Y,(v).X))
#define length(v) ((long double)hypot((v).Y,(v).X))
#define lengthSqr(v) (dot(v,v))
#define dot(a,b) ((conj(a)*(b)).real())
#define cross(a,b) ((conj(a)*(b)).imag())
#define rotate(v,t) (polar(v,t))
#define rotateabout(v,t,a)  (rotate(vec(a,v),t)+(a))
#define reflect(p,m) ((conj((p)/(n)))*(n))
#define normalize(p) ((p)/length(p))
#define same(a,b) (lengthSqr(vec(a,b))<EPS)
#define mid(a,b) (((a)+(b))/point(2,0))
#define perp(a) (point(-(a).Y,(a).X))
#define colliner pointOnLine 
enum STATE { IN, OUT, BOUNDRY };
const double PI = acos(-1.0);
#ifndef ONLINE_JUDGE
int __builtin_popcount(int mask) {
	int cnt = 0;
	for (int i = 0; i < 23; i++)
		if (mask&(1 << i)) ++cnt;
	return cnt;
}
#endif
void fast_in_out() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
}
int dx[] = { 0,0,-1,1,-1,1,-1,1,0 };// remeber the secret ultimate move
int dy[] = { -1,1,0,0,-1,-1,1,1,0 };// the 0,0 not moving move 
int lx[] = { 2, 2, -1, 1, -2, -2, -1, 1,0 };
int ly[] = { -1, 1, 2, 2, 1, -1, -2, -2,0 };
const ld eps = 1e-9;
const int N = 1e5 + 50, M = 500 + 10, mod = 1e9 + 7;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main() {
	fast_in_out();
	//cout << fixed << setprecision(9);
	//freopen("fetiera.in", "r", stdin);
	//kolo ray7 , ya 5rabyy
	int n; cin >> n;
	vector<ll>v(n+1),cum(n+1);
	for (int i = 1; i <= n; i++)
		cin >> v[i], cum[i] = v[i] + cum[i - 1];
	ll ans = 1e18;
	for (int i = 0; i <= n; i++) {
		ll l = cum[i];
		ll r = cum[n] - cum[i];
		ans = min(ans, abs(r - l));
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3328
using System;

namespace ABC114_B
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string input = Console.ReadLine();
			int minNumber = 753;
			for (int i = 0; i < input.Length - 2; i++)
			{
				int value = int.Parse(input.Substring(i, 3));

				if (minNumber > Math.Abs(753 - value))
				{
					minNumber = Math.Abs(753 - value);
				}
			}
			
			Console.WriteLine(minNumber);
		}
	}
}


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

#ifdef DEBUG
#define debug(x) cout << #x << ": " << x << endl
#else
#define debug(x)
#endif

#define int ll

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPS(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;

const ll INF = 1e18;
const ll MOD = 1e9+7;

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

ll gcd(ll a, ll b)
{
    if(b == 0) return a;
    return gcd(b, a%b);
}

ll extgcd(ll a, ll b, ll& x, ll& y)
{
    ll d = a;
    if(b != 0)
    {
        d = extgcd(b, a%b, y, x);
        y -= (a / b) * x;
    }
    else
    {
        x = 1;
        y = 0;
    }
    return d; 
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

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

    ll N, M; cin >> N >> M;
    vl A(N); REP(i, N) cin >> A[i], A[i]/=2;
    ll l = 1; REP(i, N) l = lcm(l, A[i]);
    REP(i, N)
    {
        if(l / A[i] % 2 == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (l <= M) + (M-l)/(2*l) << endl;
}
    

Measured memory_bytes: 1024
// id: ALDS1_3_A
// CPU: 00:sec  Memory: KB
#include <cstdio>
#include <stack>
#include <string>
#include <cctype>
#include <cstdlib>

using std::stack;
using std::string;
//using std::stoi; // 新标准函数，oj似乎不支持

static const int MAX_LEN = 6;

int main()
{
	stack<int> opds;
	char str[MAX_LEN + 1];

	while ( scanf("%s", str) != EOF ) {
		string s(str);

		if ( isdigit(s[0]) ) {
			//opds.push(stoi(s));
			opds.push(atoi(s.c_str()));
		}
		else {
			int rhs = opds.top();
			opds.pop();
			int lhs = opds.top();
			opds.pop();

			if ( s == "+" )
				opds.push(lhs + rhs);
			else if ( s == "-" )
				opds.push(lhs - rhs);
			else
				opds.push(lhs * rhs);
		}
	}

	printf("%d\n", opds.top());

	return 0;
}


Measured memory_bytes: 2864
S = list(input())
K = int(input())
N = len(S)

cnt = [[S[0],1]]
for i in range(1,len(S)):
  if S[i] == cnt[-1][0]:
    cnt[-1][1] += 1
  else:
    cnt.append([S[i],1])
ans = 0
if len(cnt) == 1:
  ans = (K*cnt[0][1])//2
elif cnt[0][0]==cnt[-1][0]:
  ans = (K-1)*((cnt[0][1]+cnt[-1][1])//2)
  ans += K*sum([cnt[i][1]//2 for i in range(1,len(cnt)-1)])
  ans += cnt[0][1]//2
  ans += cnt[-1][1]//2
else:
  ans = K*sum([cnt[i][1]//2 for i in range(len(cnt))])
print(ans)

Measured memory_bytes: 38384
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    map<string, int> mp;
    int n; cin >> n;
    while (n--) {
        string s; cin >> s;
        mp[s]++;
    }

    cout << "AC x " << mp["AC"] << "\n";
    cout << "WA x " << mp["WA"] << "\n";
    cout << "TLE x " << mp["TLE"] << "\n";
    cout << "RE x " << mp["RE"] << "\n";
    
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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; }

struct UnionFind {
    vector<int> par;

    UnionFind(int sz) {
        par.assign(sz, -1);
    }

    bool merge(int x, int y) {
        x = root(x), y = root(y);
        if(x == y) return (false);
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return (true);
    }

    int root(int k) {
        if(par[k] < 0) return (k);
        return (par[k] = root(par[k]));
    }

    int size(int k) {
        return (-par[root(k)]);
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

int main(){
    int n,m; cin >> n >> m;
    UnionFind uf(n);
    rep(i,m){
        int a,b; cin >> a >> b;
        a--; b--;
        uf.merge(a,b);
    }
    int ans = 0;
    rep(i,n){
        chmax(ans, uf.size(i));
    }
    cout << ans << endl;
}



Measured memory_bytes: 4032
#include <algorithm>
#include <cstdio>
#include <map>
using ll = long long;
ll arr[100005], sum[100005];
int idx[100005], fa[100005], sz[100005];
std::map<ll, int> app;
int main()
{
	// freopen("ARC103-F.in", "r", stdin);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%lld", arr + i);
		app[arr[i]] = i;
		idx[i] = i;
		sz[i] = 1;
	}
	std::sort(idx, idx + n, [&] (int x, int y) { return arr[x] > arr[y]; });
	for (int i = 0; i + 1 < n; i++)
	{
		int u = idx[i];
		ll x = n - sz[u] * 2;
		if (x <= 0 || !app.count(arr[u] - x))
		{
			puts("-1");
			return 0;
		}
		fa[u] = app[arr[u] - x];
		sz[fa[u]] += sz[u];
		sum[fa[u]] += sum[u] + sz[u];
	}
	if (sum[idx[n - 1]] != arr[idx[n - 1]])
	{
		puts("-1");
		return 0;
	}
	for (int i = 0; i + 1 < n; i++)
		printf("%d %d\n", idx[i] + 1, fa[idx[i]] + 1);
	return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)3e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

void solve() {
    int n;
    cin>>n;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        if(i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }
    cout<<ans;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int t = 1;
    //cin>>t;
    while(t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3656
import java.util.*;
class Main{
		public static void main(String[] args) {
			Scanner Cf=new Scanner(System.in);
			int N=Cf.nextInt();
			//no slimes should combine with
			//each other that means no 
			//same Ai's should group together
			int[] array=new int[N];
			for(int i=0;i<N;i++) {
				array[i]=Cf.nextInt();
			}
			int count = 0;
			if(array.length==2) {
				if(array[0]==array[1]) {
					System.out.println(1);
				}
				else {
					System.out.println(0);
				}
			}
			else {
			for(int j=0;j<N;) {
				
				if(	j+1<array.length &&
						j>0 && array[j-1]==array[j]
								&& array[j]==array[j+1] ) {
					count++;
					j=j+2;
				}
				else if(j>0 && j+1<array.length && array[j-1]==array[j] && array[j]!=array[j+1]
						) {
					count++;
					j=j+2;
				}
				else if(j==array.length-1 && array[j-1]==array[j]) {
					count++;
					break;
				}
				else {
					j++;
				}
			}
//			if(array[array.length-1]==array[array.length-2]) {
//				count++;
//			}
			
			System.out.println(count);
			}
			}
}


Measured memory_bytes: 21972
import numpy as np
N = int(input())
A = np.array(list(map(int,input().split())))
while len(A) > 1:
    min_A = min(A)
    A = A%min_A
    A = A[A>0]
    A = np.append(A,[min_A])
    answer = min_A
    if answer == 1:
        break
print(min_A)

Measured memory_bytes: 23092