akhauriyash/Code-Regression huggingface dataset:
from itertools import combinations_with_replacement

N, M, Q = map(int, input().split())

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

ans = 0
for i in combinations_with_replacement(range(1, M+1), N):
    tmp = 0
    for a, b, c, d in A:
        if i[b-1] - i[a-1] == c:
            tmp += d
    ans = max(ans, tmp)
print(ans)



Measured memory_bytes: 9184
#include <iostream>
#include <map>
#include <set>
#include <string>
#include<string.h>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <cctype>
using namespace std;
typedef long long ll;

int main(){
	long long a,b,n;
	long long x;
	scanf("%lld%lld%lld",&a,&b,&n);
	if(n<b) x=n;
	else x=b-1;
	printf("%lld\n",(a*x)/b-a*(x/b));
	
}

Measured memory_bytes: 3824
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
typedef pair<P, int> PP;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			if (mod <= ans * x) ans = ans * x % mod;
			else ans *= x;
		}
		if (mod <= x * x) x = x * x % mod;
		else x *= x;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
	}
	fact_memo[n] = (ans + mod) % mod;
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

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

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

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

int n, ans;
P r[114], b[114];
bool used[114];
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> r[i].second >> r[i].first;
	}
	rep(i, n) {
		cin >> b[i].first >> b[i].second;
	}
	sort(b, b + n);
	sort(r, r + n, greater<P>());
	rep(i, n) {
		swap(r[i].second, r[i].first);
	}
	rep(i, n) {
		rep(j, n) {
			if (!used[j]) {
				if (r[j].first < b[i].first && r[j].second < b[i].second) {
					ans++;
					used[j] = true;
					break;
				}
			}
		}
	}
	cout << ans << endl;
}

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

int main()
{
	string in;
	cin >> in;
	int ans = 0;
	for (int i = 0; i < 3; ++i)
	{
		ans += (in[i] == '1');
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc170/tasks/abc170_c

use proconio::input;

fn main() {
    input! {
      x: i32,
      n: i32,
      ps: [i32; n]
    }
    let mut ans: Option<i32> = None;
    'outer: for i in 0..=x {
        for j in [-1, 1].iter() {
            let val = x + i * j;
            if !ps.contains(&val) {
                ans = Some(val);
                break 'outer;
            }
        }
    }
    println!("{}", ans.unwrap());
}


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

int main(){
  int x,y;
  cin>>x>>y;
  bool flag=false;
  for(int i=0;i<=x;i++){
    if(4*x-2*i==y){
      flag=true;
      break;
    }
    
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
  return 0;
}








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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int dp[3010][3010];
int prv[3010][3010];

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

  string S, T;
  cin >> S >> T;

  int N = SZ(S);
  int M = SZ(T);
  
  REP(i,N) REP(j,M){
    if(S[i] == T[j]){
      if(dp[i+1][j+1] < dp[i][j] + 1){
        dp[i+1][j+1] = dp[i][j] + 1;
        prv[i+1][j+1] = 2;
      }
    }
    if(dp[i+1][j] < dp[i][j]){
      dp[i+1][j] = dp[i][j];
      prv[i+1][j] = 0;
    }
    if(dp[i][j+1] < dp[i][j]){
      dp[i][j+1] = dp[i][j];
      prv[i][j+1] = 1;
    }
  }

  int ii = 0, jj = 0;
  REP(i,N+1) REP(j,M+1) if(dp[ii][jj] < dp[i][j]) ii = i, jj = j;
  //cout << dp[ii][jj] << endl;

  string ans;
  while(ii && jj){
    int p = prv[ii][jj];
    if(p == 2){
      --ii;
      --jj;
      ans += S[ii];
    }
    else if(p == 1){
      --jj;
    }
    else{
      --ii;
    }
  }
  reverse(ALL(ans));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 70912
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void solve(long long n, std::vector<long long> a) {
  sort(all(a));
  ll num = a[n - 1];

  ll minDiff = 1e10;
  ll r = a[0];
  rep(i, n - 1) {
    ll tmp = abs(a[i] - (num - a[i]));
    if (tmp < minDiff) {
      minDiff = tmp;
      r = a[i];
    }
  }

  print(num << " " << r);
}

int main() {
  long long n;
  scanf("%lld", &n);
  std::vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  solve(n, std::move(a));
  return 0;
}


Measured memory_bytes: 1024
import java.util.*

private const val TWO = 2

fun main(args: Array<String>) {
    multipleOf2AndN()
}
fun multipleOf2AndN() {
    val n = Scanner(System.`in`).nextInt()
    val result = n * TWO / gcd(n, TWO)

    println(result)
}

private tailrec fun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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 (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll a;
cin>>a;
ll l=a+a*a+a*a*a;
cout<<l<<endl;
return 0;
}

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

int main() {
  int x, y;
  cin >> x >> y;
  int group1 = 0, group2 = 0, group3 = 0;
  
  
  if (x == 2) {
    group3++;
  } else if (x == 4 || x == 6 || x == 9 || x == 11) {
    group2++;
  } else {
    group1++;
  }

  if (y == 2) {
    group3++;
  } else if (y == 4 || y == 6 || y == 9 || y == 11) {
    group2++;
  } else {
    group1++;
  }
  
  if (group1 == 2 || group2 == 2 || group3 == 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
}

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

using namespace std;

typedef long long	ll;

int main(){
	ll a, b, c;

	cin >> a >> b >> c;

	ll x = c - a - b;

	// cout << 4LL * a * b << endl;

	if(x > 0LL && x * x > 4LL * a * b){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
from math import sqrt, floor
from itertools import accumulate

N, K = map(int, input().split())
A = list(map(int, input().split()))
assert N == len(A)

def divisors(n):
    ds = [d for d in range(1, floor(sqrt(n)) + 1) if n % d == 0]
    for d in ds:
        yield n // d
    if n == ds[-1] ** 2:
        ds.pop(-1)
    ds.reverse()
    for d in ds:
        yield d

S = sum(A)
for d in divisors(S):
    X = [a % d for a in A]
    X.sort()
    AC = accumulate(X)
    SB = accumulate(reversed([(d - x) % d for x in X]))
    SB = reversed(list(SB)[:-1])
    k = [a for a, s in zip(AC, SB) if a == s][0]
    if k <= K:
        print(d)
        break


Measured memory_bytes: 3188
d,g=map(int,input().split())
P=[]
C=[]
for i in range(d):
    x,y=map(int,input().split())
    P.append(x)
    C.append(y)
v=sum(P)
for i in range(1<<d):
	t=0
	c=0
	L=[i for i in range(d)]
	for j in range(d):
		if i&(2**j):
			L.remove(j)
			t+=(j+1)*100*P[j]+C[j]
			c+=P[j]
	if t>=g:
		v=min(v,c)
	else:
		if L:
			s=max(L)
			for k in range(P[s]-1):
				t+=100*(s+1)
				c+=1
				if g<=t:
					v=min(v,c)
					break
print(v)


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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int l,r;
  l = a+b;
  r = c+d;
  if(l>r){
    cout<<"Left"<<endl;
  }else if(l<r){
    cout<<"Right"<<endl;
  }else{
    cout<<"Balanced"<<endl;
  }
  return 0;
}

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

int r, n;
string girl, gg;

int count(char c){ 
    int r = 0;
    for(int i = 0; i < gg.length(); i++){
        if(gg[i] == c) r++;
    }
    return r;
}

int main(){
    cin >> r;
    while( r-- > 0 ){
        cin >> n;
        cin >> girl;
        int max = 0;
        for(int i = 1; i < girl.length(); i++){
            gg = girl;
            int j = 0, k = 0, m = n-1;
            while( count('B') && count('G') ){
                j = (j+m+(k==i))%gg.length();
                gg.erase(j,1);
                if(j == gg.length()) j = 0;
                k++;
            }
            int c = count('B');
            if( c > max ){
                 max = c;
            }
            if(k < i) break;
        }
        cout << max << endl;
    }
    return 0;
}

Measured memory_bytes: 1232
from math import cos, radians, sqrt

A, B, H, M = list(map(int,input().split()))

m = H * 60 + M
h = 360.0 / 60.0 * (m % 60)
mi = 360.0 / 720.0 * (m % 720)
arg = abs(h - mi)

print(sqrt(A**2 + B**2 - 2.0 * A * B * cos(radians(arg))))

Measured memory_bytes: 9460
a=int(input())
b,c=map(int,input().split())
d=list(map(int,input().split()))
result=[]
for i in d:
    result.append(b-i*0.006)
result2=[]
for i in result:
    result2.append(abs(c-i))
print(1+result2.index(min(result2)))


Measured memory_bytes: 9196
#include<stdio.h>
long dp[1001][1001];
int mod = 1e9+7;
int main()
{
    int H, M;
    char c;
    scanf("%d%d", &H, &M);
    getchar();
    dp[0][1] = 1;
    for(int i=1; i<=H; i++)
    {
        for(int j=1; j<=M; j++)
        {
            scanf("%c", &c);
            if(c == '.')
            {
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
                dp[i][j] %= mod;
            }
        }
        getchar();
    }
    printf("%ld\n", dp[H][M]);
    return 0;
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main()
{
  int n[3], k;
  rep(i, 0, 3) cin >> n[i];
  cin >> k;

  vvi v(3);
  rep(i, 0, 3){
    rep(j, 0, n[i]){
      int t; cin >> t;
      v[i].pb(t);
      sort(all(v[i]), greater<int>());
    }
  }

  typedef pair<int,vector<int>> data;
  priority_queue<data> que;
  set<data> st;
  que.push(data(v[0][0]+v[1][0]+v[2][0], vi({0, 0, 0})));
  rep(i, 0, k){
    auto ans = que.top();
    que.pop();
    cout << ans.first << endl;

    rep(j, 0, 3){
      if(ans.second[j] + 1 < n[j]){
        int sum = ans.first - v[j][ans.second[j]] + v[j][ans.second[j]+1]; 
        auto num = ans.second;
        num[j]++;
        auto d = data(sum, num);
        if(!st.count(d)){
          st.insert(d);
          que.push(d);
        }
      }
    }
  }

  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;
 
ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}
using namespace std;

int main()
{
	fast;
	ll n; cin>>n; ll sum = 0;
	for(ll i = 1; i <= n; i++)
	{
		if(i % 3 == 0 && i % 5 == 0) continue;
		else if(i % 5 == 0) continue;
		else if(i % 3 == 0) continue;
		else sum += i;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<cmath>
#include<algorithm>
using namespace std;

int main(void)
{
	int N;
	cin >> N;

	vector<long long> a(N);
	vector<long long> sum(N, 0);
	cin >> a[0];
	sum[0] = a[0];
	for(int i=1; i<N; i++)
	{
		cin >> a[i];
		sum[i] = sum[i-1] + a[i];
	}

	vector<long long> table(N-1, 0);
	for(int i=0; i<N-1; i++)
	{
		long long x = sum[i];
		long long y = sum.back() - x;
		table[i] = abs(x - y);
	}

	long long ret = *min_element(table.begin(), table.end());
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 4992
N = int(input())
S = input()
result = 0
'''
for i in range(N):
    print(result)
    for j in range(i+1,N):
        if S[i] != S[j]:
            for k in range(j ,N):
                if k- j == j - i:
                    continue
                if S[j] != S[k] and S[i] != S[k]:
                    result +=1
print(result)
'''
r = S.count('R')
g = S.count('G')
b = S.count('B')
target = set('RGB')
result = r * g * b
for i in range(N):
    for j in range(1, min(i, (N - i - 1)) + 1):
        if target == set(S[i] + S[i-j] + S[j + i]):
            result -= 1
print(result)

Measured memory_bytes: 9152
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] inputStr = scanner.nextLine().split(" ");
        int a = Integer.valueOf(inputStr[0]);
        int b = Integer.valueOf(inputStr[1]);
        int ans = 0;
        int totalTapCnt = 1;

        while(totalTapCnt < b) {
            totalTapCnt += (a - 1);
            ans++;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
A, B, m, = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))


ans = min(a) + min(b)
for _ in range(m):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1] + b[y-1] - c)

print(ans)


Measured memory_bytes: 24808
#include<stdio.h>
int main()
{
  int n;
  scanf("%d",&n);
  char s[n+1];
  scanf("%s",s);
  if(n%2==1)
    printf("No\n");
  else
  {
    int f=0;
    for(int i=0;i<n/2;i++)
      if(s[i]!=s[i+n/2])
      {
      f=1;
      break;
      }
    if(f==1)
      printf("No\n");
    else
      printf("Yes\n");
  }
  return 0;
}

Measured memory_bytes: 1616
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
using Graph =vector<vector<int>>;

struct UnionFind
{
  vector<int> par;
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    REP(i,n){
      par[i] = i;
    }
  }

  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  int size(int x) {
    return sizes[find(x)];
  }
};


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

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

  UnionFind uf(n);

  for(int i=0;i<m;i++){
    int A=a[i],B=b[i];
    if(uf.same(A,B))continue;
    uf.unite(A,B);
  }
  set<int> se;
  for(int i=0;i<n;i++){
    se.insert(uf.find(i));
  }
  cout<<se.size()<<endl;
}

Measured memory_bytes: 6784
n = int(input())
a = input()
r = [None] * (n + 1)
for i in range(n, 0, -1):
    r[i] = (ord(a[2 * i - 2]) ^ sum(r[i * 2::i])) % 2
print(r.count(1))
print(*(i for i, x in enumerate(r) if x))

Measured memory_bytes: 12032
#include <stdio.h>
 
int main() {
int a,b,c,i,n;
n=0;
scanf("%d%d%d",&a,&b,&c);
for(i=a ; i<=b ; i ++){
if( c%i == 0 ) n=n+1;
}
printf("%d\n",n);
return 0;
}

Measured memory_bytes: 596
# print('input >>')
N, M = map(int,(input().split()))
X = list(map(int,(input().split())))
X.sort()
Xdiff = [X[i + 1] - X[i] for i in range(len(X) - 1)]
Xdiff.sort(reverse=True)
ans = (X[-1]-X[0]) - sum(Xdiff[:N-1])

# print('----------output----------')
print(ans)

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

int main() {
  int n, m;
  cin >> n >> m;

  char A[50][50], B[50][50];

  for (int y=0; y<n; y++) {
    for (int x=0; x<n; x++) {
      cin >> A[y][x];
    }
  }

  for (int y=0; y<m; y++) {
    for (int x=0; x<m; x++) {
      cin >> B[y][x];
    }
  }

  bool exist=false;

  for (int ly=0; ly<n; ly++) {
    for (int lx=0; lx<n; lx++) {
      if (ly+m>n or lx+m>n) continue; // -1必要?

      bool match=true;
      for (int y=0; y<m; y++) {
        for (int x=0; x<m; x++) {
          if (A[ly+y][lx+x]!=B[y][x]) match=false;
        }
      }

      if (match) exist=true;
    }
  }

  if (exist) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n,m;
    cin >> n >> m;
    ll ans=1;
    for(ll i=1;i*i<=m;i++){
        if(m%i==0&&i*n<=m){
            ans=max(ans,i);

            ll x=m/i;
            if(x*n<=m){
                ans=max(ans,x);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3596
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vi z_function(string s)
{
	ll n=sz(s);
	vi z(n);
	z[0]=0;
	for(ll i=1,l=0,r=0;i<n;i++)
	{
		if(i<=r) z[i] = min(z[i-l],r-i+1);
		while(i+z[i]<n && s[z[i]] == s[i+z[i]]) z[i]++;
		if(i+z[i]-1>r)
		{
			r=i+z[i]-1;
			l=i;
		}
	}

	return z;
}

int solve()
{
	ll n,ans=0;
	string s;
	cin>>n>>s;

	rep(i,0,n)
	{
		string r = s.substr(i,n-i);
		vi z = z_function(r);
		rep(j,0,sz(r)) if((j+z[j])>=2*z[j]) ans=max(ans,z[j]);
	}
	cout<<ans<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

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

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <cfenv>
#include <cmath>
#include <string>
#include <algorithm>
#include <cassert>
#include <functional>
#include <deque>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >>n;
  double x = n/3.0;
  double ret = pow(x,3);
  printf("%f10\n", ret);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for (int i=(n-1); i>=0; --i)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#ifdef BALBIT
#define IOS()
#define bug(...) fprintf(stderr,"#%d (%s) = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define bug(...)
#endif

const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"-1\n"; exit(0);}

ll mpow(ll a, ll n, ll mo = mod){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mo;
        a = a*a %mo;
        n>>=1;
    }
    return re;
}

ll inv (ll b, ll mo = mod){
    if (b==1) return b;
    return (mo-mo/b) * inv(mo%b) % mo;
}

const int maxn = 1e5+5;

int n, m, v, p;
int a[maxn];
int org[maxn];
int first[maxn];
ll ps[maxn];

bool can(int it) {
    bug(it);
    int cst = a[it] + m;
    if (cst < a[p-1]) return 0;
    it = first[it];
    ll votes = m*(ll)v;
    FOR(i,0,n) {
        if (i<p-1) votes -= m;
        else votes -= min(m,max(cst-a[i],0));
    }
    bug(it, votes);
    return votes<=0;
}

main(){
    IOS();
    cin>>n>>m>>v>>p;

    REP(i,n) cin>>a[i];

    sort(a,a+n,greater<int>());
    REP(i,n) {
        if (i==0 || a[i]!=a[i-1]) {
            first[i]=i;
        }else {
            first[i]=first[i-1];
        }
        ps[i+1] = a[i]+ps[i];
    }

    int l = 0, r = n;
    while (l!=r) {
        int mid = (l+r)/2;
        if (!can(mid)) {
            r=mid;
        }else{
            l=mid+1;
        }
    }
    cout<<l<<endl;
}


Measured memory_bytes: 1792
def CheckCards(Mark):
    for i in range(1, 14):
        if [Mark, i] not in Cards:
            print(Mark + " " + str(i))

n = int(input())
Cards = []
for i in range(n):
    Cards.append(input().split())
    Cards[i][1] = int(Cards[i][1])

CheckCards("S")
CheckCards("H")
CheckCards("C")
CheckCards("D")

Measured memory_bytes: 7752
import java.util.Scanner;

class Main {

  static boolean RS(String S, int n) {
    if (n%2 == 1)
      return false;
    for(int i = 0; i < n/2; i++)
      if(S.charAt(i) != S.charAt(i+n/2))
        return false;
    return true;
  }
  
  static void PutYN(boolean b) {
    if(b)
      System.out.println("Yes");
    else
      System.out.println("No");
      
  }
  
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    
    int n = stdIn.nextInt();
    String S = stdIn.next();
    
    PutYN(RS(S, n)); 
  }
}


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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define sort(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> p;

int main(){
int a;
cin>>a;
int x ,y;
x=a/100;
y=a%10;
if(x==y){
	cout<<"Yes"<<endl;
  }
  else{
	  cout<<"No"<<endl;
	}
}

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

int main() {
  int N, K, index = 0, _min = 1001, cnt = 0, sum = 0;
  cin >> N >> K;
  vector<int> p(N);
  rep(i, N) cin >> p[i];

  while(cnt < K) {
    _min = 1001;
    rep(i, N) {
      if (p[i] < _min) {
        _min = p[i];
        index = i;
      }
    }
    sum += _min;
    cnt++;
    p[index] = 1001;
  }
  cout << sum << '\n';
}

Measured memory_bytes: 3632
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n, m = f()
    data = []
    for i in range(n):
        data.append(f())
    
    ans = 0
    for i in range(8):
        neg = [1] *3
        for j in range(3):
            if i&(1<<j):
                neg[j] = -1
        
        data = sorted(data, key = lambda x: -(neg[0]*x[0]+neg[1]*x[1]+neg[2]*x[2]))

        cur_ans = 0
        cur_ans += abs(sum([i[0] for i in data[:m]]))
        cur_ans += abs(sum([i[1] for i in data[:m]]))
        cur_ans += abs(sum([i[2] for i in data[:m]]))

        ans = max(ans, cur_ans)
    
    print(ans)



solve()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define lc "\n"
#define fast_io ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
#define c(a,n) for(size_t i = 0; i < n; i++) cin >> a[i];
#define ffor(n) for(size_t i = 0; i < n; i++)
#define asort(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.begin(), a.end(), greater<int>())
 
typedef vector<int> vi;
typedef vector<float> vf;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef map<string,int> msi;
typedef map<int,int> mii;
typedef unordered_map<string,int> umsi;
 

int32_t main()
{
    fast_io;
    int n;
    cin >> n;
    vi a(n);
    c(a, n);
    vi dp(100005);
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    for(int i = 2; i < n; i++)
        dp[i] = min(dp[i-1] + abs(a[i]-a[i-1]),dp[i-2] + abs(a[i]-a[i-2]));
    cout << dp[n-1];

    return 0;
}

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

using namespace std;

const int MAXN=200200;

int main()
{
	static int n,R[MAXN],mi[MAXN];
	scanf("%d",&n);
	for(register int i=0;i<n;i++)
	{
		scanf("%d",&R[i]);
		mi[i]=min(R[i],i>0?mi[i-1]:INT_MAX);
	}
	int ma=0,ans=INT_MIN;
	for(int i=n-1;i>0;i--)
	{
		ma=max(ma,R[i]);
		ans=max(ans,ma-mi[i-1]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4732
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
#define ll long long
const ll mod=1e9+7;
const int maxn=1e2+5;
const int maxk=1e5+5;
int a[maxn];
ll num[maxk],front[maxk];
void update(int k)
{
    front[0]=num[0];
    for(int i=1;i<=k;i++)
        front[i]=(front[i-1]+num[i]-(front[i-1]+num[i]>=mod)*mod);
    return;
}
ll query(int l,int r)
{
    if(l==-1) return front[r];
    else return (front[r]-front[l]+(front[r]-front[l]<0)*mod);
}
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    num[0]=1;
    update(k);
    for(int i=1;i<=n;i++)
    {
        memset(num,0,sizeof(num));
        for(int j=0;j<=k;j++)
            num[j]=query(max(0,j-a[i])-1,j);
        update(k);
    }
    printf("%lld\n",num[k]);
    return 0;
}


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

int IsPrime(int num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
int main(void){
    // Your code here!
    int qnum;
    cin >> qnum;
    int a[100001],b[100001],num[100001];
    num[0]=0;
    num[1]=0;
    for(int i=0;i<100001;i++){
        a[i]=IsPrime(i);
        b[i]=a[(i+1)/2];
        if(i>2)num[i]=num[i-1]+(a[i]&&b[i]);
    }
    for(int temp=0;temp<qnum;temp++){
        int aa,bb,count=0;
        cin>>aa>>bb;
        cout<<num[bb]-num[aa-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  
  cin >> N >> K;
  
  int r = 1;
  
  for (int i = 0; i < N; i++) {
    if (K > (r * 2 - r))
      r *= 2;
    else
      r += K;
  }
  
  cout << r << endl;
}

Measured memory_bytes: 256
/* COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>

#define all(x) x.begin(), x.end()
#define MOD 998244353
#define debug(x) cout << #x << " = " << x << "\n"

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;
int gcd(int a, int b)
{
    if (b == 0)
    {
        return a;
    }
    return gcd(b, a % b);
}
void solve()
{
    //code here.
    int x;
    cin >> x;
    if (x >= 30)
    {
        cout << "Yes";
        return;
    }
    cout << "No";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll T = 1;
    //cin >> T; // If only one test case then you can comment this line out.

    while (T--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <functional>

using namespace std;

typedef long long ll;

const int N = 5005;

ll a[N];

int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	sort(a, a + n, greater<ll>() );

	int cnt = 0;
	ll sum;
	for(int i = 0; i < n; i++){
		sum = 0;
		for(int j = i; j < n; j++){
			sum += a[j];
			if(sum >= k){
				cnt = max(cnt, j + 1);
				sum -= a[j];
			}
		}
	}

	printf("%d\n", n - cnt);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n;
    static int[] H = new int[300];
    public static final int NULL = 2 << 31 - 1;

    public static void main(String[] args) {
        read();
        solve();
    }

    public static void read() {
        n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            H[i + 1] = sc.nextInt();
        }
    }

    public static void solve() {
        for (int i = 1; i <= n; i++) {
            int key, leftKey, rightKey, parentKey;
            key = getKey(i);
            leftKey = getLeftKey(i);
            rightKey = getRightKey(i);
            parentKey = getParentKey(i);

            String s;
            s = String.format("node %d: key = %d, ", i, key);
            if (parentKey != NULL) {
                s += String.format("parent key = %d, ", parentKey);
            }
            if (leftKey != NULL) {
                s += String.format("left key = %d, ", leftKey);
            }
            if (rightKey != NULL) {
                s += String.format("right key = %d, ", rightKey);
            }
            System.out.println(s);
        }
    }

    public static int getKey(int ix) {
        if (ix > n) {
            return NULL;
        }
        return H[ix];
    }

    public static int getLeftKey(int ix) {
        int leftIx = ix * 2;
        return getKey(leftIx);
    }

    public static int getRightKey(int ix) {
        int rightIx = ix * 2 + 1;
        return getKey(rightIx);
    }

    public static int getParentKey(int ix) {
        if (ix == 1) {
            return NULL;
        }

        int parentIx = ix / 2;
        return getKey(parentIx);
    }
}

Measured memory_bytes: 29828
#include<stdio.h>
int main(){
    char num[1001];
    while(true){
        int sum = 0;
        scanf("%s",&num);
        if(num[0]=='0')break;
        for(int i =0;num[i]!='\0';i++){
            sum +=num[i]-'0';
        }
        printf("%d\n",sum);
    }return 0;
}



Measured memory_bytes: 2728
N, K = map(int, input().split())
A = [int(x) for x in input().split()]

# (e + 1)桁目のAの値が 1 であるものをカウント
num = [0] * 41
for e in range(40, -1, -1):
    mask = 1 << e
    for a in A:
        if a & mask:
            num[e] += 1

res = 0
for d in range(40, -2, -1):
    # (d + 1)桁目のKの値が 0 ならスキップ
    # 1桁目（d == -1）のときはスキップしない
    if d != -1 and not (K & (1 << d)):
        continue

    tmp = 0
    for e in range(40, -1, -1):
        mask = 1 << e
        if e > d:
            if K & mask:
                tmp += mask * (N - num[e])
            else:
                tmp += mask * num[e]
        elif e == d:
            tmp += mask * num[e]
        else:
            tmp += mask * max(num[e], N - num[e])
    res = max(res, tmp)
print(res)


Measured memory_bytes: 14984
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] str = br.readLine().split(" ");
    int A = Integer.parseInt(str[0]);
    int B = Integer.parseInt(str[1]);
    int C = Integer.parseInt(str[2]);
    
    int ans = B/A >= C ? C : B/A;
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 22612
//BISMILLAH
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int t;
    cin>>t;
    int cAC=0,cWA=0,cTLE=0,cRE=0;
    while(t--)
    {

        string str;
        cin>>str;
        if(str=="AC") cAC++;
       else if(str=="WA") cWA++;
       else if(str=="TLE") cTLE++;
       else if(str=="RE") cRE++;
    }

    cout<< "AC x "<<cAC<<endl;
    cout<< "WA x "<<cWA<<endl;
    cout<< "TLE x "<<cTLE<<endl;
    cout<< "RE x "<<cRE<<endl;
}


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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
 *
**/

#define endl '\n'
#define MOD 10E9
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)
#define PI 3.141592653589793

template<class T> bool minn(T &a ,T b){ return (a > b ? (a = b , true) : false); };
template<class T> bool maxn(T &a ,T b){ return (a < b ? (a = b , true) : false); };

               
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;  
  
#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif 

  string s; cin >> s;
  string t; cin >> t;
  cout << (t + s) << endl;
   
         
#ifdef LOCAL_DEFINE 
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}            

Measured memory_bytes: 256
def main():
    H, W = map(int, input().split())
    c = [list(map(int, input().split())) for _ in range(10)]
    A = [list(map(int, input().split())) for _ in range(H)]

    minimum_cost = [float("inf")] * 10
    minimum_cost[1] = 0
    pattern = [{
        "via": 1,
        "cost": 0
    }]
    while len(pattern):
        p = pattern.pop(0)
        via = p["via"]
        cost = p["cost"]
        for i in range(10):
            nextcost = cost + c[i][via]
            if nextcost < minimum_cost[i]:
                minimum_cost[i] = nextcost
                pattern.append({"via": i, "cost": nextcost})

    retval = 0
    for i in range(H):
        for j in range(W):
            if A[i][j] == -1:
                continue
            retval += minimum_cost[A[i][j]]
    print(retval)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int m=0;
  int a;
  int sum=0;
  for(int i=0; i<n; i++){
    cin >> a;
    sum += a;
    m = max(m, a);
  }
  cout << sum - m/2 << endl;
}

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

int main() {
	unsigned long long int health;
	cin >> health;
	int count = 0;
	while (health > 0) {
		health = health >> 1;
		count += 1;
	}

	unsigned long long int attacks = 1;
	for (int i = 0; i < count; i++) {
		attacks = attacks << 1;
	}
	cout << attacks - 1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, m;
	char N[100][10];
	int M[100];
	char T[10];
	int sum;
	int i, j, k;
	
	while (1){
		scanf("%d%d", &n, &m);
		if (n == 0 && m == 0){
			break;
		}
		
		for (i = 0; i < n; i++){
			scanf("%s", N[i]);
			scanf("%d", &M[i]);
		}
		
		sum = 0;
		for (i = 0; i < m; i++){
			scanf("%s", T);
			for (k = 0; k < n; k++){
				for (j = 0; j < 8; j++){
					if (N[k][j] != '*'){
						if (N[k][j] != T[j]){
							break;
						}
					}
				}
				if (j == 8){
//printf("[%s]", N[k]);
					sum += M[k];
				}
			}
		}
		
		printf("%d\n", sum);
	}
	return (0);
}

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

//使用する配列の最大要素数
#define MAX_SIZE_N 8
//使用する変数の宣言と初期化
int n=0,counts=0;
double xymap[MAX_SIZE_N][MAX_SIZE_N]={0};
double xy[2][MAX_SIZE_N]={0};
double sum=0,average=0;

// nPnの順列に対して処理を実行する
void foreach_permutation(int n, std::function<void(int *)> f) {
  int indexes[n];
  for (int i = 0; i < n; i++) indexes[i] = i;
  do {
    f(indexes);
  } while (std::next_permutation(indexes, indexes + n));
}

int main()
{
  cin >> n;
  rep(i,n){
    cin >> xy[0][i] >> xy[1][i];
  }

  rep(i,n){ 
    rep(j,n){
       xymap[i][j]=sqrt((xy[0][i]-xy[0][j])*(xy[0][i]-xy[0][j])+(xy[1][i]-xy[1][j])*(xy[1][i]-xy[1][j]));
    }
  }

  foreach_permutation(n, [](int *indexes) {
   rep(i,n-1){
     sum+=xymap[indexes[i]][indexes[i+1]];
     }
   counts++;
  });

  cout << fixed;
  cout << setprecision(8) << sum/(double)counts;
    
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
	int A, B, K,ans[1000],s = 0;

	map<int, int>mp;

	cin >> A >> B >> K;

	for (int i = 0; i < K; i++) {
		if (A + i < A || A + i > B)continue;
		if (mp[A + i] == 0) {
			ans[s] = A + i;
			s++;
		}
		mp[A + i]++;
	}

	for (int i = 0; i < K; i++) {
		if (B - i < A || B - i > B)continue;
		if (mp[B - i]==0) {
			ans[s] = B - i;
			s++;
		}
		mp[B - i]++;
	}

	sort(ans, ans + s);

	for (int i = 0; i < s; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int h,w,n;

int main(void){
	scanf("%d%d%d",&h,&w,&n);
	printf("%d\n",min((n+w-1)/w,(n+h-1)/h));
	return 0;
}


Measured memory_bytes: 256
# solution
import io

n,m = map(int,input().split())
S = []
for _ in range(m):
  s = list(map(int,input().split()))
  del s[0]
  k = 0
  for i in s:
    k +=  1<<(i-1)
  S.append(k)

p = list(map(int,input().split()))

qwe = [[] for _ in range(m+1)]
qwe[0] = [i for i in range(2**n)]
for i in range(m):
  for j in qwe[i]:
    if str(bin(j & S[i])).count('1')%2==p[i]:
      qwe[i+1].append(j)
      
print(len(qwe[m]))

Measured memory_bytes: 3064
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();
if(a==b){
System.out.println("a == b");
}else if(a<b){
System.out.println("a < b");
}else{
System.out.println("a > b");
}
}
}

Measured memory_bytes: 26092
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

ll n,a;

bool possible(ll val,int cnt,int al)
{
	ll num = 1;
	rep(i,cnt){
		num *= val;
	}
	rep(i,al-cnt){
		num *= (val+1);
	}
	if(num >= n){
		return true;
	}else{
		return false;
	}
}

void out(ll val,int cnt,int al)
{
	ll num = 1;
	rep(i,cnt){
		num *= val;
	}
	rep(i,al-cnt){
		num *= (val+1);
	}
	show(num);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> a;
	vl vec;
	srep(i,1,100){
		ll hoge = floor(pow(n,(double)1/i));
		rrep(j,i+1){
			if(possible(hoge,j,i)){
				vec.pb(hoge*i+i-j+a*(i-1));
				break;
			}
		}
	}
	sort(all(vec));
	cout << vec[0] << "\n";
	return 0;
}


Measured memory_bytes: 512
n,*a=`dd`.split.map &:to_i
p 2*n-2
x,y=a.minmax
if y.abs>x.abs
i=a.index(y)+1
(1..n).each{|e|puts '%d %d'%[i,e] if e!=i}
(1...n).each{|e|puts '%d %d'%[e,e+1]}
else
i=a.index(x)+1
(1..n).each{|e|puts '%d %d'%[i,e] if e!=i}
n.downto(2){|e|puts '%d %d'%[e,e-1]}
end

Measured memory_bytes: 4092
#include<stdio.h>

int main()
{
	int N;
	scanf("%d", &N);
	int A[101], element;
	for (element = 0; element <= N - 1; element++)
	{
		scanf("%d ", &A[element]);
	}

	int i, j, k, l, m = 0, mini;
	for (i = 0; i <= N - 2; i++)
	{
		l = 0;
		mini = i;
		for (j = i; j <= N - 1; j++)
		{
			if (A[j] < A[mini])
			{
				mini = j;
				l = 1;
			}
		}
		if (l == 1)
		{
			k = A[i];
			A[i] = A[mini];
			A[mini] = k;
			m++;
		}
	}

	for (i = 0; i <= N - 2; i++)
	{
		printf("%d ", A[i]);
	}
	printf("%d\n", A[N - 1]);
	printf("%d\n", m);
	return 0;

}

Measured memory_bytes: 1032
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let a = v[0];
	let b = v[1];
	if a > b {
		println!("{}", a - 1);
	}else{
		println!("{}", a);
	}
}

Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

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


int main()
{
	int N, M;
	int P[100000], Y[100000];
	vector<int> yd[100001];

	cin >> N >> M;

	rep(i, M) {
		cin >> P[i] >> Y[i];
		yd[P[i]].push_back(Y[i]);
	}

	rep(i, N) 	sort(yd[i + 1].begin(), yd[i + 1].end());

	rep(i, M) {
		printf("%012lld\n", (long long) (P[i]) * 1000000 +
			(int) (lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i])
				- yd[P[i]].begin()) + 1);
	}

               
               return 0;
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
#define debug(x) cout << #x << " = " << x << '\n';
using namespace std;





int main() {
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int n, k, r, s, p;
    string a;
    cin >> n >> k >> r >> s >> p >> a;
    ll ans = 0;
    for (int i = 0; i < k; i++) {
        for (int j = i; j < n; j += k) {
            ans += (a[j] == 'r' ? p : (a[j] == 'p' ? s : r));
            if (j + k < n && a[j] == a[j + k]) j += k;
        }
    }

    cout << ans;


}


Measured memory_bytes: 512
#include <iostream>

using namespace std;


int main(){
  int N,M,X;cin>>N>>M>>X;
  int A[M];
  int mn = 0;
  int mx = 0;
  for(int i = 0; M > i; i++){
    int t;cin>>t;
    if(t < X)mn++;
    else mx++;
  }
  cout <<min(mn,mx) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,val[100005],l[100005],r[100005];
vector<int> g[100005];
void die()
{
	cout<<"No"<<endl;
	exit(0);
}
void solve(int v,int p)
{
	l[v]=-1e9-1;
	r[v]=1e9+1;
	if(val[v]!=-1) l[v]=r[v]=val[v];
	for(int i=0;i<g[v].size();i++)
	{
		int to=g[v][i];
		if(to==p) continue;
		solve(to,v);
		if(l[to]<-1e8) continue;
		if(l[v]<-1e8)
		{
			l[v]=l[to]-1;
			r[v]=r[to]+1;
		}
		else
		{
			if(abs(l[to])%2==abs(l[v])%2)
				die();
			l[v]=max(l[v],l[to]-1);
			r[v]=min(r[v],r[to]+1);
		}
	}
	if(l[v]>r[v]) die();
}
void make(int v,int p)
{
	for(int i=0;i<g[v].size();i++)
	{
		int to=g[v][i];
		if(to==p) continue;
		if(val[to]==-1)
		{
			if(l[to]<=val[v]-1&&val[v]-1<=r[to]) val[to]=val[v]-1;
			else val[to]=val[v]+1;
		}
		make(to,v);
	}
}
int main()
{
	cin>>n;
	for(int i=1;i<=n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	memset(val,-1,sizeof(val));
	cin>>k;
	for(int i=1;i<=k;i++)
	{
		int v,p;
		cin>>v>>p;
		val[v]=p;
	}
	solve(1,-1);
	val[1]=l[1];
	make(1,-1);
	cout<<"Yes"<<endl;
	for(int i=1;i<=n;i++)
		cout<<val[i]<<endl;
	return 0;
}


Measured memory_bytes: 15360