akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n = 1) : n(n), f(n + 1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i * i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x; }
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
  Sieve sieve(1e6);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  map<int, int> mp;
  rep(i, n) {
    auto f = sieve.factor(a[i]);
    for (auto p : f) {
      mp[p.first] = max(mp[p.first], p.second);
    }
  }

  mint lcm = 1;
  for (auto p : mp) {
    rep(i, p.second) { lcm *= p.first; }
  }

  mint ans;
  rep(i, n) {
    mint b = lcm / a[i];
    ans += b;
  }
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 4984
#include<iostream>
#include<string>
#include<vector>
#include<iomanip> //桁数
using namespace std;

int main(){
    long w,h,x,y;
    cin >> w >> h >> x >> y;
    std::cout << fixed;
    cout << setprecision(6) << (w*h)/2.0 << " ";
    if(abs(2*x-w)<0.001 && abs(2*y-h)<0.001 ) cout << "1" << endl;
    else cout << "0" << endl; 
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;
 

void solve()
{
    char str[5] = { 0 };
    scanf("%s", str);
    if (str[1] == 'B') {
        str[1] = 'R';
    }
    else {
        str[1] = 'B';
    }
    printf("%s\n", str);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



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

#define SZ(x) (int)((x).size())
#define xx first
#define yy second
#define pii pair<int, int>



void solve() {
    string s, t;
    cin >> s >> t;

    int ans = SZ(s) * SZ(t);
    for (int i = 0; i < SZ(s); i++) {
        if (i + SZ(t) > SZ(s))
            break;

        int cnt = 0;
        for (int j = 0; j < SZ(t); j++)
            cnt += s[i + j] != t[j] ? 1 : 0;
        ans = min(ans, cnt);
    }
    cout << ans << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


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

int main()
{
	int a1,a2,a3,b1,b2,b3;
	int x[4][4];
	
	for(int i=1; i<=3; i++){
		for(int j=1; j<=3; j++){
			cin>>x[i][j];
		}
	}
	
	a1=0;
	b1=x[1][1]-a1;
	b2=x[1][2]-a1;
	b3=x[1][3]-a1;
	
	a2=x[2][1]-b1;
	a3=x[3][1]-b1;
	
	if(a2+b2==x[2][2] && a2+b3==x[2][3] && \
	   a3+b2==x[3][2] && a3+b3==x[3][3]){
		 cout<<"Yes"<<endl;
		 return 0;
	}
	
	cout<<"No"<<endl;
	return 0;
}

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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<int, int>;
using P3 = pair<P,int>;
using PP = pair<P, P>;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    ll ans = 0;
    for(ll l=0,r=0,x=0;l<n;l++){
        while(r<n && (x&a[r])==0){
            x ^= a[r];
            r++;
        }
        ans += (r-l);
        x ^= a[l];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
N=int(input())
A=list(map(int,input().split()))
A=[0]+A
B=[0]*(N+1)
#print(A)

for i in range(N,0,-1):
  tmp=0
  for j in range(2,N//i+1):
    if B[i*j]: tmp+=1
  B[i]=(A[i]+tmp)%2
  
#print(B)
C=[]
for i in range(1,N+1):
  if B[i]: C.append(i)
#print(C)

print(len(C))
if len(C): print(*C)

Measured memory_bytes: 72156
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
#define pii pair < ll , ll >
#define vi vector < int >
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define init(x, a) memset(x, a, sizeof(x))
#define vll vector < long long int >
#define sll set < long long int >
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main()
{
    ll n,m,i,j,s=0;
    cin>>n;
    for(i=n;i>0;i/=10)s+=i%10;
    if(n%s==0)cout<<"Yes";
    else cout<<"No";
    return(0);
}
/*int main()
{
    fastIO;
    ll n,m,i,j,k,prog=1,val=1;
    cin>>k;
    while(k)
    {
        for(i=0;i<9 and k>0;i++,k--)
        {
            cout<<val<<endl;
            val+=prog;
        }
        val-=prog;
        prog*=10;
        val+=prog;
    }
}*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1LL<<60;
long double pi=3.141592653589793238462643383279L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    int r=0;
    rep(i,0,n){
        int a;cin>>a;
        if(a%2==0){
            if(a%3!=0&&a%5!=0)r=1;
        }
    }
    if(r)cout<<"DENIED"<<endl;
    else cout<<"APPROVED"<<endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#define ways(n,m) C(n+m-2,n-1)
#define lint long long
#define mod 1000000007
#define N 200010
#define inv(x) fast_pow(x,mod-2)
using namespace std;
int fac[N],facinv[N];
int fast_pow(int x,int k)
{
	int ans=1;
	while(k)
	{
		if(k&1) ans=(lint)ans*x%mod;
		x=(lint)x*x%mod,k>>=1;
	}
	return ans;
}
inline int getinv(int n)
{
	for(int i=fac[0]=1;i<=n;i++) fac[i]=(lint)fac[i-1]*i%mod;
	facinv[n]=inv(fac[n]);
	for(int i=n-1;i>=0;i--) facinv[i]=(lint)facinv[i+1]*(i+1)%mod;
	return 0;
}
inline int C(int n,int m)
{
	return (lint)fac[n]*facinv[m]%mod*facinv[n-m]%mod;
}
int main()
{
	int n,m,a,b;scanf("%d%d%d%d",&n,&m,&a,&b);
	getinv(max(n,m)<<1);int ans=0;
	for(int i=1;i<=n-a;i++)
		(ans+=(lint)ways(i,b)*ways(m-b,n-i+1)%mod)%=mod;
	printf("%d\n",ans);return 0;
}

Measured memory_bytes: 1792
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt
from functools import lru_cache, reduce
INF = 1 << 60
mod = 1000000007
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# ここから書き始める
def my_factorial(n):
    ret = 1
    i = 1
    while i <= n:
        ret *= i
        i += 1
        ret %= mod
    return ret


n, m = map(int, input().split())
if abs(n - m) >= 2:
    print(0)
elif n == m:
    ans = (((my_factorial(n) ** 2) % mod) * 2) % mod 
    print(ans)
else:
    if n < m:
        n, m = m, n
    ans = (my_factorial(n) * my_factorial(m)) % mod
    print(ans)

Measured memory_bytes: 5424
N = input()
N = int(N)
#print(N)
N-=1

dit = [0 for _ in range(100)]
i = 0
while True:
  dit[i] = N % 26
  N = N // 26
  if N == 0:
    break
  else:
    N -= 1
  i+=1

#print(dit)
name = ""
for j in range(i,-1,-1):
  name += chr(97+dit[j])
  
print(name)

Measured memory_bytes: 9188
N = input()
li2 = input().split()
li = []
for l in li2:
  li.append(int(l))
li.sort()
li.reverse()
t = 0
ans = 0
for i in li:
  if t % 2 == 0:
    ans += int(i)
  else:
    ans -= int(i)
  t += 1

print(ans)

Measured memory_bytes: 3060
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G();
		int H = I[0], W = I[1], h = I[2], w = I[3];
		var t = YesNo(H, W, h, w);
		Console.WriteLine(t ? "Yes" : "No");
		if (t) for (var y = 0; y < H; y++)
			{
				for (var x = 0; x < W; x++) Console.Write("{0}{1}", map[y, x], x == W - 1 ? "" : " ");
				Console.WriteLine();
			}
	}
	int[,] map;
	void Swap2()
	{
		var Y = map.GetLength(0);
		var X = map.GetLength(1);
		var m2 = new int[X, Y];
		for (var x = 0; x < X; x++) for (var y = 0; y < Y; y++) m2[x, y] = map[y, x];
		map = m2;
	}
	bool YesNo(int H, int W, int h, int w)
	{
		if (h == H && w == W) return false;
		if (H % h == 0 && W % w == 0) return false;
		if (H % h == 0)
		{
			var t = YesNo(W, H, w, h);
			Swap2();
			return t;
		}
		var rem = H % h;
		var dup = h - rem;
		var N = H / h;
		var a = dup * (2 * N + 1);
		var b = 2 * rem * (N + 1);
		var c = dup * (N + 1);
		map = new int[H, W];
		for (var q = 0; q < W; q++)
		{
			for (var i = 0; i < N; i++)
			{
				for (var j = 0; j < rem; j++) map[i * h + j, q] = a;
				for (var j = rem; j < h; j++) map[i * h + j, q] = -b;
			}
			for (var i = N * h; i < H; i++) map[i, q] = c;
		}
		return true;
	}
}


Measured memory_bytes: 19920
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;
int main(void) {
    
   int n;
   cin>>n;
    int a[100000];
    int b[100000];
    int c[100000];

    int b_n[100000];
    long long int ai,ci;
    long long int sum=0;

    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        cin>>c[i];
    }

    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);

    for(int i=0;i<n;i++){
        ai = lower_bound(a,a+n,b[i])-a;
        ci = (c+n)-upper_bound(c,c+n,b[i]);
        //cout<<ai<<","<<ci<<endl;
        sum += ai * ci;// (n-ci);
    }
  
    cout<<sum<<endl;   
    return 0;
}

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

int main(){
  int  a, b;
  cin >> a >> b;
  int d = a / b;
  int r = a % b;
  cout << d << ' ' << r << ' ';
  cout << fixed << setprecision(6) << (double)a/(double)b << endl;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

    ll n,k;
    cin>>n>>k;

    ll sum[n+2]={};
    for(int i=1;i<=n+1;i++)sum[i]=(sum[i-1]+i)%mod;

    ll ans=0;
    for(int i=k;i<=n;i++){
        ans = (ans+(sum[n]-sum[n-i])-sum[i-1]+1)%mod;  
        while(ans<0)ans+=mod;
    } 

    cout<<ans+1<<endl;

    return 0;
}


Measured memory_bytes: 5184
#[allow(dead_code)]
fn main() {
    let mut n = i::u();
    let mut ans = 1;
    let mut m = 0;
    for i in 1..n + 1 {
        let mut c = 0;
        let mut l = i;
        while l % 2 == 0 {
            l /= 2;
            c += 1;
        }
        if c > m {
            ans = max(ans, i);
            m = c;
        }
    }
    println!("{}", ans);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1000000007;

ll pow(ll x,ll y){
  if(y==0){
    return 1;
  }else if(y==1){
    return x%MOD;
  }else if(y%2==0){
    return pow(x,y/2)*pow(x,y/2)%MOD;
  }else{
    return pow(x,y-1)*x%MOD;
  }
}
int main(){
  ll H,W,A,B;cin >> H >> W >> A >> B;
  vector<ll> fact(H+W);
  vector<ll> factINV(H+W);
  fact[0]=1;factINV[0]=1;
  for(ll i=1;i<H+W;i++){
    fact[i] = fact[i-1]*i % MOD;
    factINV[i] = pow(fact[i],MOD-2);
  }
  ll ans = 0;
  for(ll i=1;i+B<=W;i++){
    ll x = fact[H-A+B-2+i]*fact[W+A-B-1-i]%MOD;
    x = x*factINV[W-B-i]%MOD*factINV[B-1+i]%MOD;
    ans = (ans+x)%MOD;
  }
  ans = ans *factINV[H-A-1]%MOD*factINV[A-1]%MOD;
  cout << ans << endl;
}

Measured memory_bytes: 6428
#include<bits/stdc++.h>
using namespace std;
const int DN=1e5+5;
int n,dp[3][DN],a[3],ma;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[j];
            dp[j][i]=a[j];
            if(i==1)
                continue;
            for(int h=0;h<3;h++)
                if(h!=j)
                    dp[j][i]=max(dp[j][i],a[j]+dp[h][i-1]);
        }
    }
    for(int i=0;i<3;i++)
        ma=max(ma,dp[i][n]);
    cout<<ma;
}


Measured memory_bytes: 1408
n, m, = gets.split.map(&:to_i)
g = Array.new(n){[]}
ARGF.readlines.each do |line|
  x,y, = line.split.map{|i| i.to_i - 1}
  g[x] << y
  g[y] << x
end
g.each{|i| i.sort! }
count = 0
while hasi = g.find_index{|i| i.size == 1}
  # g.delete hasi; count += 1
  g[g[hasi][0]].delete hasi
  g[hasi] = []
  count += 1
end
puts count


Measured memory_bytes: 1788
n = gets.to_s.to_i
c = gets.to_s.chars

ans = c.count('W')

l = 0
r = n - 1
cnt = 0
while l < r
  if c[l] == 'W' && c[r] == 'R'
    cnt += 1
    l += 1
    r -= 1
  elsif c[l] == 'W'
    r -= 1
  elsif c[r] == 'R'
    l += 1
  else
    l += 1
    r -= 1
  end
end

ans = [ans, cnt].min
puts ans


Measured memory_bytes: 30496
#
import sys
import math
import numpy as np
import itertools

# いくつか入力
a, b, m = (int(i) for i in input().split())  

aprice = [int(i) for i in input().split()] 
bprice = [int(i) for i in input().split()] 
c = [[int(i) for i in input().split()] for i in range(m)] 
#print(aprice,bprice,c)
amin=999999
for i in range(a):
    amin = min(amin,aprice[i])
bmin=999999
for i in range(b):
    bmin = min(bmin,bprice[i])

p=[]
for i in range(m):
#    print(c[i][0],c[i][1],c[i][2])
    p.append(aprice[c[i][0]-1]+bprice[c[i][1]-1]-c[i][2])

answer = amin+bmin
for i in p:
    answer = min(answer, i) 

print(answer)


Measured memory_bytes: 45500
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(20);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define sp " "
#define int long long
#define double long double
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI=3.141592653589793;
const int L=1e18;


void solve()
{
    string s;
    cin >> s;
    int ans=0, cur=0;
    for(int i=0;i<3;i++)
	{
		if(s[i]=='S')
		{
			ans=max(ans,cur);
			cur=0;
		}
		else cur++;
	}
	ans=max(ans, cur);
	cout << ans;
}

int32_t main()
{
	FastIO;
	Fast_D;
	solve();
	return 0;
}


Measured memory_bytes: 3636
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (x, a) = (v[0], v[1]);
    if x < a {
        println!("0");
    } else {
        println!("10");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

ll MAX_N = 400010, n;
vec dat(MAX_N,INF);
void init(ll _n){
    n = 1;
    while(n < _n) n *= 2;
    rep(i, n*2 - 1) dat[i] = INF;
}

void update(ll k, ll a){
    k += n - 1;
    dat[k] = a;
    while(k > 0){
        k = (k - 1) / 2;
        dat[k] = min(dat[k*2 + 1], dat[k * 2 + 2]);
    }
}

ll query(ll a, ll b, ll k, ll l, ll r){
    if(r <= a || b <= l) return INF;
    if(a <= l && r <= b) return dat[k];
    ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return min(vl, vr);
}

int main() {
    cin>>N>>M;
    vec l(M), r(M), c(M);
    rep(i,M) cin>>l[i]>>r[i]>>c[i];
    vec ord(M);
    rep(i,M) ord[i] = i;
    sort(ALL(ord) , [&](ll x, ll y){
        return l[x] < l[y];
    });
    init(N + 10);
    update(1,0);
    rep(i,M){
        ll id = ord[i];
        ll last_dist = query(l[id], n,0,0,n );
        //cout<<i<<' '<<last_dist<<endl;
        update(r[id], min(query(r[id], r[id] + 1, 0, 0, n), last_dist + c[id]));
    }
    ll ans = query(N, N + 1, 0, 0, n);
    cout<<(ans == INF ? -1 : ans)<<endl;
    //reps(i,1,N + 1) cout<<query(i, i + 1, 0, 0, n)<<endl;
}

Measured memory_bytes: 6528
#include<stdio.h>

#define N 100000

int A[N],n;

int partition(int p,int r){
  int x,i,j,tmp;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j] <= x){
      i++;
      tmp=A[i]; A[i]=A[j]; A[j]=tmp;
    }
  }
  tmp=A[i+1]; A[i+1]=A[r]; A[r]=tmp;
  return i+1;
}

int main(void){

  int i,p;
  
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  p=partition(0,n-1);

  for(i=0;i<n;i++){
    if(i) printf(" ");
    if(i==p) printf("[%d]",A[i]);
    else printf("%d",A[i]);
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 2096
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>
#include <functional>

using namespace std;

int main() {
  while( true ) {
	int n, m;
	cin >> n >> m;
	if ( n == 0 && m == 0 ) break;

	vector<int> xs( n );
	for ( int i = 0; i < n; i++ ) {
	  cin >> xs[ i ];
	}
	sort( xs.begin(), xs.end(), greater<int>() );
	
	int sum = 0;
	for ( int i = 0; i < n; i++ ) {
	  sum += ( (i + 1) % m == 0 ? 0 : xs[ i ] );
	}
	cout << sum << endl;
  }  
}

Measured memory_bytes: 1212
#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 < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int res = 0;
    int n;
    cin >> n;
    vector<pair<int, int> > v[n];
    rep (i, n) {
        int a;
        cin >> a;
        rep (j, a) {
            int x, y;
            cin >> x >> y;
            x--;
            v[i].emplace_back(x, y);
        }
    }
    
    FOR (bit, 0, 1 << n) {
        vector<bool> trust(n);
        rep (i, n) {
            if (bit & (1 << i)) trust[i] = true;
        }
        bool ok = true;
        rep (i, n) {
            if (trust[i]) {
                rep (j, v[i].size()) {
                    int x = v[i][j].first, y = v[i][j].second;
                    if ((y && !trust[x]) || (!y && trust[x])) ok = false;
                }
            }
        }
        if (ok) res = max(res, __builtin_popcount(bit));
    }
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==========================================================
	public void solve() {
		int H = ni();
		int W = ni();
		int N = ni();
		int x = Math.max(H, W);
		out.println((N + x -1) / x);
    }
    // Set に入れるなら　PPKEY　を使う！
    static class PP{
    	public int key, val;
    	public PP(int key, int val) {
    		this.key = key;
    		this.val = val;
    	}
		public int getKey() {
			return key;
		}
		public void setKey(int key) {
			this.key = key;
		}
		public int getVal() {
			return val;
		}
		public void setVal(int val) {
			this.val = val;
		}
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


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

int main(){
  string S; cin >> S;
  int m = (S[5]-'0')*10 + (S[6]-'0');

  if(m <= 4){
    cout << "Heisei" << endl;
  } else {
    cout << "TBD" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String args[]){
    Scanner scan=new Scanner(System.in);
    int a=scan.nextInt();
    int b=scan.nextInt();
    int ans=0;
    if(b%a==0){
      ans=a+b;
    }else{
      ans=b-a;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
# print(a,b)
count = 0
for i in range(n):
    if a[i]>=b[i]:
        count += b[i]
    else:
        count += a[i]
        b[i] -= a[i]
        if a[i+1]>=b[i]:
            count += b[i]
            a[i+1] -= b[i]
        else:
            count += a[i+1]
            a[i+1] = 0
print(count)

Measured memory_bytes: 19116
x, y = [int(_) for _ in input().split()]
ans = 0
ans += (x-1 == 0)*300000 + (x-2 == 0)*200000 + (x-3 == 0)*100000
ans += (y-1 == 0)*300000 + (y-2 == 0)*200000 + (y-3 == 0)*100000
if x == 1 and y == 1: ans += 400000
print(ans)

Measured memory_bytes: 9192
#include <cstdio>
#include <set>
#include <algorithm>

using namespace std;

int a[4000];

int main() {
    int n, x, i, j;
    long long ans = 0;
    
    scanf("%d %d", &n, &x);
    
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        
        a[i + n] = a[i];
        ans += a[i];
    }
    
    for (i = 1; i < n; i++) {
        long long sum = (long long)x * i;
        multiset <int> s;
        
        for (j = 0; j <= i; j++) s.insert(a[n - j - 1]);
        
        for (j = 0; j < n; j++) {
            s.insert(a[n + j]);
            s.erase(s.find(a[n + j - i - 1]));
            
            sum += *s.begin();
        }
        
        ans = min(ans, sum);
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


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

using namespace std;

typedef long long int ll;
#define pb push_back
#define ALL(a) (a).begin() , a.end()

int mod = 1e9 + 7;
int add(int a, int b){
	if(a + b >= mod)return a+ b - mod;
	return a + b;
}
int mul(int a, int b){
	return 1LL * a * b  % mod;
}
int const N = 200 * 1010;

/********************i**********************************/
void solve(){
	int n, w;
	cin >> n >> w;
	vector<vector<ll>> dp(n, vector<ll> (w + 1, 0LL));
	for(int x =0; x<n; x++)
	{
		int a, b;
		cin >> a >> b;
		if(x == 0){
			for(int y = a; y<= w; y++)dp[x][y] = b;
			continue;
		}
		for(int y = 1; y<= w; y++){
			dp[x][y] = max(dp[x][y-1] , dp[x-1][y]);
			if(y >= a)dp[x][y] = max(dp[x][y], dp[x-1][y-a] + b);
		}
	}
	cout << dp[n-1][w];
}

/******************************************************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	int t;
	t = 1;
	// cin >> t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 79488
from collections import deque
n = int(input())
P = int(''.join(input().split()))
Q = int(''.join(input().split()))

def dfs(s,ans):
    if len(s)>n+1 or int(s)>max(P,Q):
        return ans
    if len(s)==n+1:
        ans+=1
        if int(s)==P:
            global a
            a = ans
        if int(s)==Q:
            global b 
            b = ans
        return ans
    for c in [str(i) for i in range(1,n+1)]:
        if c not in s:
            ans = dfs(s+c,ans)
    return ans

ans = 0
a,b = 0,0
dfs('0',ans)
print(abs(a-b))

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

int main() {
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++)cin >>a[i];
	bool flag = false;
	int j = 0;
	int i = 1;
	while(i < n){
	          if(a[j] == 2){
	          	flag = true;
	          	break;
	          }
	          j = a[j]-1;
	          i++;
	}
	if(flag) cout << i << endl;
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 640
n = int(input())
card_ls = list(map(int, input().split()))
card_ls.sort()
have_to_eat = 0
for i in range(1,n):
    if card_ls[i-1] == card_ls[i]:
        have_to_eat += 1
if have_to_eat % 2 == 1:
    have_to_eat += 1
ans = n - have_to_eat
print(ans)


Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vii;
typedef long long ll;
 
#define  modu 1000000007

int main() {
   
    {
        ll n,p,i;
        cin>>n>>p;
        for(i= pow(p,(1.0/n))+1;i>=1;i--)
            if(p%(ll)pow(i,n)==0)
            {
                cout<<i;
                break;
            }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define all(a)  a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define _for(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

using namespace std;

int N, M;
vector<vector<int> > graph;
vector<pair<int, int> > edges;

bool vis[2005];
double dis[2005];

void dfs(int x){
   for(int n = 0; n < graph[x].sz; ++n){
      if(vis[graph[x][n]] == 0){
         vis[graph[x][n]] = 1;
         dis[graph[x][n]] = dis[x] + 1.00;
         dfs(graph[x][n]);
      }
   }
}

int main(){
   cin >> N >> M;
   graph.resize(N + 5);
   int x, y;
   for(int n = 1; n < N; ++n){
      scanf("%d%d", &x, &y);
      edges.pb(mp(x, y));
      graph[x].pb(y);
      graph[y].pb(x);
   }   
   int res = 1e9;
   for(int n = 1; n <= N; ++n){
      memset(vis, 0, sizeof(vis));
      dis[n] = 0;
      vis[n] = 1;
      dfs(n);
      int tres = 0;
      for(int i = 1; i <= N; ++i){
         if(2 * dis[i] > M){
            ++tres;
         }
      }
      res = min(res, tres);
   }
   for(int n = 0; n < edges.sz; ++n){
      x = edges[n].ff;
      y = edges[n].ss;
      memset(vis, 0, sizeof(vis));
      dis[x] = 0.500;
      dis[y] = 0.500;
      vis[x] = 1;
      vis[y] = 1;
      dfs(x);
      dfs(y);
      int tres = 0;
      for(int i = 1; i <= N; ++i){
         if(2 * dis[i] > M){
            ++tres;
         }
      }
      res = min(res, tres);
   }
   cout << res << endl;
   return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double db;
typedef vector<ll> VI;
typedef vector<pair<ll,ll> > VII;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
//
#define M 1000000007
#define INF (ll)0x3f3f3f3f3f3f3f3f
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define itr iterator
#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
void fileioe(){
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout); 
	freopen("error.txt","w",stderr);
}

void error_out() { cerr << endl; }
template <typename Head, typename... Tail>
void error_out(Head H, Tail... T) {
  cerr << " " << H;
  error_out(T...);
}
void time_elapsed(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}
#ifndef ONLINE_JUDGE
#define error(...) cerr << "[" << #__VA_ARGS__ << "]:", error_out(__VA_ARGS__)
#define fioe() fileioe()
#define time() time_elapsed()
#else
#define error(...) 1
#define fioe() 1
#define time() 1
#endif


//
int main()
{
	GO
	//fioe();
	ll h,w,n;
	cin>>h>>w>>n;
	ll x=ceil((n*1.0)/max(h,w));
	cout<<x<<endl;	
	time();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		
		int result = 3;
		
		for(int i = 0; i < 3; i++) {
			if(S.charAt(i) != T.charAt(i))result--;
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 21844
N=int(input())
L=list(map(int,input().split()))
cnt=0
for i in range(N):
    for j in range(i):
        for k in range(j):
            if L[i]==L[j] or L[j]==L[k] or L[k]==L[i]:
                continue
            if L[i]+L[j]>L[k] and L[j]+L[k]>L[i] and L[k]+L[i]>L[j]:
                cnt+=1
print(cnt)

Measured memory_bytes: 68156
#include<bits/stdc++.h>
using namespace std;
int main(){
    long n;
    cin >> n;
    long a[n];
    vector<pair<int,int> >b(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        b[i].first = a[i];
        b[i].second= i;
    }
    vector<pair<int,int> >ans;
    sort(b.begin(),b.end());
    if(abs(b[0].first) <= abs(b[n-1].first) ){
        ans.push_back(make_pair(b[n-1].second,0));
        ans.push_back(make_pair(b[n-1].second,0));
        for(int i=0;i<n-1;i++){
            ans.push_back(make_pair(i,i+1));
            ans.push_back(make_pair(i,i+1));
        }
    }else{
        ans.push_back(make_pair(b[0].second,n-1));
        ans.push_back(make_pair(b[0].second,n-1));
        for(int i=n-1;i>0;i--){
            ans.push_back(make_pair(i,i-1));
            ans.push_back(make_pair(i,i-1));
        }
    }
    cout << ans.size()<<endl;
    for(int i=0;i<ans.size();i++){
        cout << ans[i].first+1 << " "<<ans[i].second+1<<endl;
    }


}

Measured memory_bytes: 3620
b=input()

ans = 0
ans_list = [0]*len(b)
for i in range(len(b)):
  if (b[i] == 'A')or (b[i] =='C')or(b[i] =='G')or(b[i] =='T'):
    ans += 1
  else:
    ans = 0
  ans_list[i] = ans
print(max(ans_list))

Measured memory_bytes: 3060
// Problem : C - Green Bin
// Contest : AtCoder Beginner Contest 137
// URL : https://atcoder.jp/contests/abc137/tasks/abc137_c
// Memory Limit : 1024,000000 MB
// Time Limit : 2000,000000 milisec
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  cout.precision(16);
  cout << fixed;

  int n;
  cin >> n;

  vector<string> a(n);
  for (auto &&i : a) {
    cin >> i;
    
    sort(i.begin(), i.end());
  }
  
  map<string, int> b;
  
  for (auto&& i : a)
    b[i]++;
  
  long long ans = 0;
  
  for (auto&& i : b) {
    for (int j = 0; j < i.second; ++j)
      ans += i.second - j - 1;
  }
  
  cout << ans;
}


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

int n;

int dfs(long long v, int m) {
    if (n < v) return 0;
    else return (m==7) + dfs(10*v+3, m|1) + dfs(10*v+5, m|2) + dfs(10*v+7, m|4);
}

int main() {
    cin >> n;
    cout << dfs(0, 0) << endl;
}


Measured memory_bytes: 256
def is_prime?(x)
  return false if x < 2
  return true if x == 2
  return false if x % 2 == 0
  i = 3
  while i <= x / i do
    return false if x % i == 0
    i += 2
  end
  true
end

n = gets.to_i
numbers = (1..n).map {gets.to_i}
puts numbers.select {|x| is_prime?(x)}.size

Measured memory_bytes: 8932
int main()
{
  int n, k, q;
  scanf("%d %d %d", &n, &k, &q);
  int point[n], i;
  for (i = 0; i < n; i++)
    point[i] = 0;
  int a[q];
  for (i = 0; i < q; i++)
  {
    scanf("%d", &a[i]);
    point[a[i] - 1]++;
  }
  int tmp = q - k;
  for (i = 0; i < n; i++)
  {
    if (point[i] > tmp)
    {
      printf("Yes\n");
    }
    else
    {
      printf("No\n");
    }
  }
}

Measured memory_bytes: 1280
#include <stdio.h>
int n;
int A[10000];
void judge(){
  int i,count=0;
  int j,flag;
  for(i=0;i<n;i++){
    flag=0;
    for(j=2;j*j<=A[i];j++){
      if( A[i] % j ==0){
	flag = 1;
	break;
      }
    }
    if(flag == 0) count++;
  }
  printf("%d\n",count);
}
int main(){
  scanf("%d",&n);
  int i;
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  judge();
  return 0;
}

Measured memory_bytes: 2720
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    int a=100000;
    int b=-1;
    for(int i=0;i<N;i++){
        int x; cin >> x;
        if(x<a) a=x;
        if(x>b) b=x;
    }
    cout << b-a << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <fstream>
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>

using namespace std;
#define ALL(c) (c).begin(), (c).end()
#define REP(i,n) for(ll i=0; i < (n); ++i)
using ll = long long;
using vl = vector<ll>;
int main(){
#ifdef _WIN32
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cout << fixed << setprecision(8);
	ll n, a, d, m; cin >> n >> a >> d >> m;
	vl x(m), y(m), z(m);
	REP(i, m) cin >> x[i] >> y[i] >> z[i];

	ll k; cin >> k;
	vl op;
	for (ll i = m - 1; i >= 0; i--){
		if (y[i] > k || k > z[i]) continue;
		if (x[i] == 0){
			k = z[i] - (k - y[i]);
		}
		else if (x[i] == 1){
			op.push_back(1);
		}
		else if (x[i] == 2){
			op.push_back(2);
		}
	}

	reverse(ALL(op));
	REP(i, k-1) a += d;

	REP(i, op.size()){
		if (op[i] == 1){
			a++;
		}
		else{
			a /= 2;
		}
	}

	cout << a << endl;
}

Measured memory_bytes: 7584
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	int ans =0;
	int minVal = numeric_limits<int>::max();
	while(n--){
	    int p; cin>>p;
	    if(p <= minVal){
	      ans++;
	      minVal = min(minVal, p);
	    } 
	}
	cout << ans << endl;
}

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

int main() {
  string s,t;
  cin>>s>>t;
  vector<ll> table1(30, 0);
  vector<ll> table2(30, 0);
  rep(i,s.size()) {
    char si = s[i]-'a';
    char ti = t[i]-'a';
    table1[ti]++;
    table2[si]++;
    if(table1[ti] != table2[si]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 776
open Batteries
module Strmap = Map.Make(String)

let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let s_lst = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%s " (fun a -> a)) in
  let m = Scanf.scanf "%d " (fun a -> a) in
  let t_lst = Array.to_list @@ Array.init m (fun _ -> Scanf.scanf "%s " (fun a -> a)) in

  let strmap = Strmap.empty in
  let strmap = List.fold_left (fun accum x -> Strmap.modify_opt x (fun v_opt -> match v_opt with
        Some v -> Some (v + 1)
      | None -> Some 1
    ) accum) strmap s_lst
  in
  let strmap = List.fold_left (fun accum x -> Strmap.modify_opt x (fun v_opt -> match v_opt with
        Some v -> Some (v - 1)
      | None -> Some (-1)
    ) accum) strmap t_lst
  in

  let assoc = Strmap.bindings strmap in
  let assoc = List.sort (fun (k1,v1) (k2,v2) -> (compare v2 v1)) assoc in
  let max = snd (List.hd assoc) in

  Printf.printf "%d\n" @@
  if max > 0 then max else 0



Measured memory_bytes: 1536
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int N,M,S;
int dp[3000+1][2000+1];
int dp2[3000+1][2000+1];
vector<int> ns[8];
vector<int> ms,ss;
vector<int> ret;
int main() {
	while(1){
		cin >> N >> M >> S;
		if(N==0&&M==0&&S==0)break;
		ns[N].push_back((int)ms.size());
		ms.push_back(M);
		ss.push_back(S);
		ret.push_back(0);
	}
	int n=1;
	for(int i=0;i<=2000;i++){
		dp2[0][i]=1;
	}
	for(int a=1;a<=49;a++){
		for(int j=3000;j>=0;j--){
			int v=min(2000,j);
			for(int k=1;k<=v;k++){
				if(k-1>=j-k){
					dp[j][k]=dp2[j-k][j-k];
				}
				else{
					dp[j][k]=dp2[j-k][k-1];
				}
			}
			dp2[j][0]=dp[j][0];
			for(int k=1;k<=v;k++){
				dp2[j][k]=dp2[j][k-1]+dp[j][k];
				if(dp2[j][k]>=100*1000){
					dp2[j][k]-=100*1000;
				}
			}
		}
		if(a==n*n){
			for(int i=0;i<ns[n].size();i++){
				int j=ns[n][i];
				if(ms[j]>=ss[j]){
					ret[j]=dp2[ss[j]][ss[j]];
				}
				else
				{
					ret[j]=dp2[ss[j]][ms[j]];
				}
			}
			n++;
		}
	}
	for(int i=0;i<ret.size();i++){
		cout << ret[i] << endl;
	}
}

Measured memory_bytes: 47268
while True:
    line = input().rstrip()
    if line == "0 0":
        break
    lst = list(map(int, line.split()))
    h = lst[0]
    w = lst[1]
    print("#"*w)
    for i in range(h-2):
        print("#" + "."*(w-2) + "#")
    print("#"*w)
    print()


Measured memory_bytes: 5608