akhauriyash/Code-Regression huggingface dataset:
global MOD,facts,inv
MOD = 998244353

def nCr(n,r):
    global facts,inv
    return (facts[n] * inv[r]) % MOD * inv[n-r] % MOD

N,A,B,K = map(int,input().split())

facts = [0]*(N+10)
facts[0] = facts[1] = 1
for i in range(2,N+1):
    facts[i] = (facts[i-1] * i) % MOD
inv = [0]*(N+10)
inv[N] = pow(facts[N],MOD-2,MOD)
for i in range(N,0,-1):
    inv[i-1] = (inv[i] * i) % MOD

ans = 0
for i in range(N+1):
    bal = K - (i * A)
    m,f = bal % B,bal // B
    if m == 0 and f <= N and f >= 0:
        ans = (ans + (nCr(N,i) * nCr(N,f))) % MOD
        
print(ans)
#239423 29392 39299 394239932


Measured memory_bytes: 26740
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef int64_t ll;
typedef long double ld; 

ll n, k;
vector<ll> a;

void solve() {
    cin >> n >> k;
    a.resize(n + 1);
    for(ll i = 1; i <= n; i++) cin >> a[i];
    unordered_set<ll> s1, s2;
    ll cp = 1, moves = 0;
    while(s1.find(cp) == s1.end()) {
        s1.emplace(cp);
        cp = a[cp];
        moves++;
        if(moves == k) {cout << cp; return;}
    }
    //cout << moves << " " << cp << "\n";
    k -= moves; moves = 0;
    while(s2.find(cp) == s2.end()) {
        s2.emplace(cp);
        cp = a[cp];
        moves++;
        if(moves == k) {cout << cp; return;}
    }
    k = k % moves;
    while(k--) {
        cp = a[cp];
    }
    cout << cp;
}

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

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < (int)s.size() - 1; i++) {
    if (s[i] != s[i + 1]) {
      ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}

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

int main() {
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	
	int output = 0;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if (i * 500 + j * 100 + k * 50 == x)
					output++;
			}
		}
	}

	cout << output << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;


public class Main {
	static FastReader in = new FastReader();

	public static void main(String[] args) {
		solve();
	}

	static void solve() {
		int n = in.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		for(int i = 0; i < n; i++)
		{
			a[i] = in.nextInt();
			b[i] = in.nextInt();
			c[i] = in.nextInt();
		}
		
		int[][] dp = new int[n][3];
		dp[0][0] = a[0];
		dp[0][1] = b[0];
		dp[0][2] = c[0];
		
		for(int i = 1; i < n; i++)
		{
			dp[i][0] = a[i] + Math.max(dp[i - 1][1], dp[i - 1][2]);
			dp[i][1] = b[i] + Math.max(dp[i - 1][0], dp[i - 1][2]);
			dp[i][2] = c[i] + Math.max(dp[i - 1][0], dp[i - 1][1]);
		}
		
		System.out.println(Math.max(Math.max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]));
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		int[] readarr(int abc) {
			int[] a = new int[abc];
			for (int i = 0; i < abc; i++)
				a[i] = nextInt();
			return a;
		}
	}
}


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

typedef struct town
{
    long long teleport;
    bool visited;
    long long first_visited;
};

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    long long N, K;
    ist >> N >> K;

    vector<struct town> A;

    for (int i = 0; i < N; i++)
    {
        struct town tmp;
        A.emplace_back(tmp);

        int input;
        ist >> input;

        A.at(i).teleport = input;
        A.at(i).visited = false;
        A.at(i).first_visited = 0;
    }

    /* ------- 計算 ------- */

    long long count = 0;
    long long visiting = 0;

    long long loop_start;
    long long loop_size;

    while (1)
    {
        if (count == K)
        {
            ost << visiting + 1 << endl;
            return;
        }

        if (A.at(visiting).visited)
        {
            loop_start = A.at(visiting).first_visited;
            loop_size = count - A.at(visiting).first_visited;
            break;
            
        }
        A.at(visiting).visited = true;
        A.at(visiting).first_visited = count;
        count++;
        visiting = A.at(visiting).teleport - 1;
    }

    K -= loop_start;
    K %= loop_size;

    for (long long i = 0; i < K; i++)
    {
        visiting = A.at(visiting).teleport - 1;
    }

    ost << visiting + 1 << endl;
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


Measured memory_bytes: 9564
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  char op;
  int B;
  cin >> A >> op >> B;
  
  if ( op == '+' ){
    cout << A + B << endl;
  }
  
  else if ( op == '-' ){
    cout << A - B << endl;
  }
}

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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int cntR = 0;
    for (char c : s)
        cntR += (c == 'R');
    if (cntR > n - cntR)
        cout << "Yes";
    else
        cout << "No";
}


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

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>>ab(m, vector<int>(0));
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		if (a > m)continue;
		a--;
		ab.at(a).push_back(b);
	}
	ll ans = 0;
	priority_queue<int, vector<int>, less<int>> pq; // 小さいものを残す
	for (int i = 0; i < m; i++) {
		for (auto a : ab.at(i))pq.push(a);
		if (pq.size() == 0)continue;
		else {
			ans += pq.top();
			pq.pop();
		}
		//cout << i << " "<<ans << endl;
	}
	cout << ans << endl;
}

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

using namespace std;
using LL = long long;

constexpr int MAXN = 1e5 + 5;

int a, b, c, k;

int main () {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> a >> b >> c >> k;
    int cnt(0);
    while (a >= b) {
        b <<= 1;
        cnt++;
    }
    if (cnt > k) return cout << "No" << endl, 0;
    while (b >= c) {
        c <<= 1;
        cnt++;
    }
    if (cnt > k) return cout << "No" << endl, 0;
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int a[100005], b[100005];
int main() {
  int n; 
  string s;
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    a[i + 1] = s[i] == 'x';
  }
  a[0] = a[n];
  for (b[0] = 0; b[0] <= 1; b[0]++) {
    for (b[1] = 0; b[1] <= 1; b[1]++) {
      for (int i = 2; i <= n + 1; i++) {
        b[i] = b[i - 2] ^ b[i - 1] ^ a[i - 1];
      }
      bool ok = true;
      ok &= b[0] == b[n];
      ok &= b[1] == b[n + 1];
      if (ok) {
        for (int i = 1; i <= n; i++) {
          cout << (b[i] ? 'W' : 'S');
        }
        cout << endl;
        return 0;
      }
    }
  }
  
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

	cout << s.front() << s.length() - 2 << s.back() << endl;

}

Measured memory_bytes: 892
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> vec(m);
  rep(i,m) scanf("%d", &vec[i]);

  vector<bool> used(n+1, false);
  for(int i=m-1; i>=0; i--){
    if(!used[vec[i]]) printf("%d\n", vec[i]);
    used[vec[i]]=true;
  }
  for(int i=1; i<=n; i++) if(!used[i]){
    printf("%d\n", i);
  }

  return 0;
}

Measured memory_bytes: 3436
#include <iostream>
#include <string>

using namespace std;



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s; string t;
	cin >> s >> t;
	bool is = false;

	for (int i = 0; i < s.length(); i++) {
		if (s[i] != t[i])is = true;

	}
	if (is == true)cout << "No";
	else cout << "Yes";


	return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int p[MAXN];
int ind[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, n){
		scanf("%d", &p[i]);
		p[i]--;
		ind[p[i]] = i;
	}
	int ans = 0;
	for(int i = 0; i < n; ){
		int j = i;
		for(j++; j < n && ind[j] > ind[j - 1]; j++);
		ans = max(ans, j - i);
		i = j;
	}
	ans = n - ans;
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
int main(){
  int N;
  int D[100][2];
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    scanf("%d %d", &D[i][0], &D[i][1]);
  }
  for(int i=0;i<N-2;i++){
    if(D[i][0]==D[i][1] && D[i+1][0]==D[i+1][1] && D[i+2][0]==D[i+2][1]){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int n;
	string s;

	cin >> n >> s;

	int ans = 0;
	for(int i = 0; i < n - 2; ++i)
	{
		if (s.substr(i, 3) == "ABC")
		{
			ans++;
			i += 2;
		}
	}
	cout << ans;
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

using namespace std;

int main()
{
    int N,K;
    cin >> N >> K;
    vector<bool> person(N,false);
    int d, num;
    rep(i,N)
    {
        cin >> d;
        rep(j,d)
        {
            cin >> num;
            person[num-1] = true;
        }
    }

    int count = 0;
    rep(i,N) if(person[i] == false) count++;
    cout << count << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int base=-2;
    int N;
    cin>>N;
    
    if(N==0){
        cout<<0<<endl;
    }
    
    stack<int> stk;
    int rest=0;
    while(N!=0){
        rest=N%base;
        stk.push(abs(rest));
        N=(N-abs(rest))/base;
    }
    
    while(stk.size()!=0){
        cout<<stk.top();
        stk.pop();
    }
    
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
    #include <bits/stdc++.h>
    #define ll  long long
    #define pb push_back
    #define mp make_pair
    #define ff first
    #define ss second
    #define vi vector<int>
    #define br cout <<"\n";
    #define all(x)  (x).begin(),(x).end()
    #define tr(c,i) for(auto i : c)
    #define pii pair< int,int >
    #define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
    #define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
    #define er(x) cout << x << " "
    #define err(x,y) cout << x << " "<<y
    using namespace std;
    clock_t time_p = clock();
    void dem()
    {
        time_p=clock()-time_p;
        cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
    }
    using namespace std ;
    const ll MAX =  1000 * 1000 ;
    const int dx[] = { 1, -1 , 0 , 0  };
    const int dy [] = { 0 ,0 , 1 , -1  };
    const int MOD = 1000 * 1000 * 1000 + 9 ;
    const int N = 301 ;
    const int INF = INT_MAX ;
    const int M = 200005;


    int main (){
  ll n ;
  cin >> n ;
  ll res = n - 1 ,i ;
  for (  i =  1 ; i <=  min ( n , MAX )  ; ++ i ){
      if ( n % i == 0 ) {
    res = min ( res , abs( i - 1 ) + abs ( n/ i  - 1 ));  }
  }

  cout << res  ;
    return 0 ;
    }
/*
1
10
5 6 5 2 1 7 9 7 2 5
*/



Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def S(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    N, M = LI()
    if N % 2 == 1:
        for i in range(1, M+1):
            print(i, N - i)
    else:
        for i in range(1, M + 1):
            x = i
            y = N - i + 1
            if y - x > (x - y) % N:
                print(x, y)
            else:
                print(x, y - 1)



if __name__ == '__main__':
    main()

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

int main() {
  int n; cin >> n;
  vector<int> num(n);
  int max1=0, max2=0;
  for(int i=0; i<n; i++){
    cin >> num[i];
    if(max1<num[i]) max1=num[i];
    else {
      if(max2<num[i]) max2=num[i];
    }
  }
   
  if(max1==max2){
    for(int i=0; i<n; i++)  cout << max1 << endl;
  }else{
    for(int i=0; i<n; i++){
      if(num[i]!=max1)  cout << max1 << endl;
      else  cout << max2 << endl;
    }  
  } 
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int n[200][3],x,y[200],z[200];
int main(){
cin>>x;
for(int i=0;i<x;i++){cin>>n[i][0]>>n[i][1]>>n[i][2];}
for(int i=0;i<3;i++){memset(z,0,sizeof(z));
for(int k=0;k<200;k++){z[n[k][i]]++;}
for(int j=0;j<x;j++){if(z[n[j][i]]==1){y[j]+=n[j][i];}}
}
for(int i=0;i<x;i++){cout<<y[i]<<endl;}}

Measured memory_bytes: 1164
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku
#define N 100000
int p[N+1];

void eratosthenes(void){
    int i,j;
    for(i=2;i<N;i++)
        p[i]=1;
    for(i=2;i*i<N;i++){
        if(p[i]){
            for(j=2*i;j<=N;j=j+i){
                p[j]=0;
            }
        }
    }
}
int main(void){
	int n=in(),i,j,t[1001]={},tmp;
	long long ans=1;
	eratosthenes();
	for(i=2;i<=n;i++){
		for(j=2;j<=i;j++){
			if(p[j]&&i%j==0){
				tmp=i;
				while(tmp%j==0){
					t[j]++;
					tmp/=j;
				}
			}
		}
	}
	for(i=2;i<=n;i++)ans=ans*(t[i]+1)%mod;
	llprint(ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 

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

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

    vector<ll> div;
    for(ll i=1; i*i<=sum; ++i){
        if(sum%i == 0){
            if(i != sum/i) { div.push_back(i); div.push_back(sum/i); }
            else div.push_back(i);
        }
    }
    sort(div.begin(), div.end(), greater<ll>());

    
    for(auto d:div){
        vector<ll> r(n), left(n), right(n);
        for(int i=0; i<n; ++i) r[i] = a[i]%d;
        sort(r.begin(), r.end());
        for(int i=0; i<n; ++i){
            left[i] = r[i] + (i == 0? 0:left[i-1]);
        }
        for(int i=n-1; i>=0; --i){
            right[i] = d-r[i] + (i == (n-1)? 0:right[i+1]);
        }

        for(int i=0; i<n-1; ++i){
            ll cnt = max(left[i], right[i+1]);
            if(cnt <= k){
                cout << d << endl;
                return 0;
            }
        }
    }

    return 0;
}

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

#define ll long long
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x << endl
#define N 200005

#define newLine	printf("\n");

#define sll(X) scanf("%lld", &X);
#define pll(X) printf("%lld", X);
#define printAll(X, n)	for(int i=0;i<n;i++)	printf("%lld ", X[i]); newLine;
#define scanAll(X, n)	for(int i=0;i<n;i++)	scanf("%lld", &X[i]);

int main() {
	ll n;
	cin>>n;
	string s, t;
	cin>>s>>t;
	ll ans = 2*n;
	for(int i=0;i<n;i++) {
		ll k = 0, flag = 0;
		for(int j=i;j<n;j++) {
			if(s[j] == t[k]) {
				k ++;
			} else {
				flag = 1;
				break;
			}
		}
		if(!flag) {
			// cout<<i<<"\n";
			ans = 2*i + (n-i);
			break;
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=9; i++)
    {
        if(n%i==0)
        {
            if(n/i>=1&&n/i<=9)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}


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

template <typename T> inline void read (T &x) {bool b = 0; char c; while (!isdigit (c = getchar()) && c != '-');
if (c == '-') c = getchar(), b = 1; x = c - 48; while (isdigit(c = getchar())) x = (x<<3) + (x<<1) + c - 48; if (b)x=-x;}
template <typename T> inline void wrip(T x) {if (x > 9) wrip(x / 10); putchar(x%10 + 48); }

template <typename T> inline void write(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar(' ');}
template <typename T> inline void writeln(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar('\n');}
inline char readch() {char c; do c = getchar(); while (c == '\n' || c == ' '); return c;}
inline void reads(string &s) {char c; while((c=getchar())==' '||c =='\n'); s=c; while((c=getchar())!=' '&&c!='\n') s+=c;}
inline void getlines(string &s) {char c; while((c=getchar())=='\n'); s=c; while((c=getchar())!='\n') s+=c;}
typedef const int csint;

#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair <int, int> ii;
typedef vector <int> vi;

const ld pi = acos(-1);
const ll inf = 1e16;
const int mod = 1e9 + 7,
N = 1e6 + 11;

int n;
ll bit[N], s[N];
void Inc(ll &a, ll b) {
    a += b;
    if (a >= mod)
        a -= mod;
}
void update(int p, ll val) {
    for (; p <= n; p += p & -p)
        Inc(bit[p], val);
}
ll get(int p) {
    ll ans = 0;
    for (; p > 0; p -= p & -p)
        Inc(ans, bit[p]);
    return ans;
}
int a[N];
void Try(int x) {
    if (x > n) {
        for (int i = 1; i <= n; i++)
            a[i + n] = a[n];
        for (int i = 1; i <= n; i++)
            for (int j = i + 1; j <= i + a[i]; j++)
                for (int k = j + 1; k <= i + a[i]; k++)
                    if (a[j] != a[k])
                        return;
        for (int i = 1; i <= n; i++)
            cout << a[i] << ' ';
        cout << '\n';
        return;
    }
    for (int i = 1; i <= n; i++) {
        a[x] = i;
        Try(x + 1);
    }
}
int main() {
    #ifdef makacha
        freopen("m.inp", "r", stdin);
        freopen("m.out", "w", stdout);
    #endif // makacha
    read(n);
    ll res = 1;
    s[0] = 1;
    for (int i = 1; i < n; i++) {
        s[i] = s[i - 1];
        Inc(s[i], get(i));
        res += s[i] * (n - 1) % mod * n % mod;
        update(i + 3, s[i]);
    }
    s[n] = s[n - 1];
    Inc(s[n], get(n));
    res += s[n] * (n - 1) % mod;
    cout << res % mod;
    #ifdef makacha
        freopen("m.ans", "w", stdout);
        if (n <= 9)
            Try(1);
    #endif // makacha
}


Measured memory_bytes: 17792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n, m;
    cin >> n >> m;

    char a[n][n];
    char b[m][m];

    rep(i, 0, n){
        rep(j, 0, n){
            cin >> a[i][j];
        }
    }

    rep(i, 0, m){
        rep(j, 0, m){
            cin >> b[i][j];
        }
    }

    rep(i, 0, n){
        rep(j, 0, n){
            bool check = true;
            rep(k, 0, m){
                rep(l, 0, m){
                    if(i + k >= n){
                        check = false;
                        break;
                    }else if(j + l >= n){
                        check = false;
                        break;
                    }
                    if(b[k][l] != a[i + k][j + l]){
                        check = false;
                        break;
                    }
                }
                if(!check) break;
            }
            if(check){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio   ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll        long long
#define yes       printf("YES\n")
#define no        printf("NO\n")
#define pb        push_back
#define srtd(x)   sort(x.begin(),x.end())
#define rvsd(x)   reverse(x.begin(),x.end())
#define scn(n)    scanf("%lld",&n)
#define scab(a,b) scanf("%lld %lld",&a,&b)
#define pn(n)     printf("%lld\n",n)
#define pab(a,b)  printf("%lld %lld",a,b)
#define nl        cout<<endl
#define MAX       1000011
#define PI        acos(-1.0)
#define mmst(a,b) memset(a,b,sizeof(a));
#define FOR(i,n)  for(ll i=1;i<=n;i++)
#define LOP(i,n)  for(ll i=0;i<n;i++)
//Emama_ Nahid//
using namespace std;

int main()
{
    fastio;
    ll n,m,i,j,k,t,r,p;
    cin>>t;
    string s;
    ll ar[5];
    mmst(ar,0);
    LOP(i,t)
    {
        cin>>s;
        if(s=="AC")
            ar[0]++;
        else if(s=="WA")
            ar[1]++;
        else if(s=="TLE")
            ar[2]++;
        else if(s=="RE")
            ar[3]++;
    }
    cout<<"AC x "<<ar[0]<<endl;
    cout<<"WA x "<<ar[1]<<endl;
    cout<<"TLE x "<<ar[2]<<endl;
    cout<<"RE x "<<ar[3]<<endl;


    return 0;
}





Measured memory_bytes: 3612
import fractions
N = int(input())
A = list(map(int, input().split()))
L = [0]
R = [0]

for i in range(N-1):
  L.append(fractions.gcd(L[i], A[i]))
  R.append(fractions.gcd(R[i], A[N-1-i]))
  
ans = 0

for i in range(N):
  ans = max(ans, fractions.gcd(L[i], R[N-1-i]))

print(ans)

Measured memory_bytes: 16136
#include<bits/stdc++.h>
using namespace std;
long long n,a[200100],tmp[200100];
map<long long,long long> m;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		m[a[i]]++;
	}
	map<long long,long long> :: iterator it;
	long long ans=0;
	for(it=m.begin();it!=m.end();it++)
		ans+=(it->second)*(it->second-1)/2;
	for(int i=0;i<n;i++)
		cout<<ans-m[a[i]]+1<<endl;
}

Measured memory_bytes: 12928
from collections import Counter

n = int(input())
s = input()
if s[0] != '0':
    print(0)
    exit()

d = Counter(map(int, s.split()))
mod = 998244353

if 0 not in d or d[0] > 1:
    print(0)
    exit()
if n == 1:
    print(1)
    exit()

ans = 1
for i in range(1,len(d)):
    if i not in d:
        print(0)
        exit()
    ans = (ans * d[i-1]**d[i]) % mod

print(ans % mod)



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

#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;

int main(int argc, char *argv[]) {
    ll r;
    cin >> r;
    
    if (r < 1200) MSG("ABC")
    else if (r < 2800) MSG("ARC")
    else MSG("AGC")
    return 0;
}


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

int main(void)
{
	using namespace std;
	string card, shaffuru;
	int m, number;
	while(true)
	{
		cin >> card;
		if(card == "-")
			break;
		cin >> m;
	shaffuru = card;
	for(int i = 0; i < m; i++)
	{
		cin >> number;
		for(int j = 0; j < number; j++)
			shaffuru[card.size() - number + j] = card[j];
		for(int j = 0; j < card.size() - number; j++)
			shaffuru[j] = card[j + number];
		card = shaffuru;
	}
	cout << shaffuru << endl;
	}
	return 0;
}


Measured memory_bytes: 3160
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new ABC130().Solve130B(new ConsoleInput(Console.In, ' '));
        }
    }
  public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
  class ABC130
    {
        public void Solve130A(ConsoleInput cin)
        {
            var x = cin.ReadInt;
            var a = cin.ReadInt;
            if (x < a)
                WriteLine(0);
            else
                WriteLine(10);
            ReadLine();
        }

        public void Solve130B(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var x = cin.ReadInt;
            int[] bound = cin.ReadIntArray(n);
            int count = 0;
            int[] sum = new int[bound.Length+1];
            sum[0] = 0;
            for (int i=0; i<n; i++)
            {
                sum[i+1] = sum[i] + bound[i];
            }
            foreach (int dist in sum)
            {
                if(dist <= x)
                {
                    count++;
                }
            }
            WriteLine(count);
            ReadLine();
        }
    }
}


Measured memory_bytes: 13268
#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 a,b; cin >> a >> b;
  if(a < 6){
    cout << 0 << endl;
  }
  else if(a <=12){
    cout << b/2 << endl;
  }
  else{
    cout << b << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
const int inf = 1 << 30;
const ll mod = 1e9 + 7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
vector<int> G[200010];
int son[200010];
bool used[200010];
ll kai[200010];
ll re[200010];
ll ans[200010];
ll res[200010];

ll modpow(ll x, ll y){
    if(y == 0) return 1;

    ll x2 = modpow(x, y / 2) % mod;
    x2 = x2 * x2 % mod;
    
    if(y % 2 == 1) x2 = x2 * x % mod;

    return x2;
}


void dfs(int v){
    used[v] = true;
    res[v] = 1;
    son[v] = 0;
    for(auto u : G[v]){
        if(used[u]) continue;
        dfs(u);
        ll mul = kai[son[u] + son[v]] * re[son[u]] % mod;
        mul = mul * re[son[v]] % mod;
        res[v] = res[v] * mul % mod;
        res[v] = res[v] * res[u] % mod;
        son[v] += son[u];
    }
    son[v]++;
}

void dfs2(int v, ll s){
    used[v] = true;
    ll mul = kai[N - 1] * re[son[v] - 1] % mod;
    mul = mul * re[N - son[v]] % mod;
    ans[v] = mul * res[v] % mod;
    ans[v] = ans[v] * s % mod;
    ll s2 = N - son[v];
    for(auto u : G[v]){
        if(used[u]) continue;
        mul = kai[N - son[u] - 1] * re[s2] % mod;
        mul = mul * re[N - son[u] - 1 - s2] % mod; 
        mul = mul * s % mod;
        mul = mul * res[v] % mod;
        ll com = kai[son[v] - 1] * re[son[u]] % mod;
        com = com * re[son[v] - son[u] - 1] % mod;
        mul = mul * modpow(com, mod - 2) % mod;
        mul = mul * modpow(res[u], mod - 2) % mod;
        dfs2(u, mul);
    }
}

void init(){
    kai[0] = 1;
    for(int i = 1; i <= N; i++){
        kai[i] = kai[i - 1] * i;
        kai[i] %= mod;
    }
    for(int i = 0; i <= N; i++){
        re[i] = modpow(kai[i], mod - 2);
    }
}

int main(){
    cin >> N;
    for(int i = 1; i < N; i++){
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    init();
    dfs(1);
    for(int i = 1; i <= N; i++) used[i] =false;
    dfs2(1, 1);

    for(int i = 1; i <= N; i++) cout << ans[i] << endl;
    return 0;
}

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

const int N = 100 + 20;
int a[N], n;
bool ans = true;

int main() {
  	cin >> n;
  	for (int i = 0; i < n; i++)
      	cin >> a[i];
 	for (int i = 0; i < n; i++)
      	ans &= !(a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0);
 	return cout << (ans? "APPROVED": "DENIED") << "\n", 0;
}

Measured memory_bytes: 256
#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 = 1000000007;

ll sum(ll l, ll r){
	return (l + r) / 2 * (r -l + 1);
}

int main(){
	int n, k;
  	cin >> n >> k;
  
  	ll ans = 0;;
  
  	for(int i = k; i <= n+1; i++){
    	ll l = sum(0, i-1);
      	ll r = sum(n-i+1, n);
      	ans += r-l+1;
    }
  	cout << ans % mod << endl;
}

Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstring>
#include <cmath>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()

using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

const int INF = 1<<29;

int gcd(int m, int n){
	return (n==0?m:gcd(n, m%n));
}

int main(){
	int n, a, b;
	cin >> n >> a;
	rep(i, n-1){
		cin >> b;
		a = gcd(a, b);
	}

	vector<int> ans;
	FOR(i, 1, sqrt(1.*a)+1){
		if(a%i == 0){
			ans.push_back(i);
			ans.push_back(a/i);
		}
	}
	sort(all(ans));
	ans.erase(unique(all(ans)), ans.end());
	rep(i, ans.size()){
		cout << ans[i] << endl;
	}

    return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
int main(){
 string s;
  cin>>s;
  for(int i=0;i<3;i++)
  if(s.at(i)=='1')s.at(i)='9';
  else s.at(i)='1';
  cout << s <<endl;
 
}

Measured memory_bytes: 256
from collections import Counter

S = list(input())
C = Counter(S)
if len(S) == 1:
    print('YES')
    exit()
"""
条件を考えてみる
一種類の字しかない時は回文
２種類の時も，長さが２より大きい時は回文
同じ文字をに連続で並べないといけない時に回文になる。

ある文字が他の文字よりも2つ以上多い時には回文になる。
"""

L = C.values()
if len(L) <= 1:
    print('NO')
elif len(L) == 2 and len(S) > 2:
    print('NO')
elif max(L) - min(L) >= 2:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 4340
#include <bits/stdc++.h>
 
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
 
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, X, ans=1, c=0;
	for(cin>>N>>X;N;N--) {
		int a;
		cin>>a;
		if((c+=a)>X) break;
		ans++;
	}
	cout<<ans<<'\n';
	return 0;
}

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

int main() {
  
  double a, b;
  cin >> a >> b;
  
  if(a > b)
    cout << "GREATER" << endl;
  else if(a < b)
    cout << "LESS" << endl;
  else if(a == b) 
    cout << "EQUAL" << endl;
  
//  cout << std::setprecision(15) << a << endl;
//  cout << std::setprecision(15) << b << endl;
  
}

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

using namespace std;

int main(){
  int n,k,q; cin >> n >> k >> q;
  vector<int> b(n,k-q);
  for(int i=0;i<q;i++){
    int a;
    cin >> a;
    b[a-1]++;
  }
  for(int i=0;i<n;i++){
    if(b[i]<=0){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }
}

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

int n,l;
  cin >> n>> l;
  
  if(l<=0 && n+l-1>=0) cout << ((n+2*l-1)*n)/2;
  else if(l<0) cout << ((n+2*l-1)*n)/2-(n+l-1);
  else cout << ((n+2*l-1)*n)/2-l;
return 0;}

Measured memory_bytes: 3612
N = int(input())
S = list(input())

r = len([s for s in S if s == "R"])
g = len([s for s in S if s == "G"])
b = len([s for s in S if s == "B"])

res = r * g * b

for i in range(N-2):
    for j in range(i+1, N-1):
        k = j + (j - i)
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            res -= 1

print(res)


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll h, w, c=0;
  cin >> h >> w;
  string s;
  forll(i, 0, h){
	cin >> s;
	forll(i, 0, w){
	  if (s[i] == '#')
		c++;
	}
  }
  if (c > (h + w - 1))
	cout << "Impossible" << endl;
  else
	cout << "Possible" << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <string>
#include <cstring>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const ll MOD = (ll)1e9 + 7;
ll add(ll x, ll y)
{
    x += y;
    if (x >= MOD) return x - MOD;
    return x;
}
ll sub(ll x, ll y)
{
    x -= y;
    if (x < 0) return x + MOD;
    return x;
}

const int N = 2010;
int n, m, k;
ll dp[2 * N][N];

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    scanf("%d%d%d", &n, &m, &k);
    if (n == 0 || m == 0)
    {
        printf("1\n");
        return 0;
    }
    for (int i = 1; i < k; i++)
        dp[1][i] = 1;
    for (int i = 1; i < 2 * N - 1; i++)
    {
        ll sum = 0;
        for (int j = 0; j < N; j++)
        {
            sum = add(sum, dp[i][j]);
            if (j >= k)
                sum = sub(sum, dp[i][j - k]);
            dp[i + 1][j] = sum;
        }
    }
    ll ans = 0;
    for (int i = 1; i < 2 * N; i++)
        for (int j = n; j >= 0; j -= k - 1)
        {
            int z = i * (k - 1) + 1 - j;
            if (z <= 0 || z > m) continue;
            ans = add(ans, dp[i][j]);
        }
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 63488
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int n, cnt = 0, maxn = 0, minn = 9999999999;
	string s, s1;


	cin >> s;

	if (s.length() == 1) {
		if (s[0] == 'A' || s[0] == 'C' || s[0] == 'G' || s[0] == 'T') {
			cout << 1 << endl;
			return 0;
		}
	}


	for (int i = 0; i < s.length(); i++) {

		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {

			bool flag = false;
			int cnt1 = 1;
			maxn = max(maxn, cnt1);

			for (int j = i + 1; j < s.length(); j++) {
				if (s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T') {
					cnt1++;
					maxn = max(maxn, cnt1);
				}
				else {
					break;
				}
			}


		}
			   
	}


	if (maxn == 0) {
		if (s[s.length() - 1] == 'A' || s[s.length() - 1] == 'C' || s[s.length() - 1] == 'G' || s[s.length() - 1] == 'T' ) {
			cout << 1 << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
	else {
		cout << maxn << endl;
	}


	

	



	return 0;
}

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

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

  vector<long long> L(2);
  L.at(0) = 2;
  L.at(1) = 1;

  if (N <= 1) {
    cout << L.at(N) << endl;
  } else {
    for (int i = 2; i <= N; i++) {
      long long num = L.at(i - 1) + L.at(i - 2);
      L.push_back(num);
    }
    cout << L.at(N) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()

wlist = [0] * (n + 1)
blist = [0] * (n + 1)

for i in range(n):
    if s[i] == ".":
        wlist[i + 1] = wlist[i] + 1
        blist[i + 1] = blist[i]
    elif s[i] == "#":
        wlist[i + 1] = wlist[i]
        blist[i + 1] = blist[i] + 1

ans = n

for i in range(n + 1):
    tmp = blist[i] + (wlist[n] - wlist[i])
    if ans > tmp: ans = tmp
print(ans)

Measured memory_bytes: 18712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int n; cin >> n;
    ll kk, k; cin >> k;
    
    ll sa = 0;

    int a[n], aa[n], f[n];
    rep(i, n){
        cin >> a[i];
        sa += a[i];
    }
    rep(i, n) cin >> f[i];

    if(sa <= k){
        cout << 0 << endl;
        return 0;
    }

    sort(f, f+n);
    sort(a, a+n);
    reverse(a, a+n);
    // reverse(f, f+n);

    ll l=0, r=1e12;
    while(r-l>1){
        ll mid = (l+r)/2;

        rep(i, n){
            aa[i] = a[i];
        }

        ll cnt = 0;
        rep(i, n){
            cnt += max(0LL, a[i]-mid/f[i]);
        }
        if(cnt > k){
            l = mid;
        }else{
            r = mid;
        }
    }
    cout << r << endl;
    // printf("%d\n", N);
    return 0;
}

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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;
const int K = 500;
const int maxN = 2e4 + 1;

void solve() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	
	for (int i = 0; i < s.size(); i++) {
		int x = s[i] - 'A';
		x = (x + n % 26) % 26;
		s[i] = (char)(x + 'A');
	}
	cout << s;
}
	

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  
  if(b <= a && c <= a) {
    printf("%d\n", a * 10 + b + c);
  } else if(a <= b && c <= b) {
    printf("%d\n", b * 10 + a + c);
  } else {
    printf("%d\n", c * 10 + a + b);
  }
}

Measured memory_bytes: 1732
#include <stdio.h>
int main(void){
 int i,x=0;
  char s[200001],t[200001];
  
  scanf("%s",&s);
  scanf("%s",&t);
  
  for(i=0;s[i]!='\0';i++){
    if(s[i]!=t[i])x++;
  }
  printf("%d",x);
  return 0;
}

Measured memory_bytes: 2092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
#define intt long long
#define PI 3.14159265358979323846

using namespace std;
int main() {
    intt N, K, R, S, P; std::cin >> N >> K >> R >> S >> P;
    std::string T; std::cin >> T;
    intt ans = 0;
    for (int i = 0; i < K; ++i) {
        std::string s;
        int j = i;
        while (j < N) {
            s.push_back(T[j]);
            j += K;
        }
        int t = 0;
        for (int k = 0; k < s.size(); ++k) {
            if (k > 0 && s[k] == s[k - 1] && t == 1) {
                t = 0;
                continue;
            }
            else {
                if (s[k] == 'r')
                    ans += P;
                else if (s[k] == 's')
                    ans += R;
                else if (s[k] == 'p')
                    ans += S;
                t = 1;
            }
        }
    }
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3764
l = int(input())
# l = 1000000
r = 1
while 2 ** r <= l:
    r += 1
r = min(19, r - 1)
# print(r)

n = r + 1
# print(n)

ts = [i for i in range(1, n)]
ts.reverse()
# print(ts)

m = (n - 1) * 2

points = {}

for t in ts:
    a = l - 2 ** (t - 1)
    b = 2 ** r
    if a >= b:
        points[t] = a
        l -= 2 ** (t - 1)

m += len(points)
print(n, m)
for i in range(1, (n - 1) * 2 + 1):
    p = (i - 1) // 2 + 1
    if i % 2 == 0:
        print(p, p + 1, 0)
    else:
        print(p, p + 1, 2 ** (p - 1))

for k in points.keys():
    print(k, n, points[k])


Measured memory_bytes: 3064
from heapq import heappop, heappush
def solve(graph,start,goal,numnodes):
    que = []
    heappush(que,(0,start-1))
    mindists = [float("inf")]*numnodes
    while que:
        ccost,cnode = heappop(que)
        if mindists[cnode] < ccost: continue
        for nnode,mcost in graph[cnode]:
            tcost = ccost+mcost
            if mindists[nnode] > tcost:
                mindists[nnode] = tcost
                heappush(que,(tcost,nnode))
    return mindists[goal-1]
n = int(input())
m = int(input())
graph = [[] for _ in range(n)]
for _ in range(m):
    a,b,c,d = map(int,input().split(","))
    graph[a-1].append((b-1,c))
    graph[b-1].append((a-1,d))
s,g,V,P = map(int, input().split(","))
V -= solve(graph,s,g,n)
V -= P
V -= solve(graph,g,s,n)
print(V)


Measured memory_bytes: 5672
from collections import deque

h, w = map(int, input().split())
black = 0
data = []
for _ in range(h):
    s = input()
    for i in range(w):
        if s[i] == "#":
            black += 1
    data.append(s)

dist = [[-1]*w for _ in range(h)]
queue = deque()
queue.append((0, 0))
dist[0][0] = 0

while queue:
    x, y = queue.popleft()
    for dx, dy in [(-1, 0), (1, 0), (0, 1), (0, -1)]:
        tox, toy = x + dx, y + dy
        if 0 <= tox < h and 0 <= toy < w and dist[tox][toy] == -1 and data[tox][toy] == '.':
            dist[tox][toy] = dist[x][y] + 1
            queue.append((tox, toy))

print(h * w - black - dist[-1][-1] - 1 if dist[-1][-1] != -1 else -1)


Measured memory_bytes: 40176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;



int main() {

    char c;
    cin >> c;
    ++c;

    cout << c  << endl;

    return 0;
}

Measured memory_bytes: 256