akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 100005;
const int LGN = 18;
int x[N], nxt[N][LGN];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; cin>>n;
	for(int i = 1; i <= n; i++){
		cin>>x[i];
	}
	int l; cin>>l;
	for(int i = 1; i <= n; i++){
		nxt[i][0] = upper_bound(x + 1, x + n + 1, x[i] + l) - x - 1;
	}
	for(int k = 1; k < LGN; k++){
		for(int i = 1; i <= n; i++){
			nxt[i][k] = nxt[nxt[i][k - 1]][k - 1];
		}
	}
	int q; cin>>q;
	while(q--){
		int a, b;
		cin>>a>>b;
		if(a > b)swap(a, b);
		int ans = 1;
		for(int i = LGN - 1; i >= 0; i--){
			if(nxt[a][i] < b){
				ans += (1<<i);
				a = nxt[a][i];
			}
		}
		cout<<ans<<'\n';
	}

	return 0;
}

Measured memory_bytes: 8320
def main():
    N, Ma, Mb = map(int, input().split())
    a = [0] * N
    b = [0] * N
    c = [0] * N
    for i in range(N):
        a[i], b[i], c[i] = map(int, input().split())
    
    dp = [[[float('inf')] * 401 for _ in range(401)] for _ in range(41)]
    dp[0][0][0] = 0
    for i in range(N):
        for j in range(N*10+1):
            for k in range(N*10+1):
                if dp[i][j][k] == float('inf'):
                    continue
                # 選ばない場合
                dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k])
                # 選んだ場合
                dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i])

    ans = float('inf')
    for i in range(1,N*10+1):
        for j in range(1,N*10+1):
            if Ma * j == Mb * i:
                ans = min(ans,dp[N][i][j])

    if ans == float('inf'):
        ans = -1

    print(ans)

main()

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

int main(){
	string s;cin>>s;
	int cnt=0;
	for(char c:s){
		cnt+=c-'0';
	}
	if(stoi(s)%cnt==0)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
import bisect
n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
m = len(c)
ans = 0
for x in b:
    #挿入できる箇所を返す
    p = bisect.bisect_left(a, x)
    q = m - bisect.bisect_right(c, x)
    ans += p*q
print(ans)


Measured memory_bytes: 23092
#include<iostream>
#define D(x) cout<<"D:"<<#x<<'='<<x<<endl;
using namespace std;
typedef long long ll;
inline ll next(void)
{
	ll k;
	cin>>k;
	return k;
}
int main(void)
{
//	freopen("$.in", "r", stdin);
//	freopen("$.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n = next();
	cout<<(n+1)/2;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
  string str;
  cin>>str;
  int num1 = 0;
  int num2 = 0;
  int num3 = 0;
  for(int i=0;i<str.length();i++){
    if(str[i] == 'a')num1++;
    if(str[i] == 'b')num2++;
    if(str[i] == 'c')num3++;
  }
  if(num1 == 1&&num2==1&&num3==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var nums = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var list = new LinkedList<int>();
        var isOdd = num % 2 == 1;
        for(var i = 0; i < num; i++)
        {
            if (isOdd) list.AddFirst(nums[i]);
            else list.AddLast(nums[i]);
            isOdd = !isOdd;
        }
        foreach(var val in list)
        {
            Write($"{val} ");
        }
        WriteLine();
    }
}

Measured memory_bytes: 46656
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  int A, B;
  cin >> A >> B;
  if(A > 9 || B > 9) {
    cout << "-1";
    return 0;
  }
  cout << A * B;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>

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

using ll = long long;
using Graph = vector<vector<int> >;

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;

int main()
{
	string s;
	cin >> s;
	int ans = 0;
	int now = 0;
	rep(i, s.size()) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
			now++;
			ans = max(ans, now);
		}
		else {
			ans = max(ans, now);
			now = 0;
		}
	}
	cout << ans << endl;
}


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

int main(){
    string n;

    cin >> n;
    for (int i = 0; i < n.length(); i++) {
        if(n[i] == '9'){
            cout << 1;
        } else {
            cout << 9;
        }
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
  int a, b;
  cin >> a >> b;
  if(a<b){
    rep(i,b){
      cout << a;
    }
  }
  if(a>b){
    rep(i,a)
    cout << b;
  }
  if(a==b){
    rep(i,a)
    cout << b;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

struct query{
  ll type;//0=empty, 1=add-sum ,2=set-max
  ll value;
  query(ll a=0,ll b=0):type(a),value(b) {}
};

ll INF=(1LL<<60);

struct segtree{
  ll SIZE;
  vector<query> s;
  vector<ll> t;// sum-add
  vector<ll> u;// max-set

  segtree(ll n=1){
    SIZE=1;
    while(SIZE<n)SIZE*=2;
    s.clear();
    t.clear();
    u.clear();
    s.resize(SIZE*2, query());
    t.resize(SIZE*2, 0);
    u.resize(SIZE*2, 0);
  }
  
  void func(ll k,ll l,ll r,query q){
    if(q.type==1){
      if(s[k].type==0)s[k]=q;
      else s[k].value+=q.value;
      t[k]+=q.value*(r-l);
      u[k]+=q.value;
    }
    if(q.type==2){
      s[k]=q;
      t[k]=q.value*(r-l);
      u[k]=q.value;
    }
  }

  void compute(ll k,ll l,ll r){
    query q=s[k];
    s[k]=query();
    if(q.type==0||r-l==1)return;
    ll m=(l+r)/2;
    func(k*2+1,l,m,q);
    func(k*2+2,m,r,q);
  }

  void Update(ll a,ll b,query x,ll k,ll l,ll r){
    if(b<=l || r<=a)return;
    compute(k,l,r);
    if(a<=l && r<=b){
      func(k,l,r,x);
    }else{
      ll m=(l+r)/2;
      Update(a,b,x,k*2+1,l,m);
      Update(a,b,x,k*2+2,m,r);
      t[k]=t[k*2+1]+t[k*2+2];
      u[k]=max(u[k*2+1],u[k*2+2]);
    }
  }

  ll Dfs(ll type,ll a,ll b,ll k,ll l,ll r){
    if(b<=l || r<=a){
      if(type==1)return 0; //add
      if(type==2)return -INF; // max
    }
    compute(k,l,r);
    if(a<=l && r<=b){
      if(type==1)return t[k];
      if(type==2)return u[k];
    }else{
      ll m=(l+r)/2;
      ll lv=Dfs(type,a,b,k*2+1,l,m);
      ll rv=Dfs(type,a,b,k*2+2,m,r);
      if(type==1)return lv+rv; // add
      if(type==2)return max(lv,rv); // max
    }
  }

  void Add(ll a,ll b,ll x){
    Update(a,b,query(1,x), 0,0,SIZE);
  }
  void Set(ll a,ll b,ll x){
    Update(a,b,query(2,x), 0,0,SIZE);
  }
  ll Getsum(ll a,ll b){
    return Dfs(1,a,b, 0,0,SIZE);
  }

  ll Getmax(ll a,ll b){
    return Dfs(2,a,b, 0,0,SIZE);
  }
  
};

int main() {
  ll n,m;
  cin >> n >> m;
  vector<vector<pll>> G(n+1);
  segtree T(n+1);
  T.Set(0,n+1,0);
  for(ll i=0;i<m;i++) {
    ll l,r,a;
    cin >> l >> r >> a;
    G[r].push_back({l,a});
  }

  for(ll i=1;i<=n;i++) {
    T.Add(i,i+1,T.Getmax(0,i));
    for(auto p:G[i]) {
      ll l=p.first;
      ll a=p.second;
      T.Add(l,i+1,a);
    }
  }
  cout << T.Getmax(0,n+1) << endl;
}

Measured memory_bytes: 27520
<?php

list($n) = explode(' ', trim(fgets(STDIN)));
$p_list = explode(' ', trim(fgets(STDIN)));

$counter = 0;
$min = $n;
foreach ($p_list as $p) {
    if ($p > $min) {
        continue;
    }

    ++$counter;
    $min = $p;
}

echo $counter;


Measured memory_bytes: 18932
N, Y = map(int, input().split())

for i in range((Y // 10000)+1)[::-1]:
    if ((Y - 10000 * i) < 0) and ((N - i) < 0):
        print("-1 -1 -1")
        exit()
    Y2 = Y - 10000*i
    N2 = N - i
    for j in range((Y2 // 5000)+1)[::-1]:
        if ((Y2 - 5000 * j) < 0) and ((N2 - j) < 0):
            print("-1 -1 -1")
            exit()
        Y3 = Y2 - 5000 * j
        N3 = N2 - j
        if N3 * 1000 == Y3:
            print(i, j, N3)
            exit()

print("-1 -1 -1")


Measured memory_bytes: 3064
#include <iostream>

int main() {
    int n; std::cin >> n;
    int s = 1;
    bool inc = false, dec = false;
    int p; std::cin >> p;
    for (int i = 1; i < n; i ++) {
        int v; std::cin >> v;
        if (!inc && ! dec) {
            if (p < v) {
                inc = true;
            } else if (p > v) {
                dec = true;
            }
        } else if (inc) {
            if (p > v) {
                s++;
                inc = false;
            }
        } else if (dec) {
            if (p < v) {
                s++;
                dec =false;
            }
        }
        p = v;
    }

    std::cout << s  << std::endl;
    return 0;
}

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

int main() {
  int n;cin>>n;
  vector<int> a(n);
  int cnt=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  if(i%2==1&&a[i]%2==1)cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3620
x=range(int(input()))
f=lambda a,d,b,c : a*d - b*c 
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
_=0
P+=[P[0]]
for j in x:_+=f(P[j][0],P[j+1][1],P[j][1],P[j+1][0])
print(_*0.5)

Measured memory_bytes: 7736
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)

MOD = 1000000007  # type: int

def solve(N: int):
    elms = [0] * (N + 1)
    for i in range(2, N + 1):
        tmp = i
        j = 2
        while j <= i:
            while tmp % j == 0:
                elms[j] += 1
                tmp //= j
            j += 1
    ret = 1
    for e in elms:
        if e > 0:
            ret *= e + 1
            ret %= MOD
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

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



int main() {
	speed;
	cout << fixed << setprecision(6);
	/*start*/
	int n;
	cin >> n;
	vector<pair<int,int>>a(n);
	rep(i, n) {
		int b;
		cin >>b ;
		a[i] = make_pair(b, i+1);
	}
	sort(All(a));
	rep(i, n) {
		cout << a[i].second << " ";
		
	}
	ed;
	return 0;
}



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

int main()
{
  int k,a,b;
  bool ans = false;
  cin >> k >> a >> b;
  for(int i = a;i <=b;i++){
    if(i % k == 0){
      ans = true;
      break;
    }
  }
  if(ans) cout << "OK" << endl;
  else cout << "NG" << endl;
}


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

int main(){

    int n,tem,minj,count; count = 0;

    cin >> n;
    vector<int> list(n);
    for(int i = 0; i < n; i++){
        cin >> list.at(i);
    }

    for(int i = 0; i < n;i++){
        minj = i;
        for(int j = i; j < n;j++){
            if(list.at(j) < list.at(minj)) 
            minj = j;
        }
        if(minj != i){
      		tem = list.at(i);
            list.at(i) = list.at(minj);
            list.at(minj) = tem;
            count++;
        }
        }
    for(int i = 0; n-1 > i; i++){
    cout << list.at(i) << ' ';
    }
    cout << list.at(n-1) <<endl;
  	cout << count << endl;
}



Measured memory_bytes: 3108
n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

l = prime_factorize(n)

import collections
count = collections.Counter(l)

total = 0
for dup in count.items():
    total += 1
    appear = dup[1]
    if appear > 1:
        ite = 1
        accu = 1
        while accu < appear:
            ite += 1
            accu += ite
            if accu > appear:
                continue
            total += 1

print(total)


Measured memory_bytes: 65876
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<string>
#include<iomanip>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
int n, m;

void calc() {
    vector<pair<int, int> > v(n);
    ll sum = 0;
    rep(i, n) {
        cin >> v[i].first >> v[i].second;
        sum += v[i].first * v[i].second;
    }
    sort(v.begin(), v.end(), [](auto &left, auto &right){return left.second > right.second;});
    //rep(i, n) cout << v[i].first << " " << v[i].second << endl;
    rep(i, n) {
        sum -= min(m, v[i].first) * v[i].second;
        m -= min(v[i].first, m);
        if (m == 0) break;
    }
    cout << sum << endl;
}
int main() {
    while (cin >> n >> m && !(n == 0 && m == 0)) calc();
}




Measured memory_bytes: 3172
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
h,w = map(int,input().split())
a = []
for i in range(h):
    a.append(input())
row = []
col = []
for i in range(h):
    if a[i] == "."*w: row.append(i)
for j in range(w):
    flag = 0
    for i in range(h):
        if a[i][j] != ".": flag = 1
    if flag == 0:
        col.append(j)
#print(row,col)
for i in range(h):
    flag = 0
    if i in row:
        #print("y")
        flag = 1
    if flag == 0:
        for j in range(w):
            if j not in col: print(a[i][j],end="")
        print("")



        

Measured memory_bytes: 4468
// C - Vacation
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define chmax(x,y) x=max(x,y)

int main(){
	int N; cin>>N;
	vector<vi> happy(N+1, vi(3)); // 0:海 1:山 2:家
	vector<vi> dp(N+1, vi(3));
	rp(day, 1, N+1) rp(to, 0, 3) cin>>happy[day][to];

	// rp(day,0,N+1){
	// 	printf("%3d: ",day);
	// 	rp(to,0,3){
	// 		printf("%3d ",happy[day][to]);
	// 	}
	// 	puts("");//
	// }
	// puts("---");//


	rp(day, 1, N+1){ // day 今日
		rp(from, 0, 3) rp(to, 0, 3) // 0:海 1:山 2:家
			if(from != to)
				chmax(
					dp[day][to],
					dp[day-1][from] + happy[day][to]
				);
	}

	// rp(day,0,N+1){
	// 	printf("%3d: ",day);
	// 	rp(to,0,3){
	// 		printf("%3d ",dp[day][to]);
	// 	}
	// 	puts("");//
	// }
	// puts("===");//

	int ans = 0;
	rp(to, 0, 3) chmax(ans, dp[N][to]);

	cout<< ans <<endl;
}


Measured memory_bytes: 11136
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc, char* argv[])
{
	//ABC164 B
	int a,b,c,d;
	// A B C D 整数 1 -- 100
	// 体 攻 体 攻
	//cin >> x >> y >> a >> b >> c;

	cin >> a >> b >> c >> d;

	// aが0以下になったらNo cが0以下になったらYes
	while (1) {
		// 高橋→青木
		c -= b;
		if (c <= 0) {
			cout << "Yes";
			break;
		}

		// 青木→高橋
		a -= d;
		if (a <= 0) {
			cout << "No";
			break;
		}
	}


	return 0;
}

Measured memory_bytes: 3624
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] x = new int[n];
		int[] sort = new int[n];
		for(int i=0;i<n;i++) {
			x[i] = in.nextInt();
			sort[i] = x[i];
			
		}
		Arrays.sort(sort);
		int low = sort[n/2-1];
		int high = sort[n/2];
		for(int i=0;i<n;i++) {
			if(x[i]<=low) System.out.println(high);
			else System.out.println(low);
		}
		
		in.close();

	}

}


Measured memory_bytes: 101564
#include<bits/stdc++.h>
#include<math.h>
#define N 100005
#define K 200005
#define MOD (long long )1e18L +5
#define ll long long int
using namespace std;
  ll a[405];
void add_self(int &a,int b)
{
    a+=b;
    if(a>=MOD)
    {
        a-=MOD;
    }
}
void sub_self(int &a,int b)
{
    a-=b;
    if(a<0)
    {
        a+=MOD;
    }
}
ll sum(ll l,ll r)
{
    ll sum1=0;
    for(ll i=l;i<=r;i++)
    {
        sum1+=a[i];
    }   
    return sum1;
}
ll min(ll a,ll b)
{
    return a<=b?a:b;
}
int main() {
    int n;
    cin>>n;
  
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll dp[n+1][n+1];
    // total cost of combining interval {i,j} into one vertex
    //think of it as a binary tree0
    for(int l=n-1;l>=0;l--)
    {
        for(int r=l;r<n;r++)
        {
            if(l==r)
            {
                dp[l][r]=0;
            }
            else{
            dp[l][r]=MOD;
            ll s=sum(l,r);
            for(int i=l;i<=r-1;i++)
            {
                dp[l][r]=min(dp[l][r],dp[l][i]+dp[i+1][r]+s);// we are calculating the value of the interval {l,r}
            }
            }
        }
            
    }
    cout<<dp[0][n-1]<<endl;

}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>

#define N_MAX 100000

using namespace std;

vector<int> a, b, index;

bool index_cmp(int l, int r);

int main(){
    int N, M;
    int left, right, sum;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int a_tmp, b_tmp;
        cin >> a_tmp >> b_tmp;
        a.push_back(a_tmp);
        b.push_back(b_tmp);
        index.push_back(i);
    }
    sort(index.begin(), index.end(),index_cmp);

    left = a[index[0]];
    right = b[index[0]];
    sum = 1;
    for(int i = 1; i < M; i++){
        if(a[index[i]] < right && b[index[i]] < right){
            right = b[index[i]];
        }
        else if(a[index[i]] >= right){
            sum += 1;
            left = a[index[i]];
            right = b[index[i]];
        }
    }
    cout << sum << '\n';
}

bool index_cmp(int l, int r){
    return a[r] > a[l];
}

Measured memory_bytes: 1644
#include<bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
 

int32_t main()
{
	IOS
	string s;cin>>s;
	cout <<( s[2]==s[3] && s[4]==s[5] ? "Yes" : "No" ) << endl;
	
}


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

using namespace std;

int n, a[N], b[N];

bool S(int i, int j, int k) {
	return a[i] <= k && a[j] <= k;
}

bool B(int i, int j, int k) {
	return a[i] > k && a[j] > k; 
}

int chk(int k) {
	for (int i = 0; i < n - 1; ++i) {
		if (B(n + i, n + i + 1, k) || B(n - i, n - i - 1, k))
			return 0;
		if (S(n + i, n + i + 1, k) || S(n - i, n - i - 1, k))
			return 1;
	}
	return S(1, 1, n);
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= 2 * n - 1; ++i) scanf("%d", &a[i]);
	int l = 1, r = 2 * n - 1, ans = 0;
	for (; l < r; ) {
		int mid = (l + r) / 2;
		if (chk(mid)) {
			r = mid;
		} else l = mid + 1;
	}
	printf("%d", r);
	return 0;
}

Measured memory_bytes: 1024
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

S = input()
ans = 0
for i in range(len(S)//2):
    if S[i] != S[-i-1]:
        ans += 1

print(ans)

Measured memory_bytes: 22328
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;

void solve()
{
   ll a;ld b;cin>>a>>b;
   b=b*a;
   cout<<(ll)trunc(b)<<"\n";
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//If wrong on pretest 2 means logically wrong


/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 3748
# coding: utf-8
# Your code here!

import numpy as np

c = np.array([list(map(int,input().split())) for _ in range(3)])

for i in range(3):
    c[i] -= min(c[i])
    
for i in range(3):
    c[:,i] -= min(c[:,i])
    
if(np.all(c==0)):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 12876
#include<iostream>
#include<stdio.h>
using namespace std;

class Amida{
public:
	void shokika(int a[],int b);
	void irekae(int bou[], int a, int b);
	void show(int bou[], int a);
};

void Amida::shokika(int a[],int b){
	for (int i = 0; i < b; i++){
		a[i] = i+1;
	}
}

void Amida::irekae(int bou[], int a, int b){
	int work;
	work = bou[a-1];
	bou[a-1] = bou[b-1];
	bou[b-1] = work;
}

void Amida::show(int bou[], int a){
	for (int i = 0; i < a; i++){
		cout << bou[i] << endl;
	}
}

int main(){
	int tate, yoko, *tatebou;
	Amida ami;
	cin >> tate >> yoko;

	tatebou = new int[tate];
	ami.shokika(tatebou, tate);

	int a, b;
	for (int i = 0; i < yoko; i++){
		scanf("%d,%d", &a, &b);
		ami.irekae(tatebou, a, b);
	}

	ami.show(tatebou,tate);

	return 0;
}


Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int dfs(int v, int n, int bit) {
    if (v > n) return 0;
    int res = (bit == 7);
    res += dfs(v * 10 + 3, n, bit | (1LL << 0));
    res += dfs(v * 10 + 5, n, bit | (1LL << 1));
    res += dfs(v * 10 + 7, n, bit | (1LL << 2));
    return res;
}

void _main() {
    int N;
    cin >> N;
    cout << dfs(0, N, 0) << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

int main()
{
	int a,b;

	cin >> a >> b;

	if (a < b) {
		cout << "a < b" << endl;
	}
	else if (a > b) {
		cout << "a > b" << endl;
	}
	else {
		cout << "a == b" << endl;
	}
    return 0;
}


Measured memory_bytes: 3000
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i < n; i++)
#define repv(i,n) for(int i = n-1; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
using namespace std;
typedef long long ll;

char BUF[3500000];
inline void I(int&a){scanf("%d",&a);}
inline void I(int&a,int&b){scanf("%d%d",&a,&b);}
inline void I(int&a,int&b,int&c){scanf("%d%d%d",&a,&b,&c);}
inline void I(int&a,int&b,int&c,int&d){scanf("%d%d%d%d",&a,&b,&c,&d);}
inline void L(ll&a){scanf("%lld",&a);}
inline void L(ll&a,ll&b){scanf("%lld%lld",&a,&b);}
inline void L(ll&a,ll&b,ll&c){scanf("%lld%lld%lld",&a,&b,&c);}
inline void L(ll&a,ll&b,ll&c,ll&d){scanf("%lld%lld%lld%lld",&a,&b,&c,&d);}
inline void S(string&str){str.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)str.pb(BUF[i]);}
inline void SV(vector<int>&v){v.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)if('a'<=BUF[i]&&BUF[i]<='z')v.pb(BUF[i]-'a');else v.pb(BUF[i]-'A');}

const auto EPS = 1e-10;
const auto INF = 100000000;
const auto MOD = 1000000007;
typedef pair<ll,ll> P;

ll n, m;

int main(){
    L(n,m);
    ll ans = 0;
    ans = min(n,m/2);
    m -= n*2;
    if(m > 0) ans += m/4;
    cout << ans << endl;
}
































Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {

  int N; cin >> N;
  vector<ll> A(N);
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  
  map<ll, ll> dup;
  ll sum = 0;
  dup[sum]++;
  for (auto a: A) {
    sum += a;
    dup[sum]++;
  }
  
  ll ans = 0;
  for(auto itr = dup.begin(); itr != dup.end(); ++itr) {
    ans += itr->second * (itr->second - 1) / 2;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 14336
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const double EPS = 1e-8;
const int INF = 1001001001;

typedef complex<double> P;
struct L : public vector<P> {
	L(const P &a, const P &b){
		push_back(a);
		push_back(b);
	}
};
double cross(const P& a, const P& b){
	return imag(conj(a)*b);
}
double dot(const P& a, const P& b){
	return real(conj(a)*b);
}
P projection(const L& l, const P& p){
	double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
	return l[0] + t*(l[0]-l[1]);
}
bool intersectSP(const L& s, const P& p){
	return abs(s[0]-p) + abs(s[1]-p) - abs(s[1]-s[0]) < EPS;
}
double distanceSP(const L& s, const P& p){
	const P r = projection(s, p);
	if(intersectSP(s, r)) return abs(r - p);
	return min(abs(s[0]-p), abs(s[1]-p));
}

struct UFO
{
	int r;
	P x, v;
	bool alive;
	UFO() : alive(true) {}
};

int main()
{
	double R;
	int n;
	while(scanf("%lf%d", &R, &n), n){
		UFO ufo[100];
		rep(i, n){
			double x0, y0, v;
			scanf("%lf%lf%d%lf", &x0, &y0, &ufo[i].r, &v);
			ufo[i].x = P(x0, y0);
			if(norm(ufo[i].x) > EPS)
				ufo[i].v = -v*ufo[i].x/abs(ufo[i].x);
			else
				ufo[i].v = P(0.0, 0.0);
		}
		
		int cnt = 0;
		for(;;){
			int nearest = -1;
			rep(i, n){
				if(ufo[i].alive){
					if(norm(ufo[i].x) > norm(ufo[i].v))
						ufo[i].x += ufo[i].v;
					else
						ufo[i].x = P(0.0, 0.0);
					
					if(abs(ufo[i].x) < R+EPS){
						ufo[i].alive = false;
						++cnt;
					}
					else if(nearest==-1 || norm(ufo[nearest].x) > norm(ufo[i].x))
						nearest = i;
				}
			}
			if(nearest == -1)
				break;
			
			L beam(R*ufo[nearest].x/abs(ufo[nearest].x), 10000.0*ufo[nearest].x);
			rep(i, n){
				if(!ufo[i].alive)
					continue;
				if(distanceSP(beam, ufo[i].x) < ufo[i].r + EPS){
					ufo[i].alive = false;
				}
			}
		}
		printf("%d\n", cnt);
	}
	return 0;
}

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

class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        char[] s = fs.next().toCharArray();
        char[] t = fs.next().toCharArray();
        int sum = 0;
        for(int i=0;i<s.length;i++){
            if(s[i]!=t[i]){
                sum++;
            }
        }
        System.out.println(sum);
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        private boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

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

Measured memory_bytes: 35948
# -*- coding: utf-8 -*-
X, Y = map(int, input().split())

def get_money(rank):
    money = 0
    if rank == 1:
        money = 300000
    elif rank == 2:
        money = 200000
    elif rank == 3:
        money = 100000
    return money

ans = 0
ans += get_money(X)
ans += get_money(Y)

if X == 1 and Y == 1:
    ans += 400000

print(ans)

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

using namespace std;
using ll = long long;


ll sqint(ll num){

    ll l = 0;
    ll r = 1e10;

    while(r - l > 1){
        ll mid = (r + l) / 2;
        (mid * mid <= num ? l : r) = mid;
    }
    return l;
}


int main()
{
    string a, b;
    cin >> a >> b;
    a += b;
    int t = stoi(a);
    cout << (sqint(t) * sqint(t) == t ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }


    // int N = Integer.parseInt(scanner.nextLine());
    // int N = scanner.nextInt(), M = scanner.nextInt();
    // scanner.nextLine();
    // int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    // long[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToLong(Long::parseLong).toArray();
    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.nextLine());
        long[][] c = new long[N][2];
        for (int i = 0; i < N; i++) {
            c[i] = Arrays.stream(scanner.nextLine().split(" ")).mapToLong(Long::parseLong).toArray();
        }
        int div = 1;
        for (int i = 2; i <= N; i++) {
            div *= i;
        }
        double total = dfs(new LinkedHashSet<>(), c, N);
        System.out.println(total / div);
    }


    static double dfs(LinkedHashSet<Integer> visited, long[][] c, int N) {
        if (visited.size() == N) {
            List<Integer> order = new ArrayList<>(visited);
            double sum = 0;
            for (int i = 1; i < visited.size(); i++) {
                long x = c[order.get(i - 1)][0] - c[order.get(i)][0];
                long y = c[order.get(i - 1)][1] - c[order.get(i)][1];
                sum += Math.sqrt(x * x + y * y);
            }
            return sum;
        }

        double total = 0;
        for (int i = 0; i < N; i++) {
            if (!visited.contains(i)) {
                visited.add(i);
                total += dfs(visited, c, N);
                visited.remove(i);
            }
        }
        return total;
    }

}


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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<bitset<64>> va(n);
  for (int i = 0; i < n; ++i) {
    ll a;
    cin >> a;
    va[i] = bitset<64>(a);
  }

  // 各桁ごとの1の出現回数
  vector<int> v_cnt(64, 0);
  for (int i = 0; i < 64; ++i) {
    for (int j = 0; j < n; ++j) {
      auto &bs = va[j];
      v_cnt[i] += bs[i];
    }
  }

  for (int i = 0; i < 64; ++i) {
    bool rev = v_cnt[i] % 2 == 1;
    for (int j = 0; j < n; ++j) {
      // A_jのi桁目を決定する
      if (rev) {
        auto &bs = va[j];
        bs[i] = bs[i] == 0 ? 1 : 0;
      }
    }
  }

  for (int i = 0; i < va.size(); ++i) {
    cout << va[i].to_ullong() << '\n';
  }
  return 0;
}

Measured memory_bytes: 4684
// #pragma GCC optimize("Ofast,unroll-loops")
// #pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define dd double
#define ld long double
#define sl(n) scanf("%lld", &n)
#define si(n) scanf("%d", &n)
#define sd(n) scanf("%lf", &n)
#define pll pair <ll, ll>
#define pii pair <int, int>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define inf (1LL << 61)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define for1(i, stop) for(ll i = 1; i <= stop; ++i)
#define for0(i, stop) for(ll i = 0; i < stop; ++i)
#define rep1(i, start) for(ll i = start; i >= 1; --i)
#define rep0(i, start) for(ll i = (start-1); i >= 0; --i)
#define ms(n, i) memset(n, i, sizeof(n))
#define casep(n) printf("Case %lld:", ++n)
#define pn printf("\n")
#define pf printf
#define EL '\n'
#define fastio std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const ll sz = 1e6 + 10;
ll ara[sz];

bool check[sz], vis[sz];

vector <int> factor[sz];

int main()
{
    for(ll i = 2; i < sz; i++) {

        if(!check[i]) {
            for(ll j = i; j < sz; j += i) {
                check[j] = 1;
                factor[j].pb(i);
            }
        }
    }

    ll n;
    cin >> n;

    for1(i, n) sl(ara[i]);

    ll fullg = ara[1];
    for1(i, n) fullg = __gcd(fullg, ara[i]);

    bool pc = 1;

    for1(i, n) {
        ll now = ara[i];

        for(int &p : factor[now]) {
            if(vis[p]) {
                pc = 0;
                break;
            }

            vis[p] = 1;
        }

        if(!pc) break;
    }

    if(pc) cout << "pairwise coprime" << EL;
    else if(fullg == 1) cout << "setwise coprime" << EL;
    else cout << "not coprime" << EL;

    return 0;
}


Measured memory_bytes: 67844
#include "stdio.h"

int main()
{
  int a, b, count = 0;
  scanf("%d %d", &a, &b);
  while(b > 1)
  {
    b = b - a;
    count++;
    if(b > 0)
    {
      b++;
    }
  }
  printf("%d\n", count);
  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

typedef vector<ll> Edges;
typedef vector<Edges> Graph;

const ll V_MAX = 510101;
vector<ll> ts(V_MAX, -1);
int topologicalSort(Graph &G){
	ll V = G.size();
	vector<ll> indeg(V, 0);
	queue<ll> qu;

	REP(i, V){
		REP(j, G[i].size()){
			indeg[G[i][j]]++;
		}
	}
	REP(i, V){
		if(!indeg[i]) qu.push(i);
	}

	ll depth = 0;
	while(!qu.empty()){
		ll s = qu.size();
		REP(i, s){
			ll now = qu.front();qu.pop();
			ts[now] = depth;
			REP(j, G[now].size()){
				ll next = G[now][j];
				indeg[next]--;
				if(!indeg[next]) qu.push(next);
			}
		}
		depth++;
	}

	REP(i, V){
		if(ts[i] == -1) return -1;
	}
	return depth;
}

struct battle{
	ll x, y;
	bool operator<(const battle &right)const{
		return (x != right.x ? x < right.x : y < right.y);
	}
};

vector<battle> id2b(510101);
map<battle, ll> b2id;
ll V;

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

    ll N;
    cin >> N;


    ll now = 0;
    REP(i, N){
    	REP(j, N){
    		if(i>=j) continue;
    		battle b = {i, j};
    		id2b[now] = b;
    		now++;
    	}
    }
    V = N*(N-1)/2;
    REP(i, V){
    	b2id[id2b[i]] = i;
    }

    Graph G(V);

    REP(i, N){
    	vector<ll> tmp(N-1);
    	REP(j, N-1) cin >> tmp[j], tmp[j]--;
    	REP(j, N-2){
    		ll x1, y1, x2, y2;
    		x1 = i;
    		y1 = tmp[j];
    		x2 = i;
    		y2 = tmp[j+1];
    		if(x1>y1) swap(x1, y1);
    		if(x2>y2) swap(x2, y2);
    		battle b1 = {x1, y1}, b2 = {x2, y2};
    		G[b2id[b1]].push_back(b2id[b2]);
    	}
    }

    int res = topologicalSort(G);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 74624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<pii>>;
using mat = vector<vector<int>>;
const int MOD = 1e9 + 7;

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

    ll a, b, x;
    cin >> a >> b >> x;
    if (a == 0)
        a = -x + 1;
    else
        a = (a - 1) / x * x + 1;
    b = (b / x + 1) * x - 1;
    cout <<  (b - a + 1) / x << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
  char S[10],T[10];
  scanf("%s %s", &S, &T);
  
  int A,B;
  scanf("%d %d", &A, &B);
  
  char U[10];
  scanf("%s", &U);
  
  int haveA = A;
  int haveB = B;
  
  if(strcmp(S,U) == 0) haveA--;
  if(strcmp(T,U) == 0) haveB--;
  
  printf("%d %d", haveA, haveB);
  
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
// #include <atcoder/all>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
// using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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; }

// auto mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

  vc(mint) dp(n+1);
  dp[0] = 1;

  mint x = 0;

  REPe(i, n) {
    if (i-3 >= 0) x += dp[i-3];
    dp[i] = x;
  }

  cout << dp[n] << endl;

  return 0;
}

Measured memory_bytes: 3556
#include <algorithm>
#include <array>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <string>
#include <string_view>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

int64_t read_int() {
    int64_t ret = 0, sgn = 1;
    int ch = getchar_unlocked();
    while (isspace(ch)) { ch = getchar_unlocked(); }
    if (ch == '-') { sgn = -1; ch = getchar_unlocked(); }
    for (; isdigit(ch); ch = getchar_unlocked())
        ret = (ret * 10) + (ch - '0');
    ungetc(ch, stdin);
    return sgn * ret;
}

char read_char() {
    int ch = getchar_unlocked();
    while (isspace(ch)) { ch = getchar_unlocked(); }
    return ch;
}

string read_word() {
    string ret;
    int ch = getchar_unlocked();
    while (isspace(ch)) { ch = getchar_unlocked(); }
    for (; ch != EOF && !isspace(ch); ch = getchar_unlocked())
        ret += ch;
    ungetc(ch, stdin);
    return ret;
}

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()

template <typename T> inline void assign_min(T& x, const T& value) noexcept { x = min(x, value); }
template <typename T> inline void assign_max(T& x, const T& value) noexcept { x = max(x, value); }

constexpr char LF = '\n';

int main() {
    int N = read_int();
    vector<char> C(N);
    REP(i, N) C[i] = read_char();

    int total_w = 0, total_r = 0;
    REP(i, N) {
        if (C[i] == 'W')
            ++total_w;
        else
            ++total_r;
    }

    // 0~iをすべてRにし、i+1~N-1をWにしたい
    // max(前半のWの数, 後半のRの数)
    auto ans = min(total_w, total_r);
    int n_w = 0, n_r = 0;
    REP(i, N) {
        if (C[i] == 'W')
            ++n_w;
        else
            ++n_r;
        assign_min(ans, max(n_w, total_r - n_r));
    }
    cout << ans << LF;
}


Measured memory_bytes: 3140
fun main(args: Array<String>) {
    a80(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a80(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val (days, pricePerDay, price) = args[0].split(" ").map { it.toInt() }
    println(if (days * pricePerDay < price) days * pricePerDay else price)
}

Measured memory_bytes: 38312
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n, ww, memo = -1;
  scanf("%lld%lld", &n, &ww);
  vll w(n), v(n);
  for (ll i = 0; i < n; i++) scanf("%lld%lld", &w[i], &v[i]);
  long long dp[100001] = {0};
  vector<vll> check(100001, vll(n));
  for (ll i = 1; i <= ww; i++) {
    dp[i] = dp[i - 1];
    for (ll j = 0; j < n; j++) {
      if (i < w[j] || check[i - w[j]][j] == 1) continue;
      if (chmax(dp[i], dp[i - w[j]] + v[j])) memo = j;
    }
    if (memo != -1) {
      check[i] = check[i - w[memo]];
      check[i][memo] = 1;
    }
    else check[i] = check[i-1];
    memo = -1;
  }
  printf("%lld\n", dp[ww]);
}


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

using namespace std;

int main()
{
    int n1 = 0, n2 = 0;
    cin >> n1 >> n2;

    vector< vector<int> > mat(n1);
    vector<int> colVec(n2);

    for(int i = 0; i < n1; i++)
    {
	mat[i].reserve(n2);
	for(int j = 0; j < n2; j++){ cin >> mat[i][j]; }
    }
    
    for(int i = 0; i < n2; i++){ cin >> colVec[i]; }

    //Multiplication
    for(int i = 0; i < n1; i++)
    {
        int sum = 0;
        for(int j = 0; j < n2; j++)
        {
            sum += mat[i][j] * colVec[j];
        }
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int N; cin >> N;
	double ans = 0.0;
	double rate = 380000.0;
	for (int i = 0; i < N; ++i) {
		double x; cin >> x;
		string u; cin >> u;
		if (u == "JPY") {
			ans += x;
		} else {
			ans += x * rate;
		}
	}
	printf("%.10f\n", ans);
	return;
}
int main() {
	solve();
	return 0;
}

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

int h,w,a[2010][2010],b[2010],st[2010],ans;
char s[2010][2010];

void work()
{
	scanf("%d %d",&h,&w),ans=h;
	for (int i=1; i<=h; i++)  scanf("%s",s[i]+1);
	for (int i=1; i<h; i++)
		for (int j=1; j<w; j++)
			a[i][j]=(s[i][j]=='#')^(s[i][j+1]=='#')^(s[i+1][j]=='#')^(s[i+1][j+1]=='#');
	h--,w--;
	for (int i=1; i<=h; i++)
		{
			for (int j=1; j<=w; j++)
				if (a[i][j])  b[j]=0;  else  b[j]++;
			int top=0;
			for (int j=1; j<=w; j++)
				{
					while ((top)&&(b[st[top]]>=b[j]))
						ans=max(ans,(b[st[top]]+1)*(j-st[top-1])),top--;
					st[++top]=j;
				}
			while (top)  ans=max(ans,(b[st[top]]+1)*(w+1-st[top-1])),top--;
		}
	printf("%d",ans);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 19968