akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
const int INF = 1e9+1;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}

int N;


int main() {
    cin >> N;
    vector<int> x(N+1,0), y(N+1,0), t(N+1,0);
    for (int i = 1; i <= N; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }
    for (int i = 0; i < N; i++) {
        int d = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
        int td = t[i+1]-t[i];
        if (td < d || abs(td - d) % 2 != 0) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";


}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
struct Edge
{
    ll to;
    ll weight;
    Edge(ll t, ll w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

vector<ll> dijkstra(Graph &G, ll start)
{
    vector<ll> dist(G.size(), INF);
    priority_queue<P, vector<P>, greater<P>> que;
    dist[start] = 0;
    que.push({dist[start], start});
    while (!que.empty())
    {
        ll cost = que.top().first;
        ll idx = que.top().second;
        que.pop();
        if (dist[idx] < cost)
            continue;

        for (auto e : G[idx])
        {
            if (dist[e.to] <= cost + e.weight)
                continue;
            dist[e.to] = cost + e.weight;
            que.push({dist[e.to], e.to});
        }
    }
    return dist;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--, t--;
    Graph G1(n), G2(n);
    for (int i = 0; i < m; i++)
    {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--, v--;
        G1[u].push_back({v, a});
        G1[v].push_back({u, a});
        G2[u].push_back({v, b});
        G2[v].push_back({u, b});
    }

    vector<ll> fromStart = dijkstra(G1, s);
    vector<ll> toEnd = dijkstra(G2, t);

    vector<ll> ans(n);
    ll cost = INF;
    int idx = n - 1;
    for (int i = n - 1; i >= 0; i--)
    {
        ll tmpCost = fromStart[i] + toEnd[i];
        if (tmpCost <= cost)
        {
            cost = tmpCost;
            idx = i;
        }
        ans[i] = cost;
    }

    for (int i = 0; i < n; i++)
    {
        cout << 1000000000000000 - ans[i] << endl;
    }
    return 0;
}

// 両替を都市iで行う場合，kenkooooさんが支払う金額は「sからiに円による支払いで移動する際の最小の金額」と「iからtにスヌークによる支払いで移動する際の最小の金額」スヌークになる．これらの和を最小化するような都市iを求めればよい．「sからiに円による支払いで移動する際の最小コスト」と「tからiにスヌークによる支払いで移動する際の最小コスト」が求まればよい．（iからtへの最短経路長とtからiへの最短経路長は等しい）sから各iへの最短経路長はダイクストラ法を用いるとO((n + m)logn)程度で求めることが出来る．tからiへの最短経路長も同様．

// 候補がどんどん減っていく順に考えると大変なためこういう時は候補がどんどん増えていく順に考えるようにする．例えば，n-1年後は都市nで両替するしかない->n-2年後はnかn-1のコストが小さい方，n-3年後は前の答えとn-2のminのように決定していくことが出来る．


Measured memory_bytes: 21084
n, k = gets.split.map(&:to_i)
mod = 10 ** 9 + 7

a = b = 0

ans = 0
1.upto(n + 1) do |i|
    a += i - 1
    b += n - i + 1
    ans = (ans + b - a + 1) % mod if i >= k
end

puts ans

Measured memory_bytes: 14416
N,M = map(int,input().split())
*P, = map(int,input().split())
XY = [list(map(int,input().split())) for _ in [0]*M]

def get_Parent(n):
    if Parent[n] == -1:return n
    par = get_Parent(Parent[n])
    Parent[n] = par
    return par
def merge(x,y):
    x = get_Parent(x)
    y = get_Parent(y)
    if x!=y: Parent[y] = x
    return
def is_united(x,y):
    return get_Parent(x)==get_Parent(y)

Parent = [-1]*N
for x,y in XY:
    x-=1
    y-=1
    merge(x,y)
print(sum(is_united(i,p-1) for i,p in enumerate(P)))

Measured memory_bytes: 34520
#include<stdio.h>

int main(void)
{
 int S,h,m,s;
 scanf("%d",&S);
 h=S/3600;
 m=(S-3600*h)/60;
 s=S-h*3600-m*60;
 printf("%d:%d:%d\n",h,m,s);

}

Measured memory_bytes: 2740
#include <bits/stdc++.h>
#include <atcoder/dsu>
using namespace std;
using namespace atcoder;
int main(){
  int N;
  cin >> N;
  vector<int> x(N), y(N);
  for (int i = 0; i < N; i++){
    cin >> x[i] >> y[i];
  }
  vector<tuple<int, int, int>> P(N);
  for (int i = 0; i < N; i++){
    P[i] = make_tuple(y[i], x[i], i);
  }
  sort(P.begin(), P.end());
  set<pair<int, int>> st;
  dsu E(N);
  for (int i = 0; i < N; i++){
    int X = get<1>(P[i]);
    int id = get<2>(P[i]);
    st.insert(make_pair(X, id));
  }
  for (int i = 0; i < N; i++){
    int X = get<1>(P[i]);
    int id = get<2>(P[i]);
    auto itr = st.upper_bound(make_pair(X, id));
    while (itr != st.end()){
      int id2 = (*itr).second;
      if (E.same(id, id2)){
        break;
      }
      E.merge(id, id2);
      itr++;
    }
    st.erase(make_pair(X, id));
  }
  for (int i = 0; i < N; i++){
    cout << E.size(i) << endl;
  }
}

Measured memory_bytes: 17164
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)
const long long int MOD = 1000000007;

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

	rep(i, 5) {
		int a;
		cin >> a;
		if (a == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3668
program reconciled;
uses math;
const
  md: int64 = 1000000007;
  f20000: int64 = 368774859;
  f40000: int64 = 422550956;
  f60000: int64 = 309944332;
  f80000: int64 = 65533322;
function fact(n: int64): int64;
var
  i, k, f: int64;
begin
  f := f80000;
  k := 80001;
  if n < 80000 then
  begin
    f := f60000;
    k := 60001;
  end;
  if n < 60000 then
  begin
    f := f40000;
    k := 40001;
  end;
  if n < 40000 then
  begin
    f := f20000;
    k := 20001;
  end;
  if n < 20000 then
  begin
    f := 1;
    k := 1;
  end;
  for i := k to n do
    f := i*f mod md;
  fact := f;
end;
var
  n, m, x: int64;
begin
  read(n, m);
  if abs(n-m) > 1 then
  begin
    writeln(0);
    halt(0);
  end;
  x := ifthen(n = m, 2, 1);
  x := x*fact(n) mod md;
  x := x*fact(m) mod md;
  writeln(x);
end.

Measured memory_bytes: 128
a,b,h,m = gets.split.map(&:to_i)
t = 60*h + m
aa = (t.to_f/2) - (t/720)*360
ab = (6*t)%360
angle = (aa-ab).abs
angle = 360 - angle if angle > 180
angle *= (Math::PI/180)
puts Math.sqrt(a**2 + b**2 - 2*a*b*Math.cos(angle))

Measured memory_bytes: 14728
use std::vec::Vec;
use std::cmp::min;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 3);
  (v[0], v[1], v[2])
}

fn main() {
  let (n, a, b) = read_touple::<usize>();
  let x: Vec<usize> = read_vec();
  let mut life = 0;
  let di = diff(&x, n);

  for &e in &di {
    if e * a < b {
       life += e * a;
    } else {
      life += b;
    }
  }
  println!("{}", life);
}

fn diff(v: &Vec<usize>, n: usize) -> Vec<usize> {
  let mut res = Vec::new();
  for i in 0..n-1 {
    res.push(v[i+1] - v[i]);
  }
  res
}

Measured memory_bytes: 9464
#include <stdio.h>
int main() {
  int ans,n,b,a,w,t,r,k;
  a=0;
  w=0;
  t=0;
  k=0;
  r=0;
  char s[10];    
  
  scanf("%d",&n);
  for(k=0;k<n;k++)
  {
	scanf("%s",s);
  	{
    	if(s[0]=='A')
    {
        a++;
    }
    	else if(s[0]=='W')
    {
    	w++;
    }
    	else if(s[0]=='T')
    {
    	t++;
    }
    	else
    {
		r++;
    }
    }
  }
  printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",a,w,t,r);
    
  return 0;
}

Measured memory_bytes: 1696
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;

int a[maxn];
int b[maxn];

bool cmp(int a, int b){
	return a > b;
}
int main(){
	int n ,m ;
	cin >> n >> m;
	long long sum = 0;
	for(int i = 1 ; i <= m ; i++)
		scanf("%d",a + i);
	sort(a+1,a+1+m);
	for(int i = 1 ; i < m ; i++){
		b[i] = abs(a[i+1] - a[i]);
		sum += b[i];
	}
	sort(b+1,b+m,cmp);

	for(int i = 1 ; i < n ; i++)
		sum -= b[i];
	cout << sum << endl;
}

Measured memory_bytes: 1024
from bisect import *
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

left = 0
right = 200001

while right - left > 1:
    mid = left + (right - left) // 2
    count = 0
    for i in range(n-1, -1, -1):
        count += n - bisect_left(a, mid - a[i])
        if count >= m:
            break


    if m <= count:
        left = mid
    else:
        right = mid

    #print(mid, count)

ans = 0
a_accum = [0]
for i in range(n):
    a_accum.append(a_accum[i] + a[-1-i])


for i in range(n-1, -1, -1):
    count = n - bisect_left(a, left - a[i])
    ans += a_accum[count] + a[i] * count
    m -= count


ans += left * m
print(ans)


Measured memory_bytes: 60236
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MAX_V=114514LL;
const ll MAX = 510000LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

//const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  ll n;cin>>n;
  vl a(n+1);
  rep(i,n+1)cin>>a[i];
  COMinit();
  map<ll,ll>M;
  ll key=-1;
  rep(i,n+1){
    M[a[i]]++;
  }
  for(auto p:M){
    if(p.second==2)key=p.first;
  }
  ll id1=-1,id2=-1;
  rep(i,n+1){
    if(a[i]==key&&id1==-1){
      id1=i;
    }
    else if(a[i]==key){
      id2=i;
    }
  }
  ll point=id1-0+n-id2;
  for(ll i=1;i<=n+1;i++){
    if(point+1<i){
      cout<<COM(n+1,i)<<endl;
    }
    else {
      ll ans=COM(n+1,i);
      ll d=COM(point,i-1);
      ans=ans+MOD-d;
      ans%=MOD;
      cout<<ans<<endl;
    }
  }
}



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

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

using namespace std;

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

	int cnt[4]={};
	for(char c:s){
		if     (c=='N') cnt[0]++;
		else if(c=='S') cnt[1]++;
		else if(c=='E') cnt[2]++;
		else if(c=='W') cnt[3]++;
	}

	bool ok=true;
	if(cnt[0]*cnt[1]==0 && cnt[0]+cnt[1]>0) ok=false;
	if(cnt[2]*cnt[3]==0 && cnt[2]+cnt[3]>0) ok=false;
	puts(ok?"Yes":"No");

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N, C;
    cin >> N >> C;
    vector<vector<long long>> D(C, vector<long long>(C)), c(N, vector<long long> (N));
    for(int i = 0; i < C; i++){
        for(int j = 0; j < C; j++) cin >> D[i][j];
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++) {
            cin >> c[i][j];
            c[i][j]--;
        }
    }
    vector<vector<long long>> cnt(3, vector<long long> (C));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            cnt[(i + j) % 3][c[i][j]]++;
        }
    }
    long long ans = 1e18;
    for(int i = 0; i < C; i++){
        for(int j = 0; j < C; j++){
            if(i == j) continue;
            for(int k = 0; k < C; k++){
                long long res = 0;
                if(i == k || j == k) continue;
                for(int l = 0; l < C; l++){
                    res += cnt[0][l] * D[l][i] + cnt[1][l] * D[l][j] + cnt[2][l] * D[l][k];
                }
                ans = min(ans, res);
            }
        }
    }
    cout << ans << endl;
}

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

int main(){
	int n;
	scanf("%d", &n);
	for(int i=0 ; i < n ; i++ ){
		int h, m;
		scanf("%d:%d", &h, &m);
		double s = h * 30.0 + m / 2.0 ;
		double l = m * 6.0 ;
		if( l < s ){
			swap( l , s );
		}
		double d = min( l-s , s-l+360.0 );
		if( d < 30.0 ){
			puts("alert");
		}else if( d < 90.0 ){
			puts("warning");
		}else{
			puts("safe");
		}
	}
}

Measured memory_bytes: 0
n,x = map(int, input().split())

tmp = 1
pat = 1
plist = [1]
bag_list = [1]
for i in range(n):
    tmp = 1 + tmp + 1 + tmp + 1
    pat = pat * 2 + 1
    bag_list.append(tmp)
    plist.append(pat)

def calc(x, nn):
    if x == 1:
        return 1 if nn == 0 else 0
    tt = bag_list[nn-1] + 2
    # print(nn,x,tt)
    if x == tt:
        # print(plist[nn-1] + 1)
        return plist[nn-1] + 1
    elif x == bag_list[nn]:
        # print(plist[nn])
        return plist[nn]
    elif x < tt:
        # print(0)
        return calc(x-1, nn-1)
    elif x > tt:
        # print(plist[nn-1] + 1)
        return calc(x-1-1-bag_list[nn-1], nn-1) + plist[nn-1] + 1

print(calc(x, n))


Measured memory_bytes: 3064
#include<stdio.h>

int main()
{
  int k, i, a, b, c, max_d;
  int tmp_a, tmp_b, tmp_c;
  int d[] = {1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 
             41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
  long sum = 0;
  
  scanf("%d", &k);
  
  for(a = 1; a <= k; a++)
  {
    for(b = 1; b <= k; b++)
    {
      for(c = 1; c <= k; c++)
      {
        tmp_a = a;
        tmp_b = b;
        tmp_c = c;
        for(i = 0; i < 26; i++)
        {  
          if(a == b && b == c)    
            max_d = a;
          
          else if(tmp_a % d[i] == 0 && tmp_b % d[i] == 0 && tmp_c % d[i] == 0)
          {
            tmp_a /= d[i];
            tmp_b /= d[i];
            tmp_c /= d[i];
            max_d *= d[i];
            i = 0;
          }
        }
        sum += max_d;
        max_d = 1;
      }
    }
  }
  
  printf("%ld", sum);
  
  return 0;
}

Measured memory_bytes: 1728
#include<iostream>
#include<string>
#include<vector>
#include<string>
using namespace std;


string want;
vector<string> print;
void init(){
  want="";
  print.resize(0);
}

int input(){
  cin>>want;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    string tmp;
    cin>>tmp;
    tmp+=tmp;
    print.push_back(tmp);
  }
  return n;
}

int solve(){
  int res=0;
  for(int i=0;i<print.size();i++){
    if(print[i].find(want)!=string::npos){
      res++;
    }
  }
  return res;
}




int main(){
  init();
  input();
  cout<<solve()<<endl;
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")



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

	string s;
	cin >> s;

	if (s[s.length() - 1] == 's') s = s + "es";
	else s = s + "s";
	cout << s << "\n";


	return 0;
}




Measured memory_bytes: 3660
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

r=I()
g=I()
print(2*g-r)

Measured memory_bytes: 3316
#include <iostream>
#include <numeric>
#include <vector>

int main() {
  unsigned int N;
  std::cin >> N;

  std::vector<unsigned int> answer(N, 0);
  for (unsigned int i = 1; i < N; ++i) {
    unsigned int A;
    std::cin >> A;
    answer.at(A - 1) += 1;
  }

  for (auto x : answer) {
    std::cout << x << std::endl;
  }

  return 0;
}


Measured memory_bytes: 4052
use std::collections::BTreeSet;
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let input = read::<String>();
    let s = input.chars().collect::<BTreeSet<char>>();
    println!("{}",if s.len() == 3 {"Yes"} else { "No"}) ;

}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n, k; cin >> n >> k;
	if( k == 1 ) cout << 0 << endl;
	else cout << max(0, n-k) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
bool jjjjaa(int hhjajxxx)
{
    long double yyyyya = sqrt(hhjajxxx);
    return ((yyyyya - floor(yyyyya)) == 0);
}
int main()
{
    int n;
    cin>>n;
    int nn=n%10;
    if(nn==0 || nn ==1 || nn==6 || nn==8) cout<<"pon";
    else if(nn == 2 || nn==4 || nn ==5 || nn==7 || nn==9) cout<<"hon";
    else if(nn==3) cout<<"bon";
    else ;
    
    return 0;
}


Measured memory_bytes: 3680
n = int(input())
a = [-1] + [int(input()) for _ in range(n)]
c = 0
for i in range(n):
    if a[i]+1 < a[i+1]:
        c = -1
        break
    if a[i]+1 != a[i+1]:
        c += a[i]
if c != -1:
    c += a[n]
print(c)


Measured memory_bytes: 12584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll fun(ll n){
    int k=(n+1)%4;
    ll sum=0;
    for(ll i=n-k+1;i<=n;i++){
        sum^=i;
    }
    return sum;
}
int main()
{
    ll l,r;
    scanf("%lld%lld",&l,&r);
    if(l==r)
        cout<<l;
    else
        cout<<(fun(l-1)^fun(r));
    return 0;
}


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

int main(){

    int n, m;

    scanf("%d%d", &n, &m);

    printf("%d\n", (n - 1) * (m - 1));
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC170D
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            
            int[] A = new int[N+1];
            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(input[i]);
            }
            A[N] = 1000001;
            Array.Sort(A);
            int m = A[N-1];
            //Console.WriteLine(m);
            int[] seen = new int[m];
            int count = 0;
            for(int i = 0; i < N; i++)
            {

                if (A[i] != A[i + 1])
                {
                    if (seen[A[i] - 1] == 0)
                    {
                        //Console.WriteLine(A[i]);
                        seen[A[i] - 1] += 1;
                        count += 1;
                        int n = A[i];
                        int nn = A[i];
                        while (n <= m - nn)
                        {
                            n += nn;
                            seen[n - 1] += 1;
                            //Console.WriteLine(n);
                        }
                    }
                }
                else
                {
                    seen[A[i] - 1] += 1;
                    int n = A[i];
                    int nn = A[i];
                    while (n <= m - nn)
                    {
                        n += nn;
                        seen[n - 1] += 1;
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 46536
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoders {
	class Program {
		static void Main(string[] args) {

			var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}

			var a = inputArray[0];
			var b = inputArray[1];

			var ans = string.Empty;
			if (a > b) {
				ans = createRepeatedString(b, a);
			}
			else {
				ans = createRepeatedString(a, b);
			}

			//答えの出力
			Console.WriteLine(ans);

		}

		private static string createRepeatedString(long str,long rep) {

			var ans = String.Empty;
			for (int i = 0; i < rep; i++) {
				ans += str;
			}

			return ans;
		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray =  Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 11348
/* ex 9_1
   アカウント名 */

#include <stdio.h>
#include <stdlib.h>


typedef struct node{
    char elem;
    struct node *next;
} node;

void push(node **first, char elem){
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    free(tmp);
    return elem;
}


int main(void){
    char str[100001];
    char tmp, *ptr;
    int removed_num = 0;
    node *first = NULL;
    scanf("%s", str);
    ptr = str;
    while(*ptr != '\0'){
        if(first == NULL){
            push(&first, *ptr);
        }
        else if((*first).elem != *ptr){
            tmp = pop(&first);
            removed_num += 2;
        }
        else{
            push(&first, *ptr);
        }
        ptr++;
    }
    printf("%d\n", removed_num);
    return 0;
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    string s;
    cin >> s;
    int ans = 0;
    rep(i, s.size() / 2 + 1)
    {
        if (s[i] != s[s.size() - i - 1])
        {
            ans++;
            s[i] = s[s.size() - i - 1];
        }
    }
    c(ans);
    //c(s);
    ed;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[]){
  int i,j,l;
  char k;
  int num;
  int row=4, col=13;//row : design, col : number
  int design2num['X'];
  int card[row][col];
  //init
  for(i=0; i<row; i++)
    for(j=0; j<col; j++)
      card[i][j]=0;
  design2num[0]='S';
  design2num[1]='H';
  design2num[2]='C';
  design2num[3]='D';
  design2num['S']=0;
  design2num['H']=1;
  design2num['C']=2;
  design2num['D']=3;
  //get data
  scanf("%d", &num);
  for(i=0; i<num; i++){
    (void)getchar(); //dammy
    scanf("%c %d", &k, &l);
    card[design2num[k]][l-1]=1;
  }
  //Are there every cards ?
  for(i=0; i<row; i++)
    for(j=0; j<col; j++)
      if( card[i][j]==0 )
	printf("%c %d\n", design2num[i], j+1);
  return(0);
}


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

int main() {
  int H,W;
  cin >> H >> W;
  vector<char>c(W);
  for (int i =0; i < H; i++){
    for (int l =0; l < W; l++){
      cin >> c.at(l);
    }
    for (int k =0; k < W; k++){
      cout << c.at(k);
    }
    cout << endl;
    for (int m =0; m < W; m++){
      cout << c.at(m);
    }
    cout << endl;
  }
}

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

int main(){
  string S;
  cin>>S;
  int N=S.size();
  int count=0;
  int count_max=0;
  
  for (int i=0; i<N; i++){
    if (S.at(i)=='A'||S.at(i)=='C'||S.at(i)=='G'||S.at(i)=='T'){
      count++;
    }
    if (count_max<=count){
      count_max=count;
    }
    if (S.at(i)!='A'&&S.at(i)!='C'&&S.at(i)!='G'&&S.at(i)!='T'){
      count=0;
    }
  }
  
  cout<<count_max<<endl;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));
	int n;
	cin >> n;
	string s;
	cin >> s;
	int c=0;
	repp(i,0,n-1)
	{
		if(s[i]!=s[i+1])
		{
			c++;
		}
	}
	c++;
	cout << c << endl;
}


Measured memory_bytes: 512
//#include "bits/stdc++.h"
#include "vector"
#include "iostream"
#include <fstream>
#include <string>
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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


	string S;
	cin >> S;

	int saki = stoi(S.substr(0, 2));
	int ato = stoi(S.substr(2, 2));

	bool saki_MM = INRANGE(saki, 1, 12);
	bool ato_MM = INRANGE(ato, 1, 12);

	if (saki_MM and ato_MM) cout << "AMBIGUOUS" << endl;
	else if (saki_MM and !ato_MM) cout << "MMYY" << endl;
	else if (!saki_MM and ato_MM) cout << "YYMM" << endl;
	else cout << "NA" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    vector<ll> a(N);
    REP(i,N) cin >> a[i];

    ll cnt = 0;
    for(int j=0; j < N; ++j) {
        if(j%2==0) cnt += a[j];
        else cnt -= a[j];
    }

    vector<ll> ans;
    ans.push_back(cnt);
    for(int i=1; i < N; ++i){
        cnt *= -1;
        cnt += 2*a[i-1];
        ans.push_back(cnt);
    }

    REP(i,N) cout << ans[i] << (i==N-1 ? '\n' : ' ');
    return 0;
}

Measured memory_bytes: 3060
/*
17D8101013F 森田　匡博
ID:key4 使用言語:C++
*/

#include <iostream>
#include <cmath>

int Euclid(int a, int b) 
{
  int tmp;
  while(b > 0) {
    tmp = a % b;
    a = b;
    b = tmp;
  }
  return a;
}

int main() 
{
  int a, b, ans;
  std::cin >> a >> b;
  ans = Euclid(a, b);
  std::cout << ans << "\n";

  return 0;
}



Measured memory_bytes: 3100
#include<iostream>
#include <bits/stdc++.h>
#include<algorithm>
#include <cstring>
#define endl "\n"
#define SRK ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define EPS 1e-6
typedef long long ll;
using namespace std;


    int main()
{
    SRK;
    int i,temp = 0;
    string a,b;
    cin >> a >> b;
    if (a.length() == b.length())
    {
        for (i = 0; i < a.length(); i++)
        {
            if (a[i] == b[i])
            {
                continue;
            }
            else if ((a[i]-'0') > (b[i]-'0'))
            {
                temp = 1;
                cout << "GREATER\n";
                break;
            }
            else
            {
                temp = 1;
                cout << "LESS\n";
                break;
            }
        }
    }
    else
    {
        if (a.length() > b.length())
        {
            temp = 1;
            cout << "GREATER\n";
        }
        else
        {
            temp = 1;
            cout << "LESS\n";
        }
    }
    if (temp == 0)
    {
        cout << "EQUAL\n";
    }


}



Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
constexpr ll infl = 1ll<<60;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string str;
    cin>>str;
    int n = (int)str.size();
    ll sum = 0ll;
    ll cur = 0ll;
    for(int i=0;i<n;++i){
        if(str[i] == '<')cur++;
        else if(str[i] == '>'){
            int j=i;
            ll count = 0ll;
            while(j <n and str[j] == '>')j++,count++;
            if(cur <= count){
                sum += count*(count+1)/2;
                if(cur > 1)sum += (cur-1)*cur/2;
            }else {
                if(count > 1) sum+= (count-1)*count/2;
                sum += cur*(cur+1)/2;
            }
            i=j-1;
            cur = 0;
        }
    }
    if(cur != 0){
        sum += cur*(cur+1)/2;
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 1172
N = int(input())
H = list(map(int, input().split()))

inv = 0
max_inv = 0
for n in range(1, N):
    if H[n] <= H[n-1]:
        inv += 1
    else:
        max_inv = max(max_inv, inv)
        inv = 0

max_inv = max(max_inv, inv)
print(max_inv)



Measured memory_bytes: 15020
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import java.lang.*;



public class Main {
    
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] s = new int[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        int[] t = new int[q];
        for (int i = 0; i < q; i++) {
            t[i] = sc.nextInt();
        }
        
        int count = 0;
        for (int i = 0; i < q; i++) {
            for (int j = 0; j < n; j++) {
                if (t[i] == s[j]) {
                    //System.out.println("found " + Character.getNumericValue(t.charAt(i)));
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 40300
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll sq(ll x) {return (x * x) % MOD;}
ll modP(ll a, ll b) {return (!b ? 1 : (sq(modP(a, b / 2)) * (b % 2 ? a : 1)) % MOD);}

int AGCT[] = {'A', 'G', 'C', 'T'};

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	int cnt = 0;
	bool flag = false;
	int mx = 0;
	for (int i = 0; i < s.size(); i++){
		if (find(AGCT, AGCT + 4, s[i]) != AGCT + 4){
			if (!flag) flag = true;
			cnt += 1;
		}
		else{
			if (flag){
				flag = false;
				mx = max(mx, cnt);
				cnt = 0;
			}
		}
	}
	mx = max(mx, cnt);
	cout << mx << endl;
	return 0;
}



Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <limits>//setprecision
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#include <numeric> //accumulate,,,
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
//int MOD = 1000000007;
typedef pair<long long,long long> P;

void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M,long long MOD) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2,MOD);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a; else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

vector<vector<int>> Edge(10005);
vector<int> score(10005);
vector<pair<int,int>> indegree(10005);
vector<int> ans(10005);
vector<bool> seen(10005);

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N;cin >> N;
    for(int i = 0;i<N;i++) indegree.at(i).second = i;
    for(int i = 0;i<N-1;i++){
        int a,b;cin >> a >> b;a--;b--;
        Edge.at(a).push_back(b);
        Edge.at(b).push_back(a);
        indegree.at(a).first++;
        indegree.at(b).first++;
    }
    for(int i = 0;i<N;i++){
        int sc;cin >> sc;
        score.push_back(sc);
    }
    sort(score.begin(),score.end(),greater<int>());
    sort(indegree.begin(),indegree.end(),greater<pair<int,int>>());
    queue<pair<int,int>> Q;
    Q.push(make_pair(indegree.at(0).second,0));
    //次数大きいのにスコア高いのを入れると、破滅する時がある（それはそう）
    //なので、次数大きい頂点から順に（BFS）スコア高いのを入れていけばよい
    int index = 0;
    while(!Q.empty()){
        int from = Q.front().first,Index = Q.front().second;
        Q.pop();
        ans.at(from) = score.at(Index);
        seen.at(from) = true;
        for(int to : Edge.at(from)){
            if(seen.at(to)) continue;
            seen.at(to) = true;
            Q.push(make_pair(to,++index));
        }
    }
    int maxiScore = 0;
    for(int i = 0;i<N;i++){
        for(int j = 0;j<Edge.at(i).size();j++){
            maxiScore += min(ans.at(i),ans.at(Edge.at(i).at(j)));
        }
    }
    cout << maxiScore / 2 << endl;
    for(int i = 0;i<N;i++) cout << ans.at(i) << endl;
}


Measured memory_bytes: 4216
# https://atcoder.jp/contests/code-festival-2017-quala/tasks/code_festival_2017_quala_c
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


# 回文の二次元版
# 1次元回文→文字数が奇数だったら,一つの文字以外出現回数はすべて2の倍数。偶数だったら出現回数はすべて2の倍数
# 二次元では？
# H,Wがともに偶数なら→すべての文字の出現回数は4の倍数
# Hが奇数、Wが偶数なら→4の倍数でない要素を、真ん中に詰めていきたい(そのような要素がWについても回文になっているか評価)
# つまり4の倍数が(W*(H-1))個分ある かつ それ以外の要素は2の倍数ある
# Wが奇数、Hが偶数→↑WHをひっくり返すだけ
# W,Hがともに奇数→(W-1)*(H-1)個分ある かつ それ以外の要素は1つ以外2の倍数である

# 上記を一般化すると、二次元回文が満たすべき条件は、
# - 同一文字4個セットは(W-(W&1))*(H-(H&1))//4 個以上ある
# - 同一文字奇数個の要素はちょうどH&1&W個ある(両方奇数のとき1になる)
# - その他の要素はすべて2の倍数個である(ただしこの条件は2番めの条件に内包される)

from collections import Counter

H, W = read_ints()
cnt = Counter()
for _ in range(H):
    cnt.update(input())

# コーナーケース処理
# if H == 1 or W == 1:


num4 = 0
num1 = 0
for v in cnt.values():
    if v & 1:  # 条件2
        num1 += 1

    while v >= 4:  # 条件1の4文字セットを作る 4以上なら4個セットを作ることができる
        v -= 4
        num4 += 1

if num4 >= (W - (W & 1)) * (H - (H & 1)) // 4 and num1 == H & 1 & W:
    print('Yes')
else:
    print('No')


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

int main(){
    int64_t A, B, K;
    cin >> A >> B >> K;
    int64_t d = min(A, K);
    A -= d;
    K -= d;
    B = max(int64_t(0), B-K);
    cout << A << " " << B << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#define loop_input(fmt,...) while(~scanf(fmt,__VA_ARGS__))
typedef long long ll;

int main() {
    int n;
    loop_input("%d", &n) {
        ll min = LLONG_MAX, max = LLONG_MIN, sum = 0;
        int a;
        while(n-- && ~scanf("%d", &a)) {
            if (min >= a)   min = a;
            if (max <= a)   max = a;
            sum += a;
        }
        printf("%lld %lld %lld\n", min, max, sum);
    }
    return 0;
}


Measured memory_bytes: 2716
using System;
class Program
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    string[] B = Console.ReadLine().Split(' ');
    int sum = 0;
    
    for (int i = 0; i < N; i++)
    {
      int A = 0;
      if (i == 0){
        A = int.Parse(B[i]);
      }
      else if (i == N - 1){
        A = int.Parse(B[i - 1]);
      }
      else{
        A = Math.Min(int.Parse(B[i - 1]), int.Parse(B[i]));
      }
      sum += A;
    }
    
    Console.WriteLine(sum);
  }
}

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

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

    int ans = -1;
    for (int i = 1; i <= 1250; i++) {
        if (8 * i / 100 == A && i / 10 == B) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)
#define P pair<int,int>
ll n, k,b,c,i,j,x,y,z=0,m=0;
ll a[100000], yy[100000] = {};
string s;
P p[100000];
vector<ll> v;

int main() {
	cin >> k >> x;
	k--;
	if (x - k < -1000000)for (i = 0; i <= x + k; i++) cout << -1000000 + i << " "; 
	else for (i = 0; i <= 2*k; i++) {
		if (x - k + i > 1000000)break;
		cout <<x-k + i << " ";
	}

	//cout << z;
	return 0;
}





Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<intmax_t> a(N);
  for (size_t i=0; i<N; ++i)
    scanf("%jd", &a[i]);

  intmax_t f=0;
  for (size_t i=0; i<N; ++i)
    f += a[i]-1;

  printf("%jd\n", f);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bitset>
#define MOD 1000000007
#define md 998244353
#define INF LLONG_MAX
#define F first
#define S second
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define sz(x) (long long)x.size()
#define vi vector<int>
#define vll vector<long long>
#define vpl vector<pair<long long,long long> >
#define vpi vector<pair<int,int> >
#define pb push_back
#define debug(x) cerr<<#x<<"= "<<x<<endl
#define all(v) v.begin(),v.end()
#define TT ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define endl '\n'
#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())
#define MAXN 200005
typedef long long ll;
typedef long double ld;
using namespace std;

ll BigMod(ll base,ll pow,ll mod)
{
    if(pow==0||base==1)return 1;
    else if(pow==1)return base;
    else if(pow%2)return BigMod(base,pow-1,mod)*base%mod;
    else {ll x=(BigMod(base,pow/2,mod)%mod);x=(x*x)%mod;return x;}
}

ll isprime(ll prime)
{
	ll cnt=0;
	for(int i=2;i*i<=prime;i++)
	{
		if(prime%i==0)return false;
		
	}
	return true;
}

   void DBG() { cerr << "]" << '\n'; }
template<class H, class... T> void DBG(H h, T... t) {
    cerr << h;
    if (sizeof...(t)) cerr << ", ";
    DBG(t...);
}
 
#ifdef LOCAL // compile with -DLOCAL
    #define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
    #define dbg(...) 0
#endif 

//***************** GRAPH VISITED *****************************************************
const int dx[]={+1,-1,+0,+0};
const int dy[]={+0,+0,+1,-1};
const int f1x[]={+0,+0,+1,-1,-1,+1,-1,+1};   /// Kings Move
const int f1y[]={-1,+1,+0,+0,+1,+1,-1,-1};  /// Kings Move
const int f2x[]={-2, -2, -1, -1,  1,  1,  2,  2};  /// Knights Move
const int f2y[]={-1,  1, -2,  2, -2,  2, -1,  1}; /// Knights Move

const int maX=1e3+10;
ll vis[maX][maX];
ll n,m;
void DFS(ll x, ll y)
{
	cout<<x<<' '<<y<<endl;
	vis[x][y]=1;
	
	for(ll i=0;i<4;i++)
	{
		ll d=x+dx[i];
		ll dd=y+dy[i];
		
		if(d>=1 && d<=n && dd>=1 && dd<=m && vis[d][dd] !=1) DFS(d,dd);
	}
   	
	for(ll i=x;i<=n;i++)if(vis[i][y] ==0) DFS(i,y);
	for(ll i=x-1;i>=1;i--)if(vis[i][y]==0)DFS(i,y);
	for(ll i=y;i<=m;i++)if(vis[x][i]==0)DFS(x,i);
	for(ll i=y-1;i>=1;i--)if(vis[x][i]==0)DFS(x,i);
	 
 
	
}


//**********************************MAIN_FUNCTION ************************************************************
int main( ) {
 
      ll  k,l=0,q;
        ll t,i,j,x,y;
       string str;
       cin>>str;
       ll mx=-1;
       for(i=0;i<str.size();i++)
       {
       	 
       	if(str[i]=='R')l++;
       	else
       	{
       		///cout<<l<<endl;
       		mx=max(mx,l);
       		l=0;
		   }
	   }
		   cout<<max(mx,l)<<endl; 
     
	return 0;
}
 

Measured memory_bytes: 3540
s = list(input())
l = len(s)
ans = 0
if l % 2 == 0:
    for i in range(int(l/2)):
        if s[i] != s[l-i-1]:
            ans += 1
        else:
            pass
else:
    for j in range(int((l-1)/2)):
        if s[j] != s[l-j-1]:
            ans += 1
        else:
            pass
print(ans)


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

#include <set>
#include <iterator>
using namespace std;
// using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF (ll)1e17
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
// typedef tree<pll, null_type, less<pll>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
const int  N=3e5 +10, M=(ll)1e9+1 ;
const int mod =(ll)1e9+7 ,sz=5, MAX=(ll)1e6+10;
string fir="Monocarp",sec="Bicarp";

void work(){
	ll n,k,ans=0;
	cin >> n >> k;

	vl sum(N,0);

	for(ll i=1;i<=n+1;i++){
		sum[i]=sum[i-1]+i-1;
		// cout << sum[i] << " ";
	}
	// cout << "\n";
	for(ll i=k;i<=n+1;i++){
		ll min=sum[i];
		ll max=sum[n+1]-sum[n+1-i];
		// cout << min << "  " << max << "\n";
		// cout << min[i] << " " << max[i] << "\n"; 
		ans=(ans+max-min+1+mod)%mod;
	}
	cout << ans;

}

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

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	// precomp();
	ll t;
	// cin >> t;
	t=1;
	while(t--){
	        work();
	
	}
return 0;
}
	

Measured memory_bytes: 5568
#include<iostream>

using namespace std;

int main () {

    char s[200];
    char p[100];

    bool answer = false;

    cin >> s;
    cin >> p;

    // cout << "Complete Cin" << endl;

    // 文字列を文字列終了直後にコピーする。
    for (int i = 0; ; i++) {

        // cout << "Now Loading1" << endl;

        bool flag = false;
        
        if(s[i] == 0) {

            int x = i;
            
            for(int j = x; j < x * 2; j++) {
                s[j] = s[j - x];
            }

            s[x * 2] = 0;

            flag = true;

        }

        if (flag == true) {
            break;
        }
    }

    for (int i = 0; ; i++) {

        // cout << "Now Loading2" << endl;

        if (s[i] == 0) {
            break;
        }

        if (p[0] == s[i]) {
            
            // cout << "Now Loading3" << endl;

            int x = i;
            int j = 0;

            while (1) {
                if (p[j] == 0 && p[j - 1] == s[x - 1]) {
                    answer = true;
                    break;
                }
                if (p[j] != s[x]) {
                    break;
                }

                j++;
                x++;
            }

        }
    }

    if (answer) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

int main() {
    string S;
    cin >> S;
    int n = S.size();

    ll ans = 0;
    for (int i = 0; i < (1<<(n - 1)); i++) {
        vi nums = {0};
        for (int j = 0; j < (n - 1); j++) {
            // +
            if (i & 1<<j) {
                nums.push_back(j + 1);
            }
        }
        nums.push_back(n);

        for (int j = 0; j < nums.size() - 1; j++) {
            ans += stoll(S.substr(nums[j], nums[j + 1] - nums[j]));
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define pb push_back
#define ll long long
#define ff first
#define ss second
using namespace std;

string s,t;
int dp[3001][3001];

int lcs(int i,int j){
    if(i>s.size() || j>t.size()){
        return 0;
    }
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    if(s[i-1]==t[j-1]){
        return dp[i][j] = lcs(i+1,j+1)+1;
    }
    else{
        return dp[i][j] = max(lcs(i+1,j),lcs(i,j+1));
    }
}

int main(){
    cin>>s>>t;
    memset(dp,-1,sizeof(dp));
    lcs(1,1);
    int m = s.size();
    int n = t.size();
    string p ="";
    int i=1,j=1;
    while(i<=m && j<=n){
        if(s[i-1]==t[j-1]){
            p = p+ s[i-1];
            i++;
            j++;
        }
        else if(dp[i][j+1]>dp[i+1][j]){
            j++;
        }
        else{
            i++;
        }
    }
    cout<<p<<endl;
    return 0;
}

Measured memory_bytes: 35840