akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define oo 0x3fffffff
using namespace std;

int cost[11][11];
int h,w;
int mincost[11];

void f(void){
    int i,j,k;

    for(k=0;k<10;k++){
        for(i=0;i<10;i++){
            for(j=0;j<10;j++){
                if(i==j || j==k) continue;
                if(cost[i][k]+cost[k][j]<cost[i][j])
                    cost[i][j]=cost[i][k]+cost[k][j];
            }
        }
    }
}

int main(){
    int i,j,k=0,x,y;    scanf("%d %d",&h,&w);

    for(i=0;i<10;i++)for(j=0;j<10;j++) scanf("%d",&cost[i][j]);
    f();

    for(i=0;i<10;i++) mincost[i]=cost[i][1];

    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            scanf("%d",&x);
            //if(x==-1) continue;
            //printf("%d\n",x);
            if(x!=-1) k +=mincost[x];
        }
    }

   printf("%d",k);




    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int INF = 10111111;

int main(){
    int n ,x, y;
    cin >> n >> x >> y;
    --x; --y;
    vector<int> ans(n);
    rep(sv, n){
        vector<int> dist(n, INF);
        queue<int> q;
        auto push = [&](int v, int d){
            if(dist[v] != INF) return;
            dist[v] = d;
            q.push(v);
        };
        push(sv, 0);
        while(!q.empty()){
            int v = q.front(); q.pop();
            int d = dist[v];
            if(v-1 >= 0) push(v-1, d+1);
            if(v+1 < n) push(v+1, d+1);
            if(v == x) push(y, d+1);
            if(v == y) push(x, d+1);
        }
        rep(i, n) ans[dist[i]]++;
    };
    rep(i, n) ans[i] /= 2;
    repr(i, 1, n) {
        cout << ans[i] << endl;
    }
}

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


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}





void oneCase () {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> ed(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        ed[a].push_back(b);
        ed[b].push_back(a);
    }
    for (auto& v : ed) {
        cout << v.size() << "\n";
    }

}




int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long int
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e7;
const ll MOD=1e18;
const int TOT_PRIMES=19;
const int MAX_A=70;
ll dp[90000];
using namespace std;
int main() 
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    cout.tie(0);
	ll n;
	cin>>n;
	ll cnt=0;
	for(int i=0;i<100;i++){
		for(int j=0;j<i;j++){
			dp[cnt]=i;
			cnt++;
		}
	}
	ll tot=0;
	for(ll i=2;i*i<=n;i++){
		ll u=0;
		while(n%i==0){
			n=n/i;
			u++;
		}
		tot=tot+dp[u]-1;
	}
	if(n>1)
		tot+=1;
	cout<<tot;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N; cin >> N;
    vector<int> a(N+1, 0), b(N+1, 0);
    
    for(int i=1; i<=N; ++i) cin >> a[i];
    for(int i=1; i<=N; ++i) cin >> b[i];

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

    int ans = 0;
    for(int i=1; i<=N; ++i){
        chmax(ans, a[i]+b[N]-b[i-1]);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(ll i=0;i< (n);i++)
#define rep1(i,n) for(ll i=1;i<= (n);i++)
using namespace std;
typedef long long ll;
const static ll MOD = (1e+9)+7;

ll modcross(ll a,ll k){
    if(k == 0)return 0;
    if(k % 2 == 1)return (a + modcross(a,k-1)) % MOD;
    ll t = modcross(a,k/2) % MOD;
    return (t * 2) % MOD; 
}
ll modpow(ll a,ll k){
    if(k == 0)return 1;
    if(k % 2 == 1)return (a * modpow(a,k-1)) % MOD;
    ll t = modpow(a,k/2) % MOD;
    return (t * t) % MOD; 
}

int main(){
    ll n,k;cin>>n>>k;
    vector<ll> A(n,0);rep(i,n)cin>>A[i];
    ll ans = 0;
    for(ll i = 0;i<n-1;i++){
        for(ll j = i+1;j<n;j++){
            if(A[i]>A[j])ans += modcross(k,k+1) * modpow(2,MOD-2) % MOD;
            if(A[i]<A[j])ans += modcross(k,k-1) * modpow(2,MOD-2) % MOD;
            ans %= MOD;
        }
    }
    cout<<ans%MOD<<endl;
    return 0;
}

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

int main(){
int n;
cin>>n;
int hano=0;
for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
        if(4*i+7*j==n)
            hano=1;
    }
}
if(hano==1){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
return 0;
}


Measured memory_bytes: 3604
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

var n int
var slice [][]int

func main() {
	sc.Split(bufio.ScanWords)

	slice = make([][]int, 2)

	n = nextInt()
	for i := 0; i < 2; i++ {
		slice[i] = make([]int, n)
		for j := 0; j < n; j++ {
			slice[i][j] = nextInt()
		}
	}

	// fmt.Println(slice)

	// ans := rec(3, 0, 0)

	ans := -1
	for i := 0; i < n; i++ {
		sum := 0
		for j := 0; j <= i; j++ {
			sum += slice[0][j]
			// fmt.Println(slice[0][j])
		}

		sum += slice[1][i]

		for k := i + 1; k < n; k++ {
			sum += slice[1][k]
		}

		if ans < sum {
			ans = sum
		}

	}

	fmt.Println(ans)

}


Measured memory_bytes: 640
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int q = sc.nextInt();
    String s = sc.next();
    int[] l = new int[q];
    int[] r = new int[q];

    for (int i = 0; i < q; i++) {
      l[i] = sc.nextInt();
      r[i] = sc.nextInt();
    }

    int[] data = new int[n+1];

    for (int i = 0; i < n-1; i++) {
      if (s.substring(i,i+2).equals("AC")) {
        data[i+1] = data[i] + 1;
      } else {
        data[i+1] = data[i];
      }
    }

    // for (int i = 0; i < n; i++) {
    //   System.out.print(data[i]+" ");
    // }

    // System.out.println();

    for (int i = 0; i < q; i++) {
      System.out.println(data[r[i]-1]-data[l[i]-1]);
    }

  }

}


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

using namespace std;

using int64 = long long;
const int mod = 998244353;

const int64 infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

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

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

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

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

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int R;
  cin >> R;
  cout << 3 * R * R << endl;

}





Measured memory_bytes: 256
import java.util.Scanner;

	public class Main {
	
		public static void main(String[] args) {
			// TODO 自動生成されたメソッド・スタブ
	
			Scanner sc = new Scanner(System.in);
	
			String S = sc.nextLine();
	
			if (S.equals("ABC")) {
				System.out.println("ARC");
			} else if (S.equals("ARC")) {
				System.out.println("ABC");
			}
		}
	
	}


Measured memory_bytes: 35676
N  = int(input())
A_list = list(input().split())
Colors = [0]*3
output = 1
for i in range(N):
    a = int(A_list[i])
    num = Colors.count(a)
    for j in range(3):
        if a == Colors[j]:
            Colors[j] += 1
            break
    output *= num
output = int(output%1000000007)
print(output)

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

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int ans = 0;
  char b ;
  string input;
  cin >> input;
  for (char x: input) {
    cin>> b ;
    if (b != x) ans++;
  }
  cout << ans;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n,m,x; cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int> (m));
    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> a[i][j];
        }
    }
    int ans = 2e9;
    rep(bit,(1<<n)){
        vector<int> k(m);
        int cost = 0;
        rep(i,n){
            if((bit >> i) & 1) {
                rep(j,m){
                    k[j] += a[i][j];
                }
                cost += c[i];
            }
        }
        bool ok = true;
        rep(i,m){
            if(k[i] < x) ok = false;
        }
        if(ok) chmin(ans, cost);
    }
    if(ans == 2e9) cout << "-1" << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 3636
#![allow(unused_imports)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let n = read!(usize);
    let a = read![[i64]];

    let mut costs: Vec<i64> = Vec::with_capacity(n + 10);
    // とりあえず取りやめない場合のコストを計算 累積和
    for i in 0..n {
        if i == 0 {
            costs.push(a[0].abs());
        } else {
            let prev = costs[i - 1];
            costs.push((a[i] - a[i - 1]).abs() + prev);
        }
    }
    {
        let prev = costs[n - 1];
        costs.push(a[n - 1].abs() + prev);
    }

    for i in 0..n {
        if i == 0 {
            let range1 = costs[n] - costs[1];
            let x = a[1].abs();
            println!("{}", range1 + x);
        } else if i == n - 1 {
            let range1 = costs[i - 1];
            let x = a[i - 1].abs();
            println!("{}", range1 + x);
        } else {
            let range1 = costs[i - 1];
            let range2 = costs[n] - costs[i + 1];
            let x = (a[i - 1] - a[i + 1]).abs();
            println!("{}", range1 + x + range2);
        }
    }
}


Measured memory_bytes: 7292
#include <bits/stdc++.h>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define REPR(i, n) for (int i = n-1; i >= 0; --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTG(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<n)
#define bit_check(bit, i) (bit>>i) & 1
#define setpre(n) fixed << setprecision(n)
#define NEWL cout << endl;
using namespace std;
using PII = pair<int, int>;
using VP = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using ll = long long;
const int INF = 1e9;

int main() {
  int N;
  cin >> N;
  VP blue(N);
  VP red(N);
  REP(i, N) cin >> red.at(i).first >> red.at(i).second;
  REP(i, N) cin >> blue.at(i).first >> blue.at(i).second;
  SORT(blue);
  int ans = 0;
  REPx(x, blue)
  {
    int xb = x.first;
    int yb = x.second;
    int idx = -1;
    int y_max = -INF;
    REP(i, red.size())
    {
        int xr = red.at(i).first;
        int yr = red.at(i).second;
        if (xr < xb && yr < yb)
        {
            if (yr > y_max)
            {
                y_max = yr;
                idx = i;
            }
        }
    }
    if (idx != -1)
    {
        ans++;
        red.erase(red.begin() + idx);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
opn = [list(map(str,input().split())) for i in range(n)]
pnt = [list(map(int,input().split())) for i in range(n)]
ma = -10**100

for i in range(1,1024):
    stt = str(format(i,'010b'))
    p = 0
    for i,sh in enumerate(opn):
        ci = 0
        for j, st in enumerate(sh):
            if stt[j] == "1" and st == "1":
                ci += 1
        p += pnt[i][ci]
    if ma < p:
        ma = p

print(ma)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	char a;
	cin >> a;
	if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')cout << "vowel" << endl;
	else cout << "consonant" << endl;
	return 0;
}


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

string S;
bool flag = false;

int main() {
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'U' || S[i] == 'D') continue;
		if (i % 2 == 0 && S[i] == 'L') flag = true;
		if (i % 2 == 1 && S[i] == 'R') flag = true;
	}
	if (flag == false) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import functools, fractions
def lcm(a, b):
	return a * b // fractions.gcd(a, b)
def check(L, NM):
    res = []
    for i in range(NM):
        res.append(int(i*(L/NM)+1))
    return res
def check2(x, L, NM):
    return int((x-1)*NM/L)
def main():
    N,M = map(int,input().split())
    S = input()
    T = input()
    L = lcm(N,M)
    ans = L
    a = list(set(check(L, N)) & set(check(L, M)))
    for i in a:
        if S[check2(i, L, N)] != T[check2(i, L, M)]:
            ans = -1
            break
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 20088
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


class SEGMENT_TREE:
    def __init__(self, N):
        self.N = N
        self.tree = [0] * (2 * N)  # 問題により修正

    def init(self, arr):
        N = self.N
        for i in range(N):
            self.tree[N + i] = arr[i]
        for i in range(N - 1, 0, -1):
            self.tree[i] = gcd(
                self.tree[i * 2], self.tree[i * 2 + 1])  # 問題により修正

    def update(self, p, value):
        i = p + self.N
        self.tree[i] = value
        while i > 1:
            self.tree[i // 2] = gcd(self.tree[i], self.tree[i ^ 1])  # 問題により修正
            i //= 2

    def query(self, l, r):
        N = self.N
        res = 0  # 問題により修正
        l += N
        r += N
        while l < r:
            if (l & 1):
                res = gcd(res, self.tree[l])  # 問題により修正
                l += 1
            if (r & 1):
                r -= 1
                res = gcd(res, self.tree[r])  # 問題により修正
            l //= 2
            r //= 2
        return res


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    seg = SEGMENT_TREE(N)
    seg.init(A)
    ans = 0
    for i in range(N):
        tmp = gcd(seg.query(0, i), seg.query(i + 1, N))
        ans = max(ans, tmp)
    print(ans)


Measured memory_bytes: 105752
#include <stdio.h>
#define ll long long

ll MOD = 1000000007;

ll pow2(ll a, ll b){
    ll ret = 1;
    while(b > 0){
        if(b%2 == 1){
            ret = ret*a%MOD;
        }
        a = a*a%MOD;
        b /= 2;
    }
    return ret;
}

ll mul(int s, int e){
    ll ret = 1;
    for(int i = s; i <= e; i++){
        ret = ret*i%MOD;
    }
    return ret;
}

ll fact(int n){
    return mul(1, n);
}

ll nCr(int n, int r){
    return mul(n-r+1, n) * pow2(fact(r), MOD-2) % MOD;
}


int main(void)
{
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    ll ans = (pow2(2, n) - 1 + MOD - nCr(n, a) + MOD - nCr(n, b)) % MOD;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
N = int(input())
S = input()

s_l = {}
for i in range(N-1):
    t = {}
    s = S[i+1:]
    t['s'] = s
    t['R'] = s.count('R')
    t['G'] = s.count('G')
    t['B'] = s.count('B')
    s_l[i] = t

s = 0
for a in range(N-2):
    s1 = S[a]
    for b in range(a+1, N-1):
        s2 = S[b]
        if s1 == s2:
            continue
        n = s_l[b]['s']
        pat = ['R', 'G', 'B']
        pat.remove(s1)
        pat.remove(s2)
        count = s_l[b][pat[0]]
        d = b - a
        if len(n) > d-1 and n[d-1] == pat[0]:
            count -= 1
        s += count

print(s)


Measured memory_bytes: 78488
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
	int n,m;
int main(){
	scanf("%d%d",&n,&m);
	int i;
	for(i=m/n;i>=1;i--)
		if(m%i==0)
			if((m/i)>=n){
				printf("%d",i);
				return 0;
			}
	return 0;
}

Measured memory_bytes: 256
import qualified Data.Map.Strict as M
import Data.Char
import Data.List (foldl')

countChars :: String -> M.Map Char Int
countChars = foldl' (\acc c ->
                    if isAlpha c then flip (M.adjust succ) acc c
                                 else acc) initial
        where
            initial = M.fromAscList $ zip ['a'..'z'] (repeat 0)

showCount :: M.Map Char Int -> [String]
showCount = map (\(c,n) -> c:" : " ++ show n) . M.toAscList

main = getContents >>= mapM_ putStrLn . showCount . countChars . map toLower

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

ll dp[3001][6001];

void chmax(ll& a, ll b) { a = max(a, b); }

int main(){
	int N, T;
	cin >> N >> T;
	vector<pair<int,int>> A(N);
	for (int i = 0;i < N;i++) {
		cin >> A[i].first >> A[i].second;
	}
	for (int i = 0;i < 3001;i++)
		for (int j = 0;j < 6001;j++)
			dp[i][j] = 0;
	sort(all(A));
	for (int i = 0;i < N;i++) {
		for (int j = 0;j < T;j++) {
			chmax(dp[i + 1][j + A[i].first], dp[i][j] + A[i].second);
			chmax(dp[i + 1][j], dp[i][j]);
		}
	}
	ll ans = 0;
	for (int i = 0;i <= N;i++) {
		for (int j = 0;j < 6001;j++) {
			chmax(ans, dp[i][j]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 140928
mod=10**9+7
n,a,b=map(int,input().split())
ans=pow(2,n,mod)-1 #n種類の花を使って花束を作る総数は2^n-1通り
comb1=1 #nCaの計算
for i in range(n-a+1,n+1): #n*(n-1)*…*(n-a+1)を計算
 comb1*=i
 comb1%=mod
for i in range(1,a+1): #1/a!=1/(1*2*…*a)=1^(p-2)*2^(p-2)*…*a^(p-2) (p=10**9+7)を計算
 comb1*=pow(i,mod-2,mod)
 comb1%=mod
comb2=1
for i in range(n-b+1,n+1): #n*(n-1)*…*(n-b+1)を計算
 comb2*=i
 comb2%=mod
for i in range(1,b+1): #1/b!=1/(1*2*…*b)=1^(p-2)*2^(p-2)*…*b^(p-2) (p=10**9+7)を計算
 comb2*=pow(i,mod-2,mod)
 comb2%=mod
ans-=(comb1+comb2) #nCa、nCbを総数から引く
ans%=mod
print(ans)


Measured memory_bytes: 39280
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from itertools import product
    n=int(input())
    match=[[0]*n for _ in range(n)]
    V=0 # V=n(n-1)/2
    for i,j in product(range(n),repeat=2):
        if(i>=j): continue
        match[i][j]=V
        V+=1

    def toID(i,j):
        if(i>j): i,j=j,i
        return match[i][j]

    E=[[] for _ in range(V)]
    for i in range(n):
        A=list(map(lambda x:int(x)-1,input().split()))
        for j in range(1,n-1):
            E[toID(i,A[j-1])].append(toID(i,A[j]))
    # あとは頂点VのグラフをdfsしてLongest pathの長さを求める
    # -1: unchecked, -2: checked and uncalculated
    dp=[-1]*V
    flag=True
    def dfs(v):
        global flag
        dp[v]=-2
        length=0
        for nv in E[v]:
            if(dp[nv]==-2):
                print(-1)
                exit()
            if(dp[nv]==-1):
                dfs(nv)
            length=max(length,dp[nv]+1)
        dp[v]=length
    # calculate
    for i in range(V): dfs(i)
    print(max(dp)+1 if(flag) else -1)
resolve()

Measured memory_bytes: 131328
package main

import (
	"fmt"
)

func main() {
	var h, w, n int
	fmt.Scan(&h, &w, &n)
	m := h
	if w > m {
		m = w
	}
	if n%m == 0 {
		fmt.Println(n / m)
	} else {
		fmt.Println(n/m + 1)
	}
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

signed main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	YesNo(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d));
}



Measured memory_bytes: 3016
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
  int n, k;
  cin >> n >> k;
  if ((n-1)%(k-1)==0) 
  cout <<(n-1)/(k-1);
  else 
  cout<<(n-1)/(k-1)+1;
}

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

int main(void) {
	int N;
	cin >> N;
	string S1, S2;
	cin >> S1 >> S2;
	if (S1.length() == 1) { cout << 3 << endl; return 0; }
	string type = "none";
	long long int ans = 0;
	for (int i = 0; i < N; i++) {
		if (S1[i] == S2[i]) {
			//縦パターン
			if (type == "none") {
				//最初の時
				ans += 3;
				type = "Vertical";
			}
			else if (type == "Vertical") {
				//縦 -> 縦
				ans *= 2;
			}
			else if (type == "Horizon") {
				//横 -> 縦
				//ans *= 2;
			}
			type = "Vertical";
		}
		else {
			//横パターン
			if (type == "none") {
				//最初の時
				ans += 6;
				type = "Horizon";
			}
			else if (type == "Vertical") {
				//縦 -> 横
				ans *= 2;
			}
			else if (type == "Horizon") {
				//横 -> 横
				ans *= 3;
			}
			type = "Horizon";
			i++;
		}
		ans = ans % (int)(pow(10, 9) + 7);
		//cout << i << " : " << ans << endl;
	}
	cout << ans % (int)(pow(10, 9) + 7) << endl;
	return 0;
}


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

int main() {
 	    long n,w,a,b;
        cin>>n>>w;
        vector<pair<long,long>>p; long val=0;
        for(long i=0;i<n;i++){cin>>a>>b; p.push_back({b,a}); val=val+b;}
       
        long dp[n+1][val+1];
        for(int i=0;i<=n;i++)dp[i][0]=0;       //dp[i][j] is min weight for value atleast i considering frst i elements
                                               //see it can be solved in one array only as in dp realtion there is i-1 for both terms
        for(int i=1;i<=val;i++)dp[0][i]=10000000001; //max value of weight+1 but see it should not overflow if something added to it
         //here it measn impossible and as we used min so we need LONG_MAX in base case
             for(long i=1;i<=n;i++){
             for(long j=1;j<=val;j++){
                 
                 if(j-p[i-1].first<0)dp[i][j]=dp[i-1][j];
                 else{
                dp[i][j]=min(dp[i-1][j-p[i-1].first]+p[i-1].second,dp[i-1][j]);
               }
             }
        }
        long ans; //find  max value so that is weight req is less or equal w
        for(long i=0;i<=val;i++){
           // cout<<dp[n][i]<<endl;
            if(dp[n][i]<=w)ans=i;
        }
        cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 82424
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define NUM 4001

struct Edge{
	Edge(short arg_to,ll arg_cost){
		to = arg_to;
		cost = arg_cost;
	}
	bool operator<(const struct Edge &arg) const{
		return cost < arg.cost;
	}
	short to;
	ll cost;
};

struct Info{
	void set(int arg_loc,int arg_rank){
		loc = arg_loc;
		rank = arg_rank;
	}
	short loc,rank;
};

int N;
Info pre[NUM][NUM];
ll table[NUM];
vector<short> MAX_DIVIDE[NUM]; //dp[場所][ある場所から出発するエッジ集合の中でのrank] = 到達までの最大分割数
vector<Edge> G[NUM];


int main(){

	scanf("%d",&N);

	table[0] = 0;

	for(int i = 1; i <= N; i++){
		scanf("%lld",&table[i]);
		table[i] += table[i-1];
	}

	//各場所からエッジを張る
	for(int left = 0; left <= N-1; left++){
		for(int right = left+1; right <= N; right++){
			G[left].push_back(Edge(right,table[right]-table[left]));
		}
		sort(G[left].begin(),G[left].end());
	}

	G[N].push_back(Edge(N+1,HUGE_NUM));

	int L,R,mid;
	int base_rank,start_index,next_loc,next_rank,out_rank;
	ll base_cost;

	//MAX_DIVIDE[場所][相対入次rank] = 左の最大分割数
	for(int loc = 0; loc <= N; loc++){
		MAX_DIVIDE[loc].assign(N-loc+1,-1);
	}

	int work[NUM];
	MAX_DIVIDE[0][0] = 0;

	for(int loc = 0; loc <= N-1; loc++){

		//★本来の到着地点★
		for(int i = 0; i < G[loc].size(); i++){
			work[i] = i;
		}

		//ある出発エッジについて、出発するまでの、左方最大分割数を求める
		for(int i = 1; i < G[loc].size(); i++){
			if(MAX_DIVIDE[loc][i] < MAX_DIVIDE[loc][i-1]){
				MAX_DIVIDE[loc][i] = MAX_DIVIDE[loc][i-1];
				work[i] = work[i-1];
			}
		}

		for(int i = 0; i < G[loc].size(); i++){

			if(MAX_DIVIDE[loc][i] == -1)continue;

			next_loc = G[loc][i].to;
			base_cost = G[loc][i].cost;

			//base_costよりも大きい、next_locにおける最小のエッジのインデックスを求める
			L = 0,R = G[next_loc].size()-1,mid = (L+R)/2;
			next_rank = BIG_NUM;

			while(L <= R){
				if(G[next_loc][mid].cost > base_cost){
					next_rank = mid;
					R = mid-1;
				}else{
					L = mid+1;
				}
				mid = (L+R)/2;
			}

			if(next_rank == BIG_NUM)continue;

			if(MAX_DIVIDE[next_loc][next_rank] >= MAX_DIVIDE[loc][i]+1)continue;

			MAX_DIVIDE[next_loc][next_rank] = MAX_DIVIDE[loc][i]+1;
			pre[next_loc][next_rank].set(loc,work[i]);
		}
	}

	int maximum = MAX_DIVIDE[N][0],final_rank = 0;

	if(maximum == 1){
		printf("1\n\n");
		return 0;
	}

	stack<int> S;

	int tmp_loc = N,tmp_rank = final_rank;
	Info info;

	while(pre[tmp_loc][tmp_rank].loc > 0){
		S.push(pre[tmp_loc][tmp_rank].loc);
		info = pre[tmp_loc][tmp_rank];
		tmp_loc = info.loc;
		tmp_rank = info.rank;
	}

	printf("%d\n",maximum);

	if(!S.empty()){
		printf("%d",S.top());
		S.pop();

		while(!S.empty()){
			printf(" %d",S.top());
			S.pop();
		}
	}
	printf("\n");


	return 0;
}



Measured memory_bytes: 192028
import sys
input = sys.stdin.buffer.readline

N = int(input())
a = list(map(int, input().split()))

# dp[i][j] 区間a[i,j)だけ残った時点で互いの点数を一旦0とし、ゲームを最後まで続けた場合のX-Yの値
dp = [[0]*(N+1) for _ in range(N+1)]

# こちらもメモ化再帰ではpypy3でも間に合わない
# j==i+1, i+2, ...とループしてdpテーブルの上三角部分を対角線と平行に埋めていく。jをshift_iと書き換えてループ
for shift_i in range(1, N+1):
    for i in range(N+1):
        if i+shift_i >= N+1:
            continue
        if shift_i == 0:
            dp[i][i] = 0
        elif ((i+shift_i)-i)%2 == N%2: # 先手番
            dp[i][(i+shift_i)] = max(a[i] + dp[i+1][(i+shift_i)], a[(i+shift_i)-1] + dp[i][(i+shift_i)-1])
        else:
            dp[i][(i+shift_i)] = min(-a[i] + dp[i+1][(i+shift_i)], -a[(i+shift_i)-1] + dp[i][(i+shift_i)-1])

print(dp[0][N])

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

#define ll long long
#define ld long double

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define repA(i,A)   for(auto i:A)

#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)	A.rbegin(),A.rend()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V> 
#define Vpll vector<pll>

#define endl "\n"

const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265

const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    ll A[n+1],B[n+1],C[n];
    rep(i,1,n+1)	cin>>A[i];
    rep(i,1,n+1)	cin>>B[i];
    rep(i,1,n)	cin>>C[i];
    ll cnt=0;
    rep(i,1,n+1){
    	if(i!=n){
    		if(A[i+1]==A[i]+1){
    			cnt += C[A[i]];
    		}
    	}
    	cnt += B[A[i]];
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

int main(int argc, const char * argv[]) {
    
    double r ;
    
    std::cin >> r ;
    
    double a = r * 2 * M_PI ;
    double b = r * r * M_PI ;
    
    printf("%.6f %.6f\n", b, a);
    
    return 0 ;
}


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

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ii, null_type,less<ii>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>
#define Mod 1000000007
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define T int t;cin>>t;rep(i,t)



void solve() {

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

    ll arr1[n], arr2[m];
    rep(i, n) cin >> arr1[i];
    rep(i, m) cin >> arr2[i];

    int i = 0;
    ll count = 0;
    while (i < n && count + arr1[i] <= k) {
        count += arr1[i];
        i++;
    }

    if (i == 0) {
        while (i < m && count + arr2[i] <= k) {
        count += arr2[i];
        i++;
        }
    cout << i << "\n";
    return;
    }

    ll ans = i, curr = i;
    int j = 0;
    for (j = 0; j < m && i > 0; j++) {

        if (count + arr2[j] <= k) {
            count += arr2[j];
            curr++;
        }
        else {
            count += arr2[j];
            curr++;
            while (i > 0 && count > k) {
                count -= arr1[i - 1];
                i--;
                curr--;
            }
        }

        ans = max(ans, curr);
    }

    while (j < m && count + arr2[j] <= k) {
        count += arr2[j];
        j++;
        curr++;
    }
    ans = max(ans, curr);
    cout << ans << "\n";
}

int main()
{
    fastio;
    // T
    solve();
    //code
    return 0;
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int ans, cnt, n;
	cin >> n;
	vector<char> vec(n);
	for (int i = 0; i < n; i++) {
		cin >> vec[i];
	}
	cnt = count(vec.begin(), vec.end(), 'E');
	ans = cnt;	
	for (int i = 0; i < n; i++) {
		if (vec[i] == 'E') cnt--;
		ans = min(ans, cnt);
		if (vec[i] == 'W') cnt++;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))
a1 = sorted(a)
sum_a = 0
sum_b = 0

for i in range(n):
    if(n%2==0):
        if(i%2 != 0):
            sum_a += a1[i]
        else:
            sum_b += a1[i]
    else:
        if(i%2 == 0):
            sum_a += a1[i]
        else:
            sum_b += a1[i]
print(sum_a-sum_b)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[])
{
    vector<string> svec;
    string x;
    while(1)
    {
        cin >> x;
        if(x=="0") break;
        svec.push_back(x);

    }
    for (auto var : svec)
    {
        int tmp = 0;
        for (auto var2 : var)
        {
            tmp += stoi(string(1,var2));
        }
        cout << tmp << endl;
    }

    return 0;
}



Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	cout << (N/3) << endl;
}

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

int main()
{
    int A, B, C, result;
    cin >> A >> B >> C;
    int MAX_ABC = max(A, max(B, C));
    int Min_ABC = min(A, min(B, C));
    int mid = A + B + C - MAX_ABC - Min_ABC;
    result = MAX_ABC * 10 + Min_ABC + mid;
    cout << result << endl;
    // ここにプログラムを追記
}



Measured memory_bytes: 256
char s[4005],t[4005];
u[4005],m,i,j,c;
main(n){
	for(;~scanf("%s%s",s,t+1);i=m=!printf("%d\n",m)){
		for(n=strlen(s);!i|t[i];i++)
			for(j=strlen(s);j--;m<c?m=c:0)
				u[j+1]=c=s[j]-t[i]?0:u[j]+1;
	}
}

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

int main()
{
	map<int,int> count;
    int n,m;
  	cin>>n>>m;
  	int k,a;
  	for(int i=0 ; i<n ; ++i)
    {
    	cin>>k;
      	for(int j=0 ; j<k ; ++j)
        {
        	cin>>a;
          	++count[a];
        }
    }
  	int ans=0;
  	for(auto &i:count)
    {
    	ans+=(i.second==n);
    }
  	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import math
a, b, h, m = map(int, input().split())
ra = 2*math.pi * h / 12 + 2*math.pi / 12 * m / 60
rb = 2*math.pi * m / 60
ax, ay = a * math.cos(ra), a * math.sin(ra)
bx, by = b * math.cos(rb), b * math.sin(rb)
dx, dy = abs(ax - bx), abs(ay - by)
print(math.sqrt(dx*dx + dy*dy))

Measured memory_bytes: 9584
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vpair ta(n);
    rep(i, n) cin >> ta[i].fi >> ta[i].se;
    pair<ll, ll> ans(0, 0);
    rep(i, n) {
        if (ta[i].fi >= ans.fi && ta[i].se >= ans.se) {
            ans = ta[i];
        }
        else {
            pair<ll, ll> tmp;
            tmp.fi = ans.fi / ta[i].fi;
            tmp.se = ans.se / ta[i].se;
            if (ans.fi % ta[i].fi != 0) tmp.fi++;
            if (ans.se % ta[i].se != 0) tmp.se++;
            ll mx = max(tmp.fi, tmp.se);
            ans.fi = mx * ta[i].fi;
            ans.se = mx * ta[i].se;            
        }
    }

    cout << ans.fi + ans.se << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
const long long Mod=1000000007;
int n,k;
long long fac[4000010],inv[4000010],f[2010][2010],s[2010];
long long pw(long long x,long long y)
{
	long long res=1;
	while (y)
	{
		if (y&1)
		{
			res=res*x%Mod;
		} 
		y>>=1;
		x=x*x%Mod;
	}
	return res;
}
long long c(int n,int m)
{
	if (n<m)
	{
		return 0;
	}
	return fac[n]*inv[n-m]%Mod*inv[m]%Mod;
}
int main()
{
	scanf("%d%d",&n,&k);
	if (k==1)
	{
		puts("1");
		return 0;
	}
	fac[0]=1;
	for (int i=1;i<=n*k;i++)
	{
		fac[i]=fac[i-1]*i%Mod;
	}
	inv[n*k]=pw(fac[n*k],Mod-2);
	for (int i=n*k-1;i>=0;i--)
	{
		inv[i]=inv[i+1]*(i+1)%Mod;
	}
	f[0][0]=1;
	for (int i=1;i<=n;i++)
	{
		s[n+1]=0;
		for (int j=n;j>=0;j--)
		{
			s[j]=(s[j+1]+f[i-1][j])%Mod;
		}
		for (int j=1;j<=i;j++)
		{
			f[i][j]=s[j-1]*c(i*k-j-1,k-2)%Mod;
			//cout<<f[i][j]<<" ";
		}
		//cout<<endl;
	}
	long long ans=0;
	for (int i=1;i<=n;i++)
	{
		ans=(ans+f[n][i])%Mod;
	}
	//cout<<ans<<endl;
	ans=ans*fac[n]%Mod;
	printf("%lld\n",ans);
    return 0;
}
//花开堪折直须折，莫待无花空折枝。
//——《金缕衣》

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

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define LOG 19
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less< i64 >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int dis[105][105] ;

char s[105][105] ;

int n , m ;

bool isValid(int x, int y)
{
    if( x>n || x<1 || y>m || y<1 ) return 0 ;
    return 1 ;
}

int cost(int x1, int y1, int x2, int y2)
{
    if( s[x1][y1] =='.' && s[x2][y2] == '#' ) return 1 ;
    return 0 ;
}

int dx[] = {0,1} ;
int dy[] = {1,0} ;

int bfs()
{
    for(int i=1; i<=n ; i++) for(int j=1 ; j<=m ; j++) dis[i][j] = n*m+5 ;

    priority_queue< pair< int , pair<int,int> > > pq ;

    if( s[1][1] == '#' ) dis[1][1] = 1 ;
    else dis[1][1] = 0 ;
    pq.push( mp( -dis[1][1] , mp(1,1) ) ) ;

    while( !pq.empty() )
    {
        pair<int,pair<int,int>> p = pq.top() ;

        p.xx *= -1 ;

        pq.pop() ;
        if( dis[p.yy.xx][p.yy.yy] != p.xx ) continue ;

        for(int i=0 ; i<2 ; i++)
        {
            int x = p.yy.xx+dx[i] , y = p.yy.yy+dy[i] ;
            if( !isValid(x,y) ) continue ;
            if( dis[x][y] > dis[p.yy.xx][p.yy.yy] + cost(p.yy.xx,p.yy.yy,x,y) )
            {
                dis[x][y] = dis[p.yy.xx][p.yy.yy] + cost(p.yy.xx,p.yy.yy,x,y) ;
                pq.push( mp( -dis[x][y] , mp(x,y) ) ) ;
            }
        }
    }
    return dis[n][m] ;
}

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

    for(int i=1;  i<=n ; i++)
    {
        scanf("%s",s[i]+1) ;
    }

    printf("%d\n", bfs() ) ;

    return 0 ;
}


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

class Pt{
    public:
    double x, y;
    Pt(double x = 0, double y = 0):x(x),y(y){}
    Pt operator + (Pt p){return Pt(x + p.x, y + p.y);}
    Pt operator - (Pt p){return Pt(x - p.x, y - p.y);}
    Pt operator / (double d){return Pt(x / d, y / d);}
    Pt operator * (double d){return Pt(x * d, y * d);}
    Pt operator * (Pt p){return Pt(x * p.y, -y * p.x);}
    bool operator > (Pt p){return ((abs(x - p.x) > 1e-7) ? x > p.x: y > p.y);}
    double norm(){return hypot(x, y);}
    Pt rot90(){return Pt(-y, x);}
    Pt rot180(){return Pt(-x, -y);}
    Pt rot270(){return Pt(y, -x);}
    string str(){stringstream ss;ss<<x<<", "<<y;return ss.str();}
};

vector<Pt>cc_cross(Pt p1, double r1, Pt p2, double r2){
    double d = (p1 - p2).norm();
    if(r1 + r2 < d)return vector<Pt>(0);
    double rc = (d * d + r1 * r1 - r2 * r2) / (2 * d);
    double rs = sqrt(max(r1 * r1 - rc * rc, 0.0));
    Pt diff = (p2 - p1) / d;
    vector<Pt>points = {p1 + diff * rc + diff.rot90() * rs, p1 + diff * rc + diff.rot270() * rs};
    return points;
}

void AOJ_CGL7E(){
    Pt p1, p2;
    double r1, r2;
    cin >> p1.x >> p1.y >> r1;
    cin >> p2.x >> p2.y >> r2;
    vector<Pt>points = cc_cross(p1, r1, p2, r2);
    if(points[0] > points[1])swap(points[0], points[1]);
    printf("%.10f %.10f %.10f %.10f\n", points[0].x, points[0].y, points[1].x, points[1].y); 
}

void AOJ_0090(){
    for(int N; cin >> N,N;){
        vector<Pt>v(N);
        vector<Pt>c;
        for(int i = 0; i < N; i++){
            scanf("%lf,%lf", &v[i].x, &v[i].y);
            c.push_back(v[i]);
        }
        for(int i = 0; i < N; i++){
            for(int j = 0; j < i; j++){
                vector<Pt> points = cc_cross(v[i], 1, v[j], 1);
                if(points.size() == 0)continue;
                c.push_back(points[0]);
                c.push_back(points[1]);
            }
        }
        int ans = 0;
        for(auto p : c){
            int cnt = 0;
            for(auto q : v){
                if((p - q).norm() <= 1.0)cnt++;
            }
            if(ans < cnt)ans = cnt;
        }
        cout << ans << endl;
    }
}

int main(){
    
    AOJ_0090();

    return 0;
}


Measured memory_bytes: 3352
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////
vector<LL> kai(100100);
LL powMod(LL x, int cnt, LL prime) {
	LL ans = 1;
	LL base = x;
	while (cnt) {
		if (cnt & 1) {
			ans = (ans * base) % prime;
		}
		base = (base * base) % prime;
		cnt /= 2;
	}
	return ans;
}
LL calInv(LL x, LL prime) {
	LL ans = powMod(x, prime - 2, prime);
	return ans;
}

vector<LL> soin(LL A) {
	vector<LL> ans;
	for (LL i = 2; i < 100000; ++i) {
		while (A % i == 0) {
			ans.push_back(i);
			A /= i;
		}
	}
	if (A != 1) {
		ans.push_back(A);
	}
	return ans;
}

LL nHk(int n, int k) {
	//n!/(k!(n-k)!);
	LL ans = kai[n];
	ans = (ans * calInv(kai[n - k], MOD)) % MOD;
	ans = (ans * calInv(kai[k], MOD)) % MOD;
	return ans;
}
void solve() {
	
	int N, M;
	cin >> N >> M;
	/*
	N個の積でMを作る。
	*/
	kai[0] = 1;
	kai[1] = 1;
	for (int i = 2; i < 100100; ++i) {
		kai[i] = (kai[i - 1] * i) % MOD;
	}

	vector<LL> Msoin = soin(M);
	sort(Msoin.begin(), Msoin.end());
	int len = Msoin.size();
	int now = -1;
	int cnt = 0;
	LL ans = 1;
	for (int i = 0; i < len; ++i) {
		if (Msoin[i] != now && cnt) {
			LL res;
			res = nHk(N-1 + cnt, cnt);
			ans = (ans * res) % MOD;
			cnt = 0;
		}
		now = Msoin[i];
		cnt++;
	}
	LL res;
	res = nHk(N - 1 + cnt, cnt);
	ans = (ans * res) % MOD;
	
	cout << ans << endl;
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 1024