akhauriyash/Code-Regression huggingface dataset:
#include <climits>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>


typedef std::vector<int> TList;
long long int c;
void merge(TList& A, int left, int mid, int right)
{
  int n1 = mid - left;
  int n2 = right - mid;
  TList L(A.begin() + left, A.begin() + left + n1);
  L.push_back(INT_MAX);

  TList R(n2+1);
  for(int i = 0; i < n2; ++i){
    R[i] = A[mid + i];
  }
  R[n2] = INT_MAX;
  
  int i = 0;
  int j = 0;
  for(int k = left; k < right; ++k){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else{ 
      A[k] = R[j];
      j = j + 1;
      c += L.size() - 1 - i;
    }
  }
}

void mergeSort(TList& A, int left, int right)
{
  if(left+1 < right){
    int mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);   
    merge(A, left, mid, right);
  }
}

int main()
{
    int n;
    std::cin >> n;
    TList A(n);
    for(std::size_t i = 0; i < n; ++i){
        std::cin >> A[i];
    }
    c = 0;
    mergeSort(A, 0, n);
    std::cout << c << std::endl;
}

Measured memory_bytes: 2664
N = int(input())
rates = list(input().split())

for i in range(len(rates)):
    rates[i] = int(rates[i]) // 400

MAX = 0
MIN = 0
j = 0
while j <= 8:
    for k in range(N):
        if j != 8 and j == rates[k]:
            MAX += 1
            MIN += 1
            break
        elif j == 8 and j <= rates[k]:
            MAX += 1
            if MIN == 0:
                MIN = 1
                continue
            continue
    j += 1

print(MIN, MAX)


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

int main()
{
 int a,b,h,area;
 float x;
 scanf("%d",&a);
 scanf("%d",&b);
 scanf("%d",&h);
 x=(a+b);
 area=x/2*h;
 printf("%d",area);

    return 0;
}


Measured memory_bytes: 128
import math
X = int(input())

if X/500 > 0:
    a = 1000 * math.floor(X/500)
    b = 5 * math.floor((X%500)/5)
    print(a+b)
elif X/5 > 0:
    c = 5 * math.floor(X/5)
    print(c)
else:
    print('0')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<int> V(1000001,0);
    rep(n,0,N){
        int a; cin>>a;
        V.at(a)++;
    }

    int ans=0;
    rep(i,1,V.size()){
        if(V.at(i)){
            if(V.at(i)==1) ans++;
            int _i=i;
            while(_i+i<V.size()){
                _i+=i;
                V.at(_i)=0;
            }
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 7220
#include<iostream>
#include<cstdio>
#define ll long long
#define N 100100
using namespace std;

ll n,a,b,l,r,num[N],tmp[N];

inline bool pd(ll u)
{
	ll i,j,res=0;
	for(i=1;i<=n;i++)
	{
		tmp[i]=num[i]-u*b;
	}
	for(i=1;i<=n;i++)
	{
		if(tmp[i]>0)
		{
			res+=(tmp[i]+a-1)/a;
		}
	}
	return res<=u;
}

int main()
{
	ll i,j,p;
	cin>>n>>a>>b;
	a-=b;
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&num[i]);
	}
	for(l=1,r=1e9+1;l<r;)
	{
		ll mid=((l+r)>>1);
		pd(mid)?r=mid:l=mid+1;
	}
	cout<<l;
}

Measured memory_bytes: 1792
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]


def solve():
    # N,M = map(int, input().split())
    N,M = map(int,input().split())
    # P = list(map(int(input().split())))
    P = list(map(int,input().split()))
    XY = []
    U = UnionFind(N+1)

    for x,y in [list(map(int,input().split())) for _ in range(M)]:
        U.Unite(x,y)

    ans = 0
    for e,p in enumerate(P,1):
        if U.isSameGroup(e,p):
            ans += 1
    print(ans)

    # XY= [ list(map(int(input().split()))) for _ in range(M)]


if __name__ == "__main__":
    solve()

Measured memory_bytes: 33124
from bisect 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())))

"""
前処理で、中部の祭壇でBi以下のサイズを選べるときの、中段と上段のパーツの組み合わせのパターン数を計算しておく。
"""
BPattern = []
for i in range(N):
    b = B[i]
    idx = bisect(A,b-1)
    if i == 0:
        BPattern.append(idx)
    else:
        BPattern.append(BPattern[-1]+idx)

ans = 0
for i in range(N):
    c = C[i]
    idx = bisect(B,c-1)
    if idx:
        ans+=BPattern[idx-1]

print(ans)

Measured memory_bytes: 109796
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"4 3 6"# => "safe",
// r#"6 5 1"# => "delicious",
// r#"3 7 12"# => "dangerous",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
        m: usize,
    }

    ((n - 1) * (m - 1)).to_string()
}

Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;

constexpr int INF = 1e9;
constexpr ll BIGINF = 1e18;
constexpr double EPS = 1e-16;
constexpr int MOD = 1e9 + 7;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int n;

map<string, int> a;

void input() {
  cin >> n;

  for (int i = 0; i < n; ++i) {
    string t;
    cin >> t;

    a[t]++;
  }
}

void solve() {
  int maxo = -INF;

  for (auto&& i : a) {
    maxo = max(maxo, i.second);
  }

  vector<string> ans;

  for (auto&& i : a) {
    if (i.second == maxo)
      ans.emplace_back(i.first);
  }

  sort(ans.begin(), ans.end());
  for (auto&& i : ans) {
    cout << i << '\n';
  }
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();
  input();
  solve();
}


Measured memory_bytes: 27376
x=input()
#print(x)
#print(x[0])
if x[0]==x[1]==x[2]:
	print(int(x))
elif x[1]<=x[0] and x[2]<=x[0]:
	print(int(x[0]+x[0]+x[0]))
else:
	print(int(str(int(x[0])+1)+str(int(x[0])+1)+str(int(x[0])+1)))


Measured memory_bytes: 3060
while True:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break 
    if m==-1 or f==-1:
        print('F')
    elif m+f>=80:
        print('A')
    elif m+f>=65:
        print('B')
    elif m+f>=50:
        print('C')
    elif m+f>=30:
        if r>=50:
            print('C')
        else:
            print('D')
    else:
        print('F')


Measured memory_bytes: 5592
N, M = map(int, input().split())

ans = []

for i in range(M):
   tmp = list(map(int, input().split()))
   tmp.append(i)
   tmp.append(-1)
   
   ans.append(tmp)
   
ans.sort(key=lambda x: x[1])

Check = [1]*N

for i in range(M):
    ans[i][3]=Check[ans[i][0]-1]
    Check[ans[i][0]-1] = Check[ans[i][0]-1]+1
                
ans.sort(key=lambda x: x[2])          

for i in range(M):
    ansA = str(ans[i][0]).zfill(6)
    ansB = str(ans[i][3]).zfill(6)
    tmp = [ansA, ansB]
    print(''.join(tmp))

Measured memory_bytes: 36032
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#pragma 03
using namespace std;
using namespace __gnu_pbds;
ll suffix1[200005], suffix2[200005];
int main(){
	ll n, k, c; cin >> n >> k >> c;
	string s; cin >> s;
	suffix1[n] = 0;
	for (ll i = n - 1; i >= 0; i--){
		if (s[i] == 'o') suffix1[i] = max(suffix1[i + 1], suffix1[min(n, i + c + 1)] + 1);
		else suffix1[i] = suffix1[i + 1];
	}
	if (suffix1[0] > k) return 0;
	reverse(s.begin(), s.end());
	suffix2[n] = 0;
	for (ll i = n - 1; i >= 0; i--){
		if (s[i] == 'o') suffix2[i] = max(suffix2[i + 1], suffix2[min(n, i + c + 1)] + 1);
		else suffix2[i] = suffix2[i + 1];
	}
	vll ans;
	for (ll i = 0; i < n; i++){
		if (suffix1[i] == suffix1[i + 1] || suffix2[n - 1 - i] == suffix2[n - i]) continue;
		ans.pb(i + 1);
	}
	for (ll i = 0; i < ans.size(); i++) cout << ans[i] << endl;
}

Measured memory_bytes: 6516
use std::io::{self, BufRead, BufWriter, Write};
use std::collections::BTreeSet;

fn solve<R, W>(reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let a_line = lines.next().unwrap().unwrap();
    let mut splited = a_line.trim().split_whitespace();
    let _: u32 = splited.next().unwrap().parse().unwrap();
    let k: usize = splited.next().unwrap().parse().unwrap();

    let a_line = lines.next().unwrap().unwrap();
    let mut splited = a_line.trim().split_whitespace();
    let p: Vec<i32> = splited.map(|x| x.parse().unwrap()).collect();

    
    let mut window: BTreeSet<i32> = BTreeSet::new();

    for i in 0..k {
        window.insert(p[i]);
    }

    let mut ans = 0;
    let mut plusone = false;
    let mut unsorted_count = unsorted_count(&p[0..k]);
    for i in 0..p.len() - k + 1 {
        let mut m0 = -1;
        let mut m1 = -1;
        if i > 0 {
            m1 = *window.iter().next_back().unwrap();
            window.remove(&p[i - 1]);
            window.insert(p[i + k - 1]);
            m0 = *window.iter().next().unwrap();
        if p[i + k - 2] < p[i + k - 1] {
            if unsorted_count > 0 {
                unsorted_count -= 1;
            }
        } else {
            unsorted_count = k - 1;
        }
        }

        if unsorted_count <= 0 {
            plusone = true;
            continue;
        }

        if i <= 0 {
            ans += 1;
            continue;
        }

        if ! (p[i - 1] < m0 && m1 < p[i + k - 1]) {
            ans += 1;
        }
    }

    if plusone {
        ans += 1;
    }

    writeln!(&mut writer, "{}", ans).unwrap();
}

fn unsorted_count(x: &[i32]) -> usize {
    let mut pre = x[0];
    let mut ret = 0;
    for i in 1..x.len() {
        if pre >= x[i] {
            ret = i;
        }
        pre = x[i]
    }
    return ret;
}

fn main() {
    let stdio = io::stdin();
    let input = stdio.lock();

    let stdout = io::stdout();
    let output = BufWriter::new(stdout.lock());

    solve(input, output);
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        (
            br"5 3
0 2 1 4 3", br"2
",
        ),
        (
            br"4 4
0 1 2 3", br"1
",
        ),
        (
            br"10 4
2 0 1 3 7 5 4 6 8 9", br"6
",
        ),
    ];

    #[test]
    fn test_b() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll S[200005];

int main()
{
    int N;
    cin >> N;
    S[0] = 0;
    REP(i, N)
    {
        ll a;
        cin >> a;
        S[i + 1] = a + S[i];
    }

    ll min = INF;
    FOR(i, N, 1)
    {
        min = std::min(min, abs(S[N] - 2 * S[i]));
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 1792
N=int(input())
dis_list=[list(map(int, input().split())) for _ in range(N)]
ans=0
for x1,y1 in dis_list:
  for x2,y2 in dis_list:
    ans += ((x1-x2)**2+(y1-y2)**2)**0.5
print(ans/N)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back

#define N 100010
#define MOD 1000000007

int n, m;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m;
	pair<ll, ll> a[n];	
	for (ll i = 0; i < n; ++i)
	{
		cin >> a[i].ff >> a[i].ss;
	}
	sort(a, a + n);
	ll ans = 0;
	for (ll i = 0; i < n; ++i)
	{

		if(a[i].ss < m)
		{
			ans += a[i].ff * a[i].ss;
			m -= a[i].ss;
		}
		else
		{
			ans += (m) * a[i].ff;
			m = 0;
			break;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1792
<?php
$p='';
while(1){
  list($h,$w)=explode(' ',trim(fgets(STDIN)));
  if($h||$w){

    $l='';
    for($i=0;$i<$w;$i++){$l.='#';}
    $l.=PHP_EOL;

    for($i=0;$i<$h;$i++){$p.=$l;}
    $p.=PHP_EOL;
  }
  else break;
}
print $p;

Measured memory_bytes: 15524
#include<stdio.h>
#include<math.h>
int main(void){
    int a,b;
    char op;
    for(;;){
    scanf("%d %c %d\n",&a,&op,&b);
    if(op=='?')break;
    switch(op){
    case '+':
        printf("%d\n",a+b);
        break;
    case '-':
        printf("%d\n",a-b);
        break;
    case '*':
        printf("%d\n",a*b);
        break;
    case '/':
        printf("%d\n",a/b);
        break;
    }
    }
    return 0;
}


Measured memory_bytes: 2100
I=->{gets.split.map &:to_i};N,Q=I[];A=1,c=1,1,*[0]*(N-2),1;Q.times{a,b=I[];A[a],A[b]=A[b],A[a];c!=a&&c!=b||c=a+b-c;A[c-1]=A[c+1]=1};p A.reduce(:+)-2

Measured memory_bytes: 4092
#include <iostream>

using namespace std;

int main ()
{
    int a, 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;
    return 0;
    
}


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


#define ll long long


//gcdやり直す

void swap (int *x, int *y) {
  int temp;    

  temp = *x;
  *x = *y;
  *y = temp;
}




/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}


int modpow(int a,int n,int mod){
  int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }

  return ans;
}




/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int l,r,d;
  scanf("%d%d%d",&l,&r,&d);
  int ans=r-l+1;
  for(int i=l;i<=r;i++){
    ans-=!!(i%d);
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 1692
#ABC052b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
s = input()
x = 0
maX = 0
for i in s:
    if (i == "I"):
        x += 1
        maX = max(maX, x)
    else:
        x -= 1
print(maX)

Measured memory_bytes: 3060
//by rko27
//One more....
//---------------------------------------------------------------------------------------------------------------------------------------------------

#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int  long long 
#define ll  long long 
#define pb push_back
#define mp make_pair
#define fe first
#define se second
#define nl "\n"
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)(x.size())
#define god ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

//----------------------------------------------------------------------------------------------------------------------------------------------------

const long double pi = 3.14159265358979323;
int mod=1000000000+7;
int modu=998244353;

//----------------------------------------------------------------------------------------------------------------------------------------------------

ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
ll powe(ll x, ll y){ x = x%mod, y=y%(mod-1);ll ans = 1;while(y>0){if (y&1){ans = (1ll * x * ans)%mod;}y>>=1;x = (1ll * x * x)%mod;}return ans;}
void fun()
{
//	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//	#endif
	//786
}
bool isPrime(int n){for(int i=2;i*i<=n;i++)if(n%i==0) return false;return true;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}

//-------------------------------------------------------------------------------------------------------------------------------------------------------

const int N=1e6+7;
std::vector<int> v[N];

//--------------------------------------------------------------------------------------------------------------------------------------------------------



//--------------------------------------------------------------------------------------------------------------------------------------------------------
signed main() 
{
	god;
	//rko;
	fun();
	int ttt=1; //cin>>ttt;
	while(ttt--)
	{
		double r; cin>>r;
		cout<<fixed<<setprecision(15)<<2*pi*r;
	}
	return 0;
}

Measured memory_bytes: 27220
import sys, bisect
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, W = LI()
    vw = [LI() for _ in range(N)]

    v_sum = sum([i[0] for i in vw])

    # dp[i][j]: [0, i)を使って価値j以上になる場合の重さの最小値
    dp = [[INF] * (v_sum + 1) for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0] = 0

    for i in range(N):
        for j in range(v_sum):
            v_p = max(j + 1 - vw[i][0], 0)
            if v_p >= 0:
                dp[i+1][j+1] = min(dp[i][j+1], dp[i][v_p] + vw[i][1])
            else:
                dp[i+1][j+1] = dp[i][j+1]

    # for i in dp:
    #     print(i)
    
    ans = bisect.bisect_right(dp[-1], W) - 1
    print(ans)

if __name__ == '__main__':
    resolve()


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

long long N, A[1 << 18], E = 1;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];
	sort(A + 1, A + N + 1);
	for (int i = 1; i <= N; i++) { E *= __gcd(A[i], 1LL * (i - 1)); E %= 998244353; }
	cout << E << endl;
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
s = [input() for i in range(n)]

m = int(input())
t = [input() for i in range(m)]

ans = 0
for str in s: #strは単語を表している。ループの回数としてはn回（sの配列数）
    cou = s.count(str) - t.count(str) #sの中にstr（たとえばapple)が何個あるか、tの中に同じく　str（spple)が何個あるか調べて引いてる。
    ans = max(cou, ans)

print(ans)
    


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

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

int main()
{
	REP(i,9) REP(j,9) cout<<(i+1)<<"x"<<(j+1)<<"="<<(i+1)*(j+1)<<endl;

	return 0;
}

Measured memory_bytes: 1116
#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()
typedef long long lint;
 
int main() {
  int n,m;
  cin >> n >>m;
  
  
  if(n==m)cout << "Yes" << endl;
  else cout << "No" << endl;
}



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

main()
{
	priority_queue<int> q;
	int n,k,m,i,j,len;
	int flag=0;
	int sum=0;
	
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++)
	{
		scanf("%d",&len);
		q.push(len);
	}
	
	for(i=0;i<k;i++)
	{
			sum+=q.top();
			q.pop();
	}
	printf("%d",sum);
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			Map<String, Integer> items = new HashMap<String, Integer>();
			for (int i = 0; i < n; i++) {
				String s = sc.next();
				int cost = sc.nextInt();
				items.put(s, cost);
			}
			int m = sc.nextInt();
			for (int i = 0; i < m; i++) {
				String recipeName = sc.next();
				int k = sc.nextInt();
				int sum = 0;
				for (int j = 0; j < k; j++) {
					String name = sc.next();
					if (items.containsKey(name))
						sum += items.get(name);
				}
				items.put(recipeName, Math.min(sum, items.get(recipeName)));
			}
			String query = sc.next();
			System.out.println(items.get(query));
		}
	}
}

Measured memory_bytes: 24984
#include <iostream>

 

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: 3096
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

i64 gcd(i64 a, i64 b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main() {
  i64 x, y;
  cin >> x >> y;
  i64 g = gcd(x, y);
  cout << 1 + (x / g + y / g - 1) * g << endl;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int k;

  cin >> k;

  cout << a[k - 1];

  return 0; 
}

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

int main(){
    int a, b, c;
    cin >> a >> b >>c;
    if (c -(a-b) <= 0){
        cout << 0 << endl;
    } else {
        cout << c -(a-b) << endl;
    }
    
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int sum=0,N,H,i,max=0;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&H);
    if(H>=max){
      sum++;
      max=H;
    }
    
  }
  printf("%d\n",sum);
  return 0;
}
  

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

#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define ll long long
using namespace std;

int inf = 1e18;
const int N = 5e5+5;
int mod = 1e9+7;
/*void dfs(int u,int par,int maxx)
{


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


int ncr(int n , int r ){
	r = min(r,n-r);
	int res = 1 ;
	for(int i = 1 ; i <= r ; i++ ){
		( res *= n-i+1 )%= mod;
		res /= i ;
	}
	return res ;
}
*/
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
ll arr[N];
 int sumXOR(int n)
{
     ll sum = 0;
    for (int i = 0; i < 60; i++)
    {

        ll k = (1ll<<i);
        int ct = 0;
        for(int i=0;i<n;++i)
        {
            if(arr[i]&k)
                ct++;
        }
        sum+=  k%mod*ct%mod*(n-ct)%mod;
        sum%=mod;
    }
    return sum%mod;
}
int32_t main()
{
    io
    int tt=1;
    //cin>>tt;
    while(tt--)
    {
        int n;
        cin>>n;

        rep(i,0,n)
        cin>>arr[i];
        ll ans = sumXOR(n);
        cout<<ans%mod<<el;

    }



    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
int digit(int n)
{
    int i = 1,ans = 1;
    while (n >= 10)
    {
        n /= 10;
        i *= 10;
        ans ++;
    }
    return ans % 2;
}
int main()
{
    int n;
    int ans = 0;
    scanf("%d",&n);
    for (int i = 1; i <= n; i++)
    {
        ans += digit(i);
    }
    printf("%d",ans);
}


Measured memory_bytes: 128
N = int(input())
A = []
if N%2==0:
    for i in range(1,N):
        for j in range(i+1,N+1):
            if j!=N+1-i:
                A.append((i,j))
else:
    for i in range(1,N):
        for j in range(i+1,N+1):
            if j!=N-i:
                A.append((i,j))
print(len(A))
for a in A:
    print(a[0],a[1])

Measured memory_bytes: 43120
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i=s;i<n;i++)
int main(){
    int A,B,H,M;
    cin>>A>>B>>H>>M;
    const double pie=3.1415926535897932384; 
    double rad_A=(2*pie/(3600*12))*(H*3600+M*60);
    double rad_B=((2*pie/3600)*(H*3600+M*60));
    double rad=rad_A-rad_B;
    if(rad<0)rad*=(-1);
    cout<<fixed<<setprecision(9)<<sqrt(B*B+A*A-2*A*B*cos(rad))<<endl;


 
}

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

using namespace std;

int main(){
  int n, k;
  std::cin >> n >> k;

  vector<bool> t_or_f(n, false);
  for(int i=0; i<k; i++){
    int size;
    std::cin >> size;
    for(int j=0; j<size; j++){
      int temp;
      std::cin >> temp;
      t_or_f[temp - 1] = true;
    }
  }

  int ans = 0;
  for(int i=0; i<t_or_f.size(); i++){
    if(!t_or_f[i]) ans += 1;
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
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; }
const long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];

int n, m, q;
vector<ll> a, b, c, d;

ll score(vector<int> &A)
{
    ll res = 0;
    rep(i, q) if (A[b[i]] - A[a[i]] == c[i]) res += d[i];
    return res;
}


ll dfs(vector<int> &A)
{
    if (A.size() == n)
    {
        return score(A);
    }

    ll res = 0;
    int last = (A.empty() ? 0 : A.back());
    Rep(v, last, m)
    {
        A.push_back(v);
        res = max(res, dfs(A));
        A.pop_back();
    }
    return res;
}



int main()
{
    cin >> n >> m >> q;
    a.resize(q); b.resize(q); c.resize(q); d.resize(q);
    rep(i, q)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i], --b[i];
    }
    vector<int> A;
    cout << dfs(A) << endl;
}



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

class SegmentTree {
private:
    int n;
    vector<ll> node;
    vector<int> idx;
    ll INF = (1ll << 31) - 1;
public:
    SegmentTree(int N) {
        n = 1;
        while (n < N) n *= 2;
        node.resize(2 * n - 1, -INF);
        idx.resize(2 * n - 1, -1);
        for (int i = 0; i < N; i++) {
            node[i + n - 1] = 0;
            idx[i + n - 1] = i;
        }
        for (int i = n - 2; i >= 0; i--) {
            node[i] = max(node[2 * i + 1], node[2 * i + 2]);
            if (node[2 * i + 1] >= node[2 * i + 2]) {
                idx[i] = idx[2 * i + 1];
            } else {
                idx[i] = idx[2 * i + 2];
            }
        }

    }

    void update(int i, ll x) {
        i += (n - 1);
        node[i] += x;
        while (i > 0) {
            i = (i - 1) / 2;
            int l = 2 * i + 1;
            int r = 2 * i + 2;
            node[i] = max(node[l], node[r]);
            if (node[l] >= node[r]) {
                idx[i] = idx[l];
            } else {
                idx[i] = idx[r];
            }
        }
    }

    int query() {
        return idx[0];
    }

    void disp() {
        for (int i = 0; i < 2 * n - 1; i++) {
            cout << idx[i] << " " << node[i] << "\n";
        }
    }

};

int main() {
    int N, R, L;
    cin >> N >> R >> L;
    int k = 0;
    ll v[N]{};
    SegmentTree st(N);
    int n = 1;
    while (n < N) n *= 2;
    int d[R], t[R], x[R];
    for (int i = 0; i < R; i++) {
        cin >> d[i] >> t[i] >> x[i];
        d[i]--; 
    }
    
    for (int i = 0; i < R; i++) {
        int idx = st.query();
        //cout << idx << "\n";
        v[idx] += t[i] - k;
        k = t[i];
        st.update(d[i], x[i]);
    }
    // cout << "-----\n";
    // cout << st.query(0, N, 0, 0, n) << "\n";
    // cout << "-----\n";
    v[st.query()] += L - k;
    int ans = 0;
    for (int i = N - 1; i >= 0; i--) {
        if (v[ans] <= v[i]) {
            ans = i;
        }
    }
    cout << ans + 1 << "\n";
    //st.disp();
    return 0;
}


Measured memory_bytes: 14104
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  int A, B;
  cin >> A >> B;
  if (A == B) {
    puts("Draw");
    return 0;
  }
  if (A == 1 || B == 1) {
    if (A == 1) {
      puts("Alice");
    } else {
      puts("Bob");
    }
    return 0;
  }

  if (A < B) {
    puts("Bob");
  } else {
    puts("Alice");
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

int main() {
  int a, b; cin >> a >> b;

  cout << max({a+b, a*b, a-b}) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <class T>
using ordered_set =
       tree <T,null_type,less <T>,rb_tree_tag,tree_order_statistics_node_update> ;
///find_by_order()
///order_of_key()

template <class T,class U>
void maximize(T &x,U y){
    if(x < y)x=y;
}
template <class T,class U>
void minimize(T &x,U y){
    if(x > y)x=y;
}
template <class T>
T Abs(T x){
    return (x < (T)0 ? -x : x);
}
template <class T>
T safe_sqrt(T x){
    return sqrt(max(x,(T)0));
}
template <class T,class U,class V>
T addmod(T x,U k,V MOD){
    return ((x+k)%MOD + MOD)%MOD;
}
template <class T,class U,class V>
T submod(T x,U k,V MOD){
    return ((x-k)%MOD + MOD)%MOD;
}
template <class T,class U,class V>
T mul(T x,U y,V MOD){
    return ( (x % MOD) * (y % MOD) ) % MOD;
}

#define ll long long
#define pll pair <ll,ll>
#define pii pair <int,int>
#define fir first
#define sec second
#define mp make_pair
#define pb push_back
#define emp emplace_back
#define MASK(i) ((1LL)<<(i))
#define BIT(x,i) (((x)>>(i))&1)
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)((c).size())
#define fn "test"    ///FILE_NAME_HERE

/*------------------------------------------END_OF_TEMPLATE------------------------------------------*/

namespace task{

	const int N = 1e3 + 3;
	const int base = 1e9 + 7;
	int f[N][N];
	int h,w;
	char a[N][N];

    void solve(){
    	cin>>h>>w;
    	for(int i = 1;i <= h;++i){
    		for(int j = 1;j <= w;++j){
    			cin>>a[i][j];
    		}
    	}
    	f[1][1] = 1;
    	for(int i = 1;i <= h;++i){
    		for(int j = 1;j <= w;++j){
    			if(a[i][j] == '#')continue;
    			f[i][j] = addmod(f[i][j],f[i - 1][j],base);
    			f[i][j] = addmod(f[i][j],f[i][j - 1],base);
    		}
    	}
    	cout<<f[h][w];
    }
}

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


Measured memory_bytes: 5120
import math
import fractions
a,b,c,d = map(int,input().split())
#c_d = math.floor(((c*d)//(math.gcd(c,d))))
c_d = (c*d)//(fractions.gcd(c,d))
#print((math.gcd(c,d)))
a_c = (a-1) // c
a_d = (a-1) // d
a_c_d = (a-1) // c_d
a_ans = (a-1) - a_c - a_d + a_c_d
#ans1 = (a_c + a_d - a_c_d)
#print(c_d)
b_c = b // c
b_d = b // d
b_c_d = b // c_d
b_ans = b - b_c - b_d + b_c_d
#ans2 = (b_c + b_d -b_c_d)
#print(ans2)
#print(math.floor((b-a+1)-(ans2-ans1)))
print(math.floor(b_ans-a_ans))

Measured memory_bytes: 63980
#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 all(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

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

    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max((a+b)-n, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    // まずx, y を単体で用意する
    long costs = x * a + y * b;
    long ans = costs;
    for (int i = 1; i <= Math.min(x, y); i++) {
      costs = costs - a - b + (c * 2);
      ans = Math.min(ans, costs);
    }
    for (int j = 1; j <= Math.abs(x - y); j++) {
      if (x > y) {
        costs = costs + (c * 2) - a;
      } else {
        costs = costs + (c * 2) - b;
      }
      ans = Math.min(ans, costs);
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 35672
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		long N = scan.nextLong();
		int arr[] = new int[(int)N];
		long count[] = new long[(int)N+1];
		long sum = 0;

		for (int i = 0; i < N ; i ++){
			arr[i] = scan.nextInt();
			count[arr[i]] += 1;
		}

		for(int i = 0; i <= N; i++){
			if(count[i] != 0 ){
				sum += count[i] * (count[i] -1) / 2;
			}
		}

		for(int k =0; k < N; k++){
			long ans = sum;
			if(count[arr[k]] > 1){
				ans -= count[arr[k]] * (count[arr[k]] - 1) / 2;
				ans += (count[arr[k]] - 1) * (count[arr[k]] - 2) / 2;
			}
			System.out.println(ans);
		}

	}
}

Measured memory_bytes: 101628
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,x;
  cin >> n >> x;
  vector<int> a(n);
  rep(i,n) cin >> a.at(i);
  sort (a.begin(),a.end());
  int count = 0;
  for(int i=0;i<n;i++){
    if(x < a.at(i) ) {
      x = 0;
      break;
    }
    x -= a.at(i);
    count ++;
  }
  if(x != 0)count--;
  cout << count << endl;
}

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

int main() {
long long h,n;
cin >> h >>n;
long long a[n];
for(long long i=0;i<n;i++){
    cin >> a[i];
}
long long sum=0;
for(long long i=0;i<n;i++){
    sum+=a[i];
}
if(h-sum>=1)cout << "No";
else cout << "Yes";
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
	"strings"
)

var scan *bufio.Scanner
var writer io.Writer

func init() {
	scan = bufio.NewScanner(os.Stdin)
	writer = os.Stdout
	scan.Split(bufio.ScanWords)
}

func main() {
	solve()
}

func solve() {

	c := 0
	n := nextInt()
	var s []string
	sx := make([][]string, n)
	sm := make(map[string]int, n)
	for i := 0; i < n; i++ {
		s = append(s, nextWord())
		for j := 0; j < len(s[i]); j++ {
			sx[i] = append(sx[i], string(s[i][j]))
		}
		sort.Strings(sx[i])
		c += sm[strings.Join(sx[i], "")]
		sm[strings.Join(sx[i], "")]++
	}
	fmt.Fprint(writer, c)
}

func nextWord() string {
	scan.Scan()
	str := scan.Text()
	return str
}

func nextInt() int {
	i, e := strconv.Atoi(nextWord())
	if e != nil {
		panic(e)
	}
	return i
}


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

int main(){
  int n;cin>>n;
  vector<int> h(n);
  rep(i,n){cin>>h.at(i);}
  h.at(0)--;
  bool b=true;
  
  rep(i,n-1){
    if(h.at(i)<h.at(i+1)){
      h.at(i+1)--;
    }
    if(h.at(i)>h.at(i+1)){
      b=false;
      break;
    }
    //cout<<h.at(i)<<" ";
  }
  if(n!=1){if(h.at(n-2)>h.at(n-1))b=false;}
  if(b)cout<<"Yes";
  else{cout<<"No";}
}

Measured memory_bytes: 640
PROGRAM-ID.                      ABC_107_A.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP     PIC X(7).
    01 N       PIC 9(3).
    01 i       PIC 9(3).
    01 ans     PIC X(3).

    01 ZS      PIC Z(3)9.
    01 DUMMY   PIC X(1).


PROCEDURE                        DIVISION.
    ACCEPT INP.

    UNSTRING INP
    DELIMITED BY SPACE
    INTO N i.

    SUBTRACT i FROM N GIVING i.
    ADD 1 TO i.

    MOVE i TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 1016
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n,k,a[200010]; 

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	int l=1,r=1000000000,ans=-1;
	while(l<=r){
		int mid=(l+r)/2;
		int cnt=0ll;
		for(int i=1;i<=n;i++) cnt+=(a[i]-1)/mid;
		if(cnt<=k){
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
        int n;
        cin >> n;
        int a[n], b[n], c[n];
        for (int i=0; i<n; ++i) {
                cin >> a[i] >> b[i] >> c[i];
        }
        int dp[n][3];
        dp[0][0] = a[0];
        dp[0][1] = b[0];
        dp[0][2] = c[0];
        for (int i=1; i<n; ++i) {
                dp[i][0] = max(dp[i-1][1]+a[i], dp[i-1][2]+a[i]);
                dp[i][1] = max(dp[i-1][0]+b[i], dp[i-1][2]+b[i]);
                dp[i][2] = max(dp[i-1][0]+c[i], dp[i-1][1]+c[i]);
        }
        cout << max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]) << endl;
}

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

int main(){
  int h,w;
  cin >> h >> w;
  char c[h+2][w+2];
  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      cin >> c[i][j];
    }
  }
  
  for(int i=0; i<h+2; i++){
    c[i][0] = '.';
    c[i][w+1] = '.';
  }
  
  for(int i=0; i<w+2; i++){
    c[0][i] = '.';
    c[h+1][i] = '.';
  }
  
  int flag = 1;
  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      if(c[i][j] == '#' && !(c[i-1][j] == '#' || c[i][j-1] == '#' || c[i+1][j] == '#'|| c[i][j+1] == '#')){
        flag = 0;
        break;
      }
    }
  }
  
  cout << (flag ? "Yes" : "No") << endl;
}

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


int main(){
    string S, T;
    cin >> S;
    cin >> T;
    int S_l = S.length(), T_l = T.length();

    int roop = S_l - T_l + 1;
    int ans = T_l;

    for (int i = 0; i < roop; ++i){
        int count = 0;
        for (int j = 0; j < T_l; ++j){
            if (S[i + j] == T[j]){
                //書き換える必要なし
            } else{
                count += 1;
            }
        }
        ans = (ans > count ? count : ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,min_cost=0,i=0;
    cin>>n>>k;
    vector<int> p(n);
    for(int i=0;i<n;i++)
        cin>>p[i];
    sort(p.begin(),p.end());
    while(k--)
        min_cost+=p[i++];
    cout<<min_cost;
    }

Measured memory_bytes: 3608
#include <algorithm>
#include <climits>
#include <iostream>
#include <set>
#include <queue>
#include <vector>

#define ll long long
#define x first
#define y second




using namespace std;

int main() {
    int n,k,i,j;
    cin>>n>>k;
    
    int a[n+1];
    for(i=1;i<=n;i++) cin>>a[i];
    
    for(i=1;i<=n;i++){
        if(a[i]==1) j=i;
    }
    
    int res=INT_MAX;
    
    for(i=max(0,j-k);i<j;i++){
        int t=i/(k-1)+(i%(k-1)!=0)+(n-i-k)/(k-1)+((n-k-i)%(k-1)!=0);
        res=min(res,t);
    }
  
  cout<<res+1;
    return 0;
}

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

bool isPal(string s, int st, int en){
    for(int i = st-1, j = en-1; i < j; i++, j--)
        if( s[i] != s[j] )
            return false;

    return true;
}

int32_t main(){
    IOS;
    string s;
    cin >> s;
    int len = s.size();
    int en1 = (len-1)/2;
    int st1 = (len+3)/2;
    int en2 = (len);
    if( isPal(s, 1, len) && isPal(s, 1, en1) && isPal(s, st1, en2) )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
def a():
    S = input()

    if S[3] == S[2] and S[4] == S[5]:
        print("Yes")
    else:
        print("No")


def b():
    X = int(input())
    y_500 = (X // 500) * 1000
    y_5 = ((X - (y_500 / 2)) // 5) * 5
    print(int(y_500 + y_5))


def c():
    print()


def d():
    print()


def e():
    print()


b()


Measured memory_bytes: 39860
import java.util.*;
import java.lang.*;

class Counter<T> extends TreeMap<T,Long>{
    public Counter(){
        super();
    }
    public Counter(List<T> list){
        super();
        for(T e: list) this.addOne(e);
    }
    public Long count(Object elm){
        return getOrDefault(elm,0L);
    }
    public void add(T elm, long amount){
        if(!this.containsKey(elm)) put(elm, amount);
        else replace(elm, get(elm)+amount);
        if(this.count(elm)==0) this.remove(elm);
    }
    public void addOne(T elm){
        this.add(elm, 1);
    }
    public void removeOne(T elm){
        this.add(elm, -1);
    }
    public void removeAll(T elm){
        this.add(elm, this.count(elm));
    }
    public static<T> Counter<T> merge(Counter<T> a, Counter<T> b){
        Counter<T> c = new Counter<>();
        for(T x: a.keySet()) c.add(x, a.count(x));
        for(T y: b.keySet()) c.add(y, b.count(y));
        return c;
    }
}
public class Main {

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

        Counter<Integer> wrongAnswer = new Counter<>();
        boolean[] accepted = new boolean[N+1];

        int a=0, w=0;

        for(int m=0; m<M; m++){
            int p = sc.nextInt();
            String S = sc.next();
            if(S.equals("AC")){
                if(!accepted[p]){
                    accepted[p] = true;
                    a++;
                    w += wrongAnswer.count(p);
                }
            }
            if(S.equals("WA")){
                wrongAnswer.addOne(p);
            }
        }
        System.out.printf("%d %d\n", a,w);

    }

}


Measured memory_bytes: 68392