akhauriyash/Code-Regression huggingface dataset:
N = int(input())
if N == 100000:
  print(90909)
elif N >= 10000:
  print(N-9999+909)
elif N >= 1000:
 print(909)
elif N >= 100:
 print(N-99+9)
elif N >= 10:
 print(9)
else:
 print(N)

Measured memory_bytes: 2940
N = int(input())
lst = []
for i in range(N):
    a, b, c = map(int, input().split())
    lst.append((a, b, c))

dp = [[0] * N , [0] * N, [0] * N]

for i, (a, b, c) in enumerate(lst):
    if i == 0:
        dp[0][0] = a
        dp[1][0] = b
        dp[2][0] = c
    else:
        a_ob = dp[0][i-1]
        b_ob = dp[1][i-1]
        c_ob = dp[2][i-1]
        dp[0][i] = max(b_ob + a, c_ob + a)
        dp[1][i] = max(a_ob + b, c_ob + b)
        dp[2][i] = max(a_ob + c, b_ob + c)
        
print(max(dp[0][-1], dp[1][-1], dp[2][-1]))

Measured memory_bytes: 32452
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
INF = float('inf')


N, D = map(int, input().split())

ans = 0
for _ in range(N):
    x, y = map(int, input().split())
    if math.sqrt(x ** 2 + y ** 2) <= D:
        ans += 1

print(ans)


Measured memory_bytes: 71556
s = input()
l = len(s)
ans = "Yes"
if s != s[::-1]: ans = "No"
s1 = s[::(l-1)//2]
if s1 != s1[::-1]: ans = "No"
s2 = s[(l+3)//2-1:]
if s2 != s2[::-1]: ans = "No"
print(ans)


Measured memory_bytes: 3060
N,K=[int(i) for i in input().split()]
AAA=input().split()
A = [int(i) for i in AAA]

kosuu = [0 for i in range(N+1)]
for i in range(N):
    kosuu[A[i]] = kosuu[A[i]] + 1
seikosuu = [x for x in kosuu if x > 0]
seikosuu.sort()
l = len(seikosuu)
ans=sum(seikosuu[0:l-K])
print(ans)

Measured memory_bytes: 30376
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vec(a) vector<int>a
using namespace std;


int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	fastio
	ll a,b,k;
	cin>>a>>b;
	k=max(a+b,a-b);
	k=max(k,a*b);
	cout<<k<<"\n";
	return 0;
}

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

int main()
{
	int H, W;

	while (1) {
		cin >> H >> W;
		
		if (H == 0 && W == 0) {
			break;
		}

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3088
n = int(input())
h = list(map(int, input().split()))
max_count = 0
count = 0
for i in range(1, n):
    if h[i - 1] >= h[i]:
        count += 1
    else:
        if max_count < count:
            max_count = count
        count = 0
if max_count < count:
    max_count = count
print(max_count)

Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main()
{
	ll N, A, B;
	cin >> N >> A >> B;

	cout << min(A, B) << " " <<  max(0ll, N - (N - A + N - B)) << endl;
}


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

int main() {
    string n;
    cin >> n;
    if((n[0] == n[1] || n[2] == n[3]) && (n[1] == n[2])){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] A = new int[n];
        for(int i = 0; i < n; i++){
            A[i] = sc.nextInt();
        }
        int[] count = new int[n];
        int div = 0;
        int check = 0;
        for(int i = 0; i < n; i++){
            check = A[i];
            while(check%2 == 0){
                div++;
                check = check/2;
            }
            count[i] = div;
            div = 0;
        }
        int sum = 0;
        for(int i = 0; i < n; i++){
            sum = sum + count[i];
        }
        System.out.print(sum);
    }
}

Measured memory_bytes: 33956
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
    
int main(){
  int n;
  cin >> n;
  int ans = 0;
  while(true){
    bool can = false;
    if(n < 500) can = true;
    if(can) break;
    n -= 500;
    ans += 1000;
  }
  while(true){
    bool can = false;
    if(n < 5) can = true;
    if(can) break;
    n -= 5;
    ans += 5;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
   int a,b;
   int p,q;
   int c;
   cin >> a >> b;
   vector<bool> v(a,true);
   for(int i=0;i<b;i++){
       int A;
       cin >> A;
       v[A-1] = false;
   }
   if(a == 1){
       if(v[0])cout << 1 << endl;
       else cout << 0 << endl;
   }
   else{
       if(v[0])p = 1;
        else p = 0;
        if(v[1])q = p + 1;
        else q = 0;
        for(int i=2;i<a;i++){
            if(v[i]){
                c = q;
                q += p;
                p = c;
                p %= 1000000007;
                q %= 1000000007;
            }else{
                p = q;
                q = 0;
            }
        }
   cout <<q << endl;
   }
 }

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

int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if(s < t){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <deque>
#include <vector>
#include <iostream>
using namespace std;
struct place {
	int id;
	double skip;
	place() : id(0), skip(0.0) {};
	place(int id_, double skip_) : id(id_), skip(skip_) {};
};
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N; long long C;
	cin >> N >> C;
	vector<long long> H(N);
	for (int i = 0; i < N; ++i) {
		cin >> H[i];
	}
	deque<place> que;
	que.push_back(place(0, -1.0e+99));
	vector<long long> dp(N);
	for (int i = 1; i < N; ++i) {
		while (que.size() >= 2 && (++que.begin())->skip < H[i]) {
			que.pop_front();
			que.front().skip = -1.0e+99;
		}
		int bestid = que.front().id;
		dp[i] = dp[bestid] + (H[i] - H[bestid]) * (H[i] - H[bestid]) + C;
		double final_overtake = -1.0e+99;
		while (!que.empty()) {
			int preid = que.back().id;
			double overtake = double((H[i] * H[i] + dp[i]) - (H[preid] * H[preid] + dp[preid])) / (2 * (H[i] - H[preid]));
			if (que.back().skip > overtake) {
				que.pop_back();
			}
			else {
				final_overtake = overtake;
				break;
			}
		}
		que.push_back(place(i, final_overtake));
	}
	cout << dp[N - 1] << '\n';
	return 0;
}

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

int main() {
    int n,m;
    cin >> n >> m;
    long long x,y,z;
    vector<vector<long long>> sum(8, vector<long long>(n));
    for(int i = 0; i < n; i++)
    {
        cin >> x >> y >> z;
        for(int j = 0; j < 2; j++)
        {
            for(int k = 0; k < 2; k++)
            {
                for(int l = 0; l < 2; l++)
                {
                    if (j) sum.at(j * 4 + k * 2 + l).at(i) += x * -1;
                    else sum.at(j * 4 + k * 2 + l).at(i) += x;

                    if (k) sum.at(j * 4 + k * 2 + l).at(i) += y * -1;
                    else sum.at(j * 4 + k * 2 + l).at(i) += y;

                    if (l) sum.at(j * 4 + k * 2 + l).at(i) += z * -1;
                    else sum.at(j * 4 + k * 2 + l).at(i) += z;
                }
                
            }
            
        }
        
    }

    for(int i = 0; i < 8; i++)
    {
        sort(sum.at(i).begin(), sum.at(i).end());
    }
    vector<long long> s(8);
    for(int i = 0; i < 8; i++)
    {
        for(int j = 0; j < m; j++)
        {
            s.at(i) += sum.at(i).at(n - j - 1);
        }
        
    }
    long long ans = 0;
    for(int i = 0; i < 8; i++)
    {
        ans = max(ans, s.at(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
const int maxn=1e5+1000;
using namespace std;
int n,m,fa[maxn],out[maxn];
vector<int>side[maxn];
int get(int x){
	if(fa[x]==x)return x;
	fa[x]=get(fa[x]);
	return fa[x];	
}
void uni(int x,int y){
	fa[get(x)]=get(y);	
}
void dfs(int now,int fa){
	for(int i=0;i<side[now].size();i++){
		int v=side[now][i];if(v==fa)continue;
		dfs(v,now);
		if(out[v]&1){printf("%d %d\n",v,now);}
		else{out[now]++;printf("%d %d\n",now,v);}	
	}
	return;
}
int main(){
	scanf("%d%d",&n,&m);
	if(m&1){printf("-1");return 0;}
	for(int i=1;i<=n;i++)fa[i]=i;
	for(int i=1;i<=m;i++){
		int u,v;scanf("%d%d",&u,&v);
		if(get(u)!=get(v)){side[u].push_back(v);side[v].push_back(u);uni(u,v);}
		else{
			out[v]++;
			printf("%d %d\n",v,u);
		}
	}//
	dfs(1,0);
	return 0;
}

Measured memory_bytes: 14336
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,d[100010],ans=0;
    cin>>n;
    rep(i,n){
        cin>>d[i];
    }
    rep(i,n) rep2(j,i+1,n) ans+=d[i]*d[j];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
S=set()
cnt=0
for i in A:
  if i>=3200:
    cnt+=1
  else:
    S.add(i//400)
if len(S)==0:
  low=1
  high=cnt
else:
  low=len(S)
  high=cnt+low
print(low,high)

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define digit(x) floor(log10(x))+1
#define mod 1000000007
#define L_MAX 1e18
using ll = long long;
using ld = long double;
using ii = pair<ll,ll>;
using iii = tuple<ll,ll,ll>;
using matrix = vector<vector<ll>>;
using arr = vector<ll>;
using vs = vector<string>;
using pv = vector<ii>;
using umap = unordered_map<ll,ll>;
#define in1(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define in3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define all(x) x.begin(),x.end()
#define debug(x) cerr << #x << " is " << x << endl;
void showArr(arr a){
    for(auto i : a) cout<<i<<" ";
    cout<<endl;
}
ll dx[]={-1,1,-1,1,0,0,-1,1};
ll dy[]={-1,1,0,0,-1,1,1,-1};
ll Solve(ll index,arr a,ll n,ll k,ll dp[]){
    if(index>=n-1)
        return 0;
    ll ans=L_MAX;
    if(dp[index]!=-1)
        return dp[index];
    for(int i=1;i<=k;i++){
        if(index+i<n){
            if(dp[index+i]==-1)
                dp[index+i]=Solve(index+i,a,n,k,dp);
            ans=min(ans,abs(a[index]-a[index+i])+dp[index+i]);
        }
    }
    return dp[index]=ans;
}
int main(){
    fast;
    ll n,k;
    cin>>n>>k;
    arr a;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        a.pb(x);
    }
   /* ll dp[100009];
    memset(dp,-1,sizeof(dp));
    cout<<Solve(0,a,n,k,dp)<<endl;*/
    ll dp[1000009];
    dp[n-1]=0;
    for(int i=n-2;i>=0;i--){
        dp[i]=L_MAX;
        for(int j=1;j<=k;j++){
            if(i+j<=n-1){
                dp[i]=min(dp[i],dp[i+j]+abs(a[i]-a[i+j]));
            }
        }
    }
    cout<<dp[0]<<endl;
    return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n, y;
  cin >> n >> y;
  y /= 1000;
  for (int i = 0; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      if (y == 10*i+5*(j-i)+1*(n-j)) {
	cout << i << " " << j-i << " " << n-j << endl;
	return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}


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

void solve(long long N)
{
    long double n2;
    long long A;
    if (N % 2 == 0)
        cout << 0.5000000000 << endl;
    else if (N % 2 == 1 && N != 1)
    {
        A = (N / 2) + 1;
        n2 = double(A) / double(N);
        cout << n2 << endl;
    }
    else
        cout << 1.0000000000 << 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()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	long i;
	char S[128];
	long K;
	
	scanf("%s", S);
	scanf("%ld", &K);
	
	for(i = 0;i < K;i++){
		if(S[i] != '1'){
			printf("%c\n", S[i]);
			return 0;
		}
	}
	puts("1");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int x, y;
    cin >> x >> y;
    int res = 0;
    for(int i = 0; i < 2; i++) {
        if(x < y) {
            res += y;
            y--;
        } else {
            res += x;
            x--;
        }
    }
    cout << res << endl;
    return 0;
}


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

int main(void)
{
    int n;
    cin >> n;
    int a = n % 10;
    if (a == 3)
        cout << "bon" << endl;
    else if (a == 0 || a == 1 || a == 6 || a == 8)
        cout << "pon" << endl;
    else
        cout << "hon" << endl;
    return 0;
}

Measured memory_bytes: 3548
import java.util.*;
public class Main {
		
	public static void main(String[] args) {		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
	
		int prime[] = new int[N+1];
		Arrays.fill(prime, 1);
		for(int k=2;k<=N;k++) {
			int tmp = k;
			for(int i=2;i*i<=k;i++) {
				while(tmp%i==0) {
					tmp /= i;
					prime[i]++;
				}
			}
			if(tmp!=1)prime[tmp]++;
			
		}
		
		int _3up = 0;
		int _5up = 0;
		int _15up = 0;
		int _25up = 0;
		int _75up = 0;
		
		for(int i=0;i<N+1;i++) {
			
			if(prime[i]>=75) _75up ++;
			else if(prime[i]>=25) _25up ++;
			else if(prime[i]>=15) _15up ++;
			else if(prime[i]>=5)  _5up ++;
			else if(prime[i]>=3)  _3up ++;
		}
		
		int sum5 = _75up + _25up + _15up + _5up + _3up;
		int sum4 = _75up + _25up + _15up + _5up;
		int sum3 = _75up + _25up + _15up;
		int sum2 = _75up + _25up;
		int sum1 = _75up;
		
		int ans = sum1 + sum2 * (sum5 - 1) + sum3 * (sum4 - 1) + sum4 * (sum4 - 1)/2 * (sum5 - 2);
				
		
		System.out.println(ans);
	}
	
	
}

Measured memory_bytes: 25300
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int K, X;
  cin >> K >> X;
  if(K * 500 >= X) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


#define repi(i,a,b) for(ll i = (a); i < (b); i++)
#define rep(i, n) for(ll i = 0; i < (n); ++i)



int main() {
	int N, K;
	cin >> N >> K;
	vector<bool> b(N);
	rep(i, N) b[i] = true;
	rep(i, K) {
		int d;
		cin >> d;
		rep(j, d) {
			int idx;
			cin >> idx;
			idx--;
			b[idx] = false;
		}
	}
	int c = 0;
	rep(i, N) if (b[i]) c++;
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // b > g > r
    int b,g,r;
    cin >> r >> g >> b;
    int k;
    cin >> k;
    int cnt=0;
    while ( g<=r ) g*=2, cnt++;
    while ( b<=g ) b*=2, cnt++;
    // cout << r << ' ' << g << ' ' << b << '\n';
    if ( cnt<=k ) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}

int main()
{
	ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	if(a>9||b>9) cout<<-1<<'\n';else cout<<a*b<<'\n';
	cout<<flush;
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

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

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

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{   long long i,sum=0;
    string s;
    cin>>s;
    for(i=0;i<s.length();i++){
        if(s[i]=='g'&&i%2==0){;}
        else if(s[i]=='p'&&i%2!=0){;}
        else if(s[i]=='g'&&i%2!=0){sum+=1;}
        else{sum-=1;}
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[100010];
int main() {
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans1=0,now1=0;
	for(ll i=0;i<n;i++){
		now1+=a[i];
		if(i%2==0){
			if(now1<=0){
				ans1+=abs(now1)+1;
				now1=1;
			}
		}
		else{
			if(now1>=0){
				ans1+=abs(now1)+1;
				now1=-1;
			}
		}
	}
	ll ans2=0,now2=0;
	for(ll i=0;i<n;i++){
		now2+=a[i];
		if(i%2==0){
			if(now2>=0){
				ans2+=abs(now2)+1;
				now2=-1;
			}
		}
		else{
			if(now2<=0){
				ans2+=abs(now2)+1;
				now2=1;
			}
		}
	}	
	cout << min(ans1,ans2);
	// your code goes here
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int M=100005;
int a[M],b[M];
struct f{
	int x,y,c;
}s[M];

int main ()
{
	int A,B,N;
	cin>>A>>B>>N;
	for(int i=1;i<=A;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=B;i++)
		scanf("%d",&b[i]);
	for(int i=0;i<N;i++)
		scanf("%d%d%d",&s[i].x,&s[i].y,&s[i].c);
	int ans=9999999;
	for(int i=0;i<N;i++)
	{
		ans=min(ans,a[s[i].x]+b[s[i].y]-s[i].c);
	}
	sort(a+1,a+A+1);
	sort(b+1,b+B+1);
	ans=min(ans,a[1]+b[1]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2176
def getFlavour(eat):
    ret = 0
    for i in range(1, n + 1):
        if i != eat:
            ret += l + i - 1
    return ret

n, l = map(int, input().split())
orig = getFlavour(0)
flavour = diff = float('inf')
for eat in range(1, n + 1):
    curFlavour = getFlavour(eat)
    curDiff = abs(orig - curFlavour)
    if curDiff < diff:
        diff = curDiff
        flavour = curFlavour
print(flavour)


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

const int mod = 1e9+7;

int main(){
	int s;
  	cin >> s;
  	vector<ll> dp(s+1);
  	dp[0] = 1;
  	ll x = 0;
  
  	for(int i = 1; i <= s; i++){
		if(i-3 >= 0){
        	x += dp[i-3];
          	x %= mod;
        }
      	dp[i] = x;
    }
  
  	cout << dp[s] << endl;
}

Measured memory_bytes: 3580
#include <stdio.h>

int main(void){
	double height;
	double high,low;
	scanf("%lf",&height);
	high = height;
	low = height;
	while(1){
		if(scanf("%lf",&height) == EOF){break;}
		if(height > high){
			high = height;
		}
		if(low > height){
			low = height;
		}
	}
	printf("%0.1lf\n",high-low);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main () {
  int A, B, K;
  cin >> A >> B >> K;
  int count = 0, ans;
  vector<int> data;
  for (int i = 1; i < 101; i++) {
    if(A % i == 0 && B % i == 0) {
      data.push_back(i);
    }
    if (count == K) break;
  }
  cout << data.at(data.size() - K) << endl;
  return 0;
}


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

int main()
{
	int K, S;
	cin >> K >> S;

	int cnt = 0;
	for (int iz = 0; iz <= K; iz++) {
		for (int iy = 0; iy <= K; iy++) {
			int x = S - iz - iy;
			if (0 <= x && x <= K)
				cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}



Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons;
import std.math, std.numeric;
import core.bitop;
import std.container;

void main() {
    int n; scan(n);
    auto a = readln.split.to!(int[]);
    auto b = a.enumerate.array.sort!"a.value < b.value"();

    auto set = redBlackTree!(int)();
    set.insert(-1);
    set.insert(n);

    long ans;

    foreach (bi ; b) {
        long d = (bi.index - set.lowerBound(bi.index.to!int).back) * (set.upperBound(bi.index.to!int).front - bi.index);
        ans += 1L * bi.value * d;
        set.insert(bi.index.to!int);
    }

    writeln(ans);
}



struct Stack(T) {
    private {
        size_t cap, top;
        T[] data;
    }

    this (int n) in {
        assert(n > 0, "The capacity of a stack must be a positive integer.");
    }
    body {
        cap = n;
        data = new T[](cap);
    }

    void clear() {
        top = 0;
    }

    bool empty() {
        return !top;
    }

    bool full() {
        return top == cap;
    }

    size_t length() {
        return top;
    }

    T front() in {
        assert(!empty, "The stack is empty.");
    }
    body {
        return data[top - 1];
    }

    void removeFront() in {
        assert(!empty, "The stack is empty.");
    }
    body {
        top--;
    }

    alias popFront = removeFront;

    void insertFront(T x) in {
        assert(!full, "The stack is full.");
    }
    body {
        data[top++] = x;
    }

    alias insert = insertFront;

    T[] array() {
        import std.algorithm.mutation : reverse;

        T[] arr = data[0 .. cap].dup;
        arr.reverse();
        return arr;
    }

    string toString() {
        import std.format : format;
        import std.range : retro;

        return format("[%(%s, %)]", data[0 .. top].retro());
    }
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

int main()
{
    ll n,a,ans = 1;
    cin>>n;
    a = 1;
    while(a*a<=n){
        ans = a*a;
        a++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
a,b,c = gets.chomp.split(' ').map(&:to_i)
k = gets.chomp.to_i

k.times do
  if (b <= a)
    b = b*2
    next
  end
  if (c <= b)
    c = c*2
    next
  end
  if (a < b && b < c)
    puts 'Yes'
    exit
  end
end
puts (a < b && b < c) ? 'Yes' : 'No'

Measured memory_bytes: 14368
# https://atcoder.jp/contests/diverta2019-2/tasks/diverta2019_2_d

import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop


def main():
    N = int(input())
    ga, sa, ba = map(int, input().split())
    gb, sb, bb = map(int, input().split())

    # n = exchange(N, [ga, sa, ba], [gb, sb, bb])
    # exit()

    dp1 = [0] * (N + 1)

    # A で交換して B で全部どんぐりに戻す
    for i in range(1, N + 1):
        dp1[i] = max(dp1[i - 1] + 1,
                     (dp1[i - ga] + gb) if i - ga >= 0 else 0,
                     (dp1[i - sa] + sb) if i - sa >= 0 else 0,
                     (dp1[i - ba] + bb) if i - ba >= 0 else 0)
        # print(dp1)

    N2 = dp1[N]
    dp2 = [0] * (N2 + 1)

    # B で交換して A で全部どんぐりに戻す
    for i in range(1, N2 + 1):
        dp2[i] = max(dp2[i - 1] + 1,
                     (dp2[i - gb] + ga) if i - gb >= 0 else 0,
                     (dp2[i - sb] + sa) if i - sb >= 0 else 0,
                     (dp2[i - bb] + ba) if i - bb >= 0 else 0)
        # print(dp2)

    print(dp2[N2])


if __name__ == '__main__':
    main()


Measured memory_bytes: 228636
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
ll H,W,N;
int main(){
  cin>>H>>W>>N;
  set<P>S;
  for(int i=0;i<N;i++){
  ll h,w;cin>>h>>w; P p(h,w);
    S.insert(p);
  }vector<ll>ans(10);
  for(auto x:S){
    ll i=x.first;ll j=x.second;
    for(ll a=-1;a<=1;a++)
      for(ll b=-1;b<=1;b++){
      ll I=i+a;
        ll J=j+b;
        if(1<=I-1 && I+1<=H && 1<=J-1 && J+1<=W){
        ll sum=0;
          for(ll a1=-1;a1<=1;a1++)
            for(ll b1=-1;b1<=1;b1++){
            P p(a1+I,b1+J);if(S.count(p))sum++;
            
            }ans[sum]++;
        }
      
      }
  }for(ll i=1;i<=9;i++)
    ans[i]/=i;
  ans[0]=(H-2)*(W-2);
  for(ll i=1;i<=9;i++)
    ans[0]-=ans[i];
  for(int i=0;i<10;i++)
    cout<<ans[i]<<endl;
    
    
  return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	for (size_t i = 0; i < n; i++)cin >> h.at(i);
	for (size_t i = n-1; i >= 1; i--){
		if (h.at(i) <= h.at(i - 1) - 2) {
			cout << "No" << endl;
			return 0;
		}
		else if (h.at(i) == h.at(i - 1) - 1) {
			h.at(i - 1)--;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 640
mod=10**9+7
N,K=map(int,input().split())
d=[0]*(K+1)
ans=0
for i in range(1,K+1):
    d[i]=pow(K//i,N,mod)
for i in range(K,0,-1):
    for j in range(2*i,K+1,i):
        d[i]-=d[j]
        d[i]%=mod
    ans+=d[i]*i
    ans%=mod
print(ans)

Measured memory_bytes: 11304
#include <bits/stdc++.h>
using namespace std;
long long n, ac, tle, wa, re;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
while (n--){
	string s; cin >> s;
	if (s=="AC") ac++;
	if (s=="TLE") tle++;
	if (s=="RE") re++;
	if (s=="WA") wa++;
}
cout << "AC x " << ac << endl;
cout << "WA x " << wa << endl;
cout << "TLE x " << tle << endl;
cout << "RE x " << re << endl;
return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define ALL(x) begin(x),end(x)
#define ll long long
#define ld long double

int main(){
  int n,x,t;
  cin >> n >> x >> t;
  int ans = n/x;
  if(n%x!=0) ans++;
  cout << ans*t << endl;
}

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

int main()
{
  int n;
  cin >> n;
  int a[100000] = {};
  int b[100000] = {};
  rep(i, n / 2)
  {
    int p, q;
    cin >> p >> q;
    p--; q--;
    a[p]++; b[q]++;
  }
  int a1 = -1, a2 = -1, b1 = -1, b2 = -1, ac1 = -1, ac2 = -1, bc1 = -1, bc2 = -1;
  rep(i, 100000)
  {
    if (a[i] >= ac1)
    {
      ac2 = ac1;
      ac1 = a[i];
      a2 = a1;
      a1 = i;
    }
    else if (a[i] > ac2)
    {
      ac2 = a[i];
      a2 = i;
    }
    if (b[i] >= bc1)
    {
      bc2 = bc1;
      bc1 = b[i];
      b2 = b1;
      b1 = i;
    }
    else if (b[i] > bc2)
    {
      bc2 = b[i];
      b2 = i;
    }
  }
  if (a1 != b1)
    cout << n - ac1 - bc1 << endl;
  else
    cout << min(n - ac1 - bc2, n - ac2 - bc1) << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;
const int M = 1000000007;

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

    vector<long long> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));

    long long ans = 1;
    for(auto it = a.begin(); it != a.end(); it++){
        ans *= (upper_bound(a.begin(), it, *it) - lower_bound(a.begin(), it, (*it) - t)) + 1;
        ans %= M;
    }
    cout << ans << endl;
}

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


int main (){
    int n;
    cin >> n;
    string str;
    cin >> str;
    if (n >= 3200){
        cout << str << endl;
    }
    else {
        cout << "red "<< endl;
    }

}

Measured memory_bytes: 256
import itertools,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
wv = [LI() for _ in range(N)]
V = N*10**3
dp = [[float('INF')]*(V+1) for _ in range(N+1)]
dp[0][0] = 0
for i,j in itertools.product(range(1,N+1),range(V+1)):
    w,v = wv[i-1]
    if j-v>=0:
        dp[i][j] = min(dp[i][j],dp[i-1][j-v]+w)
    dp[i][j] = min(dp[i][j],dp[i-1][j])
ans = 0
for k in range(V+1):
    if dp[-1][k]<=W:
        ans = max(ans,k)
print(ans)


Measured memory_bytes: 312200
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
  string s;
  cin >> s;
  int v;
  v+=(s[0]-'0')*1000;
  v+=(s[1]-'0')*100;
  v+=(s[2]-'0')*10;
  v+=(s[3]-'0');
  int n=v/100;
  v%=100;
  if((n<=12 && n>=1) && (v>12 || v==0)){
    cout << "MMYY" << endl;
  }else if((v<=12 && v>=1) && (n>12 || n==0)){
    cout << "YYMM" << endl;
  }else if((n<=12 && n>=1) && (v<=12 && v>=1)){
    cout << "AMBIGUOUS" << endl;
  }else{
    cout << "NA" << endl;
  }
  
}


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

int main (){
    int n;
    int ans=0;
    int sum=0;
    cin >> n;
    vector<int>step(n);
    rep(i,n){
        int num;
        cin >> num;
        step.at(i)=num;
    }
    rep(i,n-1){
        if(step.at(i+1)-step.at(i)<=0){
            sum++;
            if(i==n-2){
                ans=max(ans,sum);
            }
        }
        else {
            ans=max(ans,sum); 
            sum=0;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define mp make_pair
#define ff first
#define se second
#define MAX 1000001
#define MAXN 100005
#define mod 1000000007 
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,c,i,j,sum=0,count=0,x,y;
    cin>>n>>m;
    vector<pair<ll,ll> > vi;
    for(i=0;i<n;i++){
        cin>>x>>y;
        vi.pb(mp(x,y));
    }
    sort(vi.begin(),vi.end());
    for(i=0;i<n;i++){
        if((m-vi[i].se)>=0){
            sum+=(vi[i].ff*vi[i].se);
            m=m-vi[i].se;
        }
        else{
            if(m>0){
                sum+=(m*vi[i].ff);
                m=0;
            }
        }
    }
    cout<<sum;
}

Measured memory_bytes: 2420
#include<iostream>
using namespace std;
int main(){
    string n;
    cin>>n;

    for(int i=0;i<n.size();i++){
        if(n.at(i)=='9'){
        n.at(i)=n.at(i)-'0'-8+'0';
    }
    else if(n.at(i)=='1'){
        n.at(i)=n.at(i)-'0'+8+'0';
    }

    }
    cout<<n<<endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val NX = readLine()!!.split(" ").map(String::toInt)
    val Ls = readLine()!!.split(" ").map(String::toInt)
    val X = NX[1]

    var num = 0
    var i = 1
    for (l in Ls) {
        num += l
        if (num > X) {
            break
        }
        i++
    }
    println(i)
}

Measured memory_bytes: 36040
import itertools
N = int(input())
An = []
for _ in range(N):
    A = int(input())
    tmp = []
    for _ in range(A):
        tmp.append(list(map(int,input().split(' '))))
    An.append(tmp)

seq = []
for i in range(N):
   seq.append(i) 
max_num = 0
for i in range(N):
    comb_list = list(itertools.combinations(seq,i))
    for comb in comb_list:
        tmp = [-1]*N
        flag = True
        for i2 in range(N):
            if i2 in comb:
                continue
            for xy in An[i2]:
                if tmp[xy[0]-1] == -1:
                    tmp[xy[0]-1] = xy[1]
                else:
                    if tmp[xy[0]-1] != xy[1]:
                        flag = False
        for i2 in range(N):
            if i2 in comb: #`usotuki`
                if tmp[i2] == 1:
                    flag = False
            else:
                if tmp[i2] == 0:
                    flag = False
        if flag:
            max_num = N - i
    if max_num > 0:
        break
print(max_num)

Measured memory_bytes: 54620
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n,w = readline() |> split |> parseMap
	a = Array{Int}(2,n)
	for i in 1:n
		a[:,i] = readline() |> split |> parseMap
	end
	x = a[1,1]
	for i in 1:n
		a[1,i] -= x
	end
	s = sum(a[1,:])
	dp = zeros(Int,n,n,s+1)
	if x <= w
		dp[1,1,1] = a[2,1]
	end
	for i in 2:n
		for k in 1:min(s+1,w-x+1)
			if k == a[1,i]+1
				dp[i,1,k] = max(dp[i-1,1,k], a[2,i])
			else
				dp[i,1,k] = dp[i-1,1,k]
			end
		end
		for j in 2:i
			for k in 1:s+1
				if j*x+k<=w+1
					if k<=a[1,i]
						dp[i,j,k] = dp[i-1,j,k]
					else
						dp[i,j,k] = max(dp[i-1,j,k],dp[i-1,j-1,k-a[1,i]] + a[2,i])
					end
				end
			end
		end
	end
	println(maximum(dp[n,:,:]))
end
main()


Measured memory_bytes: 134184
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

#define rep(i, n) for(int i = 0 ; i < n ; i++)
#define f first
#define s second

typedef pair<int, int> P;
typedef map<string, P> Program;

Program prog;
vector<string> all;
vector<string> fav;
vector<string> normal;
bool watched[7][1800];
int ans;

int toMinute(string t){
  int ret = 0;
  if(t.size() == 3){
    ret += (t[0]-'0') * 60;
    ret += (t[1]-'0') * 10 + (t[2]-'0');
  }
  else if(t.size() == 4){
    int h =(t[0]-'0') * 10 + (t[1]-'0');
    ret += h * 60;
    ret += (t[2]-'0') * 10 + (t[3]-'0');
  }
  return ret;
}

bool watchFavAnime(){
  rep(i, fav.size()){
    P t = prog[fav[i]];
    for(int T = t.s ; T < t.s+30 ; T++){
      if(watched[t.f][T] == 1) return false;
      watched[t.f][T] = 1;
    }
    ans++;
  }
  return true;
}

void init(){
  prog.clear();
  fav.clear();
  all.clear();
  normal.clear();
  memset(watched, 0, sizeof(watched));
  ans = 0;
}

int main(){
  int n, p;  
  while(cin >> n, n){
    init();
    string name, tim;
    P t;
    rep(i, n){
      cin >> name >> t.f >> tim;
      int m = toMinute(tim);
      t.s = m;
      prog[name] = t;
      all.push_back(name);
    }
    
    cin >> p;
    rep(i, p){
      cin >> name;
      fav.push_back(name);
    }
    // input finish
    
    bool flag = true;
    
    flag = watchFavAnime();
    if(!flag){
      cout << "-1" << endl;
      continue;
    }
    
    rep(i, n){
      bool fl = true;
      rep(j, fav.size()){
	if(all[i] == fav[j]){
	  fl = false;
	  break;
	}
      }
      if(fl) normal.push_back(all[i]);
    }
    
    vector<P> nor;
    rep(i, normal.size()){
      nor.push_back(prog[normal[i]]);
    }
    
    sort(nor.begin(), nor.end());
    
    rep(i, nor.size()){
      int w = nor[i].f;
      int m = nor[i].s;
      bool f = true;
      for(int T = m ; T < m+30 ; T++){
	if(watched[w][T] == 1){
	  f = false;
	  break;
	}
      }
      if(f){
	for(int T = m ; T < m+30 ; T++){
	  watched[w][T] = 1;
	}
	//cout << normal[i] << endl;
	ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1332
import sys
import pdb
input = sys.stdin.readline

N, W = map(int, input().split())
ws = [0]
vs = [0]

for _ in range(N):
  w, v = map(int, input().split())
  ws.append(w)
  vs.append(v)

inf = 2e11
V = int(sum(vs))   # N * max(vs)
# V = int(100 * 1e3)   # N * max(vs)
# Weight[i番目までの品番][価値j]
Weight = [[inf for _ in range(V+1)] for __ in range(N+1)]

if ws[1] <= W:
  Weight[1][vs[1]] = ws[1]
  value_max = vs[1]
else:
  value_max = 0

for _ in range(N+1):
  Weight[_][0] = 0

# pdb.set_trace()

for num in range(2, N+1):
  for value in range(1, V+1):
    if value >= vs[num]:   # 新しい品物を入れられるとき
      Weight[num][value] = min(Weight[num][value], Weight[num-1][value], Weight[num-1][value-vs[num]] + ws[num])
      if Weight[num][value] <= W:
        value_max = max(value_max, value)
      else:
        Weight[num][value] = inf
    else:   # 新しい品物を入れられないとき
      # 重さを変えることはできない
      Weight[num][value] = Weight[num-1][value]
      # Weight[num][value] = max(Weight[num][value], Weight[num-1][value])

# print(Weight)
print(value_max)


Measured memory_bytes: 310628
#include<stdio.h>
int main()
{
    int n,m,l=0;
    scanf("%d %d",&n,&m);
    if(n>12)
    {
        printf("%d\n",m);
    }
    else if(n>=6 && n<13)
    {
        printf("%d\n",m/2);
    }
    else
    {
        printf("%d\n",l);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
map<long long,long long> mp;
int main(){
	int n;
	cin>>n;
	mp[0]++;
	long long cnt=0;
	long long t;
	long long ans=0;
	for(int i=0;i<n;i++){
		cin>>t;
		ans+=t;
		cnt+=mp[ans];
		mp[ans]++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 12800
program main
  implicit none
  integer(8) :: a, b, c, d
  read (*, *) a, b, c, d
  write (*, "(i0)") g(b, c, d) - g(a - 1, c, d)
  contains

  pure integer(8) function g(x, c, d)
    integer(8), intent(in) :: x, c, d
    g = x - f(x, c) - f(x, d) + f(x, lcm(c, d))
  end function g

  pure integer(8) function f(x, y)
    integer(8), intent(in) :: x, y
    f = x / y
  end function f

  pure integer(8) function lcm(x, y)
    integer(8), intent(in) :: x, y
    lcm = x * (y / gcd(x, y))
  end function lcm

  pure function gcd(x, y) result(a)
    integer(8), intent(in) :: x, y
    integer(8) :: a, b, r
    a = max(x, y)
    b = min(x, y)
    do while (b > 0)
      r = mod(a, b)
      a = b
      b = r
    end do
  end function gcd
end program main


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  int64 t;
  cin >> n >> t;
  vector<int64> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }

  int64 sum = 0;
  for (int i = 0; i + 1 < n; i++) {
    if (xs[i + 1] - xs[i] <= t) {
      sum += xs[i + 1] - xs[i];
    } else {
      sum += t;
    }
  }
  sum += t;

  cout << sum << endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;


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 ll INF=1e9+7;


int main(){
    string s;
    cin >> s;
    ll n=s.length();
    ll ans=n-1;
    rep(i,26){
        char c='a'+i;
        bool ok=true;
        string t=s;
        ll cnt=0;
        while(true){
            string u="";
            rep(j,t.length()){
                if(j==t.length()-1){
                    if(t[j]!=c){
                        ok=false;
                        continue;
                    }
                }
                if(t[j]!=c) ok=false;
                if(t[j]==c){
                    u+=c;
                    continue;
                }
                else if(t[j+1]==c){
                    u+=c;
                    continue;
                }
                else{
                    u+=t[j];
                    continue;
                }
            }
            if(ok) break;
            else{
                cnt++;
                t=u;
                u="";
                ok=true;
            }
        }
        ans=min(ans,cnt);
    }
    cout << ans << endl;
    return 0;
    
}

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

int main() {
  string t;
  cin >> t;
  for (int i = 0; i < t.size(); i++) {
    if (t.at(i) == '?') t.at(i) = 'D';
  }
  cout << t;
  return 0;
}


Measured memory_bytes: 3756
#include <iostream>
int main(){
    int n,m,x,y;
    std::cin >> n >> m;
    int gyouretu[n][m];
    int bectol[m];
    for(int a = 0;a < n;a++){
        for(int b = 0;b < m;b++){
            std::cin >> gyouretu[a][b];
        }
    }
    for(int c = 0;c < m;c++){
        std::cin >>bectol[c];
    }
    for(int d = 0;d < n;d++){
        y = 0;
        for(int e = 0;e < m;e++){
            x = bectol[e] * gyouretu[d][e];
            y = y + x;
            x = 0;
        }
        std::cout << y <<std::endl;
    }
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define slowanddetermined ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x); cout<<#x<<"="<<x<<endl;
#define debug2(x,y); cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define int long long
using namespace std;


int32_t main()
{
    slowanddetermined
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c;




    return 0;

}




Measured memory_bytes: 256
N,Q = map(int,input().split())
S = str(input())
t = [0]*(N+1)
for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == "AC" else 0)
for i in range(Q):
    l,r = map(int,input().split())
    print(t[r-1]-t[l-1])


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

int main(){
	int N;
	cin >> N;
	vector <int> L(2*N);
	for (int i=0; i < 2*N ;i++){
		cin >> L[i];
	}
	sort(L.begin(),L.end());
	int a=0;
	for (int i=0 ; i<N;i++){
		a += L[2*i];
	}
	cout << a;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		long ans=0;
		for(int i = 1;i<=n;i++) {
			if(i%3==0||i%5==0){continue;}
			ans+=i;
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 27548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long, long> pll;
const ll MOD = 1e9 + 1;

string S;

int main(){
	cin>>S;
	ll bn=0, res=0;
	int ls=S.size();
	for(int i=0; i<ls; i++){
		if(S[i]=='B') bn++;
		else res += bn;
	}
	cout<<res<<endl;

	return 0;
}


Measured memory_bytes: 640