akhauriyash/Code-Regression huggingface dataset:
import heapq

n, m = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]
info = sorted(info)
q = []
i = 0
j = 0
day = 1
ans = 0
for i in range(m):
    while True:
        if j >= n:
            break
        if info[j][0] == i+1:
            heapq.heappush(q, -info[j][1])
            j += 1
        else:
            break
    if q:
        ans += -heapq.heappop(q)
  
print(ans)
  

Measured memory_bytes: 73432
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) {
        cout << s;
    } else {
        cout << "red";
    }
    return 0;
}

Measured memory_bytes: 892
import sys
input=sys.stdin.readline
n=int(input())
Edge=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  Edge[a-1].append((b-1,i))
  Edge[b-1].append((a-1,i))
m=int(input())
M=[]
for i in range(m):
  M.append(tuple(map(int,input().split())))

inf=float("inf")
path=[-1]*n #根から各点までのパスが通過する辺をbitで管理したもの
path[0]=0
stack=[0]
while stack:
  cur=stack.pop()
  for next,num in Edge[cur]:
    if path[next]==-1:
      path[next]=path[cur]|(1<<num)
      stack.append(next)

def popcount(x):
  x=x-((x>>1)&0x5555555555555555)
  x=(x&0x3333333333333333)+((x>>2)&0x3333333333333333)

  x=(x+(x>>4))&0x0f0f0f0f0f0f0f0f
  x=x+(x>>8)
  x=x+(x>>16)
  x=x+(x>>32)
  return x&0x0000007f

passing=[] #Mの各u,vについて、通過する辺をbitで持ったもの
for u,v in M:
  passing.append((path[u-1]^path[v-1]))

ans=2**(n-1)
#Mのすべての部分集合について符号付で足し合わせる
for i in range(1,2**m):
  i_ct=popcount(i)#満たすべき条件の数、これで符号を決める
  condition=0
  for j in range(m):
    if i&(1<<j):#j番目の条件を満たす
      condition=condition|passing[j]
  cond_ct=popcount(condition) #iが表すMの部分集合の条件をすべて満たす場合にすべて白になる辺集合の要素数

  ans+=pow((-1),i_ct)*pow(2,n-1-cond_ct)
print(ans)

Measured memory_bytes: 42732
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <set>
#include <numeric>
using namespace std;
using ll = long long;
using ld = long double;

#define no "no"
#define No "No"
#define NO "NO"
#define yes "yes"
#define Yes "Yes"
#define YES "YES"
#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(elem, _list) for(auto& (elem) : (_list))
#define view(_list) foreach(e, _list){ cout << e << sp; } cout << next
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define ALL(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e)
#define INF 1e+9
#define PI acos(-1)
#define TAU PI * 2
#define EPS 0.00000001
const ll MOD = 998244353;

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

    if(s == 1e+9){
        rep(i, k){
            cout << s << " ";
        }
        rep(i, n - k){
            cout << 1 << " ";
        }
    }else{
        rep(i, k){
            cout << s << " ";
        }
        rep(i, n - k){
            cout << s + 1 << " ";
        }
    }

    cout << endl;

}


Measured memory_bytes: 1280
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define maxin(v) *max_element(v.begin(), v.end())
#define minin(v) *min_element(v.begin(), v.end())
#define sumall(vect) accumulate(vect.begin(), vect.end(), 0)
#define count(x, vect) count(vect.begin(), vect.end(), x)
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 100000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "------------------------------------\n"
//#define min(a, b, c) min(a, min(b, c))
//#define max(a, b, c) max(a, max(b, c))
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp;
string str;
set<ll> s;
vll v;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll a,b;
	cin>>a>>b;
	set<ll> s;
	s.insert(1);
	s.insert(2);
	s.insert(3);
	s.erase(a);
	s.erase(b);
	cout<<*s.begin();
	
	
	
} 

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

int main(){
	int N;
	cin >> N;
	vector<long long> A(N);
	vector<long long> B(N);
	for(int i=0;i<N;i++)cin >> A[i] >> B[i];
	long long ans=0;
	for(int i=N-1;i>=0;i--){
		if((A[i]+ans)%B[i]>0)ans+=B[i]-((A[i]+ans)%B[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();

    for i in 1..1010 {
        if a == i * 8 / 100 && b == i * 10 / 100 {
            println!("{}", i);
            return;
        }
    }
    println!("-1");
}


Measured memory_bytes: 4352
from collections import Counter

n = int(input())
V = list(map(int, input().split()))

V_even = V[: : 2]
V_odd = V[1: : 2]

D_even = Counter(V_even)
D_odd = Counter(V_odd)

ans = 0
even, odd = D_even.most_common(2), D_odd.most_common(2)
if even[0][0] != odd[0][0]:
    ans = n - even[0][1] - odd[0][1]
else:
    if len(D_even) == len(D_odd) == 1:
        ans = n // 2
    else:
        ans = min(
            n - even[1][1] - odd[0][1],
            n - even[0][1] - odd[1][1]
        )

print(ans)

Measured memory_bytes: 19032
program main
integer :: i,n,cnt=0,big=0
integer,allocatable :: h(:)

read *,n
allocate(h(n))
read *,h

do i = 1,n-1
cnt = 0
if (big >= n/2) exit
do j = i,n-1
if (h(j)>=h(j+1)) then
cnt = cnt + 1
else
exit
end if
end do
big = max(cnt,big)
end do

print *,big

end program

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    string op;
    cin >> op;
    op[k - 1] = op[k-1] + 32;
    cout << op << endl;
    return 0;
}

Measured memory_bytes: 3104
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
N = int(input())
a = list(map(int,input().split()))
ave = Decimal(str(sum(a)/N)).quantize(Decimal("0"),rounding=ROUND_HALF_UP)
cost = 0
for i in a:
    cost += (i-ave)**2
print(cost)

Measured memory_bytes: 5204
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() (int, string) {
	n := scanInt(sc)
	s := scanString(sc)
	return n, s
}

func resolve(n int, cs string) int {
	num := 0
	li, ri := 0, n
	for ri-li > 1 {
		for cs[li] == 'R' && li+1 < ri {
			li++
		}
		if li+1 == ri {
			break
		}
		for cs[ri-1] == 'W' && li+1 < ri {
			ri--
		}
		if li+1 == ri {
			break
		}
		num++
		li++
		ri--
	}
	return num
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 2488
#include <stdio.h>
#define N 100

int selectionSort(int *,int);
void printA(int *,int);
void swap(int *,int *);

int main(){
  int i,n,A[N],count;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  count=selectionSort(A,n);
  printA(A,n);
  printf("%d\n",count);
  return 0;
} 
int selectionSort(int A[],int n){
  int i,j,count=0,minj;
  for(i=0;i<n;i++){
    minj = i;
    for(j=i;j<n;j++){
      if (A[j] < A[minj]){
	minj = j;
      }
    }
    if(i!=minj){
      swap(&A[i],&A[minj]);
      count++;
    }
  }
  return count;
}
void printA(int a[],int n){
  int i;
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n");
}

void swap(int *p1,int *p2){
  int temp;
  temp=*p1;
  *p1=*p2;
  *p2=temp;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 3020;
int b[N][N],w[N][N];

int ctb(int ly, int lx, int k){
    int ry = ly+k-1, rx = lx+k-1;
    int ret = b[ry][rx];
    if(lx-1>=0) ret -= b[ry][lx-1];
    if(ly-1>=0) ret -= b[ly-1][rx];
    if(lx-1>=0 && ly-1>=0) ret += b[ly-1][lx-1];
    return ret;
}

int ctw(int ly, int lx, int k){
    int ry = ly+k-1, rx = lx+k-1;
    int ret = w[ry][rx];
    if(lx-1>=0) ret -= w[ry][lx-1];
    if(ly-1>=0) ret -= w[ly-1][rx];
    if(lx-1>=0 && ly-1>=0) ret += w[ly-1][lx-1];
    return ret;
}

int main(){
    int n,k;
    scanf(" %d %d", &n, &k);

    int kk = 2*k;

    rep(i,n){
        int x,y;
        char c;
        scanf(" %d %d %c", &x, &y, &c);

        x %= kk;
        y %= kk;

        rep(dx,2)rep(dy,2){
            int nx = x + kk*dx;
            int ny = y + kk*dy;
            if(nx<N && ny<N){
                if(c == 'B') ++b[ny][nx];
                else ++w[ny][nx];
            }
        }
    }

    for(int i=1; i<N; ++i){
        b[0][i] += b[0][i-1];
        w[0][i] += w[0][i-1];

        b[i][0] += b[i-1][0];
        w[i][0] += w[i-1][0];
    }
    for(int i=1; i<N; ++i)for(int j=1; j<N; ++j){
        b[i][j] = b[i][j] + b[i-1][j]+b[i][j-1] - b[i-1][j-1];
        w[i][j] = w[i][j] + w[i-1][j]+w[i][j-1] - w[i-1][j-1];
    }

    auto fb = [&](int y, int x){
        return ctb(y,x,k) + ctb(y+k,x+k,k) + ctw(y+k,x,k) + ctw(y,x+k,k);
    };
    auto fw = [&](int y, int x){
        return ctw(y,x,k) + ctw(y+k,x+k,k) + ctb(y+k,x,k) + ctb(y,x+k,k);
    };

    int ans = 0;
    rep(i,k)rep(j,k){
        ans = max(ans, fb(i,j));
        ans = max(ans, fw(i,j));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 71552
h,w = map(int,input().split())
a = [[i for i in list(str(input()))] for _ in range(h)]


dp = [[0 for _ in range(w+1)] for _ in range(h+1)]

dp[0][0] = 1

for i in range(h):
    for j in range(w):
        if i + 1 < h and a[i+1][j] == '.':
            dp[i+1][j] += dp[i][j]
            dp[i+1][j] %= 1000000007
        if j + 1 < w and a[i][j+1] == '.':
            dp[i][j+1] += dp[i][j]
            dp[i][j+1] %= 1000000007

print(dp[h-1][w-1])

Measured memory_bytes: 52276
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;

#define N 100000

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

	while (s[n] != '\0') {
		n++;
	}

	for (i = 0; i < n / 2; i++) {
		if (s[i] != s[n - i - 1]) {
			ans++;
		}
	}

	cout << ans << endl;



	

	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String s=sc.next();
		int  dp[]=new int[n];
		dp[0]=1;
		for(int i=1;i<n;i++) {
			
			if(s.charAt(i)!=s.charAt(i-1)) {
				dp[i]=dp[i-1] +1;
			}
			else dp[i]=dp[i-1];
		}
		
		System.out.println(dp[n-1]);
	}
}


Measured memory_bytes: 26452
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stdio.h>

using namespace std;

int main()
{
    int w,h,n;
    cin>>h>>w>>n;
    int max1=max(w,h);
    if(n%max1==0)
        cout<<n/max1;
    else
        cout<<n/max1+1;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i;

  long n;
  scanf("%ld",&n);

  if(n>=1&&n<10){
    printf("%ld\n",n);
  }else if(n>=10&&n<100){
    printf("9\n");
  }else if(n>=100&&n<999){
    printf("%ld\n",n-90);
  }else if(n>1000&&n<9999){
    printf("909\n");
  }else if(n>=10000&&n<99999){
    printf("%ld\n",n-9090);
  }else{
    printf("90909\n");
  }

  return 0;
}


Measured memory_bytes: 128
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((numba.types.optional(i8), ) * 2, cache=True)
def seg_f(x, y):
    if x is None:
        return y
    if y is None:
        return x
    return min(x, y)


@njit((i8[:], i8[:]), cache=True)
def build(seg, raw_data):
    N = len(seg) // 2
    seg[N:] = raw_data
    for i in range(N - 1, 0, -1):
        seg[i] = seg_f(seg[i << 1], seg[i << 1 | 1])


@njit((i8[:], i8, i8), cache=True)
def set_val(seg, i, x):
    N = len(seg) // 2
    i += N
    seg[i] = x
    while i > 1:
        i >>= 1
        seg[i] = seg_f(seg[i << 1], seg[i << 1 | 1])


@njit((i8[:], i8, i8), cache=True)
def fold(seg, l, r):
    vl = vr = None
    N = len(seg) // 2
    l, r = l + N, r + N
    while l < r:
        if l & 1:
            vl = seg_f(vl, seg[l])
            l += 1
        if r & 1:
            r -= 1
            vr = seg_f(seg[r], vr)
        l, r = l >> 1, r >> 1
    return seg_f(vl, vr)

@njit((i8, i8[:]), cache=True)
def main(N, TX):
    dp1 = np.full(N, N - 2, np.int64)
    dp2 = np.full(N, N - 2, np.int64)
    seg1 = np.full(N + N, N - 2, np.int64)
    seg2 = np.full(N + N, N - 2, np.int64)
    filled1 = np.zeros(N, np.int64)
    filled2 = np.zeros(N, np.int64)

    ans = 0
    for i in range(0, len(TX), 2):
        t, x = TX[i:i + 2]
        x -= 2
        if t == 1 and filled1[x]:
            continue
        if t == 2 and filled2[x]:
            continue
        if t == 1:
            n = fold(seg2, x, N)
            ans += n
            if n:
                dp1[n - 1] = min(dp1[n - 1], x)
                set_val(seg1, n - 1, dp1[n - 1])
        elif t == 2:
            n = fold(seg1, x, N)
            ans += n
            if n:
                dp2[n - 1] = min(dp2[n - 1], x)
                set_val(seg2, n - 1, dp2[n - 1])
    return (N - 2) * (N - 2) - ans

N, Q = map(int, readline().split())
TX = np.array(read().split(), np.int64)

print(main(N, TX))

Measured memory_bytes: 124936
import itertools


n, k = map(int, input().split())

list_n = [i for i in range(n)]

list_d = []


for tuple_e in itertools.combinations(list_n, k):
    d = 0

    for bit in tuple_e:
        d += 2 ** bit

    list_d.append((d, tuple_e))


for d, tuple_e in sorted(list_d):
    if tuple_e:
        print(f"{d}: ", end="")
        print(*tuple_e)
    else:
        print(f"{d}:")



Measured memory_bytes: 17568
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AF solver = new AF();
        solver.solve(1, in, out);
        out.close();
    }

    static class AF {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();

            if (a + b == 15) {
                out.println("+");
                return;
            }

            if (a * b == 15) {
                out.println("*");
                return;
            }

            out.println("x");
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    cin >> N >> M;
    ll A[100010];
    rep(i,0,M) cin >> A[i];
    ll dp[100010] = {};
    dp[0] = 1;
    map<ll,ll> mp;
    rep(i,0,M) mp[A[i]]++;
    rep(i,0,N+1){
        if(i >= 1 && mp[i-1] == 0){
            dp[i] += dp[i-1] % MOD;
        }
        if(i >= 2 && mp[i-2] == 0){
            dp[i] += dp[i-2] % MOD;
        }
        dp[i] %= MOD;
    }
    print(dp[N]);
    
    
}

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

int main() {
	string s;
	cin >> s;
	bool flag = true;
	int sz = s.size();
	rep(i, sz / 2) {
		if (s[i] != s[sz - i - 1]) flag = false;
	}
	int ssz = sz / 2;
	rep(i, ssz / 2) {
		if (s[i] != s[ssz - i - 1]) flag = false;
	}
	int sssz = (sz + 3) / 2;
	for (int i = sssz - 1; i < sz; i++) {
		if (s[i] != s[sssz + sz - 2 - i]) flag = false;
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define INF INT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
 
typedef long long ll;
typedef std::pair<int,int> pii;
 
using namespace std;

ll memo[1005][1005];
ll dy[2] = {0,1}, dx[2] = {1,0};

class Point{
public:
    ll x,y;
    Point(ll y,ll x):y(y),x(x){}  
};

ll dfs(vector<string>& map,Point p){
    ll h = map.size(), w = map[0].size();
    if(p.y == h-1 && p.x == w-1){
        return 1;
    }else if(memo[p.y][p.x] != -1){
        return memo[p.y][p.x];
    }

    ll ret = 0;
    REP(i,2){
        Point np = Point(p.y+dy[i],p.x+dx[i]);
        if(0 <= np.y && np.y < h && 0 <= np.x && np.x < w){
            if(map[np.y][np.x] == '#')continue;
            ret += dfs(map,np);
        }
    }

    return memo[p.y][p.x] = ret % MOD;
}

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

    ll h,w;
    cin >> h >> w;
    vector<string> map(h);
    REP(i,h)cin >> map[i];
    Point ps = Point(0,0);

    REP(j,h)REP(i,w)memo[j][i] = -1;

    ll ans = dfs(map,ps); 

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,X;
 cin>>N>>X;
 vector<int>data(N); 
  for(int i=0;i<N;i++){
  	cin>>data.at(i);
  }
int sum=0;  
 for(int i=0;i<N;i++){
 	sum=sum+data.at(i);
 }
  sum=X-sum;
  sort(data.begin(),data.end());
  int small=data.at(0);
  int count;
  
  
 count=sum/small;
  
  /*while(0<=sum){
   sum=sum-small;
    count++;*/
  //}
  cout<<count+N<<endl;
}


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

int main(){
	priority_queue<int> que;
	int a;
	for(int i=1;i<=10;i++){
		cin>>a;
		que.push(a);
	}
	for(int i=1;i<=3;i++){
		cout<<que.top()<<endl;
		que.pop();
	}
	return 0;
}

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

const int INF = 1e9+5;

int main () {
    int n;
    cin >> n;
    int arr[n];
    vector<int> dp(n,INF);
    for(int i = 0;i < n;i++) cin >> arr[i];
    dp[0] = 0;
    for(int i = 0;i < n;i++) {
        for(int j:{i + 1,i + 2}) {
            if(j < n) dp[j] = min(dp[j],dp[i] + (abs(arr[i] - arr[j])));
        }
    }
    //for(int i = 0;i < n;i++) cout << dp[i] << " ";
    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>


int main(){

  int n, t=0, h=0, i;
  char ta[100], ha[100];

  scanf("%d", &n);

  for(i=0;i<n;i++){
    scanf("%s %s", ta, ha);
    if(strcmp(ta, ha)>0) t+=3;
    else if(strcmp(ta, ha)<0) h+=3;
    else{
      t++;
      h++;
    }
  }

  printf("%d %d\n", t, h);


  return 0;
}

Measured memory_bytes: 604
import sys
sys.setrecursionlimit(2*10**6)
class UF():
 
    def __init__(self, num):
        self.par = [-1]*num
        self.size = [1]*num
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
 
    def union(self, x, y):
        rx, ry = self.find(x), self.find(y)
        if rx == ry:
            return 0
        if rx < ry:
            rx, ry = ry, rx
        self.par[rx] += self.par[ry]
        self.par[rx] = ry
        self.size[rx] += self.size[ry] 
        return 1
     
    def check(self, x, y):
        return self.find(x) == self.find(y)

n, q = map(int, input().split())
T = UF(n)
for _ in range(q):
    c, x, y = map(int, input().split())
    if c == 0:
        T.union(x, y)
    else:
        print(int(T.check(x, y)))


Measured memory_bytes: 5808
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
3
0 0 3 0 1 1 2 -1
0 0 3 0 3 1 3 -1
0 0 3 0 3 -2 5 0

output:
1
1
0
"""

import sys

EPS = 1e-9


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def check_ccw(p0, p1, p2):
    a, b = p1 - p0, p2 - p0
    if cross(a, b) > EPS:
        flag = 1
    elif cross(a, b) < -1 * EPS:
        flag = -1
    elif dot(a, b) < -1 * EPS:
        flag = 2
    elif abs(a) < abs(b):
        flag = -2
    else:
        flag = 0
    return flag


def check_intersection(p0, p1, p2, p3):
    intersected = (check_ccw(p0, p1, p2) * check_ccw(p0, p1, p3) <= 0) and \
                  (check_ccw(p2, p3, p0) * check_ccw(p2, p3, p1) <= 0)

    return intersected


def solve(_lines):
    for line in _lines:
        line = tuple(map(int, line))
        p0, p1, p2, p3 = (x + y * 1j for x, y in zip(line[::2], line[1::2]))
        intersected = check_intersection(p0, p1, p2, p3)

        if intersected:
            print('1')
        else:
            print('0')
    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    l_num = int(_input[0])
    lines = map(lambda x: x.split(), _input[1:])

    solve(lines)

Measured memory_bytes: 8048
#pragma region header
#include <bits/stdc++.h>
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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int h,w,k;cin >> h >> w >> k;
    vvc mp(h,vc(w));
    vb H(h,true);
    vb W(w,true);
    vb x = H,y = W;
    rep(i, h)rep(j, w)cin >> mp[i][j];
    int ans = 0;
    rep(bit,(1<<h)) {
        rep(Bit,(1<<w)) {
            H=x,W=y;
            rep(i, h) if(1&(bit>>i)) H[i] = false;
            rep(i,w) if(1&(Bit>>i)) W[i] = false;
            int count = 0;
            rep(i, h) {
                if(!H[i]) continue;
                rep(j, w) {
                    if(!W[j])continue;
                    if(mp[i][j]=='#') count++;
                }
            }
            if(count==k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3732
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt() : x(0) { }
	ModInt(signed sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }

	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
};
typedef ModInt<1000000007> mint;

int main() {
	int N; int K;
	while (~scanf("%d%d", &N, &K)) {
		vector<int> a(N);
		for (int i = 0; i < N; ++ i)
			scanf("%d", &a[i]);
		vector<mint> weight(N);
		random_device rd{};
		rep(i, N)
			weight[i].x = rd() % mint::Mod;
		vector<mint> prod(K);
		prod[0] = 1;
		rep(i, N) if (a[i] < K) {
			for (int j = K - 1 - a[i]; j >= 0; -- j)
				prod[j + a[i]] += prod[j] * weight[i];
		}
		vector<mint> v(K);
		int ans = 0;
		rep(i, N) if (a[i] < K) {
			rep(j, K)
				v[j] = prod[j];
			for(int j = 0; j + a[i] < K; ++ j)
				v[j + a[i]] -= v[j] * weight[i];
			bool needed = false;
			reu(j, K - a[i], K)
				needed |= v[j].get() != 0;
			ans += !needed;
		}
		printf("%d\n", ans);
	}
	return 0;
}


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

#define FOR(a,b,c) for(int a=(b),a##_end__=(c);a<a##_end__;a++)
#define chkmin(a,b) (a)=min((a),(b))
#define chkmax(a,b) (a)=max((a),(b))
#define x first
#define t second
#define ll long long 
#define db double
#define pb push_back
#define SZ(x) ((int)x.size())
#define M 500005

int a[M+M];
int n,ans,l=M,r=M-1;

void Rd(int &res){
    char c;res=0;
    while(c=getchar(),c<48);
    do res=(res<<3)+(res<<1)+(c^48);
    while(c=getchar(),c>47);
}

int main(){
    Rd(n);
    FOR(i,0,n){
        int x;
		Rd(x);
		if(i%2) a[--l]=x;
		else a[++r]=x;
	}
	if(n%2) for(int i=r;i>=l;i--) printf("%d ",a[i]);
	else FOR(i,l,r+1) printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 2944
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.nextLine();
		String b = sc.nextLine();
		int res = 0;
		for(int i = 0; i < a.length(); i++){
			if(a.charAt(i) != b.charAt(i)){
				res ++;
			}
		}
		System.out.println(res);
	}
}

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

int main(){
  int n;cin>>n;
  vector<int> a(n+1,0),x(n+1,0),ans(n+1,0);
  for(int i=1;i<=n;i++) cin>>a.at(i);

  for(int i=n;i>=1;i--){
    ans.at(i)=x.at(i)^a.at(i);
    for(int j=1;j*j<=i;j++){
      if(!(i%j)){
        x.at(j)=x.at(j)^ans.at(i);
        if((j!=1)&&(j!=i/j)) x.at(i/j)=x.at(i/j)^ans.at(i);
      }
    }
  }

  int count=0;
  for(int i=1;i<=n;i++) if(ans.at(i)) count++;
  cout<<count<<endl;
  for(int i=1;i<=n;i++) if(ans.at(i)) cout<<i<<" ";
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  string s;
  cin >> s;
  int cnt[2]={};
  for(int i=0; i<s.length(); i++){
    cnt[s[i]-'0']++;
  }
  int ans = 2*min(cnt[0], cnt[1]);
  cout << ans << endl;
  return 0;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vl A(N + 1);
    for (ll i = 0; i <= N; i++) {
        cin >> A[i];
    }
    Vl cum(N + 2);
    for (ll i = 0; i <= N; i++) {
        cum[i + 1] = cum[i] + A[i];
    }

    bool ok = true;
    ll ans = 0;
    ll cur = 1;
    for (ll i = 0; i <= N; i++) {
        if (cur - A[i] < 0) {
            ok = false;
            break;
        }
        ans += cur;
        cur -= A[i];
        ll t = cum[N + 1] - cum[i + 1];
        if (cur * 2 < t) {
            cur *= 2;
        }
        else {
            cur = cum[N + 1] - cum[i + 1];
        }
    }

    if (ok)
        cout << ans << "\n";
    else
        cout << -1 << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 4768
#include <stdio.h>

int main(void)
{
    int n=0,flag=0;
    scanf("%d",&n);
    for(int i=1;i<=9;i++){
        if(n==(n/i)*i && (n/i)<=9){
            flag=1;
            break;
        }
    }
    if(flag==1) printf("Yes");
    else printf("No");
    return 0;
}


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

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

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

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

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

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

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

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



fn solve(a: u64, b: u64, mut vs: Vec<u64>) -> (f64, u64) {
    let mut comb_table = vec![vec![0;51]; 51];
    for i in 1..51 {
        for j in 0..51 {
            if j == 0 || i == j {
                comb_table[i][j] = 1;
                continue;
            }
            comb_table[i][j] = comb_table[i-1][j-1] + comb_table[i-1][j];
        }
    }

    vs.sort_by(|a,b| b.cmp(a));
    let max = vs[0];
    if vs[0] == vs[(a-1) as usize] {
        let mut pattern = 0;
        let count = vs.iter().fold(0, |acc, x| if *x == max {
            acc + 1
        } else {
            acc
        });
        for i in a..b+1 {
            pattern += comb_table[count][i as usize];
        }
        return (vs[0] as f64, pattern)
    }

    let min = vs[(a-1) as usize];
    let mut count = 0;
    let mut result = 0;
    for i in 0..a {
        let v = vs[i as usize];
        if v > min {
            count += 1;
        }
        result += v;
    }
    let nmin = vs.iter().fold(0, |acc, x| if *x == min {
        acc + 1
    } else {
        acc
    });
    (result as f64/ a as f64, comb_table[nmin][(a-count) as usize])
}



fn main() {
    input! {
        n: u64,
        a: u64,
        b: u64,
        vs: [u64; n],
    };
    let result = solve(a, b, vs);
    println!("{:.6}", result.0);
    println!("{}", result.1);
}


Measured memory_bytes: 4352
while True:
	a, op, b = input().split()
	a = int(a)
	b = int(b)

	if op == '+':
		print(a+b)
	elif op == '-':
		print(a-b)
	elif op == '*':
		print(a*b)
	elif op == '/':
		print(a//b)
	elif op == '?':
		break

Measured memory_bytes: 7544
A1, A2, A3 = map(int, input().split())
print(min(abs(A1 - A2) + abs(A2 - A3), abs(A1 - A3) + abs(A2 - A3), abs(A2 - A1) + abs(A1 - A3), abs(A2 - A3) + abs(A3 - A1), abs(A3 - A1) + abs(A1 - A2), abs(A3 - A2) + abs(A2 - A1))
     )

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

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {


		long x = nextLong();
		long n = (long)Math.sqrt(x);
		long d = (n*(n+1))/2;
		while(true){
			long d1 = ((n-1)*(n))/2;
			long d2 = (n*(n+1))/2;
			if(d1<x&&x<=d2){
				break;
			}
			n++;
		}
		long ans =n;

		System.out.println(ans);

	}



	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    int n = sz(s) + 1;
    vector<ll> a;
    ll c = 0;
    char p = '*';
    REP(i, sz(s)) {
        if (p == s[i]) {
            c++;
        } else {
            if (p != '*') {
                a.push_back(c);
            }
            c = 1;
        }
        p = s[i];
    }

    a.push_back(c);

    ll ans = 0;
    if (s[0] == '<') {
        for (int i = 0; i < sz(a) - 1; i += 2) {
            if (a[i] <= a[i + 1]) {
                ll x = a[i] - 1;
                ans += x * (x + 1) / 2;
                ll y = a[i + 1];
                ans += y * (y + 1) / 2;
            } else {
                ll x = a[i];
                ans += x * (x + 1) / 2;
                ll y = a[i + 1] - 1;
                ans += y * (y + 1) / 2;
            }
        }
        if (sz(a) % 2 != 0) {
            ll x = a[sz(a) - 1];
            ans += x * (x + 1) / 2;
        }

    } else {
        ll x = a[0];
        ans += x * (x + 1) / 2;

        for (int i = 1; i < sz(a) - 1; i += 2) {
            if (a[i] <= a[i + 1]) {
                ll x = a[i] - 1;
                ans += x * (x + 1) / 2;
                ll y = a[i + 1];
                ans += y * (y + 1) / 2;
            } else {
                ll x = a[i];
                ans += x * (x + 1) / 2;
                ll y = a[i + 1] - 1;
                ans += y * (y + 1) / 2;
            }
        }
        if (sz(a) % 2 == 0) {
            ll x = a[sz(a) - 1];
            ans += x * (x + 1) / 2;
        }
    }

    cout << ans << EOL;
}


Measured memory_bytes: 3352
N = int(input())
S = [input() for _ in range(N)]

for i in range(N):
  S[i] = ''.join(sorted(S[i]))

S_lst = {}
for i in range(N):
  if S[i] in S_lst:
    S_lst[S[i]] += 1
  else:
    S_lst[S[i]] = 1

#nC2 の計算
sum_ = 0
for key in S_lst:
    sum_ += int((S_lst[key] * (S_lst[key] - 1)) / 2)

print(sum_)

Measured memory_bytes: 23688
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  
 ll n,i,j=0,sm1=0;
 string s;
 cin>>s;
 n=s.size();

map<char,int>m;
for(i=0;i<n;i++)m[s[i]]++;

for(auto it:m)
{
    if(it.second%2)
    {
        cout<<"No";
        return 0;
    }
}
cout<<"Yes";

}

Measured memory_bytes: 3584
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
typedef long long LL;
using namespace std;
#define MP make_pair
int n,m,a[100100];
int main() {
    scanf("%d%d",&n,&m);
    while(m--){
        int u,v;
        scanf("%d%d",&u,&v);
        a[u]++;
        a[v]++;
    }
    for(int i =1; i <= n; ++i){
        if(a[i] % 2 == 1){
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int fa[maxn],ma[maxn];
void init(){
    for (int i=0;i<maxn;i++) fa[i]=i,ma[i]=i;
}
int fnd(int *k,int x){
    return x==k[x]?x:k[x]=fnd(k,k[x]);
}
void Union(int *k,int x,int y){
    int fx=fnd(k,x),fy=fnd(k,y);
    if(fx!=fy) k[fy]=fx;
}
map<pair<int,int>,int>mp;
int main(){
    int n,k,l,u,v;
    init();
    scanf("%d%d%d",&n,&k,&l);
    while(k--){
        scanf("%d%d",&u,&v);
        Union(fa,u,v);
    }
    while(l--){
        scanf("%d%d",&u,&v);
        Union(ma,u,v);
    }
    for (int i=1;i<=n ; i++)  mp[make_pair(fnd(fa,i),fnd(ma,i))]++;
    for (int i=1;i<n;i++) printf("%d ",mp[make_pair(fnd(fa,i),fnd(ma,i))]);
    printf("%d\n",mp[make_pair(fnd(fa,n),fnd(ma,n))]);
    return 0;
 
}

Measured memory_bytes: 13696
import sys

stdin = sys.stdin


def na(): return map(int, stdin.readline().split())


def ns(): return stdin.readline().strip()


stack = []
n,k = na()
for i in range(n):
    stack.append(list(na()))
stack.sort(key=lambda x: x[0])

sp = 0
for x in stack:
    sp += x[1]
    if sp >= k:
        print(x[0])
        break

Measured memory_bytes: 29056
n = int(input())
C = list(map(int, input().split())) + [0]

total = 0
prev = 0
for i in range(n + 1):
  total += abs(C[i] - prev)
  prev = C[i]

for i in range(n):
  a = abs(C[i] - prev) + abs(C[i + 1] - C[i])
  b = abs(C[i + 1] - prev)
  print(total - a + b)
  prev = C[i]

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

/** Problem0050 : Apple and Peach **/
int main()
{
	string str;
	
	while (getline(cin, str)) {
		for (int i=0; str[i] != '\0'; i++) {
			if (str[i] == 'a') {
				if (str[i+1]=='p' && str[i+2]=='p' && str[i+3]=='l' && str[i+4]=='e') {
					cout << "peach";
					i+=4;
				} else {
					cout << "a";
				}
			} else if (str[i] == 'p') {
				if (str[i+1]=='e' && str[i+2]=='a' && str[i+3]=='c' && str[i+4]=='h') {
					cout << "apple";
					i+=4;
				} else {
					cout << "p";
				}
			} else
				cout << str[i];
		}
		cout << endl;
	}
	return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    int c = 0;
    rep(i, a, b + 1) {
        string s = to_string(i);
        if (s[0] == s[4] && s[1] == s[3]) {
            c++;
        }
    }
    cout << c << endl;
}

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

public class Test
{
    public static void Main()
    {
        //入力
        long[] R = Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        long N = R[0];//偶数の数
        long M = R[1];//奇数の数

        long count = 0;

        //𝑛P𝑟= 𝑛(𝑛−1)(𝑛−2)⋯(𝑛−𝑟+1)𝑛!(𝑛−𝑟)!←r!で割る

        count = ((N * (N - 1)) / 2) + ((M * (M - 1)) / 2);

        System.Console.WriteLine(count);
    }
}



Measured memory_bytes: 13268
package main
 
import(
  "fmt"
  "math"
)
 
func main(){
  var n int
  pow := 1
  fmt.Scan(&n)
  for i := 1; i <= n; i++{
    pow *= i
    pow %= (int(math.Pow(10, 9)) + 7)
  }
  fmt.Printf("%d", pow)
}

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

int main () {
  long long n;
  cin >> n;
  map<long long, long long> X;
  for (long long i = 0; i < n; i++) {
    long long s;
    cin >> s;
    X[s]++;
    X[s+1]++;
    X[s-1]++;  
  } 
  long long ans = -1; 
  for (auto x = X.begin(); x != X.end(); ++x) {
    if (ans < x->second) {  
      ans = x->second;  
    }    
  }
  cout << ans << endl;
}

Measured memory_bytes: 6144
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a_li = list(map(int, input().strip().split()))

    a_dict = {}

    for a in a_li:
        if str(a) in a_dict:
            a_dict[str(a)] += 1
        else:
            a_dict[str(a)] = 1

    for i in range(1, n+1):
        if str(i) in a_dict:
            print(a_dict[str(i)])
        else:
            print(0)

if __name__ == '__main__':
    main()


Measured memory_bytes: 44428
def num_divisors_table(n):
    table = [0] * (n + 1)

    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    return table

N = int(input())
X = num_divisors_table(N)
sum = 0
for i in range(N):
  sum += (i+1) * X[i+1]

print(sum)

Measured memory_bytes: 151764
import java.util.*;

class Dijkstra {
    private int size;
    private ArrayList<ArrayList<Pair>> adl;

    public Dijkstra (int size) {
        this.size = size;
        adl = new ArrayList<>();
        for (int i = 0; i < size; i++)
            adl.add(new ArrayList<>());
    }

    public void addEdge(int u, int v, int w) {
        adl.get(u).add(new Pair(v, w));
    }

    public ArrayList<Integer> shortestPath(int source) {
        ArrayList<Integer> distance = new ArrayList<Integer>();
        PriorityQueue<Pair> nearest = new PriorityQueue<>((a, b) -> a.w - b.w);
        boolean[] visit = new boolean[this.size];

        for (int i = 0; i < size; i++)
            distance.add(-1);

        nearest.offer(new Pair(source, 0));
        while (nearest.size() > 0) {
            Pair cur = nearest.poll();
            if (visit[cur.v])
                continue;

            visit[cur.v] = true;
            distance.set(cur.v, cur.w);

            for (Pair ng: this.adl.get(cur.v))
                nearest.offer(new Pair(ng.v, cur.w + ng.w));
        }
        return distance;
    }
}

class Pair {
    public int v;
    public int w;

    public Pair(int v, int w) {
        this.v = v;
        this.w = w;
    }

    public Pair() {
        this(0, 0);
    }

    public String toString() {
        return "(" + Integer.toString(v) + ", " + Integer.toString(w) + ")";
    }
}

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int v = in.nextInt();
        int e = in.nextInt();
        int s = in.nextInt();
        Dijkstra dijkstra = new Dijkstra(v);
        for (int i = 0; i < e; i++) {
            int p = in.nextInt();
            int q = in.nextInt();
            int w = in.nextInt();
            dijkstra.addEdge(p, q, w);
        }

        ArrayList<Integer> distance = dijkstra.shortestPath(s);
        for (Integer d: distance)
            System.out.println(d == -1 ? "INF" : d);
    }
}



Measured memory_bytes: 327236