akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	int ans = 0;
	int t = 100;
	while(true) {
		if(t >= n) break;
		t *= 1.01;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3652
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    cin>>n>>m;
    ll h[n];
    Ff(i,0,n)
    cin>>h[i];
    ipgraph(n,m);

    ll ans=0;
    Ff(i,0,n)
    {
      ll flag=1;
      Ff(j,0,g[i].size())
      {
        if(h[i]<=h[g[i][j]])
        {
          flag=0;
          break;
        }
      }
      if(flag)
      ans++;
    }
    cout<<ans;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(ll n, ll m){
	ll i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

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

int main() {
    int n, ans = 0;
    vector<int> v;
    queue<int> que;
    que.push(3);
    que.push(5);
    que.push(7);
    cin >> n;
    /* 順七五三数列挙 */
    while(que.size()) {
        int num = que.front();
        if(num < (int)1e8) {
            int num3 = 10*num + 3;
            int num5 = 10*num + 5;
            int num7 = 10*num + 7;
            v.push_back(num3);
            v.push_back(num5);
            v.push_back(num7);
            que.push(num3);
            que.push(num5);
            que.push(num7);
        }
        que.pop();
    }
    /* 七五三数判定 */
    for(int i = 0; i < v.size(); ++i) {
        if(v[i] > n) break;
        string s = to_string(v[i]);
        int f = 0;
        for(int j = 0; j < s.size(); ++j) {
            if(s[j] == '3') f |= 1;
            else if(s[j] == '5') f |= 2;
            else if(s[j] == '7') f |= 4;
        }
        if(f == 7) ans++;
    }

    cout << ans << '\n';
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1<<29;
typedef long long ll;

int dp[100][2][100];//dp[keta][未満である][0でない数の個数]

struct UnionFind {
  vi parent;
  UnionFind(int N) : parent(N) {
    rep(i, N)parent[i] = i;
  }

  int getRoot(int child){
    return ((parent[child] == child) ? child : parent[child] = getRoot(parent[child]));
  }
  void unite(int x, int y){
    int root_x = getRoot(x);
    int root_y = getRoot(y);
    if(root_x == root_y)return;
    parent[root_x] = parent[root_y];
  }
  bool isSame(int x, int y){
    return getRoot(x) == getRoot(y);
  }
};

const int di[] = {1, 0, -1, 0};
const int dj[] = {0, 1, 0, -1};

int main(){
    int sx, sy, tx, ty;cin >> sx >> sy >> tx >> ty;
    int x = tx - sx;
    int y = ty - sy;
    rep(i, y)cout << 'U';
    rep(i, x)cout << 'R';
    rep(i, y)cout << 'D';
    rep(i, x + 1)cout << 'L';
    rep(i, y + 1)cout << 'U';
    rep(i, x + 1)cout << 'R';
    cout << 'D';
    cout << 'R';
    rep(i, y + 1)cout << 'D';
    rep(i, x + 1)cout << 'L';
    cout << 'U';
}


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

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

const int MAX_V = 200;
ll X;
vector<ll> P;

void input_init(void) {
	cin >> X;
	P.resize(MAX_V + 1);
	for (int i = 0; i <= MAX_V; ++i) {
		ll p2 = (ll)i * i;
		ll p4 = p2 * p2;
		P[i] = p4 * i;
	}
}

pi solve(void) {
	pi val = make_pair(0, 0);
	for (int i = 0; i <= MAX_V; ++i) {
		for (int j = i; j <= MAX_V; ++j) {
			if (P[i] + P[j] == X)
				return make_pair(i, -j);
		}
	}
	for (int i = MAX_V; i >= 0; --i) {
		for (int j = i; j >= 0; --j) {
			if (P[i] - P[j] == X)
				return make_pair(i, j);
		}
	}
	return val;
}

int main(void) {
	input_init();
	pi ans = solve();
	cout << ans.first << ' ' << ans.second << '\n';
	return 0;
}


Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using uInt = long long unsigned int;
using Double = long double;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:

    void solve() {
        Int N, K, C;
        cin >> N >> K >> C;
        string S;
        cin >> S;
        S.insert(S.begin(), 'x');
        S.push_back('x');

        vector<Int> L(N + 2), R(N + 2);
        for (int i = 1; i < N + 2; ++i) {
            if (S[i] == 'x') {
                L[i] = L[i - 1];
            } else {
                if (i - (C + 1) < 0) {
                    L[i] = 1;
                } else {
                    L[i] = L[i - (C + 1)] + 1;
                }
            }
        }
        reverse(all(S));
        for (int i = 1; i < N + 2; ++i) {
            if (S[i] == 'x') {
                R[i] = R[i - 1];
            } else {
                if (i - (C + 1) < 0) {
                    R[i] = 1;
                } else {
                    R[i] = R[i - (C + 1)] + 1;
                }
            }
        }
        reverse(all(R));
        for (int i = 1; i <= N; ++i) {
            Int cnt = L[i - 1] + R[i + 1];
            if (cnt < K) {
                cout << i << endl;
            }
        }

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    Solve().solve();


    return 0;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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 GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

long long rui(long long a, long long b){
  long long ans = 1;
  while (b > 0){
    if (b & 1)
      ans = ans * a % MOD;
    a = a * a % MOD;
    b /= 2;
  }
  return ans;
}

long long comb(long long a, long long b){
  long long ans = 1;
  for (long long i = a; i > a - b; i--){
    ans = ans * i % MOD;
  }
  for (long long i = 1; i <= b; i++){
    ans = (ans * rui(i, MOD - 2)) % MOD;
  }
  return ans;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m,k; cin>>n>>m>>k;

  ll c = comb(n*m-2,k-2);
  
  ll dx=0;
  rep(i,m){
    (dx+=(i*(m-i))%MOD*(n*n)%MOD)%=MOD;
  }
  
  ll dy=0;
  rep(i,n){
    (dy+=i*(n-i)%MOD*(m*m)%MOD)%=MOD;
  }
  
  ll ans=((dx*c)%MOD+(dy*c)%MOD)%MOD;
  cout<<ans<<endl;
}


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

int main()
{		
	int n, m, c = 0;
	int k[10], p[10];
	int s[10][10];

	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		cin >> k[i];

		for (int j = 0; j < k[i]; j++)
			cin >> s[i][j];
	}

	for (int i = 0; i < m; i++)
		cin >> p[i];

	for (int i = 0; i < (1 << n); i++) {
		bool f = 1;
		for (int j = 0; j < m; j++){
			int b = 0;

			for (int u = 0; u < k[j]; u++)
				if ((i & (1 << (s[j][u] - 1))) > 0)
					b++;

			if (b % 2 != p[j]) {
				f = 0;
				break;
			}
		}
		if (f)
			c++;
	}

	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split(' ')))
colors=[8 if a>=3200 else a//400 for a in A]
c1=[1 if i in colors else 0 for i in range(8)]
c2=colors.count(8)
print(max(1,c1.count(1)),c1.count(1)+c2)

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

int main(){
  int N;
  cin >> N;
  int v[N];
  for(int i=0;i<N;++i){
    cin >> v[i];
  }
  float x;
  float y;
  float res;
  sort(v,v+N);
  res=(float) (v[0]+v[1])/2;
  for(int i=2;i<N;++i){
    res=(float) (res+v[i])/2;
    }
  cout << res<<endl;
}

Measured memory_bytes: 256
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
target = [list(map(int, input().split())) for i in range(M)]
target = sorted(target, key = lambda x:x[1], reverse=True)
# print(target)

'''
4 4
1 3
2 2
1 1
2 4


'''


for t in target:
    A.extend([t[1]] * t[0])
    if len(A) > N * 2:
        break
A.sort(reverse=True)

print(sum(A[:N]))


Measured memory_bytes: 35652
<?php
fscanf(STDIN, "%d %d", $n, $k);

for ($amount = 0;$amount < $n; $amount++){
  $safe[$amount] = 1;
}

for($i=0; $i<$k; $i++){
  fscanf(STDIN, "%d", $d);
  $a = explode(" ", trim(fgets(STDIN)));
  foreach($a as $value){
    $amount = $amount - $safe[$value-1];
    $safe[$value-1] = 0;
  }
}

echo $amount;
?>


Measured memory_bytes: 16128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    let k: u16;
    let s: String;

    input! {
        k: u16,
        s: String
    }

    // println!("{}", s.len());
    if s.len() <= k as usize {
        println!("{}", s)
    } else {
        println!("{}...", &s[0..k as usize])
    }
}


Measured memory_bytes: 2172
import itertools

N = int(input())
P = [list(map(int,input().split())) for i in range(N)]
number = 0
Sum = 0
for pair in itertools.permutations(P,N):
    for i in range(N-1):
        Sum = Sum + ((pair[i][0]-pair[i+1][0])**2+(pair[i][1]-pair[i+1][1])**2)**(1/2)
    number += 1
print(Sum/number)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h,w,a,b,i;
	while(cin>>h>>w&&h){multiset<int> t;b=0;
	for(i=0;i<h;i++){cin>>a;b+=a;t.insert(a);}
	for(i=0;i<w;i++){cin>>a;
		if(t.find(a)==t.end())b+=a;
		else{h=t.erase(a)-1;while(h--)t.insert(a);}
	}cout<<b<<endl;
	}return 0;
}

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

int main() {
  int N;
  cin >> N;
  repe(i, N, 999) {
    string s = to_string(i);
    bool ok = true;
    rep(j, 1, s.size()) if (s[j - 1] != s[j]) ok = false;
    if (ok) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3624
import numpy as np
N,M=map(int,input().split())
x=[]
for n in range(N):
	x.append(list(input()))

for __ in range(2):
	check=[]
	count=0
	for _ in range(len(x[0])):
		check.append(".")
	for xi in x:
		if xi == check:
			count+=1
	for _ in range(count):
		x.remove(check)
	x=np.array(x).T.tolist()

for i in range(len(x)):
	for j in range(len(x[0])):
		print(x[i][j],end="")
	if i != len(x)-1:
		print()

Measured memory_bytes: 14020
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func readLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	readLine(sc)
	s := readLine(sc)
	k, _ := strconv.Atoi(readLine(sc))

	t := []rune(s)[k-1]
	var res string
	for _, o := range s {
		if o == t {
			res += string(o)
		} else {
			res += string('*')
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main(void){
    int N, ans=0;
    cin >> N;

    if(N%10==0 || N%10==1 || N%10==6 || N%10==8)
      cout <<"pon" << endl;
    else if(N%10==3)
      cout<<"bon" <<endl;
    else
      cout<< "hon"<<endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l.at(i);
    }
    int cnt = 0, d = 0;
    while (d <= x and cnt < n) {
        d += l.at(cnt);
        cnt++;
    }
    if (cnt == n and d <= x) {
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

#define endl '\n'
#define ll long long

const ll mod = 1e9 + 7;
const ll maxn = 2e4 + 5;
const double pi = 3.1415926535897932384626433832795028841971693993751058209749445923078;

//iostream::sync_with_stdio(false);

int main()
{
    int n, m;
    int a[maxn];
    cin >> n >> m;
    int sum = 0;
    for(int i = 0; i < m; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    if(sum > n)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << n - sum << endl;
    }
    return 0;
}




Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
   string s;
   cin>>s;
   string t="";
   rep(i,s.size()){
       if(s[i]=='0'||s[i]=='1')t+=s[i];
       if(s[i]=='B'&&t.size()){
           int m=t.size();
           t=t.substr(0,m-1);
       }
   }
   cout<<t<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define mod 1000000007
#define vll vector<ll>
#define pll vector<pair<ll,ll>>

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
    //cin>>t;
    t=1;
	start:
	while(t--){

         ll n;
         cin>>n;
         ll ans=0;
         for(ll i=1;i<=n;i++){
                if(n%i==0)
             ans+=(n/i)-1;
         else ans+=n/i;
         }
         cout<<ans<<endl;

      }
	return 0;
}


Measured memory_bytes: 3648
fun main(args: Array<String>) {
    val t = Array(5) {
        readLine()!!.toInt()
    }.toList()

    println(f(t))
}

private fun f(t: List<Int>) : Int {

    fun orderTime(current: Int, order: Int) : Int {
        val m = current % 10
        if (m > 0) {
            return order + current + 10 - m
        }
        return order + current
    }

    fun g(orders: List<Int>, order: Int, current: Int) : Int {
        val time = orderTime(current, order)
        val rest = orders.toMutableList()
        rest.remove(order)
        if (rest.isEmpty()) {
            return time
        }

        var min = Int.MAX_VALUE
        for (nextOrder in rest) {
            min = Math.min(g(rest, nextOrder, time), min)
        }

        return min
    }

    var min = Int.MAX_VALUE

    for (order in t) {
        min = Math.min(g(t, order, 0), min)
    }

    return min
}

Measured memory_bytes: 35720
import java.util.*;

public class Main{
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			int N = sc.nextInt(), A = sc.nextInt();
			int[] D = new int[N];
			for(int i = 0; i < N; i++){
				D[i] = sc.nextInt();
			}
			int ans = 0;
			for(int i = 0; i < N; i++){
				if(i!=0 && i * A % N == 0){
					break;
				}
				int vmax = 0, vmin = 101;
				for(int j = 0; j < A; j++){
					vmax = Math.max(vmax, D[(i*A + j)%N]);
					vmin = Math.min(vmin, D[(i*A + j)%N]);
				}
				ans += vmax - vmin;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 30688
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }




int main() {
	int n, k;
	string s;
	cin >> n >> k;
	cin >> s;
	k--;
	if (s[k] == 'A') {
		s[k] = 'a';
	}
	if (s[k] == 'B') {
		s[k] = 'b';
	}
	if (s[k] == 'C') {
		s[k] = 'c';
	}
	cout << s << endl;
	return 0;
}



Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

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

using namespace std;
typedef long long ll;

int main()
{
    const ll MOD = 1000000007;

    // Input
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;

    rep(i, n) {
        cin >> a[i];
        sum += a[i];
        sum %= MOD;
    }

    ll ans = 0;

    rep(i, n - 1) {
        sum -= a[i];

        if (sum < 0) sum += MOD;

        ans += a[i] * sum % MOD;
   }
    cout << ans % MOD;

    return 0;
}


Measured memory_bytes: 4464
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62);

typedef long long i64;
typedef pair<i64,i64> P;


int n, k, a[101], b[101];
i64 px[101], py[101];

int main(){
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
		px[i] = a[i];
		py[i] = b[i];
	}
	
	sort(px, px+n);
	sort(py, py+n);
	
	i64 ans = LINF;
	for(int u = 0; u < n; u++) for(int d = 0; d < n; d++)
		for(int l = 0; l < n; l++) for(int r = 0; r < n; r++){
			int cnt = 0;
			for(int i = 0; i < n; i++){
				if(a[i] >= px[l] && a[i] <= px[r] && b[i] >= py[u] && b[i] <= py[d]){
					cnt++;
				}
			}
			if(cnt >= k) ans = min(ans, (px[r]-px[l])*(py[d]-py[u]));
		}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define Max 45

int F[Max];

int fibonacci(int n){
  if( n == 0 || n == 1)
    return F[n] = 1;
  if( F[n] != NULL ) 
    return F[n];
  return F[n] = fibonacci(n - 2) + fibonacci(n - 1);
}

int main(){

  int n, i, ans;

  scanf("%d",&n);

  for( i = 0 ; i <= n  ; i++)
    ans = fibonacci(i);

  printf("%d\n",ans);

  return 0;
}

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

int main() {
	long long ans = 0;
	long long n, x, top(0);
	cin >> n;
	for (int i = 0; i < n; ++i) {
        cin >> x;
        if (i == 0) top = x;
        if (top > x) {
            ans += top - x;
        }
        top = max(x, top);
	}
	cout << ans << endl;
	return 0;
};

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) long long((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
typedef pair<ll, ll> P;
typedef map<string, ll> M;
typedef unordered_map<ll, ll> HM;
typedef set<ll> S;
typedef multiset<ll> MS;
typedef queue<ll> Q;

int main(){
    int n,k; cin>>n>>k;
    vector<int> d(k);
    for(int i=0; i<k; i++)
        cin >> d[i];
    while(1){
        int tmp = n;
        bool flag = true;
        while(tmp){
            auto itr = find(ALL(d),tmp%10);
            if(itr != d.end()){
                flag = false;
                break;
            }
            tmp /= 10;
        }
        if(flag)
            break;
        n++;
    }
    OUT(n);
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int main(){
    int n;
    cin >> n;
    if(n%10==7){
        cout<<"Yes"<<endl;
    }else{
        n/=10;
        if(n%10==7){
            cout<<"Yes"<<endl;
        }else{
            n/=10;
            if(n%10==7){
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstring>

using namespace std;

int H, W;
char grid[110][110];

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

int memo[101][101];

inline bool IN(int x, int y) {
  return 0<=x && x<W && 0<=y && y<H;
}

int const INF = 1<<29;

int main() {
  
  while(cin >> W >> H && W) {
    
    int sx, sy;
    
    for(int i=0; i<H; i++) {
      for(int j=0; j<W; j++) {
        cin >> grid[i][j];
        if(grid[i][j] == '&') {
          sx = j, sy = i;
          grid[i][j] = '.';
        }
      }
    }
    
    int ans = 1<<29;
    
    memset(memo, -1, sizeof(memo));
    typedef pair<int, int> Pii;
    typedef pair<int, Pii> Piii;
    
    priority_queue<Piii> Q;
    Q.push(Piii(0, Pii(sx, sy)));
    while(!Q.empty()) {
      Piii piii = Q.top(); Q.pop();
      int const x = piii.second.first;
      int const y = piii.second.second;
      int const cost = -piii.first;
      
      if(x == 0 || y == 0 || x == W-1 || y == H-1) {
        cout << cost << endl;
        break;
      }
      
      for(int k=0; k<4; k++) {
        int nx = x + dx[k], ny = y + dy[k];
        if(IN(nx, ny)) {
          int ncost = cost + (grid[y][x] == '.' && grid[ny][nx] == '#');
          if(memo[ny][nx] == -1 || memo[ny][nx] > ncost) {
            memo[ny][nx] = ncost;
            Q.push(Piii(-ncost, Pii(nx, ny)));
          }
        }
      }
    }
    
  }
  
  return 0;
}

Measured memory_bytes: 1388
#include<iostream>
#include<algorithm>
using namespace std;
int H,W;
string c[300];
int dp[303][303];
int L[303][303],R[303][303];
main()
{
	cin>>H>>W;
	for(int i=0;i<H;i++)cin>>c[i];
	long ans=0;
	for(int i=1;i<W;i++)
	{
		for(int j=0;j<=H;j++)
		{
			L[j][0]=0;
			R[j][0]=0;
			for(int k=1;k<=H-j;k++)
			{
				L[j][k]=L[j][k-1]+(c[j+k-1][i-1]==c[k-1][i]);
				R[j][k]=R[j][k-1]+(c[k-1][i-1]==c[j+k-1][i]);
			}
		}
		for(int j=0;j<=H;j++)for(int k=0;k<=H;k++)dp[j][k]=1e9;
		dp[H][H]=0;
		for(int j=H;j>=0;j--)for(int k=H;k>=0;k--)
		{
			if(j>0)dp[j-1][k]=min(dp[j-1][k],dp[j][k]+(j<k?L[k-j][j]:R[j-k][k]));
			if(k>0)dp[j][k-1]=min(dp[j][k-1],dp[j][k]+(j<k?L[k-j][j]:R[j-k][k]));
		}
		ans+=dp[0][0];
	}
	cout<<ans<<endl;
}

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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll = V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define INF 1e16
#define mod 1e9+7


int main(){
  ll n,k;
  cin>>n>>k;
  str s;
  cin>>s;
  if(s[k-1]=='A')s[k-1]='a';
  if(s[k-1]=='B')s[k-1]='b';
  if(s[k-1]=='C')s[k-1]='c';
  co(s);
}
  

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

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

	int ans;
	for (int X = 1; X < 50000; X++) {
		if ((int)((double)X * 1.08) == N) {
			cout << X << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
  }
  int top() {
    return s[0];
  }
};
int main(){
  Dice d;
  for(int i=0;i<6;i++) cin >> d.s[i];
  string s;cin >> s;
  for(int i=0;i<s.size();i++) d.roll(s[i]);
  cout << d.top() << endl;
  return 0;
}

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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  for (int i=0; i<N; i++) cin >> a[i];

  vector<bool> v(K+1);
  // v[k] = true iff one can win starting with k stones

  v[0] = false;  // if no stones is left, lose
  for (int k=1; k <= K; k++) {
    v[k] = false;
    for (vector<int>::iterator it=a.begin(); it != a.end(); ++it) {
      if (*it <= k && !v[k - *it]) {
        v[k] = true;
        break;
      }
    }
  }

  
  cout << (v[K] ? "First" : "Second") << "\n";
  return 0;
}


Measured memory_bytes: 256
x = int(input())
from math import ceil, sqrt
def eratosthenes(n):
    l = [1 for i in range(n+1)]
    l[0] = l[1] = 0
    for i in range(2, ceil(sqrt(n))):
        if l[i] == 0: continue
        for j in range(i*2, n+1, i):
            l[j] = 0
    return l


l = eratosthenes(2*10**5)


while True:
    if l[x]:
        break
    x+=1
print(x)

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

int main() {
  string s, t;
  cin >> s >> t;
  vector<vector<int>> positions(26);
  for (int i = 0; i < s.size(); ++i) positions[s[i] - 'a'].push_back(i);
  ll ans = 0;
  int tpos = 0;
  int pointer = -1;
  while (tpos < t.size()) {
    if (positions[t[tpos] - 'a'].size() == 0) {
      cout << -1 << endl;
      return 0;
    }
    auto itr = upper_bound(positions[t[tpos] - 'a'].begin(),
                           positions[t[tpos] - 'a'].end(), pointer);
    if (itr != positions[t[tpos] - 'a'].end()) {
      // OK
      ans += *itr - pointer;
      pointer = *itr;
    } else {
      // next loop
      ans += (positions[t[tpos] - 'a'][0] + s.size() - pointer);
      pointer = positions[t[tpos] - 'a'][0];
    }
    tpos++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, A, B; cin >> N >> A >> B;
    if (__builtin_popcount(A ^ B) % 2 == 0) {
        cout << "NO\n";
        return 0;
    }
    cout << "YES\n";
    int ymax = 1 << (N - 1);
    vector<int> gray(ymax), ungray(ymax);
    for (int i = 0; i < ymax; i++) {
        gray[i] = i ^ (i >> 1);
        ungray[gray[i]] = i;
    }
    vector<pair<int, int>> ans;
    int x = 0, goal_y = ungray[(A ^ B) >> 1];
    for (int y = 0; y < goal_y; y++) {
        ans.emplace_back(y, x);
        ans.emplace_back(y, !x);
        x = !x;
    }
    ans.emplace_back(goal_y, x);
    for (int y = goal_y + 1; y < ymax; y++) {
        ans.emplace_back(y, x);
    }
    for (int y = ymax - 1; y >= goal_y; y--) {
        ans.emplace_back(y, !x);
    }
    for (auto &p : ans) {
        int y = p.first, x = p.second;
        cout << (((gray[y] << 1) | x) ^ A) << ' ';
    }
    cout << '\n';
    return 0;
}


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

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

    int counter = 0;
    rep(i, A + 1) {
        rep(j, B + 1) {
            rep(k, C + 1) {
                if (X == 500 * i + 100 * j + 50 * k) {
                    ++counter;
                }
            }
        }
    }

    cout << counter << endl;
}


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

using namespace std;
using ll = long long;

int main() {
    ll n;
    cin >> n;
    ll x = n / 3;
    ll y = n / 5;
    ll z = n / 15;
    ll sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0;
    if (x > 0) sum1 = (3 * x * (x + 1)) / 2;
    if (y > 0) sum2 = (5 * y * (y + 1)) / 2;
    if (z > 0) sum3 = (15 * z * (z + 1)) / 2;
    sum4 = n * (n + 1) / 2;
    ll ans = sum4 - sum1 - sum2 + sum3;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

template<class T>
class min_queue {
private:
    queue<T> Q;
    deque<T> minQ;
public:
    void push(T val) {
        Q.push(val);
        while(!minQ.empty() && minQ.back() > val) minQ.pop_back();
        minQ.push_back(val);
    }
    
    T front() {
        return Q.front();
    }
    
    void pop() {
        T remove_element = Q.front();
        Q.pop();
        if(!minQ.empty() && minQ.front() == remove_element) minQ.pop_front();
    }
    
    T getMin() {
        return minQ.front();
    }
    
    size_t size() {
        return Q.size();
    }
    
    bool empty() {
        return Q.empty();
    }
};

int main() {
    FAST_IO();
    int N, M; cin >> N >> M;
    string S; cin >> S;
    vector<pii> cnt(N + 1, {INT_MAX, -1});
    cnt[N].first = 0;
    min_queue<pii> MINQ;
    MINQ.push({0, N});
    for(int i = N - 1; i >= 0; --i) {
        if(S[i] == '0') {
            pii p = MINQ.getMin();
            if(p.first == INT_MAX) {
                cout << "-1\n";
                return 0;
            }
            cnt[i] = {p.first + 1, p.second - i};
            if(sz(MINQ) < M) {
                MINQ.push({p.first + 1, i});
            } else {
                MINQ.pop();
                MINQ.push({p.first + 1, i});
            } 
        } else {
            if(sz(MINQ) < M) {
                MINQ.push({INT_MAX, i});
            } else {
                MINQ.pop();
                MINQ.push({INT_MAX, i});
            }
        }
    }
    int start = 0;
    while(start != N) {
        cout << cnt[start].second << " ";
        start += cnt[start].second;
    }    
}


Measured memory_bytes: 1920
#include<iostream>
using namespace std;
int main()
{
	long long  N, A, B;
	cin >> N >> A >> B;
	if (N==1)
	{
		if (A == B)cout <<'1';
		else cout << '0';
	}
	else
	{
		if (A <= B)
		{
			long long minn, maxn;
			maxn =A + (N - 1)*B;
			minn =A*(N - 1) + B;
			cout << maxn - minn + 1;
		}
		else
	       cout << '0';
	}
	system("pause");
	return 0;
}

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

typedef long long int lli;
const int SIZE = 200002;
int N;
lli num[SIZE];
lli pSum[SIZE];

lli absol(lli x) {
	return x < 0 ? -x : x;
}

int main()
{
	lli ans = 10000000000000000L;
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		scanf("%lld", &num[i]);
		pSum[i] = pSum[i - 1] + num[i];
	}
	for (int i = 1; i < N; i++) {
		lli cand = absol(2 * pSum[i] - pSum[N]);
		if (cand < ans)
			ans = cand;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  ll D,N;
  cin>>D>>N;
  bool a=true;
  ll ans=0;
  if(N!=100){
      ans=N;
  }
  else{
      ans=101;
  }
  cout<<ll(ans*ll(pow(100,D)))<<endl;
}

Measured memory_bytes: 3756
#include <stdio.h>

int main(void)
{
    char c[2][4];
    scanf("%s%s",c[0],c[1]);
    puts(c[0][0]==c[1][2]&&c[0][1]==c[1][1]&&c[0][2]==c[1][0]?"YES":"NO");
    return 0;
}

Measured memory_bytes: 128
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// 出力
int
fOut(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 改行カット
// 戻り値：文字数
int
fCutCrLf(
	char *pcpStr				// <I> 文字列
)
{
	int i;

	for (i = 0; pcpStr[i] != '\0'; i++) {
		if (pcpStr[i] == '\n') {
			pcpStr[i] = '\0';
			break;
		}
	}

	return i;
}

// 実行メイン
int
fMain(
)
{
	int i, j;
	char lc1Buf[1024];

	// 文字列数 - 取得
	int liSCnt;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &liSCnt);

	// 文字列 - 取得
	int liABCnt = 0;
	int liBCnt = 0;
	int liACnt = 0;
	int liBACnt = 0;
	for (i = 0; i < liSCnt; i++) {
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

		// 改行カット
		int liLen = fCutCrLf(lc1Buf);

		// 文字列内のAB数
		for (j = 0; j < liLen - 1; j++) {
			if (lc1Buf[j] == 'A') {
				if (lc1Buf[j + 1] == 'B') {
					liABCnt++;
				}
			}
		}

		// 文字列種類
		if (lc1Buf[0] == 'B') {
			if (lc1Buf[liLen - 1] == 'A') {
				liBACnt++;
			}
			else {
				liBCnt++;
			}
		}
		else {
			if (lc1Buf[liLen - 1] == 'A') {
				liACnt++;
			}
		}
	}

	// BA文字列を連結
	if (liBACnt > 0) {
		liABCnt += liBACnt - 1;

		// 連結
		if (liACnt > 0) {
			liABCnt++;
		}
		else if (liBCnt > 0) {
			liABCnt++;
		}
	}

	// B文字列とA文字列を連結
	if (liACnt < liBCnt) {
		liABCnt += liACnt;
	}
	else {
		liABCnt += liBCnt;
	}

	return liABCnt;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOut(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> p(m);
	vector<string> s(m);
	for (int i = 0; i < m; ++i) {
		int tmp;
		string stmp;
		cin >> tmp >> stmp;
		p[i] = tmp;
		s[i] = stmp;
	}

	map<int, int> mp;
	map<int, int> ca;
	int ac = 0;
	int wa = 0;
	for (int i = 0; i < m; ++i) {
		if (s[i] == "AC") {
			if (0 == mp.count(p[i])) {
				mp[p[i]] = 1;
				ac++;
				wa += ca[p[i]];
				ca[p[i]] = 0;
			}
		} else if (s[i] == "WA") {
			if (0 == mp.count(p[i])) {
				ca[p[i]]++;
			}
		}
	}

	cout << ac << " " << wa << endl;
}



Measured memory_bytes: 15488
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

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

using namespace std;

int main(){
    int n, ans = 0; cin >> n;
    string s; cin >> s;

    REP(i, n - 1)
        if(s[i] != s[i + 1]) ans++;                                    

    cout << ans + 1;
}


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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

vector<ll> func(ll n)
{
	vector<ll> res;
	res.pb(1), res.pb(n);
	for (int i = 2; i <= sqrt(n); ++i)
	{
		if (i * 1LL * i == n)
		{
			res.pb(i);
			res.pb(i);
		}
		else if (n % i == 0)
		{
			res.pb(i);
			res.pb(n / i);
		}
	}
	return res;
}

void solve()
{
	ll n;
	cin >> n;
	vector<ll> d = func(n);
	if (d.size() == 2)
	{
		cout << n - 1 << endl;
	}
	else
	{
		sort(all(d));
		ll res = 1e18 + 7;
		for (int i = 0; i < d.size() / 2; ++i)
		{
			res = min(res, d[i] + d[d.size() - 1 - i] - 2);
		}
		cout << res << endl;
	}
}

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


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
int main(){
  string str;
  cin >> str;
  if(str[0]=='Y' && str[1]=='A' && str[2]=='K' && str[3]=='I') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
 return 0;
}

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

#include <cassert>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,a,b) for(ll i=(a); i < (b); i++)
#define RFOR(i,a,b) for(ll i=(b)-1; i >= (a); i--)
#define rep(i,n) FOR(i,0,(n))
#define rrep(i,n) RFOR(i,0,(n))

int main() {
	int N;
	cin >> N;
	vector<int> a(N), b(N);
	int res = 0;
	for(int i = 0; i < N; i++)
		cin >> a[i];
	for(int i = 0; i < N; i++)
		cin >> b[i];
	for(int i = 0; i < 30; i++) {
		vector<int> bb;
		for(int j = 0; j < N; j++) {
			bb.push_back(b[j] & ((1 << (i+1)) -1) );
		}
		ll cnt = 0;
		sort(all(bb));
		for(int j = 0; j < N; j++) {
			int aa = a[j] & ((1 << (i+1)) -1);

			cnt += bb.end() - lower_bound(all(bb), (3<<i) - aa);
			cnt += upper_bound(all(bb), (1<<(i+1))-1 -aa) - lower_bound(all(bb), (1<<i)-aa);
		}
		res |= (cnt%2) << i;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0; i != N; ++i)
#define co(o) cout << o << endl;
using namespace std;
typedef long int li;
typedef long long ll;


int main(void){
    ll a,b;
    cin >> a >> b;
    if(a==1 || b==1){
        cout << 1 << endl;
    }else{
        a=a*b;
        cout << a/2+a%2 << endl;
    }
    
}


Measured memory_bytes: 256
N=int(input())
dat=[]
for i in range(N):
  inp = input().split()
  dat.append([inp[0],int(inp[1]),i+1])
dat.sort()
for i in range(N):
  dat[i]=[dat[i][1],dat[i][0],dat[i][2]]

#print(dat)
res=[dat[0]]
for i in range(N-1):
  j=i+1
  if dat[j][1]==dat[j-1][1]:
    res.append(dat[j])
  else:
    res.sort(reverse=True)
    for k in range(len(res)):
    	print(res[k][2])
    res=[dat[j]]

res.sort(reverse=True)
for k in range(len(res)):
	print(res[k][2])


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] sarray = br.readLine().split(" ");
        Deque<Integer> stack = new ArrayDeque<Integer>();
        for(int i = 0; i < sarray.length; i++){
            if(isNum(sarray[i])){
                stack.push(Integer.parseInt(sarray[i]));
            } else {
                int n = stack.pop();
                int m = stack.pop();
                if(sarray[i].equals("+"))stack.push(m + n);
                if(sarray[i].equals("-"))stack.push(m - n);
                if(sarray[i].equals("*"))stack.push(m * n);
                if(sarray[i].equals("/"))stack.push(m / n);
            }
        }
        System.out.println(stack.pop());
    }
    
    public static boolean isNum(String str){
        try{
            Integer.parseInt(str);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }
};


Measured memory_bytes: 24380
MOD = 10**9+7
X, Y = sorted(list(map(int, input().split())))

if (X+Y)%3 != 0:
    print (0)
    exit()

if (2*X < Y):
    print (0)
    exit()

W = X - ((X+Y)//3)
H = Y - ((X+Y)//3)

mx = 10**6
fact = [1] * (mx+1) # 階乗を格納するリスト
def inv(n): # MODを法とした逆元
    return pow(n, MOD-2, MOD)
for i in range(mx):
    fact[i+1] = fact[i] * (i+1) % MOD # 階乗を計算
ans = (fact[W+H] * inv(fact[W]) * inv(fact[H])) % MOD # comb(W+H,W) = (W+H)!/(W!H!)
print (ans)

Measured memory_bytes: 42612