akhauriyash/Code-Regression huggingface dataset:
N,K=map(int,input().split())
A=[]
B=[]
C=[]
D=[]
for i in range(2*K):
    A.append(list(map(int,input().split())))
for i in range(K):
    B.append(A[2*i-1])
for i in range(K):
    for j in range(len(B[i])):
        C.append(B[i][j])
for i in range(1,N+1):
    if i not in C:
        D.append(i)
print(len(D))

Measured memory_bytes: 68668
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <queue>
#include <sstream>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
#define fi first
#define se second
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<vi> vvi;
ll k,a,b;
ll nw=1;
int main() {
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>k>>a>>b;
	nw+=k;
	if(b-a>2){
		k-=a-1;
		nw=a;
		for(;k>1;k-=2){
			nw=nw+b-a;
		}
		if(k)nw++;
	}
	cout<<nw<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import math

#https://atcoder.jp/contests/agc008/submissions/15248942
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = input()

sum_n = 0
for c in N:
    sum_n += int(c)

if sum_n % 9 == 0:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 9356
#include <bits/stdc++.h>
#define LL long long

using namespace std;

int main()
{  
    LL N,M;
    cin >> N >> M;
    vector<pair<LL,LL>> d(N);

    for(int i=0; i<N ;i++){
        cin >> d.at(i).first >> d.at(i).second ;
    }

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

    LL bill=0;
    LL cnt=0;
    int i=0;

    while(cnt < M){

        if(cnt + d.at(i).second > M ){
            bill += (M-cnt)*d.at(i).first;
            cnt += (M-cnt);
        }else{
            cnt += d.at(i).second;
            bill += d.at(i).first * d.at(i).second;
        }
        i++;
    }
    
    cout << bill << endl;
    return 0;
}

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

int main(){
  string n;
  cin >> n;
  
  for (int i = 0;i < n.size(); i++){
    if (n[i] == '7'){
      cout << "Yes" << endl;
      break;
    }
    if (i + 1 == n.size()){
      cout << "No" << endl;
    }
  }
 
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	string S;
	string Sd;
	cin >> N >> S;
	Sd = S;
	for(int i = 0;i<(int)S.length();i++){
		int num = S[i] - 'A';
		num = (num + N) % 26;
		Sd[i] = 'A' + num;
	}
	cout << Sd << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(void)
{
    int i,n,a;
    long min=1000000,max=-1000000,sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        if(min>a){
            min=a;
        }
        if(max<a){
            max=a;
        }
        sum+=a;
    }
    printf("%ld %ld %ld\n",min,max,sum);
    return 0;
}

Measured memory_bytes: 1028
N, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(len(a) - 1):
    if a[i] > x:
        ans += a[i] - x
        a[i] = x

    if a[i] + a[i+1] > x:
        prev = a[i+1]
        a[i+1] -= a[i] + a[i+1] - x
        ans += prev - a[i+1]

print(ans)




Measured memory_bytes: 14540
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,m;cin>>N;m=N;
  for(int A=1;A<N;A++){
    int a=A,b=N-A,S=0;
    while(a>0)S+=a%10,a/=10;
    while(b>0)S+=b%10,b/=10;
    m=min(m,S);
  }
  cout<<m<<endl;
}

Measured memory_bytes: 256
from bisect import bisect_right, bisect_left
s = [ord(i) - ord("a") for i in input()]
t = [ord(i) - ord("a") for i in input()]
index = [[] for _ in range(26)]

for i, x in enumerate(s):
    index[x].append(i)


l_s = len(s)

for x in index:
    if x:
        x.append(x[0] + l_s)

cnt = -1
for r in t:
    seq = index[r]
    if not seq:
        cnt = -2
        break
    i = cnt % l_s
    j = bisect_right(seq, i)
    cnt += seq[j] - i

print(cnt+1)




Measured memory_bytes: 9044
/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define MAX 3100
#define mod 1000000007
#define Case(i) cout<<"Case "<<i<<": "
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define pfn printf("NO\n")
#define pfs  printf("YES\n")
#define pf(a) printf("%lld\n",a)
#define pff(a,b) printf("%lld %lld\n",a,b)
#define pfff(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pffff(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vpp,vpp1;
vector<pair<ll,ll> >vp,vp1;
vector<ll>v,v1,v2,fin;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb;
ll n,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,maxi;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
///vector<pair<ll,ll> >adj[MAX+10];
int main()
{
    cin>>a>>b;
    if(b>=a) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
    return 0;
}


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N;
    cin >> N;
    cout << N/3 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
#define MOD 1000000007
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef vector<int> vi;
set <int> st;
int n,k,mx=0,mxcdiv=0;
vi a;
int gcd(int a,int b)
{
  if(b>=a) swap(a,b);
  if(a%b==0)
    {
      return b;
    }
  else
    {
      return gcd(b,a%b);
    }
}

int main(int argc,char const* argv[])
{
  cin >> n >> k;
  for(int i=0;i<n;i++)
    {
      int tmp;
      cin >> tmp;
      a.push_back(tmp);
      mx=max(mx,tmp);
    }
  if(k>mx)
    {
      cout << "IMPOSSIBLE" << endl;
      return 0;
    }
  if(n==1 && k==mx)
    {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  else if(n==1 && k!=mx)
    {
      cout << "IMPOSSIBLE" << endl;
    }
  int div=gcd(a[0],a[1]);
  for(int i=2;i<int(a.size());i++)
    {
      div=gcd(div,a[i]);
    }
  if(k%div==0)
    {
      cout << "POSSIBLE" << endl;
    }
  else
    {
      cout << "IMPOSSIBLE" << endl;
    }
  return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


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

    string ans="";
    while(n>0){
        n--;
        ans+=(char)('a'+n%26);
        n/=26;
    }

    reverse(all(ans));
    cout<<ans<<endl;
}




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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(long long N, std::vector<long double> x,
           std::vector<std::string> u) {
  double ans = 0;
  for(int i = 0 ; i < N ; i++){
    if( u[i] == "JPY" ){
      ans += x[i];
    }else{
      ans += x[i] * 380000;
    }
  }
  printf("%.10lf\n", ans);
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long double> x(N);
  std::vector<std::string> u(N);
  for (int i = 0; i < N; i++) {
    scanf("%Lf", &x[i]);
    std::cin >> u[i];
  }
  solve(N, std::move(x), std::move(u));
  return 0;
}


Measured memory_bytes: 256
N=int(input())
S=input()
use=[0 if S[i]=="." else 1 for i in range(N)]
now=[0 for i in range(N)]
count=sum(use)
lst=set()
lst.add(count)


for i in range(N-1,-1,-1):
    now[i]=1
    if use[i]:
        use[i]=0
        count-=1
    else:
        use[i]=1
        count+=1
    lst.add(count)
print(min(lst))


Measured memory_bytes: 63228
from collections import defaultdict, deque
n,q = map(int,input().split())
dic = defaultdict(list)
for i in range(n-1):
    a,b = map(int,input().split())
    dic[b].append(a)
    dic[a].append(b)
# print(d)

dp = [-1]+[0]*n

for i in range(q):
    p,x = map(int,input().split())
    dp[p] += x

visited = [False]*(n+1)
que = deque([1])

while que:
    parent = que.popleft()
    visited[parent] = True
    for child in dic[parent]:
        if not visited[child]:
            dp[child] += dp[parent]
            que.append(child)

print(*dp[1:])

Measured memory_bytes: 153036
#include <bits/stdc++.h>
using namespace std;
/*---define tricks---*/
#define ALL(v) v.begin(),v.end()
#define UN(v) sort(ALL(v)),v.erase(unique(ALL(v)),v.end())
#define FILL(x,y) memset(x,y,sizeof(x))
#define EACH(v,it) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define FIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define revsort(b,e) sort(b,e),reverse(b,e)
/*---define types---*/
typedef long long ll;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;
/*---define variables---*/
int n;
string s[105];
int p[105];
int x[105];
/*---define function---*/

bool cmp(int x,int y)
{
	if(s[x]!=s[y])
	{
		return s[x]<s[y];
	}
	return p[x]>p[y];
}

/*---main code---*/
int main()
{
	FIO;
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		x[i]=i;
		cin>>s[i]>>p[i];
	}
	sort(x+1,x+1+n,cmp);
	for(int i=1;i<=n;++i)
	{
		cout<<x[i]<<'\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll dp[20][10];

ll dfs(ll K, int t,int degree,ll ans){
    // cerr << "d =" << degree << "K=" << K << "t=" << t << endl;;
    if(degree == 0){
        return ans;
    }
    ans *= 10;
  
    ll sum =0;
    for(int i=-1;i<2;i++){
        if(t +i <0 || t+i >9){
            continue;
        }
        // cerr << t << endl;
        ll old = sum;
        sum += dp[degree-1][t+i];
        if(sum >=K){
            K -= old;
            ans += t+i;
            if(degree-1 ==0){
                return ans;
            }
            return dfs(K,t+i,degree-1,ans);
        }
    }
    return 0;

}


void solve(long long K){

    // n桁目で先頭がiの値の時のルンルン数を求める。
    for(int i=0;i<10;i++){
        dp[0][i] = 1;
    }
    for(int i=1;i<20;i++){
        for(int j=0;j<10;j++){
            for(int k=-1;k<2;k++){
                if(j+k <0 || j+k>9){
                    continue;
                }
                dp[i][j] += dp[i-1][j+k];
                
            }
        }
    }
    cerr << "finished DP" << endl;
   
    ll ans =0;
    bool detectF = false;
    ll sum = 0;
    bool degreeDetect = false;
    int degree = 0;

    for(int i=0;i<20;i++){
        if(degreeDetect){
            break;
        }
        for(int j=1;j<10;j++){
            if(!detectF && j==0){
                continue;
            }
            ll oldsum = sum;
            sum += dp[i][j];
            if(i==0 && sum ==K){
                ans +=j;
                K -=sum;
                degreeDetect = true;
                break;
            }
            if(sum >= K){
                cerr <<"degree=" << i<< endl;
                detectF = true;
                K -=oldsum;
                cerr << K << endl;
                degreeDetect = true;
                degree = i;
                ans += dfs(K,j,i,j);
                break;
            }
        }
    }
    cout << ans << endl;



    

    // 2分探索でルンルン数の桁と先頭の数字を求める、というのを繰り返す。


}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n, m;cin >> n >> m;
    vector<int> count(n, 0);
    for(int i=0;i<m;i++){
        int a, b;cin >> a >> b;a--;b--;
        count[a]++;
        count[b]++;
    }
    for(int i=0;i<n;i++){
        cout << count[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
use std::cmp;
use std::collections::BinaryHeap;

#[derive(Copy, Clone, Eq, PartialEq)]
struct State {
    i: usize,
    cost: i64,
}

impl Ord for State {
    fn cmp(&self, other: &State) -> std::cmp::Ordering {
        other.cost.cmp(&self.cost)
    }
}

impl PartialOrd for State {
    fn partial_cmp(&self, other: &State) -> Option<std::cmp::Ordering> {
        Some(self.cmp(other))
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut sc = scanner::Scanner::new(stdin.lock());
    let x: usize = sc.read();
    let y: usize = sc.read();
    let z: usize = sc.read();
    let n = x + y + z;
    let mut a: Vec<i64> = vec![];
    let mut b: Vec<i64> = vec![];
    let mut c: Vec<i64> = vec![];
    for _ in 0..n {
        a.push(sc.read());
        b.push(sc.read());
        c.push(sc.read());
    }

    let mut s = (0..n)
        .map(|i| (a[i] - b[i], a[i], b[i], c[i]))
        .collect::<Vec<_>>();
    s.sort();

    let mut heap = BinaryHeap::new();
    let mut b_sum = 0;
    let mut c_sum = 0;
    let mut max_bc = vec![(0, 0); n];
    for (i, &(_, _, b, c)) in s.iter().enumerate() {
        heap.push(State { i: i, cost: b - c });
        b_sum += b;
        if heap.len() == y + 1 {
            let min = heap.pop().unwrap();
            let (_, _, b, c) = s[min.i];
            b_sum -= b;
            c_sum += c;
        }
        max_bc[i] = (b_sum, c_sum);
    }

    let mut heap = BinaryHeap::new();
    let mut a_sum = 0;
    let mut c_sum = 0;
    let mut max_ac = vec![(0, 0); n];
    for (i, &(_, a, _, c)) in s.iter().enumerate().rev() {
        heap.push(State { i: i, cost: a - c });
        a_sum += a;
        if heap.len() == x + 1 {
            let min = heap.pop().unwrap();
            let (_, a, _, c) = s[min.i];
            a_sum -= a;
            c_sum += c;
        }
        max_ac[i] = (a_sum, c_sum);
    }

    let mut ans = 0;
    for i in (y - 1)..n {
        if i + 1 > n - x {
            break;
        }
        let (a, c1) = max_ac[i + 1];
        let (b, c2) = max_bc[i];
        ans = cmp::max(ans, a + b + c1 + c2);
    }
    println!("{}", ans);
}

pub mod scanner {
    use std::fmt::Debug;
    use std::io::Read;
    use std::str::{self, FromStr};

    pub struct Scanner<R: Read> {
        reader: R,
    }

    impl<R: Read> Scanner<R> {
        pub fn new(reader: R) -> Self {
            Scanner { reader: reader }
        }

        pub fn read<T>(&mut self) -> T
        where
            T: FromStr,
            T::Err: Debug,
        {
            let buf: Vec<u8> = self
                .reader
                .by_ref()
                .bytes()
                .map(|b| b.unwrap())
                .skip_while(|&b| (b as char).is_whitespace())
                .take_while(|&b| !(b as char).is_whitespace())
                .fold(Vec::new(), |mut buf, c| {
                    buf.push(c);
                    buf
                });

            unsafe { str::from_utf8_unchecked(&buf) }
                .parse()
                .expect("Parse error.")
        }
    }
}


Measured memory_bytes: 20256
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s + '\n')
def wi(n): sys.stdout.write(str(n) + '\n')
def wia(a): sys.stdout.write(' '.join([str(x) for x in a]) + '\n')


def main():
    s = rs()
    ws(s[:3])


if __name__ == '__main__':
    main()


Measured memory_bytes: 61760
#include<stdio.h>
#include<stdlib.h>

typedef struct Node{
  int key;
  struct Node *right, *left, *parent;
}Node;

Node *root, *NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }

  z->parent = y;
  if(y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}

void inorder(Node *u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i, x;
  char com[20];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    
    scanf("%s",com);
    
    if(com[0] == 'i'){
      scanf("%d",&x);
      insert(x);
    }
    else{
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}


Measured memory_bytes: 25132
#include<stdio.h>
#define MAX 101
int dp[MAX+1][MAX+1],p[MAX+1];
int Min(int a,int b){
  int tmp;
  if(a<b) return a;
  return b;
}

int main(){
  int n,i,j,r,k;
  scanf("%d",&n);
  for(i=1;i<n+1;i++)
    scanf("%d%d",&p[i-1],&p[i]);

  for(i=2;i<n+1;i++){
    for(j=1;j<n-i+2;j++){
      int r=j+i-1;
      dp[j][r]=(1<<20);
      for(k=j;k<r;k++){
        dp[j][r]=Min(dp[j][r],dp[j][k]+dp[k+1][r]+p[j-1]*p[k]*p[r]);
      }
    }
  }
  printf("%d\n",dp[1][n]);

  return 0;
}

Measured memory_bytes: 636
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var ab = IO.RSLong;
            if (ab[0] == 1 || ab[1] == 1)
            {
                WriteLine(1);
                return;
            }
            var ans = ab[0] * ab[1] / 2;
            if (ab[0] % 2 == 1 && ab[1] % 2 == 1)
                ans++;
            WriteLine(ans);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        char[] s = in.ns().toCharArray();
        int c = -1, f = s.length;
        for (int i = 0; i < s.length; i++) {
            if(c==-1&&s[i]=='C') c = i;
            if(f==s.length&&s[s.length-i-1]=='F') f = s.length-i-1;
        }
        out.println((c>-1&&c<f&&f<s.length)?"Yes":"No");
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

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

int main(){
	int N;
	cin>>N;
	int ans=1;
	int h;
	cin>>h;
	int tmp;
	for(int i=1;i<N;++i){
		cin>>tmp;
		if(tmp<h){
			continue;
		}
		else{
			ans++;
			h=tmp;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut tasks: [(usize, usize); n],
    }

    tasks.sort_by(|a, b| a.1.cmp(&b.1));
    let mut count = 0;
    for item in tasks {
        count += item.0;
        if count > item.1 {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 9164
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if((a+b==c)||(b+c==a)||(a+c==b))
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}

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

bool check[100005];
int seg[100005];

void sieve() {
    check[1] = 1;
    for(int i = 2; i * i <= 100005; i++) {
        if(!check[i]) {
            for(int j = i + i; j <= 100000; j += i)
                check[j] = 1;
        }
    }
}

void make() {
    for(int i = 1; i <= 100000; i++) {
        if(i%2 && !check[i] && !check[(i + 1)/2])
            seg[i] = 1;
    }
    for(int i = 1; i <= 100000; i++)
        seg[i] += seg[i - 1];
}

int main() {
    sieve();
    make();
    int q;
    cin >> q;
    while(q--) {
        int a, b;
        cin >> a >> b;
        cout << seg[b] - seg[a - 1] << endl;
    }
	return 0;
}

Measured memory_bytes: 1152
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    a,b=map(int,input().split())
    a-=1; b-=1
    print(100,98)
    h=99
    print('#'*49+'.'*49)
    while(a>0 or b>0):
        if(a>=24):
            s1='#.'*24+'#'
            a-=24
        else:
            s1='#.'*a+'#'*(49-2*a)
            a=0
        if(b>=24):
            s2='.#'*24+'.'
            b-=24
        else:
            s2='.#'*b+'.'*(49-2*b)
            b=0
        print(s1+s2)
        h-=1

        print('#'*49+'.'*49)
        h-=1

    for i in range(h):
        print('#'*49+'.'*49)

resolve()

Measured memory_bytes: 38496
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#include<stack>
#include<iomanip>
#include<map>
#define rep(i,n) for(int i=0;i<((int)n);i++)
#define drep(i,n) for(int i=((int)n)-1;i>-1;i--)
#define Rep(i,n0,n) for(int i=n0;i<((int)n);i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<((int)n);j++)
#define W(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
#define INF (1<<29)
#define INF2 (long long)8*(long long)INF*(long long)INF
#define mod 1000000007

typedef long long ll;

using namespace std;


int min(int x,int y){if(y<x)return y;else return x;}
int max(int x,int y){if(y>x)return y;else return x;}
int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;}
long long fact(long long x){long long i=1;rep(j,x){i*=(j+1);} return i;}
int gcd(int x, int y){if(x%y==0)return y;else if(y%x==0)return x;else return gcd(x%y,y%x);}
ll gcd(ll x, ll y){if(x%y==0)return y;else if(y%x==0)return x;else return gcd(x%y,y%x);}
void say(bool x){if(x){cout<<"Yes"<<endl;}else {cout<<"No"<<endl;}return;}


int main()
{
    int n,cnt=0,cnt2=0;
    cin >> n;
    Rep(i,1,n+1)
    {
        cnt2=0;
        Rep(j,1,i+1)if(i%2==1)
        {
            if(i%j==0)cnt2++;
        }
        if(cnt2==8)cnt++;
    }
    W(cnt)
    return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < int(b); ++i)
#define rrep(i, a, b) for(int i = (a) - 1; i >= int(b); --i)
#define trav(it, v) for(auto &it : (v))
#define all(v) (v).begin(), (v).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define sz(x) (int)(x).size()

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
    
vector<vector<int>> adj;
set<pair<int, int>> edges;
bool vis[100005];
int v[100005];

void dfs(int node, int parent) {
    if (vis[node])
        return;
    vis[node] = true;
    for (auto to : adj[node]) {
        if (to == parent)
            continue;
        dfs(to, node);
    }
    if (v[node] && node) {
        v[node] ^= 1;
        v[parent] ^= 1;
        if (edges.count(make_pair(parent, node))) {
            edges.erase(make_pair(parent, node));
            edges.insert(make_pair(node, parent));
        }
        else {
            edges.erase(make_pair(node, parent));
            edges.insert(make_pair(parent, node));
        }
    }
}

int main(){
	ios::sync_with_stdio(0);
    int N, M;
    cin >> N >> M;
    adj = vector<vector<int>>(N);
    rep(i,0,M) {
        int a, b;
        cin >> a >> b;
        --a;--b;
        v[a] ^= 1;
        adj[a].push_back(b);
        adj[b].push_back(a);
        edges.insert(make_pair(a, b));
    }
    dfs(0, -1);    
    if (v[0]) {
        cout << "-1" << endl;
        return 0;
    }
    for (auto it : edges) {
        cout << it.first+1 << " " << it.second+1 << endl;
    }
}


Measured memory_bytes: 18304
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;

struct Node {
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
     
    while(x!=NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        }else{
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if(z->key < y->key) {
            y->left = z;
        }else{
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

Node * treeMinimum(Node *x) {
    while(x->left != NIL) x = x->left;
    return x;
}

Node * find(Node *u, int k) {
    while(u!=NIL && k != u->key) {
        if (k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

Node * treeSuccessor(Node *x) {
    if (x->right != NIL) return treeMinimum(x->right);
    Node *y = x->parent;
    while(y!=NIL && x==y->right) {
        x = y;
        y = y->parent;
    }
    return y;
}

void treeDelete(Node *z) {
    Node *y;
    Node *x;
    
    if (z->left == NIL || z->right == NIL) y = z;
    else y = treeSuccessor(z);
    
    if (y->left != NIL) { 
        x = y->left;
    } else {
        x = y->right;
    }
    
    if (x != NIL) {
        x->parent = y->parent;
    }
    
    if (y->parent == NIL) {
        root = x;
    } else {
        if (y == y->parent->left) {
            y->parent->left = x;
        } else {
            y->parent->right = x;
        }
    }
    
    if (y != z) {
        z->key = y->key;
    }
    
    free(y);
}

int main() {
    int n, i, x;
    string com;
    
    scanf("%d", &n);
    
    for (i=0; i<n; i++) {
        cin >> com;
        if(com == "insert") {
            scanf("%d", &x);
            insert(x);
        }else if(com == "delete") {
            scanf("%d", &x);
            treeDelete(find(root, x));
        }else if(com == "find") {
            scanf("%d", &x);
            Node *t = find(root, x);
            if(t!=NIL) printf("yes\n");
            else printf("no\n");
        }else if(com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    
    return 0;
}


Measured memory_bytes: 22040
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

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


int dx[5] = {1, 0, -1, 0};
int dy[5] = {0, 1, 0, -1};

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

#define pi 3.14159265
int main() {
    double a, b, x;
    cin >> a >> b >> x;

    double y=0;
    if(x<=a*a*b/2){
        y=2*x/(b*a);

        cout << setprecision(20) <<90-atan(y/b)/pi*180 << endl;
    }else{
        y=2*(a*a*b-x)/(a*a);
        cout << setprecision(20) <<atan(y/a)/pi*180 << endl;
    }



    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define li long ll
#define pp pair<ll, ll>
#define lb lower_bound
#define ub upper_bound
#define mk make_pair
#define pb push_back
#define llp(i, x, n) for (ll i = x; i < n; i++)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define fr first
#define ss second
#define mod 1000000007
using namespace std;
ll sum(ll a[], ll n) 
{ 
    ll b[n];
    b[0]=a[0];
    for(int i=1;i<n;i++)
    {
    	b[i]=a[i]+b[i-1];
    }
    ll sum=0;
    for(int i=0;i<n-1;i++)
    {
    	sum=sum%mod+(a[i]%mod)*((b[n-1]-b[i])%mod);
    	sum=sum%mod;
    }
    return sum;
} 
int main()
{
	fast;
    ll n;
    cin>>n;
    ll a[n];
    llp(i,0,n)
    cin>>a[i];
    cout<<sum(a,n)%mod<<endl;
}

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

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int main() {
	char c[3][3];
	cin >> c[0][0] >> c[0][1] >> c[0][2];
	cin >> c[1][0] >> c[1][1] >> c[1][2];
	cin >> c[2][0] >> c[2][1] >> c[2][2];
	cout << c[0][0] << c[1][1] << c[2][2] << endl;
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int _compare(const void *a, const void *b) {
	if(*(long long int *)a < *(long long int *)b)
		return -1;
	else if(*(long long int *)a == *(long long int *)b)
		return 0;
	else
		return 1;
}

int main(void) {
	long long int Q, H, S, D, N, ans = 0;
	long long int nedan_for_2L[10];
	long long int nedan_for_1L[4];
	
	scanf("%lld %lld %lld %lld", &Q, &H, &S, &D);
	getchar();
	scanf("%lld", &N);

	nedan_for_2L[0] = D;
	nedan_for_2L[1] = S*2;
	nedan_for_2L[2] = S + H*2;
	nedan_for_2L[3] = S + H + Q*2;
	nedan_for_2L[4] = S + Q*4;
	nedan_for_2L[5] = H*4;
	nedan_for_2L[6] = H*3 + Q*2;
	nedan_for_2L[7] = H*2 + Q*4;
	nedan_for_2L[8] = H + Q*6;
	nedan_for_2L[9] = Q*8;

	nedan_for_1L[0] = S;
	nedan_for_1L[1] = H*2;
	nedan_for_1L[2] = H + Q*2;
	nedan_for_1L[3] = Q*4;

	qsort(nedan_for_2L, 10, sizeof(*nedan_for_2L), _compare);
	qsort(nedan_for_1L, 4, sizeof(*nedan_for_1L), _compare);

	ans = (N / 2) * nedan_for_2L[0];
	if(N % 2 == 1)
		ans += nedan_for_1L[0];

	printf("%lld", ans);

	return 0;
}

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

int main(){
  string S, T;
  cin >> S >> T;
  int A, B;
  cin >> A >> B;
  string U;
  cin >> U;
  
  if(S == U){
    cout << A-1 << " " << B << endl;
  }else {
    cout << A << " " << B-1 << endl;
  }
  return 0;
}

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

int n, m, x, y;

int maxx = -100 - 5;
int miny = 100 + 5;

int main(void) {
  // Here your code !
  scanf("%d %d %d %d", &n, &m, &x, &y);

  for (int i = 0; i < n; ++i) {
    int tmpx;
    scanf("%d\n", &tmpx);
    maxx = max(maxx, tmpx);
  }

  for (int i = 0; i < m; ++i) {
    int tmpy;
    scanf("%d\n", &tmpy);
    miny = min(miny, tmpy);
  }

  if (x >= y || maxx >= miny) {
    printf("War\n");
    return 0;
  }

  for (int i = maxx + 1; i <= miny; ++i) {
    if (x < i && i <= y) {
      printf("No War\n");
      return 0;
    }
  }

  printf("War\n");
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
//        List<Integer> sides = new ArrayList<>();
        int sides[] = new int[3];
        for(int i=0 ; i<3 ; i++) {
//            sides.add(sc.nextInt());
            sides[i] = sc.nextInt();
        }
        Arrays.sort(sides);
//        for(int i=0 ; i<3 ; i++){
//            System.out.println(sides[i]);
//        }
//        System.out.println(sides);
        double Scale = (sides[0] + sides[1] + sides[2])*0.5;
        Scale = Scale*(Scale-sides[0])*(Scale-sides[1])*(Scale-sides[2]);
        Scale = Math.sqrt(Scale);
        System.out.println((int)Scale);

    }
}


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

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

    int ans = 0;
    rep(i, 6) {
        if (s.at(i) == '1')
            ans++;
    }

    cout << ans << endl;
}

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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}
ll nCr(int n,int r){
    if(r==1)return n;
    if(r==2)return n*(n-1)/2;
    return n*(n-1)*(n-2)/6;
}
int main()
{
    int N,M;
    cin >> N >> M;
    cout << nCr(N,2) + nCr(M,2)<< endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;



int main() {
    ll x, y;
    cin >> x >> y;
    int j = 0;
    while((x<<j) <= y) ++j;
    cout << j << endl;
}

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

using namespace std;

const int INF = 1 << 30;

int N;
vector< int > g[200000], rg[200000];
int in[200000], grundy[200000];
bool notloop[200000];

int main()
{
  cin >> N;
  for(int i = 0; i < N; i++) {
    int p;
    cin >> p;
    g[--p].push_back(i);
    rg[i].push_back(p);
    ++in[p];
  }

  queue< int > que;

  for(int i = 0; i < N; i++) if(in[i] == 0) que.emplace(i);
  while(!que.empty()) {
    int p = que.front();
    notloop[p] = true;
    que.pop();
    set< int > st;
    for(auto &to : g[p]) st.emplace(grundy[to]);
    while(st.count(grundy[p])) ++grundy[p];
    for(auto &to : rg[p]) if(--in[to] == 0) que.emplace(to);
  }

  vector< int > vertex;
  for(int i = 0; i < N; i++) if(!notloop[i]) vertex.push_back(i);

  int mn = INF, cnt = 0;
  for(int i : vertex) {
    set< int > st;
    for(auto &to : g[i]) if(notloop[to]) st.emplace(grundy[to]);
    while(st.count(grundy[i])) ++grundy[i];
    if(mn == grundy[i]) ++cnt;
    else cnt = 1, mn = grundy[i];
  }
  if(vertex.size() % 2 == 1 && cnt == vertex.size()) cout << "IMPOSSIBLE" << endl;
  else cout << "POSSIBLE" << endl;
}


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

//素因数分解(関数ver)
map<int64_t,int64_t> prime_fact(int64_t n){
  int64_t a = 2;
  map<int64_t,int64_t> mp;
  while(n >= a*a){
    if(n %a == 0){
      mp[a]++;
      n /= a;
    }
    else{
      a++;
    }
  }
  if(n != 1){
    mp[n]++;
  }
  return mp;
}

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  
  map<int,int> ans;
  for(int i=0; i<N; i++){
    map<int64_t, int64_t> A = prime_fact(vec[i]);
    for(auto itr = A.begin(); itr != A.end(); itr++){
      ans[itr->first]++;
    }
  }
  
  int coprime = 0;
  
  for(auto itr = ans.begin(); itr != ans.end(); itr++){
    coprime = max(coprime,itr->second);
  }
  
  if(coprime <= 1){
    cout << "pairwise coprime" << endl;
  }
  else if(coprime != N){
    cout << "setwise coprime" << endl;
  }
  else{
    cout << "not coprime" << endl;
  }
}

Measured memory_bytes: 10660
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define INF INT_MAX
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int n,a,b,d[1000];
int main(){
   cin.tie(0);
   ios::sync_with_stdio(false);
   int c;
   cin>>a>>b>>c;
   n=min(a,b);
   int cnt=0;
   while(1){
     if(a%n==0 && b%n==0){
       cnt++;
     }
     if(cnt==c){
       break;
     }else{
       n--;
     }
   }
   cout<<n<<endl;
   return 0;
}


Measured memory_bytes: 256
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
v1, v2 = A1 - B1, A2 - B2
d1, d2 = v1 * T1, v2 * T2
if d1 > 0:
    d1 *= -1
    d2 *= -1

if d1 + d2 < 0:
    print(0)
elif d1 + d2 ==  0:
    print("infinity")
elif d1 + d2 > 0:
    s, t = divmod(-d1, d1+d2)
    print(2*s+(t!=0))

Measured memory_bytes: 3188
#include <stdio.h>
int n,k;
char a[100010];
int up,down;
int can_flip;
int ans;
int min(int a,int b){
	return a<b?a:b;
}
int main(){
	scanf("%d %d\n",&n,&k);
	scanf("%s",a);
	for(int i=0;i<n-1;i++){
		if(a[i]=='L'&&a[i+1]=='R') up++;
		if(a[i]=='R'&&a[i+1]=='L') down++;
		if(a[i]==a[i+1]) ans++;
	}
	if(up==down){
		ans = ans+min(up,k)*2;
	} else {
		if(k>min(up,down)){
			ans = ans+min(up,down)*2+1;
		} else {
			ans = ans+k*2;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
struct LazySegmentTree {
private:
    int n;
    vector<ll> node, lazy;

public:
    LazySegmentTree(vector<ll> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);

        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
    }

    void eval(int k, int l, int r) {
        if(lazy[k] != 0) {
            node[k] += lazy[k];
            if(r - l > 1) {
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }

    void add(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
        }
        else {
            add(a, b, x, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }

    ll getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        ll vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};
int main(){
    ll N,d,a;cin>>N>>d>>a;
    ll ans=0;
    vector<P> v(N);
    rep(i,N){
        cin>>v[i].fi>>v[i].se;
        v[i].se=(v[i].se-1)/a+1;
    }
    sort(all(v));
    vi t(N);
    rep(i,N)t[i]=v[i].se;
    LazySegmentTree seg(t);
    rep(i,N){
        ll k=max(0ll,seg.getsum(i,i+1));
        ans+=k;
        seg.add(i+1,upper_bound(all(v),P(v[i].fi+d*2,inf))-v.begin(),-k);
    }
    out(ans);
}

Measured memory_bytes: 14720
N = int(input())
a = list(map(int, input().split()))

ans=0
flag=0
while True:
    for i in range(N):
        if(a[i]%2 == 1):
            flag=1
    if flag == 1:
        break
    ans = ans+1

    for i in range(N):
        a[i] = a[i]/2

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ');
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

int main () {
  int k, s;
  cin >> k >> s;

  int ans = 0;
  rep(x,k+1) {
    rep(y,k+1) {
      if (0 <= s-x-y && s-x-y <=k) ans++;
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
s = input()
c = s[b-1]
ans = ''
if(c == 'A'):
    ans = s[:b-1]
    ans = ans + 'a'
    ans = ans + s[b:]
    print(ans)
elif(c == 'B'):
    ans = s[:b-1]
    ans = ans + 'b'
    ans = ans + s[b:]
    print(ans)
else:
    ans = s[:b-1]
    ans = ans + 'c'
    ans = ans + s[b:]
    print(ans)

Measured memory_bytes: 3064