akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

// #include <unordered_set>
// #include <unordered_map>

#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

#define pb push_back
#define mp make_pair

int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}

typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);


using namespace std;

#define N 1000000
int arr[N];
int a[N];
 
void eratosthenes(){
    REP(i,N){
        arr[i]=1;
    }
 
    for(int i=2;i<sqrt(N);i++){
        if(arr[i]){
            for(int j=0;i*(j+2)<N;j++){
                arr[i*(j+2)]=0;
            }
        }
    }
    arr[0]=0;
    arr[1]=0;
}

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

    vector<int> v;
    REP(i,n){
    	int tmp;
    	cin>>tmp;
    	v.pb(tmp);
    }

    v.pb(-1);

    sort(v.rbegin(),v.rend());

    int ans=0;
    int count=0;

    // cout<<v[0]<<endl;

    REP(i,n){


	   	// if(count==3)break;

    	ans++;
    	if(v[i]!=v[i+1])count++;


    	// cout<<v[i]<<" "<<ans<<" "<<count<<endl;
    }

    // cout<<ans<<endl;
    cout<<count<<endl;



}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

struct Music
{
    string title;
    int length;
};

int main()
{
    int n;
    cin >> n;
    vector<Music> vs(n);

    for (auto& v : vs)
    {
        cin >> v.title >> v.length;
    }
    string x;
    cin >> x;

    int count = 0;
    bool is_sleep = false;
    for (auto& v : vs)
    {
        if (v.title == x)
        {
            is_sleep = true;
        }
        else if (is_sleep)
        {
            count += v.length;
        }
    }
    cout << count << endl;
}


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

#define MAX_N 1000

using namespace std;

int N,d;

int main(void){
	int res = 0;

	int x;
	cin >> N >> d;
	for(int i=0;i<N;++i){
		cin >> x;
		res += x > d ? x - d : 0;
	}

	if(res>0) cout << res << endl;
	else      cout << "kusoge" << endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll c[30],s[400][30],las[30],t[400];

int main()
{
	int D;
	cin >> D;
	rep(i,26)
	{
		cin >> c[i];
	}
	rep(i,D)
	{
		rep(j,26)
		{
			cin >> s[i][j];
		}
	}
	rep(i,D)
	{
		t[i] = (i%26)+1;
	}

	ll tmp = 0;
	rep(j,D)
	{
		tmp += s[j][t[j]];
		las[t[j]] = j+1;
		rep(k,26)
		{
			tmp -= c[k] * (j+1 - las[k]);
		}
	}

	rep(i,100000)
	{
		ll r = rand() % (D-1);
		swap(t[r],t[r+1]);
		ll tmp2 = 0;
		rep(j,30)
		{
			las[j] = 0;
		}
		rep(j,D)
		{
			tmp += s[j][t[j]];
			las[t[j]] = j+1;
			rep(k,26)
			{
				tmp2 -= c[k] * (j+1 - las[k]);
			}
		}
		if (tmp2 > tmp)
		{
			tmp = tmp2;
		}
		else swap(t[r],t[r+1]);
	}
	rep(i,D)
	{
		cout << t[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3740
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll A, B;
  char op;
  cin >> A >> op >> B;
  ll ans = (op == '+') ? A + B : A - B;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
/*Shivam Bhalla */
/* f2016941@pilani.bits-pilani.ac.in */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iostream>
#include <string>
#include <cmath>
#include <cassert>
#include <bits/stdc++.h>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;
long long maxv = 1e9;


int main(){
	int N;
	cin>>N;
	vector<int>arr(N);
	for(int i=0;i<N;i++)
		cin>>arr[i];
	int count=1;
	int maxH=arr[0];
	for(int i=1;i<N;i++){
		if(arr[i]>=maxH){
			count+=1;
			maxH=arr[i];
		}
	}
	cout<<count;	
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll maxSubArraySum(int a[], int size)
{
         ll max_so_far = 0, max_ending_here = 0;
   for (int i = 0; i < size; i++)
   {
       max_ending_here = max_ending_here + a[i];
       if (max_ending_here < 0)
           max_ending_here = 0;

       /* Do not compare for all elements. Compare only
          when  max_ending_here > 0 */
       else if (max_so_far < max_ending_here)
           max_so_far = max_ending_here;
   }
                return max_so_far;
}
int main()
{
	int h,n;
	cin>>h>>n;
	vector<pair<ll,ll>> v;
	for(int i=1;i<=n;i++)
	{
		ll a,b;
		cin>>a>>b;
		v.push_back({a,b});
		
	}
	ll dp[h+1][n+1];
	ll maxi=10000000000000;
	for(int i=1;i<=h;i++)
	{
		dp[i][0]=maxi;
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=n;j++)
		{
			
				
				if(i>=v[j-1].first)
					dp[i][j]=min(dp[i][j-1],dp[i-v[j-1].first][j]+(v[j-1].second));
				else
					dp[i][j]=min(dp[i][j-1],v[j-1].second);
				
			
			
		}
	}
	cout<<dp[h][n]<<endl;
}



Measured memory_bytes: 78464
#include <iostream>

int dp[100000];
int main() {
	int n;
	int h[100000];
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> h[i];
	}
	dp[0] = 0;
	dp[1] = h[1]-h[0];
	if (dp[1]<0) {
		dp[1] = -dp[1];
	}
	for (int i = 2; i < n; i++) {
		int a = h[i] - h[i - 1];
		if (a < 0) {
			a = -a;
		}
		int b = h[i] - h[i - 2];
		if (b < 0) {
			b = -b;
		}
		if (a + dp[i - 1] < b + dp[i - 2]) {
			dp[i] = a + dp[i - 1];
			//std::cout << 11111 << std::endl;
		}
		else {
			dp[i] = b + dp[i - 2];
			//std::cout << 22222 << std::endl;
		}
	}
	std::cout << dp[n - 1] << std::endl;
	/*for (int i = 0; i < n; i++) {
		std::cout << dp[i] << std::endl;
	}*/
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

import bisect

n = int(input())
l = [int(i) for i in input().split()]
l.sort() # 二分探索するために整列

# l[i]+l[j]>l[x]を満たすxは
# 昇順に整列した配列を使うと
# 固定した2本の次のインデックスから必ず連続している
# そのため条件を満たす最大のxを二分探索で求めれば良い

count = 0
# 2本を固定して
for i in range(n-2):
    for j in range(i+1, n-1):
        # 3本目を探索
        index = bisect.bisect_left(l, l[i]+l[j])
        count += index - (j+1)

print(count)


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

int main(){
  int N,K;
  string S;
  cin>>N>>K;
  cin >>S;
  if(S[K-1]=='A'){
    S.replace(K-1,1,"a");
  }
    if(S[K-1]=='B'){
    S.replace(K-1,1,"b");
  }
    if(S[K-1]=='C'){
    S.replace(K-1,1,"c");
  }
  
  cout<<S<<endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
aa = list(map(int, input().split(' ')))

subordinates = {}
for a in aa:
    if a not in subordinates:
        subordinates[a] = 1
    else:
        subordinates[a] += 1
for i in range(n):
    if i + 1 in subordinates:
        print(subordinates[i + 1])
    else:
        print('0')


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	string s; cin >> s;

	string ans;
	if(s == "Sunny"){
		ans = "Cloudy";
	}else if(s == "Cloudy"){
		ans = "Rainy";
	}else{
		ans = "Sunny";
	}

	cout << ans << endl;

	return 0;

}


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

int main()
{
  int a, b;
  cin >> a >> b;
  if (a % 2 == 1 && b % 2 == 1) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(ll key, ll value){
      this->key = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

double exp_value(short int D1, short int D2, short int D3, ll N, vector<vector<vector<double>>>& dp){
  if(D1<0 || D2<0 || D3<0) return (double)0.0;
  if(D1==0 && D2==0 && D3==0) return (double)0.0;
  if(dp[D1][D2][D3]>=-0.5) return dp[D1][D2][D3];
  /*
  exp_value(D1, D2, D3, N, dp)
  = (N-D1-D2-D3)*exp_value(D1, D2, D3, N, dp)/N
  + D1*exp_value(D1-1, D2, D3, N, dp)/N
  + D2*exp_value(D1+1, D2-1, D3, N, dp)/N
  + D3*exp_value(D1, D2+1, D3-1, N, dp)/N
  + 1
  */
  double sum = D1+D2+D3;
  double tmp1 = (double)D1*exp_value(D1-1, D2, D3, N, dp)/sum;
  double tmp2 = (double)D2*exp_value(D1+1, D2-1, D3, N, dp)/sum;
  double tmp3 = (double)D3*exp_value(D1, D2+1, D3-1, N, dp)/sum;
  return dp[D1][D2][D3] = tmp1+tmp2+tmp3+N/sum;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  cin >> N;
  vector<short int> Dishes(3, 0);
  ll a;
  rep(i, 0, N){
    cin >> a;
    ++Dishes[a-1];
  }
  vector<vector<vector<double>>> dp(Dishes[0]+Dishes[1]+Dishes[2]+1, vector<vector<double>>(Dishes[1]+Dishes[2]+1, vector<double>(Dishes[2]+1, -1.0)));

  printf("%.10lf\n", exp_value(Dishes[0], Dishes[1], Dishes[2], N, dp));

  return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int X, Y, Z;
    cin >> X >> Y >> Z;
    X -= Z;
    int a = Z + Y;
    int ans = X / a;
    cout << ans << endl;
}

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

int main() {
    int ans=0, N, i, num_r=0, num_w = 0, c;
    string S;
    cin >> N;
    cin >> S;
    int *loc_w = new int[N];
    int *loc_r = new int[N];
    for(i=0; i<N; i++){
        c = S[i];
        if( c=='W') {
            loc_w[num_w++] = i;
            //cout << i << endl;
        }else {
            loc_r[num_r++] = i;
        }
    }
    int iter = min(num_w, num_r);
    for( i=0; i<iter; i++){
        //printf("w:%d, r:%d\n", loc_w[i], loc_r[num_r - i-1]);
        if( loc_w[i] > loc_r[num_r - i-1]){
            //flag = 0;
            break;
        }
    }
    cout << i << endl;
}

Measured memory_bytes: 4544
# frozen_string_literal: true

n, m = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

sum = as.inject(:+)

items = as.select { |a| a >= sum.to_f / (4.0 * m) }

puts items.count >= m ? 'Yes' : 'No'


Measured memory_bytes: 1788
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

class BIT:
    def __init__(self, n):
        self.n = n
        self.nums = [0] * (n+1)
        
    def add(self, i, x):
        n, nums = self.n, self.nums
        i += 1
        while i <= n:
            nums[i] += x
            i += i & -i
    
    def sum(self, i):
        nums = self.nums
        s = 0
        i += 1
        while i:
            s += nums[i]
            i -= i & -i
        return s

N, Q = rl()
bit = BIT(N)
A = rl()
for i, a in enumerate(A):
    bit.add(i, a)
for i in range(Q):
    q = rl()
    if q[0] == 0:
        bit.add(q[1], q[2])
    else:
        print(bit.sum(q[2]-1) - bit.sum(q[1]-1))


Measured memory_bytes: 134648
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = 0;
        
        ans = a * b - a - b + 1;
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    VL X(N),Y(N);
    VL U(N),V(N);
    REP(i,N){
        cin >> X[i] >> Y[i];
        U[i] = X[i] + Y[i];
        V[i] = X[i] - Y[i];
    }
    int check = (abs(X[0]) + abs(Y[0])) % 2;
    FOR(i,1,N){
        if((abs(X[i])+abs(Y[i]))%2 != check){
            cout << -1 << endl;
            return 0;
        }
    }
    if(check == 1){
        cout << 31 << endl;
    }else{
        cout << 32 << endl;
        REP(i,N){
            U[i] += 1;
            V[i] += 1;

        }
    }

    VL seed;
    LL se = 1;
    REP(i,31){
        seed.eb(se);
        se *= 2;
    }
    reverse(seed.begin(),seed.end());
    if(check == 0){
        cout << 1 <<" ";
    }
    REP(i,31){
        cout << seed[i] << " ";
    }

    cout << endl;
    REP(i,N){
        string ans;
        if(check == 0) ans+='L';
        REP(j,31){
            int b1,b2;


            if(U[i] > 0){
                b1 = 1;
                U[i] -= seed[j];
            }else{
                b1 = -1;
                U[i] += seed[j];
            }

            if(V[i] > 0){
                b2 = 1;
                V[i] -= seed[j];
            }else{
                b2 = -1;
                V[i] += seed[j];
            }

            if(b1 == 1 && b2 == 1) ans+='R';
            else if(b1 == 1 && b2 == -1) ans+='U';
            else if(b1 == -1 && b2 == 1) ans+='D';
            else ans+='L';


        }
        cout << ans << endl;
    }




}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
long long gcd(long long a, long long b){
	if (b>a){
		swap(a,b);
	}
	if (b==0) return a;
	else return gcd(b,a%b);
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
int main() {
	int n;
	long long result;
	cin>>n;
	long long t[n];
	for (int i=0;i<n;i++){
		cin>>t[i];
	}
	if (n==1){
		cout<<t[0];
	}
	else 
	{
		result=lcm(t[0],t[1]);
		for (int i=1;i<n-1;i++){
		result=lcm(result,t[i+1]);
	}
	cout<<result;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	Scanner scan = new Scanner(System.in);
	
	void compute() {
		int n = scan.nextInt();
		
		ArrayList<Integer> list = new ArrayList<>();
		ArrayList<Integer> sorted = new ArrayList<>();
		for (int i=0;i<n;i++) {
			int buf = scan.nextInt();
			list.add(buf);
			sorted.add(buf);
		}
		
		Collections.sort(sorted);
		
		int max = sorted.get(sorted.size()-1);
		int max2 = sorted.get(sorted.size()-2);
		for (int i=0;i<n;i++) {
			System.out.println(list.get(i) != max ? max : max2);
		}
	}
	
	
	public static void main(String...arg) {
		new Main().compute();
	}
}


Measured memory_bytes: 98660
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll N, K; cin >> N >> K;
	vector<ll> P(N + 1), C(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> P[i];
	}

	for (int i = 1; i <= N; i++) {
		cin >> C[i];
	}

	ll ans = -1e17;
	vector<vector<int>> lp(N + 1);
	vector<bool> vi(N + 1);
	for (int i = 1; i <= N; i++) {
		if (vi[i])continue;
		vi[i] = true;
		lp[i].push_back(i);
		ll r1 = C[i];
		int nx = P[i];
		while (nx != i) {
			vi[nx] = true;
			lp[i].push_back(nx);
			r1 += C[nx];
			nx = P[nx];
		}


		ll r2 = -1e17;
		int len = lp[i].size();
		for (int j = 0; j < len; j++) {
			ll tp = 0, his = -1e17;
			for (int k = 0; k < (K >= len) * len + K % len; k++) {
				tp += C[lp[i][(j + k) % len]];
				his = max(his, tp);
			}
			r2 = max(r2, his);
		}

		ll temp = 0;
		if (r1 < 0 || K < len)temp = r2;
		else temp = max((ll)0, (K / len - 1)) * r1 + r2;

		ans = max(ans, temp);
	}

	cout << ans << endl;
}


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

int main(){
    int n;
    string st;
    cin>>n>>st;
    int maxcut=0;
    for(int i=1;i<n-1;i++){
        int sumcut=0;
        for(int j='a';j<='z';j++){
            bool flagl1=false;
            bool flagl2=false;
            for(int k=0;k<i;k++){
                if(st[k]==j){
                    flagl1=true;
                }
            }
            for(int k=i;k<n;k++){
                if(st[k]==j){
                    flagl2=true;
                }
            }
            if(flagl1&&flagl2){
                sumcut++;
            }
        }
        if(maxcut<sumcut){
            maxcut=sumcut;
        }
    }
    cout<<maxcut;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pp pair<int, int>
#define ppp pair<pp, int>
#define fi first
#define se second
#define esp 1e-9
#define inf 1000000001
#define mod 1000000007
#define N 100010
#define base 311097
#define M 10000001
typedef long long ll;
typedef long double ld;
using namespace std;
int n, x;
int a[N];

int main() {
    //freopen("in.in", "r", stdin);// freopen("ou.ou", "w", stdout);
    cin >> n >> x;
    for (int i = 1; i <= n; i++) cin >> a[i];
    ll tot = 0;
    for (int i = 1; i < n; i++) {
        int need = max(0, a[i] + a[i + 1] - x);
        tot += need;

        int del = min(a[i + 1], need);
        a[i + 1] -= del;
        need -= del;
        a[i] -= need;

    }

    cout << tot;
    /**/ return 0;
}


Measured memory_bytes: 640
# vim: fileencoding=utf-8


def main():
    n = int(input())
    li = []
    for i in range(n):
        li.append(int(input()))
    li.sort(reverse=True)
    ans = 1
    for i in range(1, n):
        if li[i - 1] > li[i]:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

using ll = long long;

const ll MOD = 1e9 + 7;

ll modpow(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % MOD;
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}

ll dp[405][405];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, c;
	cin >> n >> c;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}

	for (int i = 1; i <= 400; i++) dp[0][i] = 1;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		vector<ll> sum(c + 1, 0);
		for (int j = a[i]; j <= b[i]; j++) {
			(sum[0] += dp[0][j]) %= MOD;
			for (int k = 0; k < c; k++) {
				(dp[k + 1][j] += dp[k][j] * j) %= MOD;
				(sum[k + 1] += dp[k + 1][j]) %= MOD;
			}
		}
		for (int k = 0; k <= c; k++) {
			for (int j = 1; j <= 400; j++) {
				dp[k][j] = sum[k];
			}
		}
		ans = sum[c];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1536
use proconio::input;
use std::cmp::min;

fn main() {
    input!(s: String);
    input!(t: String);
    let mut score = t.len();
    for i in 0..(s.len() - t.len() + 1) {
        let mut tmp_score = 0;
        for j in 0..t.len() {
            if s.chars().nth(i+j) != t.chars().nth(j) {
                tmp_score += 1;
            }
        }
        score = min(score, tmp_score);
    }
    println!("{}", score)
}

Measured memory_bytes: 2152
def main():
  n_str = input()
  n_int = int(n_str)
  n_sum = 0
  for i in range(len(n_str)):
    n_sum += int(n_str[i])
  if n_int % n_sum == 0:
    print("Yes")
  else:
    print("No")

main()


Measured memory_bytes: 2940
n, k = map(int, input().split())
p = [(int(i)+1.0)/2.0 for i in input().split()]
ans = 0
for i in range(k):
    ans += p[i]
tmp1 = ans
for i in range(k, n):
    tmp2 = (tmp1 - p[i-k])+p[i]
    ans = max(ans, tmp2)
    tmp1 = tmp2
print('{:.12f}'.format(ans))


Measured memory_bytes: 71792
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, m; cin>>n>>m;
	bool b[30][30]={};
	for(int i=0; i<n; i++){
		int k; cin>>k;
		for(int j=0; j<k; j++){
			int a; cin>>a; a--;
			b[i][a]=1;
		}
	}
	int ans=0;
	for(int i=0; i<m; i++){
		bool ok=1;
		for(int j=0; j<n; j++){
			if(!b[j][i]){
				ok=0; break;
			}
		}
		if(ok) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import bisect

N=int(input())
A=[int(x) for x in input().split()]
B=[int(x) for x in input().split()]
C=[int(x) for x in input().split()]

A.sort()
B.sort()
C.sort()

ans=0

for i in range(N):
  ans+=(bisect.bisect_left(A,B[i])*(N-bisect.bisect_right(C,B[i])))

print(ans)


Measured memory_bytes: 22592
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
map<ll, ll> mp;
ll s;
int main(void){
    // Your code here!
    cin >> s;
    ll i = 1;
    while(mp[s] == 0)
    {
        mp[s]++;
        if (s % 2 == 0) s /= 2;
        else s = s * 3 + 1;
        i++;
    }
    cout << i << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n,i,r=0,count=0;
	scanf("%d",&n);
	int A[n];
	for(i=0;i <= n-1;i++)
		{scanf("%d",&A[i]);}
	while(r==0)
		{
		for(i=0;i <= n-1;i++)
			{r += A[i] % 2;}
		if(r==0)
			{
			count++;
			for(i=0;i <= n-1;i++)
				{A[i] /= 2;}
			}
		}
	printf("%d\n",count);
return 0;
}


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

#define MaxN 250005
#define INF 2140000000
#define eps 1e-9

using namespace std;

deque <int> v;

int main()
{
    int N,X;
    cin>>N;
    for(int i=1;i<=N;i++)
    {
        cin>>X;
        if(i%2!=N%2)
            v.push_back(X);
        else v.push_front(X);
    }
    for(int i=0;i<v.size();i++)
    {
        cout<<v[i]<<' ';
    }
    return 0;
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n,wmax;cin>>n>>wmax;
  int i,j;
  vector<int> v(n);
  vector<int> w(n);
  rep(i,n)cin>>v[i]>>w[i];
  vector<vector<int>> dp(n+1,vector<int>(wmax+1,0));
  rep(i,n)
  {
    rep(j,wmax)
    {
      if(j+1-w[i]>=0)
      {
        dp[i+1][j+1]=max(dp[i][j+1-w[i]]+v[i],dp[i+1][j+1-w[i]]+v[i]);
        dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j+1]);
      }
      else dp[i+1][j+1]=dp[i][j+1];
    }
  }
  int ans=0;
  rep(i,wmax+1)ans=max(ans,dp[n][i]);
  cout<<ans<<endl;
}


Measured memory_bytes: 6776
#include <bits/stdc++.h>
using namespace std;
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; }

int n, m;
vector< vector<int> > dp(30, vector<int>(50500, 1e9));

int main() {
    cin >> n >> m;
    vector<int> c(m, 0);
    for(int i = 0; i < m; ++i) cin >> c.at(i);
    dp[0][0] = 0;

    for(int i = 0; i < m; ++i) {
        for(int j = 0; j <= n; ++j) {
            if(j-c.at(i) >= 0) {
                chmin(dp[i+1][j], dp[i+1][j-c.at(i)]+1);
            }
            chmin(dp[i+1][j], dp[i][j]);
        }
    }

    cout << dp[m][n] << endl;
}


Measured memory_bytes: 8840
public class Main {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			int cnt = sc.nextInt();
			int taro = 0;
			int hanako = 0;

			for (int i = 0; i < cnt; i++) {
				String strTaro = sc.next();
				String strHanako = sc.next();
				int compare = strTaro.compareTo(strHanako);

				if (compare > 0) {
					taro += 3;
				} else if (compare < 0) {
					hanako += 3;
				} else {
					taro++;
					hanako++;
				}
			}
			System.out.println(taro + " " + hanako);
		}
	}
}


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    char c;
    cin >> c;

    cout << (isupper(c) ? 'A' : 'a') << "\n";

    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char b; cin >> b;
    if(b == 'A')
    {
        cout << 'T' << endl;
    }
    if(b == 'T')
    {
        cout << 'A' << endl;
    }
    if(b == 'C')
    {
        cout << 'G' << endl;
    }
    if(b == 'G')
    {
        cout << 'C' << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long x[n];
    long y[n];

    set<pair<long,long> >sp;


    map<pair<long,long>,int>mp;

    vector<pair<long,long> >pp;

    for(int i=0;i<n;i++){
        cin >> x[i]>> y[i];
        pp.push_back(make_pair(x[i],y[i]));
        mp[pp[i]]++;
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i!=j){
                sp.insert(make_pair((x[i]-x[j]),(y[i]-y[j])));
                
            }
        }
    }
    int maxx = 0;

    sort(pp.begin(),pp.end());

    for(auto p:sp){
        int tmp = 0;
        auto mp2 = mp;
        for(int i=0;i<n-1;i++){
            int xtmp = pp[i].first + p.first;
            int ytmp = pp[i].second + p.second;
            if(mp2[make_pair(xtmp,ytmp)] >= 1){
                tmp++;
                mp2[make_pair(xtmp,ytmp)]--;
            }
        }
        maxx = max(tmp,maxx);
    }
    cout<<n-maxx<<endl;

}

Measured memory_bytes: 384
#include <cstdlib>
#include <iostream>
#include <set>

using namespace std;

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

    for (int c = 'a'; c <= 'z'; c++) {
        if (word.find(c) == (size_t)-1) {
            cout << word << (char)c << endl;
            exit(0);
        }
    }
    for (int i = word.size() - 1; i >= 0; i--) {
        while (true) {
            word[i]++;
            if (word[i] > 'z') {
                word.pop_back();
                break;
            }
            if (word.find(word[i]) == word.size() - 1) {
                cout << word << endl;
                exit(0);
            }
        }
    }
    cout << -1 << endl;
    exit(0);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
double px[210];
double py[210];
double pz[210];
double vx[210];
double vy[210];
double vz[210];
double r[210];
double vr[210];
pair<double,pair<int,int> >ev[110000];
double ret[210];
int c[210];
double eps=1e-9;
double ABS(double a){return max(a,-a);}
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++){
			scanf("%lf%lf%lf%lf%lf%lf%lf%lf",px+i,py+i,pz+i,vx+i,vy+i,vz+i,r+i,vr+i);
		}
		int sz=0;
		for(int i=0;i<a;i++)c[i]=1;
		for(int i=0;i<a;i++){
			ev[sz++]=make_pair(r[i]/vr[i],make_pair(i,i));
		}
		for(int i=0;i<a;i++)for(int j=i+1;j<a;j++){
			double dpx=px[j]-px[i];
			double dpy=py[j]-py[i];
			double dpz=pz[j]-pz[i];
			double dvx=vx[j]-vx[i];
			double dvy=vy[j]-vy[i];
			double dvz=vz[j]-vz[i];
			double dr=r[i]+r[j];
			double dvr=vr[i]+vr[j];
			double A=dvx*dvx+dvy*dvy+dvz*dvz-dvr*dvr;
			double B=2*(dpx*dvx+dpy*dvy+dpz*dvz+dr*dvr);
			double C=dpx*dpx+dpy*dpy+dpz*dpz-dr*dr;
			if(ABS(A)<eps){
				if(ABS(B)>eps){
					double t=-C/B;
					if(t>eps)ev[sz++]=make_pair(t,make_pair(i,j));
				}
			}else if(B*B-A*C*4>eps){
				double t1=(-B-sqrt(B*B-A*C*4))/A/2;
				double t2=(-B+sqrt(B*B-A*C*4))/A/2;
				if(t1>eps)ev[sz++]=make_pair(t1,make_pair(i,j));
				else if(t2>eps)ev[sz++]=make_pair(t2,make_pair(i,j));
			}
		}
		std::sort(ev,ev+sz);
		for(int i=0;i<sz;i++){
			if(c[ev[i].second.first]&&c[ev[i].second.second]){
				c[ev[i].second.first]=c[ev[i].second.second]=0;
				ret[ev[i].second.first]=ev[i].first;
				ret[ev[i].second.second]=ev[i].first;
			}
		}
		for(int i=0;i<a;i++)printf("%.12f\n",ret[i]);
	}
}

Measured memory_bytes: 2836
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <map>
#include <queue>
#include <string>
#include <set>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define inf (int)(1e9)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

int hako[211111];
int main(void){
  int n,x;
  cin>>n>>x;
  if(x==1||x==2*n-1) cout<<"No"<<endl;
  else {
    cout<<"Yes"<<endl;
    for(int i=1;i<=n-2;i++){
      hako[i]=i+2;
    }
    hako[n-1]=1;
    hako[n]=2;
    for(int i=n+1;i<=n*2-1;i++){
      hako[i]=i;
    }
    if(x!=2&&x<=n){
      hako[n]=x;
      hako[x-2]=2;
    }
    if(x>n){
      for(int i=1;i<=2*n-1;i++){
        hako[i]=2*n-hako[i];
      }
      if(x!=2*n-2){
        hako[n]=x;
        hako[2*n-x-2]=2*n-2;
      }
    }

    for(int i=1;i<=2*n-1;i++){
      cout<<hako[i]<<endl;
    }
  }
  return 0;
}

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

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

	bitset<1100000>	bs;
	int				n;
	int				m;
	int				sum;
	cin >> n >> m;
	vector<int>		P(n + 1);

	rep(i, m)
	{
		int		x;
		string	s;

		cin >> x >> s;
		if (s == "WA" && !bs.test(x))
			P.at(x)++;
		else if (s == "AC")
			bs.set(x);
	}
	sum = 0;
	rep(i, n + 1)
	{
		if (bs.test(i))
			sum += P.at(i);
	}
	cout << bs.count() << ' ' << sum << endl;
}


Measured memory_bytes: 768
from collections import deque
h=int(input())
q=deque()
count=0
q.append(h)
while(len(q)>0):
    hi=q.popleft()
    if(hi==1):
        pass
    else:
        attacked_hi=hi//2
        q.append(attacked_hi)
    count+=1

ans=0
for i in range(count):
    ans+=(2**i)
print(ans)


Measured memory_bytes: 3316
p = int(input())
A = [int(x) for x in input().split()]

def modinv(a, m):
        b = m
        u = 1
        v = 0
        while b:
                t = a // b
                a -= t * b
                a, b = b, a
                u -= t * v
                u, v = v, u
        u %= m
        if u < 0:
                u += m
        return u
        
inv_factorial = [1]
prod = 1
for i in range(1, p):
    prod *= i
    prod %= p
    inv_factorial.append(modinv(prod, p))

#p-1C0, p-1C1, ..., p-1Cp-1
comb = []
for i in range(p):
    l = i
    r = p-1-i
    comb.append(-1 * inv_factorial[l] * inv_factorial[r] % p)

ret = [0] * p
for i in range(p):
    if A[i] == 0:
        continue

    ret[0] += 1
    temp = 1
    for j in range(p):
        ind = p-j-1
        if j > 0:
            temp *= (-i)
            temp %= p
        ret[ind] -= comb[ind] * temp
        ret[ind] %= p

print(*ret)


Measured memory_bytes: 44764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  ll sum = 0;
  rep(i,N) sum += A[i];
  cout << sum - N << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
long long solve(string s, long long k) {
	long long n = s.size();
  	if (count(s.begin(), s.end(), s[0]) == n)
      	return (n * k) / 2;
	if (k == 1) {
    	long long ans = 0;
    	for(int i = 1; i < n; i++) {
          	if (s[i] == s[i - 1]) ans++, i++;
        }
      	return ans;
    }
	if (s[0] != s[n - 1])
      	return solve(s, 1) * k;
	int pref = 0;
	while (s[pref] == s[0]) pref++;
	string inside = s.substr(pref, n - pref) + s.substr(0, pref);
	return solve(s, 1) + solve(inside, k - 1);
}
int main() {
  	string s; long long k;
	cin >> s >> k;
	cout << solve(s, k);
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {

	long N, A, B;
	cin >> N >> A >> B;

	long a = 0, b = 0;

	a = N / (A + B);
	b = N % (A + B);

	if (A >= b) cout << a * A + b;
	else cout << a * A + A;

	return 0;
}

Measured memory_bytes: 256
N, K = list(map(int, input().split(" ")))

d = dict()

for i in range(N):
    a, b = list(map(int, input().split(" ")))
    if a in d:
        d[a] = d[a] + b
    else:
        d[a] = b
    
ans_sum = 0

for key in sorted(d.keys()):
    ans_sum += d[key]
    if (ans_sum) >= K:
        print(key)
        break

Measured memory_bytes: 10600
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;


void print() {
    cout << endl;
}
 
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}
 
template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}
 
template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}
 

int main(){
	ll n,m,q;cin >> n >> m >> q;
	vector<vector<ll>> add(n+5,vector<ll>(n+5,0));
	rep(i,m){
		ll l,r;cin >> l >> r;
		//l--;r--;
		add.at(l).at(r)++;
	}
	rep(i,n+1)rep(j,n+1){
		if(!i)continue;
		if(!j)continue;
		add.at(i).at(j) += add.at(i-1).at(j) + add.at(i).at(j-1) - add.at(i-1).at(j-1);
	}
	//print(add);
	
	vector<Pll> query(q);
	rep(i,q){
		ll p,q; cin >> p >> q;
		//--p;--q;
		query.at(i) = Pll(p,q);
	}
	rep(i,q){
		ll l = query.at(i).first, r = query.at(i).second;
		ll ans = add.at(r).at(r) - add.at(l-1).at(r) - add.at(r).at(l-1) + add.at(l-1).at(l-1);
		cout << ans << "\n";
	}
	return 0;
} 

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int a[N+5],b[14];
    int count=0,k=0,red=0;
    for(int i=0;i<N;i++){
        cin >> a[i];
        if(a[i]>=3200){
            red++;
        }
    }
    for(int i=0;i<14;i++)b[i]=0;

    for(int j=399;j<=4799;j=j+400){
        for(int i=0;i<N;i++){
            if(j<3200){
                if(j-400<a[i]&&a[i]<=j){
                    count++;
                }
            }
        }
        b[k]=count;
        count=0;
        k++;
    }
    int ans=0;
    for(int i=0;i<8;i++){
        if(b[i]>0){
            ans++;
        }
    }
    if(ans==0){
         cout << 1 << " " << red << endl;
    }else{
        cout << ans << " " << ans+red << endl;
    }
}
    

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

int main(){
	int n;
	cin >> n;
	if (n == 1) cout << 1 << endl;
	else if (2 <= n && n <= 3)cout << 2 << endl;
	else if (4 <= n && n <= 7)cout << 4 << endl;
	else if (8 <= n && n <= 15)cout << 8 << endl;
	else if (16 <= n && n <= 31)cout << 16 << endl;
	else if (32 <= n && n <= 63)cout << 32 << endl;
	else if (64 <= n && n <= 100)cout << 64 << endl;
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;

string s;

int check(string sub){
	int ret = 0;
	for(int i = 0; i < sub.size(); i++){
		if(sub[i] == 'A' or sub[i] == 'C' or sub[i] == 'G' or sub[i] == 'T'){
			continue;
		}else { 
			return ret;
		}
	}
	return sub.size();
}

int main(){
	cin >> s;
	int ans = 0;
	for(int i = 0; i < s.size(); i++){
		for(int j = s.size(); j >= i+1; j--){
			string sub = s.substr(i,j-i);
			// cout << i <<"\t"<<j-i << "\t" <<sub << endl;
			ans = max(ans, check(sub));
		}
	}
	cout << ans << endl;

}

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

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

  int counter = 0;
  for (int i = 0; i < S.size()/2; ++i) {
    if (S.at(i) != S.at(S.size()-i-1)) {
      counter++;
    }
  }
  cout << counter << endl;
}

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


static int desc(const void *a, const void *b);
static int asc(const void *a, const void *b);

int main (void){
    int n,k,i,j;
    int x,y,z;
    int count = 0;
    double dx;
    int flg = 0;
    int box[200001]={};
    char text[200001]={};
    char s[200001]={};
    char t[200001]={};
    char alf[256] = {"abcdefghijklmnopqrstuvwxyz"};
    char alfb[256] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
    char sample_text[256];
    i = 0;j = 0;
    // Input Area //
   // scanf("%d %d",x,y);
    scanf("%d",&n);
    for (i = 0; i < n; i++){
        scanf("%d",&box[i]);
    }
    qsort(box,n,sizeof(int),asc);
    for (i = 0; i < n - 1; i++){
        if (box[i] == box[i + 1]){
            flg = 1;
            break;
        }
    }
    if (flg == 0){
        printf("YES");
    }else{
        printf("NO");
    }
    //scanf("%s",&sample_text);
    //scanf("%s",&text);

    /*
    scanf("%d",&n);
    for(i = 0; i < n; i++){
        scanf("%d",&box[i]);
    }
    for(i = 0; i < n; i++){
        printf("%d",box[i]);
    }
    printf("\n");
    qsort(box,n,sizeof(int),desc);
    
    */
    // Output Area //
    
    /*
    for(i = 0; i < n; i++){
        printf("%d",box[i]);
    }
    */

}

static int desc(const void *a, const void *b){

    return *(int *) b - *(int *) a;
}

static int asc(const void *a, const void *b){
    return *(int *) a - *(int *) b;
}


/* KonoLvBANK

配列降順ソート
qsort(box,n,sizeof(int),desc);
配列昇順ソート
qsort(box,n,sizeof(int),asc);

アルファベットを次の単語に変えるやつ
    while(1){
        if (text[i] == '\0'){
            break;
        }
        for(j = 0; j < 26; j++){
            if (text[i] == alf[j]){
                if (j != 25){
                    text[i] = alf[j + 1];
                }else{
                    text[i] = alf[0];
                }
                break;
            }
        }
        i++;
    }

*/


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ll          long long
#define dl          double
#define pb          push_back
#define eb          emplace_back
#define mp          make_pair
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(i=a;i<b;i++)
#define all(v)      v.begin(),v.end()
#define allr(v)     v.rbegin(),v.rend()
#define mod         1e9+7
#define CIN(V,s,n)  for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n) for(int i=s;i<n;i++){cout <<  V[i] << " ";}
#define fast        ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);   for(ll i=0;i<V.size();i++) V[i] = 0;

// map<ll,vector<ll> > M;
// map<ll,vector<ll> >:: iterator it;
// it = M.begin();
// it.F will be ll
// it.S will be vector<ll>

using namespace std;

bool SbS(const pair<int,int> &a,const pair<int,int> &b)
{return (a.second < b.second);}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;
}

ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll rd(dl x)
{

        if((ll)x==x)
            return (ll)x;
        else
            return ((ll)x);
}


int main()
{
ll t=1;
//cin >> t;
while(t--)
{
    ll n,m,k,i,j,l,u,v,x,y,a,b,c,d;

    string s;
    cin >> s;
    set<char> S;
    for(i=0;i<4;i++)
        S.insert(s[i]);
    if(S.size()==2)
    {
        int counter=0;
        for(i=0;i<4;i++)
        {
            if(s[i]==*S.begin())
                counter++;
        }
        if(counter==2)
            cout << "Yes";
        else
            cout << "No";

        return 0;
    }
    else
        cout << "No";
}
    return 0;
}


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

int main(){
        int m,n_min,n_max,gap,gap_max,i,ans;
        int a[10000];

        while(1) {
                ans=0;
                gap_max=0;
                cin>>m>>n_min>>n_max;
                if(m==0&&n_min==0&&n_max==0) {
                        break;
                }

                for(i=0; i<m; i++) {
                        cin>>a[i];
                }

                for(i=n_min-1; i<n_max; i++) {
                        gap=a[i]-a[i+1];
                        if(gap>=gap_max) {
                                gap_max=gap;
                                ans=i+1;
                        }
                }

                cout<<ans<<endl;
        }
}



Measured memory_bytes: 3096
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write
def solve():
    P = []
    for line in readlines():
        x, y, s = map(int, line.split(","))
        P.append((x, y, s))
    L = 10
    MP = [[0]*L for i in range(L)]
    def update(k, ps):
        for x, y, s in P:
            if k <= s:
                for dx, dy in ps:
                    nx = x + dx; ny = y + dy
                    if not 0 <= nx < L or not 0 <= ny < L:
                        continue
                    MP[ny][nx] += 1
    update(0, [(0, 0)])
    update(1, [(-1, 0), (0, -1), (1, 0), (0, 1)])
    update(2, [(-1, -1), (1, -1), (-1, 1), (1, 1)])
    update(3, [(-2, 0), (0, -2), (2, 0), (0, 2)])
    z = m = 0
    for i in range(L):
        for j in range(L):
            if MP[i][j] == 0:
                z += 1
            m = max(m, MP[i][j])
    write("%d\n%d\n" % (z, m))
solve()



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

int ans = 0;
bool is(int x) {
	for(int i = 2; i * i <= x; i++)
		if(x % i == 0)
			return false;
	return true;
}
vector<int> v[5];
int main() {
	int n;
	cin >> n;
	for(int i = 2; i <= 55555; i++) {
		if(ans > 5 * 55)
			break;
		if(is(i)) {
			v[i % 5].push_back(i);
			ans++;
		}
	}
//	for(int i = 0; i < 5; i++)
//		cout << v[i].size() << endl;
	for(int i = 0; i < 5; i++) {
		if(v[i].size() >= 55) {
			for(int j = 0; j < n; j++)
				cout << v[i][j] << " ";
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



signed main() {
	int r, d, x;
	cin >> r >> d >> x;
	rep(i, 10) {
		x = r * x - d;
		cout << x << endl;
	}
}


Measured memory_bytes: 256