akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
const int mod=998244353;
int n;
char s[200005];
int a[200005],b[400005];
long long f[400005];
void Solve(int v)
{
	long long res=0;
	for(int i=1;i<=v/2;i++) res=((res<<1)+a[i])%mod;
	for(int i=1,op=0;i<=n;i+=v/2,op^=1)
	for(int j=i;j<=i+v/2-1;j++) b[j]=a[j-i+1]^op;
	bool flag=1;
	for(int i=1;i<=n;i++)
	{
		if(b[i]>a[i]) flag=0;
		else if(b[i]<a[i]) break;
	}
	if(flag) res=(res+1)%mod;
	f[v]=res;
}
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++) a[i]=s[i]-'0';
	for(int i=2;i<=2*n;i++) if(!(2*n%i)&&n%i) Solve(i);
	for(int i=2;i<=2*n;i++)
	if(!(2*n%i)&&n%i)
	for(int j=2*i;j<=2*n;j+=i)
	if(!(2*n%j)&&n%j) f[j]=(f[j]-f[i]+mod)%mod;
	long long ans=0;
	for(int i=1;i<=2*n;i++) ans=(ans+i*f[i]%mod)%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5568
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N, M, Q;
    int L,R,p,q;
    int ans(0),sum(0);
    cin >> N >> M >> Q;
    /*
    vector<vector<int>> v,t;
    v.resize(N);
    t.resize(N);
    for (int i = 0; i < N; i++)
    {
        v[i].resize(N);
        t[i].resize(N);
    }*/
    int v[501][501]={};
    int t[501][501]={};
    for (int i = 0; i < M; i++){
        cin >> L >> R;
        t[L][R]++;
    }
    for(int i=1;i<N+1;i++){
        for(int j=1;j<N+1;j++){
            v[i][j]=v[i][j-1]+t[i][j];
        }
    }
    for(int i=0;i<Q;i++){
        cin >> p >> q;
        ans=0;
        for(int j=p;j<=q;j++){
            ans+=v[j][q];
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <algorithm>

using namespace std;

using ll = long long;
using ld = long double;
using lli = long long int;
using ull = unsigned long long;

#define PI 3.14159265358979323846264338327950L

int main(){
  ull N, i, alpha;
  char temp_char;
  vector<char> string;

  cin >> N;

  while(true){
    if( N > 26){
      alpha =  N % 26;
      if(alpha == 0){
        temp_char = 'z';
      }
      else{
        temp_char = 'a' + (alpha - 1);
      }
      string.push_back(temp_char);
      
      if(N > 26){
        if((N % 26) == 0){
          N = N / 26 - 1;
        }
        else{
          N = N / 26;
        }
      }
      else{
        continue;
      }
    }
    else{
      alpha = N;
      if(alpha == 0){
        temp_char = 'z';
      }
      else{
        temp_char = 'a' + (alpha - 1);
      }
      string.push_back(temp_char);
      break;
    }
  }

  for(int i=string.size()-1; i>=0 ; i--){
    cout << string.at(i);
  }

  cout << endl;
  
  return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

int main() {
    ll k;
    cin >> k;
    vector<ll> a;
    for (ll i = 1; i < 10; i++) {
        queue<ll> q;
        q.push(i);
        while (true) {
            ll s = q.front();
            q.pop();
            if (s > 3234566667)
                break;
            a.push_back(s);
            ll p = s % 10;
			if (p!=0)
            q.push(s * 10 + p - 1);
            q.push(s * 10 + p);
			if (p!=9)
            q.push(s * 10 + p + 1);
        }
    }
    sort(a.begin(), a.end());
    cout << a[k - 1] << endl;
}

Measured memory_bytes: 4740
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()

if abs(A-B)%2 == 0:
    print(abs(A-B)//2)
else:
    A, B = max(A, B), min(A, B)
    print(min((N-B)-(-(B-A)//2), A-1-(-(B-A)//2)))


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

using namespace std;

int main(void){
    long long a, b, c;
    cin >> a >> b >> c;
    if(c >= a + b && 4 * a * b < (c - a - b) * (c - a - b)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b;
    c=a*pow(10,(int)log10(b)+1)+b;
    for(int i=1;i<=c;i++)
    if(i*i==c) {cout<<"Yes";return 0;}
    cout<<"No";
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>

using namespace std;

int main(){

	int n,year,month,day,sum;

	scanf("%d",&n);

	for(int loop = 0; loop < n; loop++){
		scanf("%d %d %d",&year,&month,&day);

		sum = 0;

		if(year % 3 == 0 || month % 2 == 1){
			sum += 20 - day;
		}else{
			sum += 19 - day;
		}

		for(int i = month+1; i <= 10; i++){
			if(year % 3 == 0 || i %2 == 1)sum += 20;
			else{
				sum += 19;
			}
		}

		for(int i = year+1; i < 1000; i++){
			if(i % 3 == 0)sum += 200;
			else{
				sum += 195;
			}
		}

		printf("%d\n",sum+1);

	}
	return 0;
}

Measured memory_bytes: 2688
loop do
  x, op, y = gets.split
  break if op == '?'

  a = x.to_i
  b = y.to_i
  ans =
  case op
  when '+'
    a + b
  when '-'
    a - b
  when '*'
    a * b
  when '/'
    a / b
  end
  puts ans
end

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

int main()
{
	int n,m;
	cin >> n >> m;
	vector<vector<tuple<int,int,int>>> list(n+1, vector<tuple<int,int,int>>());	//p, y, i, x
	for(int i = 0; i < m; i++){
		int p,y;
		cin >> p >> y;
		list[p].push_back(make_tuple(y, i, -1));
	}
	vector<tuple<int,int,int>> output;	//i, p, x
	for(int i = 1; i <= n; i++){
		sort(list[i].begin(), list[i].end());
		for(unsigned int j = 0; j < list[i].size(); j++){
			output.push_back(make_tuple(get<1>(list[i][j]), i, j+1));
		}

	}
	sort(output.begin(), output.end());
	for(unsigned int i = 0; i < output.size(); i++){
		printf("%06d%06d\n", get<1>(output[i]), get<2>(output[i]));
	}

	return 0;
}


Measured memory_bytes: 8308
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
#include<queue>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

int main(){

  int k,x; cin >> k >> x;

  for (int i=max(x-k+1,-1000000); i<=min(x+k-1,1000000); i++){
    cout << i << " ";
  }

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class Heap<T> where T : IComparable
{
    public List<T> list { get; set; }

    public int Count => list.Count;

    public T this[int index] { get { return this.list[index]; } set { list[index] = value; } }

    public Heap(List<T> list)
    {
        this.list = list;
    }

    public void Add(T t)
    {
        list.Add(t);
    }

    public int Parent(int i)
    {
        var x = (i + 1) / 2 - 1;
        return (x >= 0) ? x : -1;
    }

    public int Left(int i)
    {
        var x = 2 * i + 1;
        return (x < list.Count) ? x : -1;
    }

    public int Right(int i)
    {
        var x = 2 * i + 2;
        return (x < list.Count) ? x : -1;
    }

    public void MaxHeapify(int i)
    {
        var l = Left(i);
        var r = Right(i);
        var largest = i;
        if (l != -1 && list[l].CompareTo(list[i]) > 0)
        {
            largest = l;
        }
        if (r != -1 && list[r].CompareTo(list[largest]) > 0)
        {
            largest = r;
        }
        if (largest != i)
        {
            var tmp = list[i];
            list[i] = list[largest];
            list[largest] = tmp;
            MaxHeapify(largest);
        }
    }

    public void BuildMaxHeap()
    {
        for (int i = list.Count / 2 - 1; i >= 0; i--)
        {
            MaxHeapify(i);
        }
    }
}

class MyClass
{
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var heap = new Heap<int>(Console.ReadLine().Split().Select(int.Parse).ToList());
        heap.BuildMaxHeap();
        for (int i = 0; i < n; i++)
        {
            Console.Write(" {0}", heap[i]);
        }
        Console.WriteLine();
    }
}


Measured memory_bytes: 51572
package main

import (
	"fmt"
)

func main() {
	var str string
	var count int
	fmt.Scan(&str)

	if len(str) != 3 {
		return
	}

	if str == "RRR"{
		count = 3
	}else if str == "SSS" {
		count = 0
	}else if str == "RRS" || str == "SRR"{
		count = 2
	}else{
		count = 1
	}
	fmt.Println(count)
}

Measured memory_bytes: 1768
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<map>
#include<set>
#include<iostream>
#include<algorithm>
#include<queue>
#define re register
#define ll long long
using namespace std;
inline int gi(){
	char ch=getchar();int f=1,sum=0;
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=100010,Inf=1e9+10;
int n,a[N],dp[N];
int main(){
	n=gi();
	for(int i=1;i<=n;i++)a[i]=gi();
	dp[0]=Inf; 
	for(int i=2;i<=n;i++)
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	printf("%d\n",dp[n]); 
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vii vector<pair<int, int> >
#define fi first
#define se second
#define ii pair<int, int> 
#define int long long
#define eb emplace_back

int a[200005], pf[200005];
signed main()
{
	int n, ans=LLONG_MAX;
	cin>>n;
	for(int i=1; i<=n; i++) cin>>a[i];
	for(int i=1; i<=n; i++) pf[i] = pf[i-1]+a[i];
	for(int i=2; i<=n-2; i++)
	{
		int ll = 1, rr = i-1;
		vii f, s;
		while(ll<rr) 
		{
			int mid = (ll+rr+1)/2;
			if(2*pf[mid]>pf[i]) rr=mid-1;
			else ll=mid; 
		}
		int lb=ll;
		ll=i+1, rr=n-1;
		while(ll<rr)
		{
			int mid = (ll+rr+1)/2;
			if(2*(pf[mid]-pf[i])>pf[n]-pf[i]) rr=mid-1;
			else ll=mid;
		}
		int rb = ll;
		for(int j=lb-10; j<=lb+10; j++)
		{
			for(int k=rb-10; k<=rb+10; k++)
			{
				if(j and j<i and k>i and k<n)
				{
					int t1 = pf[j],t2 = pf[i]-pf[j], t3 = pf[k]-pf[i], t4 = pf[n]-pf[k];
					int mn = min({t1, t2, t3, t4});
					int mx = max({t1, t2, t3, t4});
					ans=min(ans, mx-mn);
				}
			}
		}		
	}
	cout<<ans;
}


Measured memory_bytes: 6772
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
int x,y,z;
  scanf("%d %d", &x, &y);
z=x+y;
  if(z < x-y) z=x-y;
  if(z < x*y)z=x*y;
  printf("%d", z);
	return 0;
	
}

Measured memory_bytes: 128
fun main(args:Array<String>){
            val num = readLine()!!.toInt()
            val list = readLine()!!.split(" ").map(String::toInt).toMutableList()
            val manzoku = readLine()!!.split(" ").map(String::toInt).toMutableList()
            val bonusup = readLine()!!.split(" ").map(String::toInt).toMutableList()
            var m = 0
            for(i in 0 until num){
                m += manzoku[list[i]-1]
                if(i >= 1 && list[i] == list[i-1]+1) m += bonusup[list[i]-2]
            }
            println(m)
        }

Measured memory_bytes: 36216
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int len = int.Parse(Reader.ReadLine());
        string inpt = Reader.ReadLine();

        int[] turnLeft = new int[len];
        int[] turnRight = new int[len];

        for (int i = 1; i < len; i++) {
            turnRight[i] = turnRight[i - 1];
            if(inpt[i - 1] == 'W') {
                turnRight[i]++;
            }
        }
        for (int i = len - 2; i >= 0; i--) {
            turnLeft[i] = turnLeft[i + 1];
            if(inpt[i + 1] == 'E') {
                turnLeft[i]++;
            }
        }

        int ans = len;
        for (int i = 0; i < len; i++) {
            ans = Math.Min(ans, turnLeft[i] + turnRight[i]);
        }
        Console.WriteLine(ans);
    }


	public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


5
WEEWW



";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 14432
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	ll n,k;cin>>n;
	k=2;
	ll a[n+1];
	for(ll i=1;i<=n;i++)cin>>a[i];
	ll dp[n+1];
	for(ll i=0;i<=n;i++)dp[i]=1e15;
	dp[0]=0;
	dp[1]=0;
	for(ll i=2;i<=n;i++){
		for(ll j=1;j<=k and i-j>=1;j++){
			dp[i]=min(abs(a[i]-a[i-j])+dp[i-j],dp[i]);
		}
	}
	//for(int i=1;i<=n;i++)cout<<dp[i]<<" ";cout<<endl;
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792
def search_RL(S):
  amount=0
  for i in range(1,len(S)):
    if S[i-1]!=S[i]:
      amount+=1
  return amount

N,K=map(int,input().split())
S=input()
sum_RL=search_RL(S)
if -(-sum_RL//2) >= K:
  if (len(S)-sum_RL-1+2*K) >len(S)-1:
    print(len(S)-1)
  else:
    print(len(S)-sum_RL-1+2*K)
else:
  if (len(S)-sum_RL-1+2*K) >len(S)-1:
    print(len(S)-1)
  else:
    print(len(S)-sum_RL+2*K+1)

Measured memory_bytes: 3316
# むずかしい
from itertools import chain
from collections import Counter

h, w = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
a = [list(map(int, input().split())) for _ in range(h)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])

ct = Counter(chain(*a))
ans = sum(ct[i] * c[i][1] for i in range(10))
print(ans)


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

typedef long long ll;
using namespace std;
int a[110];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    if(n==1){
        printf("0\n");
        return 0;
    }
    int minx=a[1],maxx=a[n];
    int sum=1e9;
    for(int i=minx;i<=maxx;i++){
        int now=0;
        for(int j=1;j<=n;j++)now+=(i-a[j])*(i-a[j]);
        sum=min(sum,now);
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  int sum = 0;
  rep(i, N) {
    cin >> vec.at(i);
    sum += vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  if(vec.at(0) < sum - vec.at(0)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3556
use std::collections::*;
// use std::io::prelude;
use std::io;
use std::io::Read;
use std::cmp::*;

fn main(){
    let t_cases = 1;
    for _ in 0..t_cases{
        solve();
    }
}

fn solve(){

    let MOD = 10i32.pow(9)+7;
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let a = buf
                .trim()
                .split_whitespace()
                .map(|x| x.parse::<usize>().unwrap())
                .collect::<Vec<usize>>();
    let (m,n) = (a[0],a[1]);

    let mut g = vec![];
    for i in 0..m{
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf = buf.trim().to_owned();
        g.push(buf.as_bytes().to_owned());
    }
    let mut dp = vec![vec![0i32;n+1];m+1];
    dp[0][1] = 1;
    for i in 1..(m+1){
        for j in 1..(n+1){
            if g[i-1][j-1]=='#' as u8{continue;}
            dp[i][j] = (dp[i-1][j]+dp[i][j-1])%MOD;
        }
    }
    println!("{}",dp[m][n]);
}

Measured memory_bytes: 8444
#include<cstdio>
long long a[105];

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++) scanf("%lld",&a[i]);
    long long have = 1000;
    int p = 1;
    while(p<=n){
        int np = p;
        while(np+1<=n && a[np+1]>=a[np]) np++;
        long long count = have/a[p];
        have -= count*a[p];
        have += count*a[np];
        p = np+1;
    }
    printf("%lld\n",have);
    return 0;
}


Measured memory_bytes: 1676
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,m; cin >> n >> m;
  vi imos(n);
  rep(i,m){
    int a,b; cin >> a >> b;
    if(b < a) swap(a,b);
    imos[--a]++;
    imos[--b]--;
  }
  rep(i,n-1) imos[i+1] += imos[i];
  rep(i,n){
    if(imos[i]%2 != 0){
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES";
  cout << "\n";
  return 0;
}


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

  int N  ;
  cin >> N ;
  vector<int> A(N) ;
  vector<int> B(N) ;
  rep(i,N) cin >> A.at(i) ;
  rep(i,N) cin >> B.at(i) ;
  int array[N];
  rep(i,N) array[i] = i+1 ;
  int j = 0 ;
  int k = 0 ;
  int a = 0 ;
  int b = 0 ;
  int count = 0 ;
  do{
    j++ ;
    count = 0 ;
        for(int i=0; i<N; i++){
            if(array[i]==A[i]) count++ ;
            if(count == N ) a = j ; 
        }
    }while(next_permutation(array,array+N));
  count = 0 ;
  do{
    k++ ;
    count = 0 ;
        for(int i=0; i<N; i++){
            if(array[i]==B[i]) count++ ;
            if(count == N ) b = k ; 
        }
    }while(next_permutation(array,array+N));
  cout << abs(b - a ) << endl ; 
 }


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

using namespace std;

#define ll long long

void solve() {
	int a, b;
	cin >> a >> b;
	int c = 1;
	while(a--) {
		int x = c*2;
		int y = c+b;
		if (x > y) {
			c = y;
		} else {
			c = x;
		}
	}
	cout << c << "\n";
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



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

int main(){
  ll N,K,ans=0;
  cin>>N>>K;
  ll A[N];
  for(ll i=0;i<N;i++) cin>>A[i];
  if(N==K) ans=1;
  else{
    ans+=(N-K)/(K-1)+1;
    if((N-K)%(K-1)!=0) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 1e11;
const ll bits = 62;
const ll mod = 1e9+7;
const ld pi = 3.14159265358979323846;


int main(){
    FASTIO;
    PRECISION;

    int h,a;
    cin>>h>>a;


    int ans =h/a;

    if(ans*a!=h){
        ans++;
    }

    cout<<ans<<"\n";

}

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

const int INF = 10000;

int N;
int A[210];

int main() {
    cin >> N;
    for(int i = 0; i < N; ++i) cin >> A[i];
    
    int res = INF;
    
    for(int i = 0; i < N; ++i) {
        int count = 0;
        
        while(A[i] % 2 == 0) {
            A[i] /= 2;
            ++count;
        }
        if(res > count) res = count;
    }
    
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int r, g, b, n;
  cin >> r >> g >> b >> n;

  int ans = 0;
  for (int i = 0; i * r <= n; i++) {
    for (int j = 0; i * r + j * g <= n; j++) {
      if ((n - (i * r + j * g)) % b == 0) ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(15);
vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	int a,b,c;
	cin >> a >> b >> c;
	cout << min(c,b/a) << endl;
}

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

template<typename T>
void chmin(T& a, T b){
  a = min(a,b);
}

void solve(){
  int N;
  cin >> N;
  vector<long long> A(N);
  for(int i = 0; i < N; ++i){
    cin >> A[i];
  }
  string S;
  cin >> S;
  // S の最後が '1' で，A.back() != 0 -> 1
  // A.back() == 0 だったら勝敗はそこで変わらないので，N = N-1 としても変わらない
  // S.back() == '0' and A.back() != 0 -> ?

  vector<long long> base;
  for(int i = N-1; i >= 0; --i){
    long long e = A[i];
    if(S[i] == '0'){
      for(auto b : base)
        chmin(e, e^b);
      if(e)
        base.push_back(e);
    }else{
      vector<long long> base_;
      for(auto b : base){
        if((e^b) < e){
          e ^= b;
        }else{
          base_.push_back(b);
        }
      }
      if(e != 0){
        puts("1");
        return;
      }
      base_.push_back(A[i]);
    }
    // cerr << "base : ";
    // for(auto e : base){
    //   cerr << e << " ";
    // }
    // cerr << endl;
    if(base.empty()){
      puts("1");
      return;
    }
  }
  if(base.size()) puts("0");
  else puts("1");
}

int main(){
  int t;
  cin >> t;
  while(t--){
    solve();
  }
}


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

int d[200][200],s[200];
int main() {
	int n,m,r;scanf("%d%d%d",&n,&m,&r);
	memset(d,0x3f,sizeof(d));
	rep(i,n)d[i][i]=0;
	rep(i,r)scanf("%d",&s[i]),s[i]--;
	rep(i,m){
		int a,b,c;scanf("%d%d%d",&a,&b,&c);a--;b--;
		d[a][b]=d[b][a]=c;
	}
	rep(k,n)rep(i,n)rep(j,n)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	vector<int>v(r);rep(i,r)v[i]=i;
	int Min=INT_MAX;
	do{
		int cnt=0;
		rep(i,v.size()-1)cnt+=d[s[v[i]]][s[v[i+1]]];
		Min=min(Min,cnt);
	}while(next_permutation(v.begin(),v.end()));
	cout<<Min<<endl;
}


Measured memory_bytes: 384
import types

_atcoder_code = """
# Python port of AtCoder Library.

__version__ = '0.0.1'
"""

atcoder = types.ModuleType('atcoder')
exec(_atcoder_code, atcoder.__dict__)

_atcoder_dsu_code = """
import typing


class DSU:
    '''
    Implement (union by size) + (path compression)
    Reference:
    Zvi Galil and Giuseppe F. Italiano,
    Data structures and algorithms for disjoint set union problems
    '''

    def __init__(self, n: int = 0):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a: int, b: int) -> int:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        x = self.leader(a)
        y = self.leader(b)

        if x == y:
            return x

        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x

        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x

        return x

    def same(self, a: int, b: int) -> bool:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        return self.leader(a) == self.leader(b)

    def leader(self, a: int) -> int:
        assert 0 <= a < self._n

        if self.parent_or_size[a] < 0:
            return a

        self.parent_or_size[a] = self.leader(self.parent_or_size[a])
        return self.parent_or_size[a]

    def size(self, a: int) -> int:
        assert 0 <= a < self._n

        return -self.parent_or_size[self.leader(a)]

    def groups(self) -> typing.List[typing.List[int]]:
        leader_buf = [self.leader(i) for i in range(self._n)]

        result = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)

        return list(filter(lambda r: r, result))
"""

atcoder.dsu = types.ModuleType('atcoder.dsu')
exec(_atcoder_dsu_code, atcoder.dsu.__dict__)
DSU = atcoder.dsu.DSU

import sys
input = sys.stdin.readline

# from atcoder.dsu import DSU

n, q = map(int,input().split())
C = [list(map(int,input().split())) for i in range(q)]

D = DSU(n)
for i in range(q):
    if C[i][0] == 0:
        D.merge(C[i][1], C[i][2])
    else:
        print(int(D.same(C[i][1], C[i][2])))


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

const int N = 1e5 + 5;
const int M = N * 2;

int fir[N], ne[M], to[M], cnt = 1, L[N], R[N], K, x, y, n;
int Num[N];

void add(int x, int y) {
	ne[++ cnt] = fir[x];
	fir[x] = cnt;
	to[cnt] = y;
}

void link(int x, int y) {
	add(x, y);
	add(y, x);
}

#define Foreachson(i, x) for(int i = fir[x]; i; i = ne[i])

void dfs(int x, int f, int l, int r) {
	l = max(l, L[x]);
	r = min(r, R[x]);
	L[x] = l, R[x] = r;
	Foreachson(i, x) {
		int V = to[i];
		if(V == f) continue;
		dfs(V, x, l - 1, r + 1);
	}
}

void dfs2(int x, int f) {
	Foreachson(i, x) {
		int V = to[i];
		if(V == f) continue;
		dfs2(V, x);
		L[x] = max(L[x], L[V] - 1);
		R[x] = min(R[x], R[V] + 1);
	}
}

void getNum(int x, int f, int g) {
	Foreachson(i, x) {
		int V = to[i];
		if(V == f) continue;
		getNum(V, x, g ^ 1);
	}
	if(Num[x] != -1 && g != Num[x]) exit(0 * puts("No"));
}

int main() {
	cin >> n;
	for(int i = 1;  i < n; ++ i)
	scanf("%d%d", &x, &y), link(x, y);
	for(int i = 1; i <= n; ++ i) L[i] = -1e9, R[i] = 1e9, Num[i] = -1;
	
	cin >> K;
	for(int i = 1; i <= K; ++ i) {
		scanf("%d%d", &x, &y);
		L[x] = R[x] = y;
		Num[x] = (y & 1);
	}
	getNum(x, 0, Num[x]);
	dfs(1, 0, -2000000000, 2000000000);
	dfs2(1, 0);
	dfs(1, 0, -2000000000, 2000000000);
	dfs2(1, 0);
	for(int i = 1; i <= n; ++ i) if(L[i] > R[i]) return 0 * puts("No");;
	puts("Yes");
	for(int i = 1; i <= n; ++ i)
	printf("%d\n", L[i]);
}

Measured memory_bytes: 14700
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int k; cin>>k;
  ll a[k]; rep(i,k) cin>>a[i];
  ll l = 2, r = 2;
  REP(i,k){
    l = (l+a[i]-1)/a[i] * a[i];
    if(l>r) return cout<<-1<<endl, 0;
    r = (r/a[i]+1)*a[i]-1;
  }
  cout << l SP r << endl;

  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n,a,b,ans;
		
		n=sc.nextLong();
		a=sc.nextLong();
		b=sc.nextLong();
		if(a + b != 0){
			ans=n/(a+b);
			n%=a+b;
			ans*=a;
			if (n<a){
				ans+=n;
			}else{
				ans+=a;
			}
		} else {
			ans=(long)0;
		}

		System.out.println(ans);
		sc.close();
	}
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;

int main(){
  ll d,g;
  cin >> d >> g;
  vector<ll> P(d),C(d),A(d);
  rep(i,d)cin>>P.at(i)>>C.at(i);
  rep(i,d)A.at(i) = 100*P.at(i)*(i+1)+C.at(i);

  ll res = (1<<30);
  for(int bit = 0; bit < (1<<d); bit++){
    ll sum = 0, num = 0;
    rep(i,d){
      if(bit&(1<<i)){
          sum+=A.at(i);
          num+=P.at(i);
      }
    }
    if(sum>=g)res=min(res,num);
    else{
      for(int i = d-1; i >= 0; i--){
        if(bit&(1<<i))continue;
        for(int j = 0; j< P.at(i); j++){
          if(sum>=g)break;
          sum += 100*(i+1);
          num++;
        }
      }
      res = min(res,num);
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
const long long mod = 1000000007;
long long mp(long long b, long long e) {
	if (e == 0) return 1;
	long long a = mp(b, e / 2);
	a = a * a % mod;
	if (e % 2) a = a * b % mod;
	return a;
}
int main() {
	long long fac[2000002], inv[2000002];
	fac[0] = 1;
	for (int i = 1; i <= 2000001; ++i) fac[i] = fac[i - 1] * i % mod;
	for (int i = 0; i <= 2000001; ++i) inv[i] = mp(fac[i], mod - 2);
	int r1, r2, c1, c2;
	scanf("%d %d %d %d", &r1, &c1, &r2, &c2);
	long long ans = 0;
	for (int c = c1; c <= c2; ++c) ans += fac[r2 + c + 1] * inv[r2] % mod * inv[c + 1] % mod - fac[r1 + c] * inv[r1 - 1] % mod * inv[c + 1] % mod, ans %= mod;
	printf("%lld", (ans + mod) % mod);
	return 0;
}

Measured memory_bytes: 31360
// C - /\/\/\/
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define allr(x) (x).rbegin(),(x).rend()
#define fst first
#define snd second

int main(){
	int N; cin>>N;
	vector<pair<int,int>> E(100000),O(100000);//[value]<count,value>
	rp(i, 0, N/2){
		int e,o; scanf("%d%d",&e,&o); e--;o--;
		E[e].fst++; E[e].snd = e+1;
		O[o].fst++; O[o].snd = o+1;
	}
	sort(allr(E)); sort(allr(O));
	int ans = N;
	ans -= E[0].snd != O[0].snd? E[0].fst + O[0].fst:
		max(E[0].fst + O[1].fst, E[1].fst + O[0].fst);
	cout<< ans <<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define reg register
#define maxn 200001
using namespace std;
int nt[maxn << 1], fi[maxn], go[maxn], d[maxn], rt;
int dp[maxn], n, sum, sumx, siz[maxn], ans, cnt;
char s[maxn];
vector<int> Q[maxn];
inline int  read() {
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
void add(int u, int v){
	nt[++cnt] = fi[u]; fi[u] = cnt; go[cnt] = v;
}
void dfs(int u, int fa){
	siz[u] = (s[u] == 'W'); 
	for(int i = fi[u]; i; i = nt[i]){
		int v = go[i]; if(v == fa) continue;
		dfs(v, u); siz[u] += siz[v];
		if(siz[v] != ans && siz[v] != 0){
			Q[u].push_back(v); Q[v].push_back(u);
		}
	}
}
void find(int x, int fa){
	sum += 2;  d[x] = 0;
	if(s[x] == 'W' && Q[x].size() % 2 == 0) sum += 1, d[x] = 2;
	if(s[x] == 'B' && Q[x].size() % 2 == 1) sum += 1, d[x] = 2;
	for(int i = 0; i < Q[x].size(); i++){
		int v = Q[x][i]; if(v == fa) continue;
		find(v, x);
	}
}
void solve(int x, int fa){
	dp[x] = d[x];
	for(int i = 0; i < Q[x].size(); i++){
		int v = Q[x][i]; if(v == fa) continue;
		solve(v, x); 
        sumx = max(sumx , dp[x] + dp[v]);
        dp[x] = max(dp[x] , dp[v] + d[x]);
	}
}
int main()
{
	n = read();
	for(int i = 1; i < n; i++){
		int x = read(), y = read();
		add(x, y); add(y, x);
	}
	scanf("%s", s + 1);
	for(int i = 1; i <= n; i++) {
		ans += ((s[i] == 'W') ? 1 : 0);
		if(s[i] == 'W') rt = i;
	}
    if(ans < 2) return printf("%d\n" , ans) & 0;
	dfs(1, 0);  find(rt, 0);
	sum = sum - 2; 	solve(rt, 0);
	cout << sum - sumx << endl;
	return 0;
}

Measured memory_bytes: 23012
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 10;
int a[maxn][maxn],n,m;
char s[maxn][maxn];
int dp[maxn][maxn];
int main() {
	scanf("%d%d",&n,&m);
	for (int i = 1; i <= n; i++)
		scanf("%s",s[i] + 1);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++)
			if (s[i][j] == '.')	a[i][j] = 0;
			else a[i][j] = 1;
	}
	memset(dp,0x3f,sizeof dp);
	dp[1][1] = a[1][1];
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (a[i][j] == 0) {
				if (i > 1) dp[i][j] = dp[i - 1][j];
				if (j > 1) dp[i][j] = min(dp[i][j],dp[i][j - 1]);
			}
			if (a[i][j] == 1) {
				if (i > 1) {
					if (a[i - 1][j] == 1) dp[i][j] = dp[i - 1][j];
					else dp[i][j] = dp[i - 1][j] + 1;
				}
				if (j > 1) {
					if (a[i][j - 1] == 1) dp[i][j] = min(dp[i][j],dp[i][j - 1]);
					else dp[i][j] = min(dp[i][j],dp[i][j - 1] + 1);	
				}
			}
		}
	}
	printf("%d\n",dp[n][m]);
}
/*
20
23113123123132231123
*/

Measured memory_bytes: 384
#include<iostream>
#include<vector>
using namespace std;
int main(void){
	int w;
	cin>>w;
	vector<int> a(w+2),d1(w+2,-1e9),d2(w+2,-1e9);
	for(int i=1;i<w+1;i++){
		cin>>a[i];
	}
	for(int i=1;i<w+1;i++){
		if(a[i]==0)d1[i]=1e9;
		else if(a[i]>0)d1[i]=d1[i-1]-1;
		else d1[i]=min(d1[i-1]-1,-a[i]);
	}
	for(int i=w;i>0;i--){
		if(a[i]==0)d2[i]=1e9;
		else if(a[i]>0)d2[i]=d2[i+1]-1;
		else d2[i]=min(d2[i+1]-1,-a[i]);
	}
	
int ans=0;
for(int i=1;i<w+2;i++){
	ans+=max(0,min(a[i],max(d1[i],d2[i])));
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3892
N,X = map(int,input().split())
Ls = list(map(int,input().split()))

ret = 0
Ds = []

for i in range(N+1):
  if i==0:
    Ds.append(0)
  else:
    Ds.append(Ds[-1]+Ls[i-1])
  if Ds[-1]<=X:
    ret += 1
    continue
print(ret)


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

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

	long long lucas[n+1];

	lucas[0]=2; lucas[1]=1;
	for (int i=2; i<n+1; ++i) {
		lucas[i] = lucas[i-1] + lucas[i-2];
	}

	cout << lucas[n] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n; cin >> n;
  vector<pair<ll, ll>> pairs;
  for(ll i=0; i<n; i++){
    ll a,b;cin >> a >> b;
    pairs.push_back(make_pair(a,b));
  }
  sort(pairs.begin(),pairs.end());
  ll ans = 0;
  ll x1 = pairs.at(0).first;
  ll l1 = pairs.at(0).second;
  for(ll i=1; i<n; i++){
    ll x2 = pairs.at(i).first;
    ll l2 = pairs.at(i).second;
    if(x1+l1<=x2-l2){
      x1 = x2;
      l1 = l2;
      continue;
    }else{
      ans++;
      if(x1+l1<=x2+l2){
      }else{
        x1 = x2;
        l1 = l2;
      }
    }
  }
  cout << n-ans << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ar array
 
const int mxN=2e5, M=998244353;
int n;
ar<int, 2> a[mxN];
ll dp[mxN+1];
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
 
	cin >> n;
	for(int i=0; i<n; ++i)
		cin >> a[i][0] >> a[i][1];
	sort(a, a+n);
	dp[n]=1;
	vector<ar<int, 2>> st{{n, (int)2e9}};
	for(int i=n-1; ~i; --i) {
		//int p=lower_bound(a, a+n, ar<int, 2>{a[i][0]+a[i][1], 0})-a;
		//dp[i]=dp[p];
		while(st.back()[1]<a[i][0]+a[i][1])
			st.pop_back();
		int p=st.back()[0];
		dp[i]=dp[p];
		st.push_back({i, a[i][0]});
		//cout << i << " " << p << endl;
		dp[i]=(dp[i]+dp[i+1])%M;
	}
	cout << dp[0];
}
// not my code but nice ans







Measured memory_bytes: 4340
def main():
    N = int(input())
    A = [list(map(int, input().split(' '))) for _ in range(2)]
    ans = 0
    for j in range(N):
        ans = max([ans, sum(A[0][:(j+1)]) + sum(A[1][j:])])
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define rep(x, a, b) for(int x = (a); x <= (b); ++x)
#define rop(x, a, b) for(int x = (a); x < (b); ++x)
#define per(x, a, b) for(int x = (a); x >= (b); --x)
using namespace std;
typedef long long LL;
typedef double DB;
int n, as, a[100005], b[100005];
int main() {
	scanf("%d", &n);
	rep(i, 1, n) {
		scanf("%d", &a[i]); b[i] = a[i];
	}
	sort(b + 1, b + 1 + n);
	rep(i, 1, n) {
		a[i] = lower_bound(b + 1, b + 1 + n, a[i]) - b;
		if((a[i] ^ i) & 1) as++;
	}
	printf("%d\n", as / 2);
	return 0;
}


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

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")



using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int res=0,res2=0;
    int a,b;
    cin>>a>>b;
    res2=a;
    if(b==1)
    {
        cout<<0<<'\n';
        return 0;
    }
    while(res2<b)
    {
        res2=(res2-1)+a;
        res++;
    }
    cout<<res+1<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
//#include <function>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main() {

  string ATCG;
  cin >> ATCG;

  int count = 0;
  int max_count = 0;
  bool flag = true;
  for(auto ss : ATCG){
    if (ss == 'A' || ss == 'C' || ss == 'G' || ss == 'T'){
      count++;
    }else {
      max_count = max(max_count, count);
      count = 0;
    }
  }
  max_count = max(max_count, count);
  cout << max_count << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
typedef long long int ll;
#define FOR(i,a,n) for(int i=a;i<n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end();
#define pos std::pair<int,int>
const int INF = 1LL << 30;
const int INF_ = 0 - INF;
const ll LLINF = 1LL << 60;
int main() {
	int x, y, z;
	std::cin >> x >> y >> z;
	x -= z;
	std::cout << x / (y+z) << std::endl;
	return 0;
 
}

Measured memory_bytes: 256
n=int(input())
x=[]
for i in range(n):
    a=int(input())
    x.append([])
    for j in range(a):
        x[-1].append(list(map(int,input().split())))
ans=0
c=2**n-1
for i in range(2**n):
    c+=1
    strc=str(bin(c))[3:]
    yn="Yes"
    for j in range(n):
        if strc[j]=="1":
            cnt=0
            for k in range(len(x[j])):
                if strc[x[j][k][0]-1]!=str(x[j][k][1]):
                    yn="No"
                    break
                else:
                    cnt+=1
            if cnt!=len(x[j]):
                break
    if yn=="Yes":
        ans=max(ans,strc.count("1"))
print(ans)


Measured memory_bytes: 3064
N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(list(set(A)))
max_v = B[-1]
max_c = A.count(max_v)
for i in range(N):
    tmp = A[i]
    if tmp != max_v:
        print(max_v)
    else:
        if max_c > 1:
            print(max_v)
        else:
            print(B[-2])


Measured memory_bytes: 17188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=2e5+10;
int a[maxn],b[maxn],n;
ll k;
bool check(ll limit)
{
    ll s=0;
    for(int i=1,j=n;i<=n;j--,i++)
    {
        if(1LL*a[i]*b[j]>limit)
        {
            ll d=1LL*a[i]*b[j]-limit;
            s+=(d+b[j]-1)/b[j];
        }
    }
    return s<=k;
}
int main()
{
    scanf("%d%lld",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
        scanf("%d",&b[i]);
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    ll l=0,r=1e13,ans=1e13;
    while(l<=r)
    {
        ll mid=(l+r)/2;
        if(check(mid))
            ans=mid,r=mid-1;
        else
            l=mid+1;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
char ch[4]={'R','Y','G','B'};
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=m;j++) putchar(ch[((i+j)/k&1)<<1|(i-j+m)/k&1]);
        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 512
import math
n = int(input())
xy = [list(map(int,input().split())) for _ in range(n)]
div = 1
for i in range(1,n):
  div *= (i+1)
ans = 0
for i in range(n):
  for j in range(n):
    if i == j:
      pass
    else:
      ans += math.sqrt((xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2)*div/n
print(ans/div)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define y1 y114514
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define pii pair<int, int>
#define M 1000000007
#define all(a) a.begin(), a.end()
typedef long long ll;

string s;
int n;
int cnt[26];

int main(){
	cin >> s;
	n = s.length();
	for(int i = 0; i < n; ++i) cnt[s[i] - 'a'] = 1;
	if(n < 26){
		int k = 0; while(cnt[k]) ++k;
		s = s + char('a' + k);
		cout << s;
	}else{
		int i = 0;
		while(i < 26 && s[i] == 'a' + 25 - i) ++i;
		if(i == 26) puts("-1");
		else{
			bool flag = 0;
			for(int i = 25; i >= 0; --i){
				for(int j = s[i] - 'a' + 1; j < 26; ++j)
					if(!cnt[j]){
						for(int k = 0; k < i; ++k) putchar(s[k]);
						putchar('a' + j);
						flag = 1;
						break;
					}
				if(flag) break;
				cnt[s[i] - 'a'] = 0;
			}
		}
	}
	
#ifndef ONLINE_JUDGE
	system("pause");
#endif
	return 0;
}


Measured memory_bytes: 504
#include <iostream>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    int a,s,d,f,g;

    cin>>a>>s>>d>>f>>g;
    
    if(a == 0){
        cout << 1<<endl;
    }else if(s==0){
        cout << 2<<endl;
    }else if(d ==0){
        cout << 3<<endl;
    }else if(f ==0){
        cout << 4<<endl;
    }else if(g ==0){
        cout << 5<<endl;
    }
    
    
}


Measured memory_bytes: 3636
import itertools
n,a,b,c=map(int,input().split())
l=[int(input()) for i in range(n)]
ans=[]
for j in itertools.product(range(4),repeat=n):
  LA=[];LB=[];LC=[]
  for k in range(n):
    if j[k]==0:LA.append(l[k])
    elif j[k]==1:LB.append(l[k])
    elif j[k]==2:LC.append(l[k])
  if LA==[] or LB==[] or LC==[]:
    pass
  else:
    ans.append(abs(a-sum(LA))+(len(LA)-1)*10+abs(b-sum(LB))+(len(LB)-1)*10+abs(c-sum(LC))+(len(LC)-1)*10)
print(min(ans))

Measured memory_bytes: 5032
# coding: utf-8
while True:
    try:
        x1 ,y1, x2, y2, x3, y3, xp, yp = map(float,raw_input().split())
        # ?????????z????????????????¨?????????????
        c1 = (x2-x1) * (yp-y2) - (y2-y1) * (xp-x2)
        c2 = (x3-x2) * (yp-y3) - (y3-y2) * (xp-x3)
        c3 = (x1-x3) * (yp-y1) - (y1-y3) * (xp-x1)
        if all((c1>0,c2>0,c3>0)) or all((c1<0,c2<0,c3<0)):
            print 'YES'
        else:
            print 'NO'
    except EOFError:
        break

Measured memory_bytes: 4244
package main
import "fmt"
func main(){
    // Your code here!
    var (
        a int
        b int
        c int
        d int
    )
    fmt.Scan(&a, &b, &c)
    if a > b {
        d = a
        a = b
        b = d
    }
    if b > c {
        d = b
        b = c
        c = d
    }
    if a > b {
        d = a
        a = b
        b = d
    }
    fmt.Println(a, b, c)
}



Measured memory_bytes: 1108
#include<bits/stdc++.h>
using namespace std;
map<int,int>ma;
#define ss second
#define ff first

long long cal(long long a){
	if(a%4==1)return 1;
	else if(a%4==2)return a+1;
	else if(a%4==3)return 0;
	else return a;
}

int main(){
	long long a,b;
	scanf("%lld %lld",&a,&b);
	if(a)a=cal(a-1);
	if(b)b=cal(b);
	printf("%lld\n",a^b);
}

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

int main(){
  int k,t;
  cin>>k>>t;
  vector<int> a(t);
  int sum=0;
  int mx=0;
  for(int i=0;i<t;i++){
    cin>>a[i];
    sum+=a[i];
    mx=max(mx,a[i]);
  }
  int ans=mx-(sum-mx);
  if(ans<2){
    ans=0;
  }else{
    ans--;
  }
  cout<<ans<<endl;
  return 0;
}


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


int main()
{
	ll n,k;
	cin>>n>>k;
	ll h[n+1];
	for (int i = 1; i <= n; ++i)
	{
		cin>>h[i];
	}
	ll dp[n+1];
	memset(dp,9999999,sizeof(dp));
	dp[1]=0;
	for (int i = 1; i <= n; ++i)
	{
		for(int j=1;j<=k;j++)
		{
			if(i+j<=n)
			{
				dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
			}
		}
		
	}
	cout<<dp[n]<<endl;
}

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

int s[2005];
long long modd = 1e9+7;
long long num1[2005];
long long num2[2005];

typedef long long ll;

ll qpow(ll a, ll n)//计算a^n % mod
{
    ll re = 1;
    while(n)
    {
        if(n & 1)//判断n的最后一位是否为1
            re = (re * a) % modd;
        n >>= 1;//舍去n的最后一位
        a = (a * a) % modd;//将a平方
    }
    return re % modd;
}
ll inv(ll x){
	return qpow(x,modd-2);
}

int main()
{
    memset(num1, 0, sizeof(num1));
    memset(num2, 0, sizeof(num2));
	int n;
	long long k;
    scanf("%d%lld", &n, &k);
    bool falg = false;
	for(int i = 0; i < n; i++){
    	scanf("%d", &s[i]);
	}
    long long ans = 0;
    for(int i = 0; i < n-1; i++){
    	for(int j = i+1; j < n; j++){
    		if(s[i]>s[j]) num1[i]++;
		}
	}
    for(int i = n-1; i > 0; i--){
    	for(int j = i-1; j >= 0; j--){
    		if(s[i]>s[j]) num2[i]++;
		}
	}
	long long kk = 0;
	kk = ((((1+k)*k))/2)%modd;
	//cout << kk << endl;
	for(int i = 0; i < n; i++){
		ans = (ans + num1[i]*kk%modd + num2[i]*(kk-k)%modd+modd)%modd;
		
	}
	
	printf("%lld\n", ans);
    return 0;
}
/*


*/

Measured memory_bytes: 256
<?php
list($a,$b,$m)=explode(" ",trim(fgets(STDIN)));
$s=explode(" ",trim(fgets(STDIN)));
$t=explode(" ",trim(fgets(STDIN)));
$ans=min($s)+min($t);
$i=0;
while($i<$m){
  list($x,$y,$c)=explode(" ",trim(fgets(STDIN)));
  $sum=$s[$x-1]+$t[$y-1]-$c;
  if($sum<$ans){
    $ans=$sum;
  }
  ++$i;
}
echo $ans;

Measured memory_bytes: 20980
"""
クエリにO(k)で答えたい
あらかじめdをmでmodしておく

aj >= aj+1 (すなわち、jが条件を満たさない)となるのは、
dが0の時と、aj+d > m の時である。

よって、0が出る回数 & mの倍数をいくつ超えるかを計算すればよい
それをnから引く
"""

k,q = map(int,input().split())

d = list(map(int,input().split()))

for loop in range(q):

    n,x,m = map(int,input().split())
    x %= m

    nd = []
    for i in d:
        nd.append(i % m)

    znum = [0]
    lsum = [0]

    for i in nd:
        if i == 0:
            znum.append(znum[-1] + 1)
        else:
            znum.append(znum[-1])

        lsum.append(lsum[-1] + i)


    zpick = ((n-1) // k) * znum[-1] + znum[(n-1) % k]
    lpick = (x + ((n-1) // k) * lsum[-1] + lsum[(n-1) % k]) // m

    print (n-1 - zpick - lpick)


Measured memory_bytes: 119388
#include<iostream>
#include<stdio.h>
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()

int my_abs(int a, int b){
    if((a-b) >= 0) return (a-b);
    else return(-(a-b));
}

int main(){
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;

    if(my_abs(a, c) <= d) printf("Yes");
    else if(my_abs(a, b) <= d && my_abs(b, c) <= d) printf("Yes");
    else printf("No");

    return 0;    
}

Measured memory_bytes: 256