akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

constexpr int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n - 1); }

const int mod = TEN(9) + 7;

bool beki[1010];

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

	beki[1] = true;

	for (int i = 2; i <= n; ++i) {
		for (int j = i * i; j <= n; j *= i) {
			beki[j] = true;
		}
	}

	for (int i = n; i >= 1; --i) {
		if (beki[i]) {
			cout << i << endl;
			return 0;
		}
	}
}




Measured memory_bytes: 256
# def
def detect_q2(step_list):
    for k,s in enumerate(step_list):

        if k % 2 == 0:
            if s == 'L':
                return False
        else:
            if s == 'R':
                return False

    return True

# input
step = str(input())
step_list = list(step)

# main
if detect_q2(step_list):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
def LI():return list(map(int,input().split()))
def MI():return map(int,open(0).read().split())
def I():return int(input())
def yes():print("Yes")
def no():print("No")

# from collections import deque, Counter
# from heapq import heappop, heappush
INF=float("inf")
# import math
# pi=math.pi

# import numpy as np
x,n=LI()
if n==0:
    print(x)
    exit()
p=LI()
p.sort()

ans=-1
tmp=INF
for i in range(-100,200):
    if i in p:continue
    k=abs(i-x)
    if k<tmp:
        tmp=k
        ans=i
    # print(i,k,ans)
print(ans)



Measured memory_bytes: 61948
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
long long int factorial(long long int k){
    long long int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
        sum %= MOD;
    }
    return sum;
}
int main()
{
    int x,y;
    cin >> x >> y;
    double ans_x = -1,ans_y = -1;
    ans_x = (2 * x - y) / 3.0;
    ans_y = (2 * y - x) / 3.0;
    if(ceil(ans_x) != floor(ans_x) || ceil(ans_y) != floor(ans_y) || ans_x < 0 || ans_y < 0)
    {
        cout << "0";
    }
    else if(ans_x == 0 || ans_y == 0)
    {
        cout << "1";
    }
    else
    {
        long long int a = ans_x,b = ans_y;
        cout << (factorial(a + b) % MOD) * modinv(factorial(a) * factorial(b),MOD) % MOD;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int N;
string S;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> N >> S;
  int a = 0, b = 0;
  REP(i, N) {
    if(S[i] == 'R') a++;
    else b++;
  }

  cout << (a > b ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	if(a>b)
	printf("0");
	else
	{
		if(n==1&&a!=b)
		printf("0");
		else
		printf("%lld",(n-2)*(b-a)+1);
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
void init(char t[],int W);
int main(){
  int H,W;
  int i,j;

  scanf("%d%d",&H,&W);
  char a[H][W+1];
  int flag_h[H];
  int flag_w[W];
  for(i=0;i<H;i++){
    scanf("%s",a[i]);
    flag_h[i]=0;
  }
  for(i=0;i<W;i++){
    flag_w[i]=0;
  }
  printf("\n");

  for(i=0;i<H;i++){
    if(a[i][0]=='.'){
      for(j=0;j<W;j++){
        if(a[i][j]=='#'){
            flag_h[i]=1;
            break;
        }
      }
    }else flag_h[i]=1;
  }

  for(i=0;i<W;i++){
    if(a[0][i]=='.'){
      for(j=0;j<H;j++){
        if(a[j][i]=='#'){
          flag_w[i]=1;
        }
      }
    }else flag_w[i]=1;
  }
  
  for(i=0;i<H;i++){
    if(flag_h[i]){
      for(j=0;j<W;j++){
        if(flag_w[j]){
          printf("%c",a[i][j]);
        }
      }printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 128
from itertools import accumulate


N, Q = list(map(int, input().split()))
S = input()
A = [list(map(int, input().split())) for i in range(Q)]

flg = []
for i in range(N-1):
    tmp_S = S[i:i+2]
    if tmp_S == 'AC':
        flg.append(1)
    else:
        flg.append(0)

# print(flg)
flg2 = [0] + flg
flg2 = list(accumulate(flg2))
# print(flg2)

for a in A:
    print(flg2[a[1]-1] - flg2[a[0]-1])


Measured memory_bytes: 34788
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N;cin >> N;
    vector<int> A(N);

    rep(i,N){
        if(i == 0)continue;
        int a;
        cin >> a;
        a--;
        A[i] = a;
    }
    map<int,int> m;
    rep(i,N){
        m[i] = 0;
    }

    rep(i,N){
        if(i == 0)continue;
        m[A[i]]++;
    }

    for(auto t : m){
        cout << t.S << endl;
    }
}

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

int main() {
    int P, Q, R; 
    cin >> P >> Q >> R;
    int min = 200;
    if (min > P+Q) {
        min = P+Q;
    }
    if (min > P+R) {
        min = P+R;
    }
    if (min > Q+R) {
        min = Q+R;
    }
    cout << min << endl;
}

Measured memory_bytes: 256
use proconio::*;
use std::collections::BinaryHeap;

fn main() {
    input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d],
    };

    let mut score = 0;
    let mut lasts = [-1; 26];
    let mut t = vec![26; d];
    let depth = 5;
    for i in 0..d {
        let mut max_score = -10000000;
        for j in 0..26 {
            let tmp = search(i, j, &c, &s, &mut lasts, depth, d, 0);
            if tmp > max_score {
                max_score = tmp;
                t[i] = j;
            }
        }
        score += max_score;
        lasts[t[i]] = i as i64;
    }

    for &a in &t {
        println!("{}", a + 1);
    }
}

fn calc_score(i: usize, j: usize, c: &Vec<i64>, s: &Vec<Vec<i64>>, lasts: &mut [i64; 26]) -> i64 {
    let mut res = s[i][j];
    let tmp = lasts[j];
    lasts[j] = i as i64;

    for j in 0..26 {
        let i = i as i64;
        let last = lasts[j];
        res -= c[j] * (i - last);
    }

    lasts[j] = tmp;
    res
}

fn search(
    i: usize,
    t: usize,
    c: &Vec<i64>,
    s: &Vec<Vec<i64>>,
    lasts: &mut [i64; 26],
    depth: usize,
    d: usize,
    cscore: i64,
) -> i64 {
    if depth == 0 || i == d - 1 {
        return calc_score(i, t, &c, &s, lasts) + cscore;
    }

    let mut max_score = -1000000;
    let tmp_last = lasts[t];
    lasts[t] = i as i64;
    let tmp_score = calc_score(i, t, &c, &s, lasts);
    let mut cands = BinaryHeap::new();
    for j in 0..26 {
        let tmp_score = calc_score(i + 1, j, &c, &s, lasts);
        cands.push((tmp_score, j));
    }
    for &(_, j) in cands.iter().take(2) {
        let tmp = search(i + 1, j, &c, &s, lasts, depth - 1, d, cscore + tmp_score);

        if tmp > max_score {
            max_score = tmp;
        }
    }

    lasts[t] = tmp_last;
    max_score + cscore
}


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

namespace abc_166b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int[] pp = new int[int.Parse(input[0])];
            int ST = int.Parse(input[1]);

            for(int i = 0; i < ST; i++)
            {
                int total = int.Parse(Console.ReadLine());
                string[] who = Console.ReadLine().Split(' ');
                for (int j = 0;j < total; j++)
                {
                    pp[int.Parse(who[j]) - 1] += 1;
                }
            }

            int count = 0;

            for(int i= 0; i< int.Parse(input[0]); i++)
            {
                if(pp[i] == 0)
                {
                    count += 1;
                }
            }

            Console.WriteLine(count);

            Console.Read();
        }
    }
}


Measured memory_bytes: 27544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(c >= a && b >= c)  cout << "Yes" << endl;
  else cout<< "No" << endl;

}

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

int main(){
  int N,X,T;
  int a;
  cin>>N>>X>>T;
  a=N/X;
  if(N%X==0){
    cout<<T*a<<endl;
  }else{
    cout<<T*(a+1)<<endl;
  }
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define MOD 1000000007
int n,m,k,f[6600][6600],Ans;
inline int Mod(int u){return u < MOD?u:u-MOD;}
int main()
{
	std::cin >> n >> m >> k,f[0][0] = 1;
	for(int i = 1;i<=(n+m-1)/(k-1);++i)
	{
		for(int j = 0;j<=m;++j) for(int l = 1;l<k;++l) f[i][j+l] = Mod(f[i][j+l]+f[i-1][j]);
		for(int j = 1;j<=m;++j)
		{
			int nxt = i*(k-1)+1 - j;
			if(nxt&&nxt <= n && (n-nxt) % (k-1) == 0 && (m-j)%(k-1) == 0) Ans = Mod(Ans + f[i][j]);
		}
		for(int j = 0;j<=m;++j) f[i][j] = Mod(f[i][j]+f[i-1][j]);
	}
	printf("%d\n",Ans);
}

Measured memory_bytes: 103552
n = int(input())
a = list(map(int, input().split()))

now = 1000
stack = 0
price = a[0]
for i in range(1, n):
    # 下がる時
    if price > a[i]:
        # 株を持っているなら下がる前の値段で売っておく
        if stack != 0:
            now += stack * price
            stack = 0
    # 値上がりする場合
    else:
        # 株を持っていないなら上がる前に買っておく
        if stack == 0:
            stack = now // price
            now -= stack * price
    price = a[i]

if stack != 0:
    now += stack * price
print(now)


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s; cin >> s;
    string t; cin >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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


    #define s scanf
    #define p printf
    #define pb push_back
    #define all(x) x.begin(), x.end()
    #define tmax(a, b, c) max(max(a, b), c)

    using namespace std;

    const int INF = 1e9;
    const long long LINF = 1e18+5;
    const double eps = 0.0000001;
    fstream fin, fout;
    typedef pair<int, int> ii;
    typedef vector<ii> vii;
    typedef long long ll;
    typedef vector<int> vi;
    typedef vector<bool> vb;
    typedef vector<char> vc;
    typedef vector<vector<int> > vvi;
    typedef vector<ll> vll;

    int main(){
    int a, b; cin >> a >> b;
    int k; cin >> k;
    for(int i = 0; i < k; i++){
        if(i % 2 == 0)
        {
            a/= 2;
            b+= a;
        }
        else{
            b/= 2;
            a+= b;
        }
    }
    cout << a << " " << b;
    }


Measured memory_bytes: 256
inpl = lambda: list(map(int,input().split()))
T1, T2 = inpl()
A1, A2 = inpl()
B1, B2 = inpl()
DA = A1*T1 + A2*T2
DB = B1*T1 + B2*T2
if DA == DB:
    print('infinity')
    exit()
elif DB > DA:
    A1, A2, B1, B2, DA, DB = B1, B2, A1, A2, DB, DA
    # swap A & B. DA > DB.
if A1 > B1:
    print(0)
    exit()

dD = DA - DB
CA = A1*T1
CB = B1*T1
dC = CB - CA

n = dC // dD
if dC % dD == 0:
    m = 2*n - 1
else:
    m = 2*n
print(m+1)


Measured memory_bytes: 38384
//****************************//
/**********  main *************/
//****************************//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
 
using namespace std;
typedef long long ll;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<b;i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
 
 
int main() {
 
	std::cin.tie(0);
 
    string n;
    cin >> n ;
    int tmp;
 
    // string str = std::to_string(n);
 
    tmp = n.find("7");
 
    ( tmp>=0 && tmp < 3) ? (cout << "Yes" << endl) : cout << "No" << endl;
 
    // if(n[0]==7 || n[1]==7 || n[2]==7 ) {
    //     cout << "Yes" << endl;
    //     return 0;
    // }
 
    // cout << "No" << endl;
 
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;

vector<pii> Graph[310];
vector<int> Graph2[310];
ll dp1[310][310];
int dp2[310][310];

int main(){
    int n,m,l;
    cin >> n >> m >> l;
    int a,b,c;

    rep(i,n){
        rep(j,n){
            dp1[i][j] = 1e14;
            dp2[i][j] = 1e9;
        }
    }

    rep(i,m){
        cin >> a >> b >> c;
        a--; b--;
        Graph[a].push_back(make_pair(b,c));
        Graph[b].push_back(make_pair(a,c));
        dp1[a][b] = c;
        dp1[b][a] = c;
    }

    rep(k,n){
        rep(i,n){
            rep(j,n){
                dp1[i][j] = min(dp1[i][j],dp1[i][k]+dp1[k][j]);
            }
        }
    }

    rep(i,n){
        rep(j,n){
            if(dp1[i][j] <= l){
                Graph2[i].push_back(j);
                Graph2[j].push_back(i);
                dp2[i][j] = 1;
                dp2[j][i] = 1;
            }
        }
    }

    rep(k,n){
        rep(i,n){
            rep(j,n){
                dp2[i][j] = min(dp2[i][j],dp2[i][k]+dp2[k][j]);
            }
        }
    }

    int q;
    cin >> q;
    int s,t;
    rep(i,q){
        cin >> s >> t;
        s--; t--;

        if(dp1[s][t] <= l) cout << 0 << endl;
        else if(dp2[s][t] == 1e9) cout << -1 << endl;
        else  cout << dp2[s][t]-1 << endl;
    }

    return 0;
}

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

using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

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

#define loop1(i,n) for(int i=1; i<=n; i++)

#define ll long long

#define ld long double

#define pii pair<int,int>

#define pll pair<ll,ll>

#define pld pair<ld,ld>

#define pb push_back
const int MAXN = 1e6+7;
ll a[MAXN];
int main(){
	fastio;
	int k,n; cin>>k>>n;
	int ant = 0;
	ll soma = 0;
	ll mx = 0;
	loop1(i,n){
		cin>>a[i];
		a[i] -= ant;
		if(i>1)soma += a[i];
		ant += a[i];
		if(i>1)mx = max(mx, a[i]);
	}
	cout<<min(soma, k-mx)<<endl;
}

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

lint n;

vector<int64_t> divisor(int64_t n) {
    vector<int64_t> ret;
    for (int64_t i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

int main() {
    cin >> n;
    auto div1 = divisor(n);
    auto div2 = divisor(n - 1);
    set<lint> ans;
    for (auto e : div1) {
        if (e == 1) {
            continue;
        }
        lint p = e;
        lint nn = n;
        while (nn % p == 0) {
            nn /= p;
        }
        if (nn % p == 1) {
            ans.insert(e);
        }
    }
    for (auto e : div2) {
        if (n % e != 0) {
            ans.insert(e);
        }
    }
    cout << ans.size() << endl;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;
int main(){
    int a;
    int b;
    cin >> a >> b;
    if(a < b){
        cout<<"a < b"<< endl;
    }
    if(a==b){
        cout<<"a == b"<< endl;
    }
    if(a > b){
        cout<< "a > b"<< endl;
    }
}


Measured memory_bytes: 3092
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=1e5;
int n,t,m,ans,sum;
int main(){
	cin>>n>>m;
	if(n>m)ans=n-1;
	else ans=n;
	printf("%d\n",ans);
}




Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()

#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>

#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>

const ll MOD = (ll)1e9 + 7; // 998244353
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;


void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}

int main() {
	string s; cin >> s;
	bool flg = false;
	REP(i, s.size()-1) if (s[i] == 'A' && s[i + 1] == 'C') flg = true;
	Yn(flg);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
    int h , w ;
    while(cin >> w >> h , w){
        int dp[102][102][2][2] = {0};
     
        dp[1][1][0][0] = 1;
        dp[1][1][0][1] = 1;
         
        for(int y = 1 ; y <= h ; y++){
            for(int x = 1 ; x <= w ; x++){
                dp[y][x][0][0] %= 100000;
                dp[y][x][0][1] %= 100000;
                dp[y][x][1][0] %= 100000;
                dp[y][x][1][1] %= 100000;
                 
                dp[y][x+1][0][0] += dp[y][x][1][0];
                dp[y+1][x][0][1] += dp[y][x][1][1];
                 
                dp[y][x+1][0][0] += dp[y][x][0][0];
                dp[y+1][x][0][1] += dp[y][x][0][1];
                 
                if(x != 1 || y != 1) dp[y+1][x][1][1] += dp[y][x][0][0];
                if(x != 1 || y != 1) dp[y][x+1][1][0] += dp[y][x][0][1];
                 
            }
        }
        cout << (dp[h][w][0][0] + dp[h][w][1][1] + dp[h][w][0][1] + dp[h][w][1][0]) % 100000 << endl;
    }
 
     
}


Measured memory_bytes: 1328
import sys
import math
from decimal import Decimal, ROUND_DOWN

if(__name__ == "__main__"):


    AList_Str = input().strip().split()
    """
    A = int(AList_Str[0])
    B = float(AList_Str[1])
    """
    A = int(AList_Str[0])
    B = float(AList_Str[1])
    C = Decimal(AList_Str[1])*A
    Multiply = C.quantize(Decimal('1.'), rounding = ROUND_DOWN)
    print(Multiply)


Measured memory_bytes: 10016
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
int main()
{
     short a{0};
     int b{0};
    cin>>a;
    vector<double>vec(0);
    for(short j{0};j<a;j++){cin>>b;
vec.push_back(b);
    }

    vector<double>::iterator it{vec.end()};
    sort(vec.begin(),vec.end(),greater<double>());
    float temp{0};
    it--;
    while(vec.size()!=1){
        temp=(*it+*(it-1))/2;
        vec.erase(it-1,it+1);
        vec.push_back(temp);
        it=vec.end()-1;
    }
        cout<<vec[0];


}

Measured memory_bytes: 256
h,w = map(int,input().split())
s = [None]*h
for i in range(h):
    s[i]=list(input())
    
###########
#Union Find
par = [] #親
rank = [] #木の深さ

#初期化
for i in range(h*w):
    #par[i]:i rank[i]:0
    par.append(i)
    rank.append(0)

#木の根を求める
def find(x,par):
    if par[x] == x:
        return x
    else:
        return find(par[x],par)

#xとyの属する集合の併合
def unite(x,y,par,rank):
    x = find(x,par)
    y = find(y,par)
    
    if x != y:
        #xとyの属している集合が異なる時
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x]==rank[y]:
                rank[x] += 1

#xとyが同じ集合に属するかの判定
def same(x,y,par):
    return find(x,par) == find(y,par)
###############
for i in range(h*w):
    if i//w + 1 < h and s[i//w][i%w] != s[i//w+1][i%w]:
        unite(i,i+w,par,rank)
    if i%w +1 < w and s[i//w][i%w] != s[i//w][i%w+1]:
        unite(i,i+1,par,rank)

res = [[0,0] for i in range(w*h)] #[".","#"]
for i in range(h*w):
    r = find(i,par)
    if s[i//w][i%w] ==".":
        res[r][0]+=1
    else:
        res[r][1]+=1

ans = 0
for i in range(h*w):
    ans += res[i][0]*res[i][1]
print(ans)

Measured memory_bytes: 28448
h, w = map(int, input().split())
grid = [list(input()) for _ in range(h)]
row_white = []
column_white = []

for i in range(h):
    for j in range(w):
        if grid[i][j] == '#':
            break
        if j == w - 1:
            row_white.append(i)
for i in range(len(row_white)):
    grid.pop(row_white[i] - i)

h = len(grid)
for j in range(w):
    for i in range(h):
        if grid[i][j] == '#':
            break
        if i == h - 1:
            column_white.append(j)
for j in range(len(column_white)):
    for i in range(h):
        del grid[i][column_white[j] - j]
for i in range(h):
    print(*grid[i], sep='')

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n, k;
  cin >> n >> k;
  cout << (n - 1 + k - 2) / (k - 1) << endl;
}

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

    namespace cysharp_test
    {
        class Program
        {
            static void Main (string[] args)
            {
                new Program ().solve ();
            }

            void solve ()
            {
                int[] nm = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();
                N = nm[0];
                M = nm[1];
                ways = new List<int>[N];
                dir = new int[N];
                distance = new int[N];
                for (int i = 0; i < N; i++)
                {
                    distance[i] = 99999;
                    dir[i] = -1;
                    ways[i] = new List<int> ();
                }
                int a = 0;
                int b = 0;
                for (int i = 0; i < M; i++)
                {
                    int[] ab = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();
                    a = ab[0] - 1;
                    b = ab[1] - 1;
                    ways[a].Add (b);
                    ways[b].Add (a);
                }

                Queue<int> target = new Queue<int> ();
                target.Enqueue (0);
                distance[0] = 0;
                while (target.Count () > 0)
                {
                    var now = target.Dequeue ();
                    for (int i = 0; i < ways[now].Count (); i++)
                    {
                        int next = ways[now][i];
                        if (distance[next] > distance[now])
                        {
                            distance[next] = distance[now] + 1;
                            dir[next] = now;
                            target.Enqueue (next);
                            ways[next].Remove (now);
                        }
                    
                }ways[now].RemoveAll(v =>true);
                }

                for (int i = 1; i < N; i++)
                    if (dir[i] == -1) { Console.WriteLine ("No"); return; }

                var sw = new StreamWriter (Console.OpenStandardOutput ()) { AutoFlush = false };
                Console.SetOut (sw);

                Console.WriteLine ("Yes");
                for (int i = 1; i < N; i++)
                {
                    if (dir[i] != -1) Console.WriteLine (dir[i] + 1);
                }
                Console.Out.Flush ();

                Console.ReadKey ();
            }

            int N, M;
            List<int>[] ways;
            int[] dir;
            int[] distance;
        }
    }

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

public class Cake
{
    public int w { get; set; }
    public int d { get; set; }
    public int s { get; set; }
}

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var cakes = new List<Cake>();
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var w = int.Parse(line[1]);
            var d = int.Parse(line[2]);
            if (n == 0 && w == 0 && d == 0) break;
            cakes.Add(new Cake { w = w, d = d, s = w * d });
            for (int i = 0; i < n; i++)
            {
                string[] line2 = Console.ReadLine().Trim().Split(' ');
                var p = int.Parse(line2[0]);
                var s = int.Parse(line2[1]);
                cutCake(cakes, p, s);
            }
            var ret = cakes.OrderBy(x => x.s).Select(x => x.s).ToArray();
            for (int i = 0; i < ret.Length; i++)
                if (i == ret.Length - 1) Console.WriteLine(ret[i]);
                else Console.Write("{0} ", ret[i]);
        }
    }
    public static void cutCake(List<Cake> c, int p, int s)
    {
        var nw = c[p - 1].w;
        var nd = c[p - 1].d;
        while (true)
        {
            if (s < nw)
            {
                c.RemoveAt(p - 1);
                if (s < nw - s)
                {
                    c.Add(new Cake { d = nd, w = s, s = nd * s });
                    c.Add(new Cake { d = nd, w = nw - s, s = nd * (nw - s) });
                }
                else
                {
                    c.Add(new Cake { d = nd, w = nw - s, s = nd * (nw - s) });
                    c.Add(new Cake { d = nd, w = s, s = nd * s });
                }
                return;
            }
            else if (s - nw < nd)
            {
                c.RemoveAt(p - 1);
                if (s - nw < nd - s + nw)
                {
                    c.Add(new Cake { d = s - nw, w = nw, s = (s - nw) * nw });
                    c.Add(new Cake { d = nd - s + nw, w = nw, s = (nd - s + nw) * nw });
                }
                else
                {
                    c.Add(new Cake { d = nd - s + nw, w = nw, s = (nd - s + nw) * nw });
                    c.Add(new Cake { d = s - nw, w = nw, s = (s - nw) * nw });
                }
                return;
            }
            else s -= (nd + nw);
        }
    }
}

Measured memory_bytes: 10244
n = int(input())
a,b = (int(i) for i in input().split())
p = list(int(i) for i in input().split())
count=[0,0,0]
for i in range(n):
    if p[i]<=a:
        count[0] += 1
    elif p[i]<=b:
        count[1] += 1
    else:
        count[2] += 1
print(min(count))

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll cnt = 0;
    rep(i, N-2) {
        if (S.substr(i, 3) == "ABC") {
            cnt++;
        }
    }
    print(cnt);
    return 0;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
B=[0,0,0,0,0,0,0,0]
free=int(0)
for i in range(n):
    if A[i]>=3200:
        free+=1
    else:
        now=int(A[i]/400)
        B[now]+=1
s=B.count(0)
s=8-s
if s==0:
    s=1
    free-=1
print("{} {}".format(s,s+free))

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

using namespace std;


int main(void){

    long long n;
    cin >> n;
    
    vector<long long> data;
    bool flag = false;
    for(long long i=1; i<=sqrt(n); i++) {
        if(n%i==0) {
            data.push_back(i);
//            cout << i << endl;
            if(i==sqrt(n)) {
                flag = true;
            }
        }

    }
    
    int size = data.size();
    for(int i=0; i<size; i++) {
        if(flag && data.size()-1 == i) break;
        data.push_back(n/data[i]);
//        cout << n/data[i] << endl;
    }
    
    sort(data.begin(), data.end());
    
    if(data.size()%2!=0) {
        string s = to_string(data[data.size()/2]);
        cout << s.size() << endl;
    }
    else {
        string s1 = to_string(data[data.size()/2]);
        string s2 = to_string(data[data.size()/2-1]);
        string s = s1.size() > s2.size() ? s1 : s2;
//        cout << s1 << endl;
//        cout << s2 << endl;
        cout << s.size() << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

int n,f1[500005],f2[500005],Ans;
char s[500005];

void KMP(int f[])
{
    for(int i=2,j=0;i<=n;++i)
    {
        while(j&&s[i]!=s[j+1])j=f[j];
        if(s[i]==s[j+1])f[i]=++j;
    }
}

inline bool Pre(const int l){return !f1[l]||l%(l-f1[l]);}
inline bool Suf(const int l){return !f2[l]||l%(l-f2[l]);}

int main()
{
    //freopen("in.txt","r",stdin);
    scanf("%s",s+1),n=strlen(s+1);
    if(n==1)return puts("1\n1"),0;
    for(int i=2;i<=n;++i)
    {
        if(s[i]!=s[1])break;
        if(i==n)return printf("%d\n1\n",n),0;
    }
    KMP(f1),std::reverse(s+1,s+n+1),KMP(f2);
    if(Pre(n))return puts("1\n1"),0;
    for(int i=1;i<n;++i)if(Pre(i)&&Suf(n-i))++Ans;
    printf("2\n%d\n",Ans);
    return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll x; cin >> x;
  ll now = 100;
  ll cnt = 0;
  while(now < x) {
    now += now / 100;
    cnt++;
  }
  cout << cnt << endl;

}
























Measured memory_bytes: 3648
N, K = map(int, input().split())

base = 1 / N
ans = 0
for n in range(1, N + 1):
    # nは出る目
    # countは2をかける回数
    count = 0
    for i in range(1,30):
        if K > n:
            n *= 2
            count += 1
        else:
            break
    else:
        ans += 0
    ans += base * ((0.5) ** (count)) # 小さいものから足していく 
            
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main()
{
    int n;
    char s[101];
    scanf("%d", &n);
    scanf("%s", s);
    int i, j, k;
    int ans = 0;
    for (i=0; i<=n-2; i++)
    {
        int left[26] = {}, right[26] = {};
        int count = 0;
        for (j=0; j<n; j++)
        {
            if (j<=i) left[s[j] - 'a'] = 1;
            else right[s[j] - 'a'] = 1;
        }
        for (k=0; k<26; k++)
        {
            if (left[k] == 1 && right[k] == 1) count ++;
        }
        if (count > ans) ans = count;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

pint pick(int x){
    pint res;
    res.second=x%10;
    while(x){
        res.first=x;
        x/=10;
    }
    return res;
}

int main(void){
    int N;
    cin >> N;
    lint sum[10][10]={};
    lint ans=0;
    for(int i=1;i<=N;i++){
        pint p=pick(i);
        sum[p.first][p.second]++;
    }
    for(int i=1;i<=9;i++) for(int j=1;j<=9;j++){
        ans+=sum[i][j]*sum[j][i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import math
N,K = list(map(int,input().split(" ")))


ans = 0

for p in range(1,N+1): # p 目
    if p >= K:
        ans += 1
    else:
        temp = K/p
        n = math.ceil(math.log2(temp))
        ans += (1/2)**n

ans /= N
print(ans)


Measured memory_bytes: 3060
#-*-coding:utf-8-*-

import math

def main():
    a,b,c = map(int,input().split())
    area=a*(b*math.sin(math.radians(c)))/2
    print("{:.5f}".format(area))
    print("{:.5f}".format(a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(c)))))
    print("{:.5f}".format(2*area/a))

if __name__=="__main__":
    main()


Measured memory_bytes: 5724
public class Main{

	public static void main(String[] args) {
		java.util.Scanner scanner = new java.util.Scanner (System.in);
		int N=scanner.nextInt() ;

		int M=scanner.nextInt() ;
		
		int a[]=new int[M+1];
		int b[]=new int[M+1];
		
		for(int i=1;i<=M;i++){
			a[i]=scanner.nextInt() ;

			b[i]=scanner.nextInt() ;
		}
		
		for(int i=1;i<=N;i++){
			int sum=0;
			for(int p=1;p<=M;p++){
				if(a[p]==i||b[p]==i){
					sum+=1;
				}
			}
			System.out.println(sum);
			
		}
		
	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	vector<vector<int>> b(2,vector<int>(n));
	rep(i,n-1){
		if(a.at(i)>a.at(i+1)) b[0][i]++;
		if(a.at(i)<a.at(i+1)) b[1][i]++;
	}
	int ans=1;
	bool flg1=false,flg2=false;
	rep(i,n-1){
		if(b[0][i]) flg1=true;
		if(b[1][i]) flg2=true;
		if(flg1 && flg2){
			ans++;
			flg1=false;
			flg2=false;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
S = input()

def ispalindrome(str): return 1 if str == str[::-1] else 0

if (ispalindrome(S) == 0):
    print("No")
    exit()

length = len(S)

if (ispalindrome(S[0:int((length - 1) / 2)]) == 0):
    print("No")
    exit()

part = length - (int((length + 3) / 2) - 1)

if (ispalindrome(S[int((length + 3) / 2) - 1:part]) == 0):
    print("No")
    exit()

print("Yes")

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
#include<vector>
using namespace std;
typedef pair<int,int> P;
priority_queue<P,vector<P>,greater<P> > q;
int h[1010000],nxt[1010000],K=0,to[1010000],cost[1010000];
void ins(int u,int v,int c){nxt[++K]=h[u];h[u]=K;to[K]=v;cost[K]=c;}
int d[1010000];
void dij(int S)
{
	memset(d,127/2,sizeof(d));
	d[S]=0;q.push(P(d[S],S)); 
	while(!q.empty())
	{
		P p=q.top();q.pop();int u=p.second;
		if(p.first>d[u])continue;
		for(int i=h[u];i;i=nxt[i])
		{
			int v=to[i];
			if(d[u]+cost[i]<d[v])
			{
				d[v]=d[u]+cost[i];
				q.push(P(d[v],v)); 
			}
		}
	}
}
int _h[1010000],_nxt[1010000],_K=0,_to[1010000],_cost[1010000],_id[1010000];
void _ins(int u,int v,int c,int dd){_nxt[++_K]=_h[u];_h[u]=_K;_cost[_K]=c;_to[_K]=v;_id[_K]=dd;}
vector<int> g[1010000];
int main()
{
	int n,m;scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int a,b,c;scanf("%d%d%d",&a,&b,&c);
		_ins(a,b,c,i);_ins(b,a,c,i);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=_h[i];j;j=_nxt[j])
		{
			int v=_id[j];
			int C=_cost[j];
			g[C].push_back(v); 
		}
		for(int j=_h[i];j;j=_nxt[j])
		{
			int C=_cost[j];int siz=g[C].size();
			if(!siz)continue;
			for(int k=1;k<siz;k++)ins(g[C][k],g[C][k-1],0),ins(g[C][k-1],g[C][k],0);
			ins(g[C][0],i+m,1);ins(i+m,g[C][0],1);
			g[C].clear();
		}
	}
	
	dij(1+m);
	if(d[n+m]==1061109567)puts("-1");
	else printf("%d",(d[n+m]+1)/2);
	return 0;
 } 

Measured memory_bytes: 66424
/* Blog: https://misteer.hatenablog.com/entry/AOJ-1619 */

#include <iostream>
#include <vector>
#include <bitset>

using namespace std;

using bits = bitset<500>;
constexpr int INF = 1 << 30;

bool solve() {
    /* ----- 入力 ----- */
    int N, M;
    cin >> N >> M;
    if (N == 0) return false;

    int ans = 0;
    if (N <= 23) {
        /* ----- Nが小さいとき ----- */
        vector<bits> B(N);
        for (auto& b : B) cin >> b;

        // 部分集合を全列挙
        for (int b = 0; b < (1 << N); ++b) {
            bits pat(0);
            for (int i = 0; i < N; ++i) {
                if ((b >> i) & 1) pat ^= B[i];
            }

            // xorが0なら要素数で更新
            if (pat.none()) {
                ans = max(ans, __builtin_popcount(b));
            }
        }
    } else {
        /* ----- Mが小さいとき ----- */
        vector<int> dp(1 << M, -INF);
        dp[0] = 0;

        for (int i = 0; i < N; ++i) {
            bits s;
            cin >> s;
            int b = s.to_ulong();  // 入力を整数に変換

            vector<int> ndp = dp;
            for (int p = 0; p < (1 << M); ++p) {
                ndp[b ^ p] = max(ndp[b ^ p], dp[p] + 1);
                // bを使う場合で更新
            }
            swap(dp, ndp);
        }
        ans = dp[0];
    }
    cout << ans << endl;
    return true;
}

int main() {
    while (solve()) {}
    return 0;
}



Measured memory_bytes: 11356
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  int N; cin >> N;
  int cnt = 1;
  int min_n;
  rep(i, N) {
    int P; cin >> P;
    if(i == 0) min_n = P;
    else {
      if(min_n > P) cnt++, min_n = P;
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
// URL: https://atcoder.jp/contests/abc134/tasks/abc134_a

import std.algorithm, std.container, std.math, std.range, std.typecons, std.string;

version(unittest) {} else
void main()
{
  int r; io.get(r);
  io.put(r^^2*3);
}

auto io = IO();

struct IO
{
  import std.algorithm, std.conv, std.format, std.meta, std.range, std.stdio, std.traits;

  dchar[] buf;
  auto sp = (new dchar[](0)).splitter;
  int precision = 10;
  string delimiter = " ";

  void nextLine()
  {
    stdin.readln(buf);
    sp = buf.splitter;
  }

  auto get(T)(ref T v)
  {
    if (sp.empty) nextLine();
    v = sp.front.to!T;
    sp.popFront();
  }

  auto getV(T...)(ref T v)
  {
    foreach (ref w; v) get(w);
  }

  auto getA(T)(size_t n, ref T v)
  if (hasAssignableElements!T)
  {
    v = new T(n);
    foreach (ref w; v) get(w);
  }

  auto getC(T...)(size_t n, ref T v)
  if (allSatisfy!(hasAssignableElements, T))
  {
    foreach (ref w; v)
      w = new typeof(w)(n);
    foreach (i; 0..n)
      foreach (ref w; v) get(w[i]);
  }

  auto getM(T)(size_t r, size_t c, ref T v)
  if (hasAssignableElements!T && hasAssignableElements!(ElementType!T))
  {
    v = new T(r);
    foreach (ref w; v) getA(c, w);
  }

  auto putA(T)(T v)
  {
    static if (isInputRange!T && hasLength!T && !isSomeString!T) {
      foreach (i, w; v) {
	putA(w);
	if (i < v.length - 1) write(delimiter);
      }
    } else if (isFloatingPoint!T) {
      writef(format("%%.%df", precision), v);
    } else {
      write(v);
    }
  }

  auto put(T...)(T v)
  {
    foreach (i, w; v) {
      putA(w);
      if (i < v.length - 1) write(delimiter);
    }
    writeln;
  }

  auto putB(S, T)(bool c, S t, T f)
  {
    if (c)
      put(t);
    else
      put(f);
  }

  auto dbg(T...)(T v)
  {
    stderr.writeln(v);
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, K: int, h: "List[int]"):
    h.sort()
    ret = float('inf')
    for l, r in zip(h, h[K-1:]):
        ret = min(ret, r - l)
    return ret


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
    K = int(next(tokens))  # type: int
    h = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, K, h)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 10040
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

n = int(arr_data[0][0])
k = int(arr_data[0][1])

arr01=arr_data[1]

arr02=sorted(list(map(int, arr01)),reverse=True)

#print(n,k,arr02)

mysum=0
for v in range(0,len(arr02)):

    if(v!=k):
        mysum+=arr02[v]
   
        
    else:
        break
print(mysum)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int dx = b-a;
    cout << (dx+1)*dx/2-b << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

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

int main()
{
    int n, k, ans = 0;
    cin >> n >> k;
    map<int, bool> sunuke;
    rep(i, k)
    {
        int d;
        cin >> d;
        rep(j, d)
        {
            int a;
            cin >> a;
            if (sunuke[a-1] == false) sunuke[a-1] = true;
        }
    }

    rep(i, n) if (sunuke[i] == false) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a, b, c, d, mx, ac, ad, bc, bd;
    cin >> a >> b >> c >> d;

    ac=a*c;
    ad=a*d;
    bc=b*c;
    bd=b*d;
    mx=ac;

    if(mx<ad)
        mx=ad;

    if(mx<bc)
        mx=bc;

    if(mx<bd)
        mx=bd;

    cout << mx << endl;


    return 0;
}


Measured memory_bytes: 3612
use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut map = HashMap::new();
    for &na in &a {
        let entry = map.entry(na).or_insert(0);
        *entry += 1;
    }
    let mut count = 0;
    for &value in map.values() {
        if value % 2 != 0 {
            count += 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 7268
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#include <math.h>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
    int N;
    cin >> N;
    int d[100005];
    for(int i=0;i<N;i++) cin >> d[i];
    sort(d,d+N);
    cout << d[N/2] - d[N/2-1] << endl;
    
}

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

int main(void) {
    string c1, c2;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> c1;
    cin >> c2;
    reverse(c2.begin(), c2.end());
    cout << (c1 == c2? "YES" : "NO") << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,m;
    cin>>n; m=n;
    vector<int>a,b,c;
    while(m--){
        int x,y,z;
        cin>>x>>y>>z;
        a.push_back(x);
        b.push_back(y);
        c.push_back(z);
    }
    for(int i=0;i<n;i++){
        int p1=0,p2=0,p3=0,d=0;
        for(int j=0;j<n;j++){
            if(i==j)
                continue;
            if(a[i]==a[j])
                p1=1;
            if(b[i]==b[j])
                p2=1;
            if(c[i]==c[j])
                p3=1;
        }
        if(p1==0)
            d+=a[i];
        if(p2==0)
            d+=b[i];
        if(p3==0)
            d+=c[i];
        cout<<d<<endl;
    }
}

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

int main() {
  int n,m,c,code,ans;
  cin>>n>>m>>c;
  vector<int> b(m);
  for(int i=0;i<m;i++) cin>>b.at(i);
  ans=0;
  
  for(int i=0;i<n;i++){
    vector<int> a(m);
    code=c;
    for(int j=0;j<m;j++){
      cin>>a.at(j);
      code+=a.at(j)*b.at(j);
    }
   if(code>0) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256