akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

using ll = long long;
using namespace std;
vector<ll> memo(100'001);
int mod = 1'000'000'007;

void init() {
    memo[0] = 1;
    memo[1] = 1;
    for (int i = 2; i < 100001; i++) {
        memo[i] = memo[i - 1] + memo[i - 2];
        memo[i] %= mod;
    }
}

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

    init();

    if (M == 0) {
        cout << memo[N] << endl;
        return 0;
    }
    vector<int> b;
    //壊れている階段
    int cur = a[0];
    int index = 0;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (i == cur) {
            if (cnt == 0) {
                cout << 0 << endl;
                return 0;
            }
            index++;
            b.emplace_back(cnt);
            cnt = 0;
            if (index >= M)continue;
            cur = a[index];
        }
        else {
            cnt++;
        }
    }

    b.emplace_back(++cnt);

    ll ans = 1;
    int size = b.size();
    for (int i = 0; i < size; i++) {
        ans *= memo[b[i] - 1];
        ans %= mod;
    }

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


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007  
#define mod2 998244353 
#define pi 3.14159265358979323846
int fac[100005];
/* Iterative Function to calculate (x^y)%p 
in O(log y) */
int power(int x, int y, int p) 
{ 
int res = 1;      // Initialize result 

x = x % p;  // Update x if it is more than or 
            // equal to p 

while (y > 0) 
{ 
    // If y is odd, multiply x with result 
    if (y & 1) 
        res = (res*x) % p; 

    // y must be even now 
    y = y>>1; // y = y/2 
    x = (x*x) % p; 
} 
return res; 
} 

// Returns n^(-1) mod p 
int modInverse(int n, int p) 
{ 
return power(n, p-2, p); 
} 

// Returns nCr % p using Fermat's little 
// theorem. 
int nCrModPFermat(int n, int r, int p) 
{ 
// Base case 
if (r==0) 
  return 1; 

// Fill factorial array so that we 
// can find all factorial of r, n 
// and n-r 
// fac[0] = 1; 
// for (int i=1 ; i<=n; i++) 
//     fac[i] = fac[i-1]*i%p; 

return (fac[n]* modInverse(fac[r], p) % p * 
        modInverse(fac[n-r], p) % p) % p; 
} 
int solve(){
    int n,k,s=0;
    cin>>n>>k;
    int a[n];
    fac[0]=1;
    rep(i,1,100005) fac[i] = fac[i-1]*i%mod; 
    rep(i,0,n) cin>>a[i];
    sort(a,a+n);
    rep(i,k-1,n){
        //cout<<a[i]<<" "<<i-(k-2)<<"\n";
        s=(s+((a[i]*(nCrModPFermat(i,k-1,mod)))%mod))%mod;
    }
    rep(i,0,n-k+1){
        //cout<<a[i]<<" "<<(n-i-1-(k-2))<<"\n";
        s=(s-((a[i]*nCrModPFermat(n-i-1,(k-1),mod))%mod))%mod;
    }
    while(s<0) s=s+mod;
    cout<<s;
    return 0;
}
 
signed main(){
    IOS;
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //if(solve()) cout<<"YES";
        //else cout<<"NO";
        cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 1792
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll x,a,b,al,bl;
  cin >> x >> a >> b;
  al = abs(x-a);
  bl = abs(x-b);
  if(al<bl) cout <<"A\n";
  else cout <<"B\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=2e5+10;
int n,k;
ll a[maxn];
int main()
{
	ll H;
	cin>>H;
	ll C=1;
	ll ans=0;
	while(H)
	{
		ans+=C;
		H>>=1;
		C<<=1;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
ll gcd(ll a, ll b)
{
    return b ? gcd(b, a % b) : a;
}
int main()
{
    ll N;
    ll temp;
    ll count,ans;
    cin >> N;
    cin >> ans;
    REP(i,N-1){
        cin >> temp;
        ans = gcd(temp,ans);
    }
    count = 0;
    while(true){
        if(ans %2 == 0){
            ans /= 2;
            count++;
        }else{
            fin(count);
            return 0;
        }
    }
    return 0;
}

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

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int main() { _
  int m1,m2,d1,d2; cin >> m1 >> d1 >> m2 >> d2;
  if (m1 == m2) cout << 0 << endl;
  else cout << 1 << endl;
  return 0;
}

Measured memory_bytes: 256
# input
N, M = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(N)]
C = [list(map(int, input().split())) for _ in range(M)]

for i in range(N):
    c = 0
    for j in range(M):
        if abs(S[i][0] - C[j][0]) + abs(S[i][1] - C[j][1]) < abs(S[i][0] - C[c][0]) + abs(S[i][1] - C[c][1]):
            c = j
    print(c + 1)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n,result=0;
        
        n = sc.nextLong();
        result = n - 1;
        
        
        for(long i = 2; i <= n / i; i++){
            if(n % i == 0){
                long j = n / i;
                if(((i - 1) + (j - 1)) < result){
                    result = (i - 1) + (j - 1);
                }
            }
        }
        
        
        System.out.println(result);
    }
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int a,b;
  cin >> a >> b;
  if ( a % 2 == 0 || b % 2 == 0) {
    cout << "Even" << endl;
  }
  
  else {
    cout << "Odd" << endl;
  }
}

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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
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; }

void Solve()
{
	ll N;
	cin >> N;
	VL L(N);
	REP(i, N) cin >> L[i];

	ll ans = 0;
	REP(i, N) {
		REPN(j, i+1, N) {
			REPN(k, j+1, N) {
				if (i == j || j == k || k == i) continue;
				if (L[i] == L[j] || L[j] == L[k] || L[k] == L[i]) continue;
				VL ansOne(3); ansOne[0] = L[i], ansOne[1] = L[j], ansOne[2] = L[k];
				sort(ALL(ansOne));
				if (ansOne[0] + ansOne[1] > ansOne[2]) {
					ans++;
				}
			}
		}
	}

	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
#define ll long long
#define fast_io cin.tie(0);cout.tie(0);ios::sync_with_stdio(0)
#define MOD 1000000007
using namespace std;

int main(){
	fast_io;
	int x,a;
	cin>>x>>a;
	if(x<a){
        cout<<"0";
        return 0;
	}
	else{
        cout<<"10";
        return 0;
	}
}


Measured memory_bytes: 256
n=int(input())
s1=input()
s2=input()
if n>1:
    if s1[0]==s1[1]:
        i=0
    else:
        i=1
else:
    i=1
ans=3

flag=False
while i<n:
    if i<n-1:
        if s1[i]==s1[i+1]:
            if flag:
                ans*=3
                i+=2
            else:
                ans*=2
                i+=2
                flag=True
        else:
            if flag:
                flag=False
                i+=1
            else:
                ans*=2
                i+=1
    else:
        if flag:
            flag=False
            i+=1
        else:
            ans*=2
            i+=1
print(ans%(10**9+7))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define inf 1000000007
using namespace std;
ll sum[214514];
int n,m;
signed main(){
	cin>>n>>m;
	vector<int> a;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.pb(x);
	}
	for(int i=0;i<n-1;i++){
		int st = a[i];
		int gl = a[i+1];
		if( st < gl){
			sum[st+2]--;
			sum[gl+1]++;
		}
		else{
			sum[st+2]--;
			sum[gl+m+1]++;
		}
	}
	for(int i=1;i<=2*m;i++){
		sum[i] += sum[i-1];
	}
	for(int i=m+1;i<=2*m;i++){
		sum[i-m] += sum[i];
	}
	for(int i=0;i<n-1;i++){
		int st = a[i];
		int gl = a[i+1];
		int bd = gl+1;
		if(gl==m)bd=1;
		if(st<gl){
			sum[bd] += gl-st-1;
		}
		else{
			sum[bd] += gl+m-st-1;
		}
	}
	ll ans = 1000000000000LL;
	ll cur = 0;
	for(int i=0;i<n-1;i++){
		int st = a[i];
		int gl = a[i+1];
		if(st<gl){
			cur += gl -st;
		}
		else{
			cur += gl;
		}
	}
	if(ans > cur)ans = cur;
	for(int i=2;i<=m;i++){
		cur += sum[i];
		if(ans > cur)ans = cur;
		//cout<<cur<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

struct grp{
    int rl;
    int rr;
    int ll;
    int lr;
};

int main(){
    string S;
    cin >> S;

    int N = S.length();
    int sum[N];

    for(int i=0; i<N; i++){
        sum[i] = 0;
    }

//ここから

    vector<grp> l;
    grp *a = new grp;
    a->rl = 0;
    for(int i=0; i<N-1; i++){
        if(S[i]=='R' && S[i+1]=='L'){
            a->rr = i;
            a->ll = i+1;
        }

        if(S[i]=='L' && S[i+1]=='R'){
            a->lr = i;
            l.push_back(*a);
            delete a; //いったん消して再生成
            grp *a = new grp;
            a->rl = i+1;
        }
    }

    a->lr = N-1;
    l.push_back(*a);

    for(auto it = l.begin(); it!= l.end(); it++){
        int x = (it->rr - it->rl)/2+1;
        int y = (it->lr - it->ll)/2+1;
        sum[it->rr] = x + (it->lr - it->ll + 1) - y;
        sum[it->ll] = y + (it->rr - it->rl + 1) - x;
        //cout << it->rl << " " << it->rr << " " << it->ll << " " << it->lr << " " << x << " " << y <<endl;
    }

    for(int i=0; i<N; i++){
        cout << sum[i] << " ";
    }

    return 0;

}

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

int main(){
    int N, K; cin >> N >> K;
    string S; cin >> S;
    
    int happy = 0;
    for(int i = 0; i < N - 1; i++){
        if(S[i] == S[i + 1]) happy++;
    }

    int ans = min(happy + 2 * K, N - 1);
    cout << ans << endl;
}

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

using namespace std;

int n, m, par[100005], ans;
pair<int, int> p[100005];

int find(int a) {
	return par[a] == a ? a : par[a] = find(par[a]);
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
		scanf("%d%d", &p[i].second, &p[i].first);
	sort(p, p + n);
	for (int i = 0; i <= m; i++)
		par[i] = i;
	for (int i = n - 1; i >= 0; i--) {
		if (p[i].second > m)
			continue;
		int ta = find(m - p[i].second);
		if (ta == m)
			continue;
		ans += p[i].first;
		par[ta] = ta ? ta - 1 : m;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 1536
#include<iostream>
using namespace std;
int main()
{
  int k;
  cin>>k;
  int a,b;
  cin>>a>>b;
  for(int i=a;i<=b;i++)
  {
    if(i%k==0)
    {
      cout<<"OK";
      return 0;
    }
  }
  cout<<"NG";
  return 0;
}

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

using namespace std;

int main() {
    int32_t m, f, r;

    while (cin >> m >> f >> r) {
        if (m == -1 && f == -1 && r == -1) {
            break;
        }

        if (m == -1 || f == -1) {
            cout << "F" << endl;
        } else if (m + f >= 80) {
            cout << "A" << endl;
        } else if (m + f >= 65) {
            cout << "B" << endl;
        } else if (m + f >= 50) {
            cout << "C" << endl;
        } else if (m + f >= 30) {
            if (r >= 50) {
                cout << "C" << endl;
            } else {
                cout << "D" << endl;
            }
        } else {
            cout << "F" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
	ll n; cin >> n;
	map<ll, ll> mp;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			++mp[i];
			n /= i;
		}
	}
	if (n != 1) ++mp[n];
	ll ans = 0;
	for (auto i : mp) {
		for (int j = 1; j <= i.second; j++) {
			i.second -= j;
			++ans;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3644
def f(n,x,i):
    if n == 0:
        if x != 0:
            if x / i == a:
                return 1
        return 0
    if memo[i][n][x] != -1:
        return memo[i][n][x]
    memo[i][n][x] = f(n-1,x,i)+f(n-1,x+ary[n-1],i+1)
    return memo[i][n][x]
n,a = map(int,input().split())
ary = list(map(int,input().split()))
memo = [[[-1 for _ in range(sum(ary)+1)] for _ in range(n+1)] for _ in range(n+1)]
print(f(n,0,0))

Measured memory_bytes: 56564
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a := iSScan(n)
	ans := 0
	for i, v := range a {
		if i%2 == 0 && v%2 == 1 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1776
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define vvl vector<vector<ll>>
#define vl  vector<ll>
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
//map<int,int>mp
int n;
string s;
ll ans;

signed main(){
	acc_io;
	cin>>n>>s;
	ll r=0,g=0,b=0;
	rep(i,0,n){
		if(s[i]=='R') r++;
		if(s[i]=='G') g++;
		if(s[i]=='B') b++;
	}
	ans=r*g*b;
	ll k;
	rep(i,0,n){
		rep(j,i+1,n){
			k=j+j-i;
			if(k<n){
				if(s[i]!=s[j] && s[j]!=s[k] && s[i]!=s[k] ) ans--;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define fio     ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define pi      3.14159265
#define ll      long long
#define repe    ll tc,cas=0;cin>>tc;while(tc--)
#define op      freopen("output.txt", "w", stdout);

#define maxn 10000010
using namespace std;

int main()
{
    fio;
    int n;
    string s;
    cin>>n>>s;
    int cnt=1;
    for(int i=1;i<n;i++)
        if(s[i-1]!=s[i])
            cnt++;

    cout<<cnt<<endl;
    return 0;
}


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

int N;

int main() {
  cin >> N;
  int a[N];
  int ans[N] = {0};

  for (int i = 0; i < N; i++) cin >> a[i];

  for (int i = 0; i < N; i++) {
    ans[a[i]-1] = i+1;
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1536
import math


def insertionsort(a, n, g):
    cnt = 0
    for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j = j - g
            cnt += 1
        a[j + g] = v
    return cnt


def shellsort(a, n):
    g = []
    gap = 1
    while gap <= math.ceil(n / 3):
        g.append(gap)
        gap = 3 * gap + 1
    g = g[::-1]
    m = len(g)
    print(m)
    print(*g)
    cnt = 0
    for i in range(m):
        cnt += insertionsort(a, n, g[i])
    print(cnt)

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
shellsort(a, n)
print("\n".join(map(str, a)))

Measured memory_bytes: 190000
#include <iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n, k, * N, total = 0;
    cin >> n >> k;
    N = new int[n];
    for (int i = 0; i < n; i++)
    {
        cin >> N[i];
    }
    sort(N, N + n);
    for (int i = 0; i < k; i++)
    {
        total += N[i];
    }
    cout << total << endl;
    delete[]N; 
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1n(i,n) for(int i=1; i<=(n); ++i)
#define repxn(i,x,n) for(int i=x; i<=(n); ++i)
#define sort_u(x) sort((x).begin(),(x).end())
#define sort_d(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
#define INF 1001001001  // 浮動小数点型
#define INF_L 1001001001001001001  // 浮動小数点型
#define bit(n,m)(((n)>>(m))&1)  // nのmビット目が1
#define MOD 1000000007
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main() {
    string s; cin >> s;
    string t; cin >> t;
    
    int ans=INF;
    rep(i,s.size()-t.size()+1){
        int k = i;
        int a = 0;
        rep(j,t.size()){
            if(s[k]!=t[j]) a++;
            k++;
        }
        ans = min(ans, a);
    }
    cout << ans << endl;
}

/*
g++ b.cpp
./a.out

oj d
oj t

debug:ctrl+shift+B problemin

*/


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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#define db(x) cout << "> " << #x << " = " \
	<< (x) << '\n'
#define db2(x, y) cout << "> " << #x << " = " \
	<< (x) << ", " << #y << " = " << (y) << '\n'
#define db3(x, y, z) cout << "> " << #x << \
	" = " << (x) << ", " << #y << " = " << \
	(y) << ", " << #z << " = " << (z) << '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;
typedef map<int, int> mii;
typedef set<int> si;

const int MX = 2e3 + 5, MOD = 1000000007;
int n, k, mem[MX][MX], C[MX][MX];

int dp(int segCnt, int blueRem) {
	if (segCnt < 0)
		return 0;
	if (!blueRem)
		return !segCnt;
	int& ret = mem[segCnt][blueRem];
	if (ret != -1)
		return ret;
	return ret = (dp(segCnt - 1, blueRem - 1) + dp(segCnt, blueRem - 1)) % MOD;
}



int main() {
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin >> n >> k;
	memset(mem, -1, sizeof(mem));
	for(int i = 0; i < MX; ++i)
		for(int j = 0; j <= i; ++j)
			C[i][j] = (j == 0) ? 1
				: ((i == 0) ? 0 : (C[i - 1][j - 1] + C[i - 1][j]) % MOD);
	for (int i = 1; i <= k; ++i) {
//		db2(i, dp(i - 1, k - 1));
		cout << (C[n - k + 1][i] * 1LL * dp(i - 1, k - 1)) % MOD << '\n';
	}
	return 0;
}


Measured memory_bytes: 30848
from sys import stdin

N, M = [int(x) for x in stdin.readline().rstrip().split()]
ans = 1
d = 1
while d ** 2 <= M:
    if M % d == 0:
        if M // d >= N:
            ans = max(d, ans)
        if M // (M // d) >= N:
            ans = max(M // d, ans)
    d += 1

print(ans)


Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

string s;
int N;

int main(){
    cin >> s;
    N = s.size();

    vi bit(N+1,0);     // bit[i] : s[0,i)のビット表現
    for(int i=0;i<N;i++){
        char c = s[i] - 'a';
        bit[i+1] = bit[i] ^ (1<<c);
    }

    vi dp(N+1,INF);     // dp[i] : s[0,i)の最小分割数
    dp[0] = 0;

    vi low(1<<26,INF);  // low[i] : ビット状態がiになる最小分割数
    low[0] = 0;

    for(int i=0;i<N;i++){
        // use s[i]
        dp[i+1] = min(dp[i+1] , low[bit[i+1]]+1);
        for(int j=0;j<26;j++){
            int x = 1 << j;
            if(low[bit[i+1]^x] == INF){
                continue;
            }
            dp[i+1] = min(dp[i+1] , low[bit[i+1] ^ x] + 1);
        }
        low[bit[i+1]] = min(low[bit[i+1]],dp[i+1]);
    }

    //cerr << "bit : " << endl;
    //for(int i=0;i<=N;i++) cerr << static_cast<bitset<26>>(bit[i]) << endl;

    //cerr << dp << endl;

    cout << dp[N] << endl;

    //cerr << static_cast<bitset<26>>(bit[3])<< endl;
}


Measured memory_bytes: 264324
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>

using namespace std;

class agcA {
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<int> a(3*N);
        for (int i = 0; i < 3*N; ++i) {
            in >> a[i];
        }
        sort(a.begin(), a.end(), greater<int>());
        long long sum = 0;
        for (int i = 0, j = 3*N-1; i < 2*N && j >= 2*N; i += 2, --j) {
            sum += a[i+1];
        }
        out << sum << "\n";
    }
};


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

	agcA solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1408
from numba import jit

@jit
def gcd(a,b):
    if b == 0: return a
    else: return gcd(b, a % b)

@jit
def main2(K):
    ans = 0
    for i in range(1,K+1):
        for j in range(1,K+1):
            for k in range(1,K+1):
                ans += gcd(gcd(i,j),k)
    return ans    


K = int(input())
print(main2(K))

Measured memory_bytes: 109812
#include <iostream>       // std::cout
#include <string>  
// std::string
using namespace std;
int main ()
{
  
  std::string str;
  int N, K;
  
  cin >>  N >> K ;
  cin >>  str ;
 
  str[K-1] = tolower(str[K-1]);
  cout << str << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

int main(void){
	int n;
	cin >> n;
	vector<string> ans;
	map<string, int> mp;
	string opr, name;
	rep(i, n) {
		cin >> opr >> name;
		if(opr == "insert") mp[name]++;
		else {
			if(mp[name]) ans.push_back("yes");
			else ans.push_back("no");
		}
	}
	rep(i, ans.size()) cout << ans[i] << endl;

	return 0;
}



Measured memory_bytes: 75884
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(c >= a && c <= b) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 35740
#include<bits/stdc++.h>
using namespace std;
int n,i,j,a[200005],k;
vector<int>b;
bool mark[200005];
int main() {
	scanf("%d",&n);
	for(i=1; i<=n; i++)scanf("%d",&a[i]);
	for(i=n; i>0; i--) {
		for(k=0,j=i+i; j<=n; j+=i)k+=mark[j];
		if((k&1)!=a[i])mark[i]=1,b.push_back(i);
	}
	printf("%d\n",b.size());
	for(i=b.size()-1; i>=0; i--)printf("%d ",b[i]);
	printf("\n");
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  map<char, int> cnt;
  rep (i, 3) cin >> cnt['A' + i];
  vector<string> s(n + 1);
  rep (i, n) cin >> s[i];
  string ans;
  rep (i, n) {
    char t1 = s[i][0];
    char t2 = s[i][1];
    if (cnt[t1] == 0 && cnt[t2] == 0) {
      cout << "No" << endl;
      return 0;
    }
    if (cnt[t1] > cnt[t2]) {
      swap(t1, t2);
    }
    if (cnt[t1] == 1 && cnt[t2] == 1) {
      if (t2 == s[i + 1][0] || t2 == s[i + 1][1]) {
        swap(t1, t2);
      }
    }
    ans += t1;
    cnt[t1]++;
    cnt[t2]--;
  }
  cout << "Yes" << endl;
  for (char i : ans) cout << i << endl;
  return 0;
}

Measured memory_bytes: 6708
#include <iostream>
#include <algorithm>
using namespace std;
#pragma warning (disable: 4996)

int N, K, A[4][10009], dp[10009][16];

int main() {
	cin >> N >> K;
	for (int i = 0; i < K; i++) {
		int p, q; scanf("%d%d", &p, &q);
		A[p][q] = 1;
	}
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= 15; j++) dp[i][j] = -(1 << 30);
	}
	dp[0][0] = 0;
	for (int i = 0; i < N - 1; i++) {
		for (int j = 0; j <= 15; j++) {
			if (dp[i][j] < 0) continue;

			dp[i + 1][0] = max(dp[i + 1][0], dp[i][j]);
			for (int cl = 0; cl <= 3; cl++) {
				for (int cr = cl + 1; cr <= 3; cr += 2) {
					// [cl, cr] に置く
					bool flag = true;
					for (int k = cl; k <= cr; k++) {
						if (A[k][i] == 1 || A[k][i + 1] == 1 || (j / (1 << k)) % 2 == 1) flag = false;
					}
					if (flag == false) continue;

					int sum = 0;
					for (int k = cl; k <= cr; k++) sum += (1 << k);
					dp[i + 1][sum] = max(dp[i + 1][sum], dp[i][j] + (cr - cl + 1) / 2);
				}
			}
		}
	}

	int maxn = 0;
	for (int i = 0; i <= 15; i++) maxn = max(maxn, dp[N - 1][i]);
	cout << maxn << endl;
	return 0;
}


Measured memory_bytes: 3988
n = int(input())
list_blue = [input() for i in range(n)]
m = int(input())
list_red = [input() for i in range(m)]

ans = 0

for i in list_blue:
    point = list_blue.count(i) - list_red.count(i)
    if ans < point:
        ans = point

print(ans)

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main (String args[]) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		double sum = 0;
		Double array[] = new Double[n];
		String ans = "Yes";
		
		for(int i = 0; i < n; i++) {
			array[i] = scan.nextDouble();
			sum = sum + array[i];
		}
		
		Arrays.sort(array, Collections.reverseOrder());
		double ng = sum / (m * 4);
		for(int i = 0; i < m; i++) {
			if(array[i] < ng) {
				ans = "No";
				break;
			}
		}
				
		System.out.println(ans);
	}
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll MOD = 1e9+7;
 
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
 	
 	int n; cin >> n;
	string a, b; cin >> a >> b;
	FOR(i, n)
		cout << a[i] << b[i];
	cout << '\n';

 
	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    MOD = 10**9 + 7
    D = int(readline())
    L = [int(readline()) for i in range(D)]
    S = int(readline())
    dp = [0]*(S+1)
    dp[S] = 1
    for i in range(D):
        l = L[i]
        for i in range(l, S+1):
            dp[i-l] -= dp[i]
    ans = 0
    for i in range(S+1):
        ans += pow(i, D, MOD) * dp[i]
    ans %= MOD
    write("%d\n" % ans)
solve()


Measured memory_bytes: 7304
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a==5&&b==5&&c==7)||(a==7&&b==5&&c==5)||(a==5&&b==7&&c==5))

        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}


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

int main(){
	long long int N, t[5];
	int	k = 0;
	cin >> N;

	while (k < 5) {
		cin >> t[k];
		k++;
	}

	int i;
	long long int x, y, z, ans = 0;
	x = N / t[0];
	y = N % t[0];
	if (y != 0) {
		x++;
	}
	ans += x;
	for (i = 1; i < 5; i++) {
		z = N - (t[i] * (ans - i));
		if (z > t[i]) {
			x = z / t[i];
			y = z % t[i];
			if (y != 0) {
				x++;
			}
		}
		else {
			x = 1;
		}
		ans += x;
	}
 	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <map>

#define INF 100000000
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;
using P = pair<int, int>;

const int MAX = 1000000;
const int MOD = 1000000007;

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

//テーブルの前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        //そのまま計算すると負の値になるのでMODを足す
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//二分累乗法
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
*/

/*
//UnionFind木
struct UnionFind{
   vector<long long int> par; //par[i] : iの親の番号
   vector<long long int> rnk; //root[i] : iの木のサイズ

   //コンストラクタ
   UnionFind(long long int n): par(n), rnk(n){
       //木の初期化
       for(long long int i = 0; i < n; i++){
           par[i] = i;
           rnk[i] = 1;
       }
   }

   //データxが属する木の根を再帰で取得
   long long int root(long long int x){
       if(par[x] == x){
           return x;
       }else{
           return par[x] = root(par[x]);
       }
   }

   //xとyが同じ木に属しているかを判定
   bool same(long long int x, long long int y){
       return root(x) == root(y);
   }

   //xとyの木を併合
   void unite(long long int x, long long int y){
       long long int rx = root(x); //xの根
       long long int ry = root(y); //yの根
       if(rx == ry) return; //根が同じならそのまま

       //併合するときにサイズを足し合わせる
       if(rnk[rx] < rnk[ry]){
           par[rx] = ry;
           rnk[ry] += rnk[rx];
       }else{
           par[ry] = rx;
           rnk[rx] += rnk[ry];
       }
   }

   //属している木のサイズを取得
   long long int size(long long int x){
       return rnk[root(x)];
   }
};
*/


/*
typedef struct edge{
   int to;
   int cost;
} edge;

vector<edge> graph[2010];
long long int d[2010];

void dijkstra(int s){
   priority_queue<P, vector<P>, greater<P> > que;
   for(int i = 0; i < 2010; i++){
       d[i] = INF;
   }
   d[s] = 0;
   que.push(P(s, 0));

   while (!que.empty()) {
       P p = que.top();
       que.pop();
       int v = p.first;
       if (d[v] < p.second) continue;

       for (int i=0; i<graph[v].size(); ++i) {
           edge e = graph[v][i];
           if (d[e.to] > d[v] + e.cost) {
               d[e.to] = d[v] + e.cost;
               que.push(P(e.to, d[e.to]));
           }
       }
   }
}
*/

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;

    int data[26] = {0};

    int i;
    for(i = 0; i < n; i++){
        data[s[i]-'a']++;
    }

    long long int ans = 1;
    for(i = 0; i < 26; i++){
        ans *= (data[i]+1);
        ans %= MOD;
    }

    cout << (ans - 1 + MOD)%MOD << endl;
}


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

struct Node{
	int key;
	struct Node *right, *left , *parent;
};

struct Node *root , *NIL;

void insert(int k)
{
	struct Node *y = NIL;
	struct Node *x = root;
	struct Node *z;
	
	z = (struct Node *)malloc(sizeof(struct Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	
	while( x != NIL)
	{
		y = x;
		if(z->key < x->key)
		{
			x = x->left;
		}
		else{
			x = x->right;
		}
	}
	z->parent = y;
	if(y == NIL)
	{
		root = z;
	}
	else{
		if(z->key < y->key)
		{
			y->left = z;
		}
		else{
			y->right = z;
		}
	}
}

void inorder(struct Node *u)
{
	if( u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}

void preorder(struct Node *u)
{
	if( u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}

int main(void)
{
	int n , i , x;
	char  com[100];
	char str1[] = "insert";
	char str2[] = "print";
	scanf("%d",&n);
	
	for( i = 0; i < n; i++)
	{
		while(scanf("%s",com) != EOF)
		if(strcmp(com,str1)==0)
		{
			scanf("%d",&x);
			insert(x);
		}
		else if( strcmp(com,str2)==0)
		{
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	return 0;
}



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

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

int main() {
  ll n, t, ans = 1;
  cin >> n;
  rep(i, n) {
    cin >> t;
    ans = lcm(ans, t);
  }
  cout << ans << endl;
  return 0;
}


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

vector<int> buf;
vector<int> G[10000000] ;
int k = 0 ;
void dfs(int i, const int size, const int range_start, const int range_end)
{
    if ( i-1 == size ) {
        for(int i = 1 ; i <= size ; ++i){
          	G[k].push_back(buf[i]) ;
        }
        k++ ;
      return ;
    }
    else{
        for(int j = buf[i-1] ; j <= range_end ; ++j){
            buf[i] = j ;
            dfs(i + 1, size, range_start, range_end);
        }
    }
}

int main(void)
{
  	int n , m , q ;
  	cin >> n >> m >> q ;
  	int a[q] , b[q] ,c[q] , d[q] ;
  	rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i] ;
    int size = n ;
    int range_start = 1 ;
    int range_end = m  ;
    buf.resize(size+1)  ;
    buf[0] = 1 ;
  	ll ans = 0 ;
    dfs(1, size, range_start, range_end);
	for(int i = 0 ; i < k ; i++ ){
      
      vector<int> A(size) ;
      int j = 0 ;
      for( auto p : G[i] ) A[j++] = p ;
      ll tem =  0 ;
      rep(l,q) if( A[b[l]-1] - A[a[l]-1] == c[l] ) tem += d[l] ; 
      ans = max(tem,ans) ;
      
      //for( auto p : G[i] ) cout << p << ' ' ;
      //cout << endl;
    }
  	cout << ans << endl;
}


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

int main () {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int al = 0;
  int bo = 0;
  for (int i = 0; i < n; i += 2) {
    al += vec.at(i);
  }
  for (int i = 1; i < n; i += 2) {
    bo += vec.at(i);
  }
  cout << al - bo << endl;
}


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

int main(){

    ll n, k; cin >> n >> k;
    string s; cin >> s;
    
    s[k-1] = s[k-1]-('A'-'a');

    cout << s << endl;

    return 0;
}

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

vector<long long> vi;

int main(){
   int n;
   scanf("%d",&n);
   for(int i=0;i<n;i++){
    long long a;
    scanf("%lld",&a);
    vi.push_back(a);
   }
   sort(vi.begin(),vi.end());
   int flag=0;
   long long sum=1,base=1;
   double b=1;
   for(int i=1;i<=18;i++){
    b*=10;
    base*=10;
   }

   if(vi[0]==0){
    printf("0");
    flag=1;
   }else {
    for(int i=0;i<vi.size();i++){
        b/=vi[i];
        sum*=vi[i];
        //printf("%lf %lld\n",b,sum);
        if(b<1||sum>base){
            //flag=1;
            sum=-1;
            break;
        }
    }
   }
   if(!flag){
    printf("%lld",sum);
   }
    return 0;
}

Measured memory_bytes: 4244
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N, X, m, mmin = 1000;
    cin >> N >> X;
    int res = N;
    REP(i, N) {
        cin >> m;
        X -= m;
        amin(mmin, m);
    }
    cout << res + X / mmin << endl;
    return 0;
}


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

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

int main() {
  int N, M; scanf("%d%d", &N, &M);

  bool edge[N][N];
  rep(i, N) rep(j, N)
    edge[i][j] = false;

  rep(i, M) {
    int a, b; scanf("%d%d", &a, &b);
    --a; --b;
    edge[a][b] = edge[b][a] = true;
  }

  int v[N-1];
  rep(i, N-1) v[i] = i+1;

  int ans = 0;
  do {
    bool flag = true;
    int from = 0, to = v[0];
    rep(i, N-1) {
      if (!edge[from][to])
        flag = false;
      from = v[i], to = v[i+1];
    }
    if (flag)
      ++ans;
  } while(next_permutation(v, v+N-1));
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include<string>
#include <set>
#include <map>
#include <queue>
#include <limits.h>
#include <bitset>
#include <cmath>


using namespace std;

#define rip(i, n, s) for (int i = (s);i < ( int )( n ); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;

void deb(vector<int> &da) {
	int n = da.size();
	rip(i, n, 0) {
		if (i == n - 1) {
			cout << da[i] << endl;
		}
		else {
			cout << da[i] << ' ';
		}
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> da(m);
	vector<int> cost(m);
	vector<int> change(n + 1, 1);
	rip(i, n + 1, 1) {
		change[i] = change[i - 1] * 2;
	}
	int a, b;
	rip(i, m, 0) {
		cin >> cost[i] >> b;
		rip(j, b, 0) {
			cin >> a;
			da[i] += change[a - 1];
		}
	}
	int gg = change[n];
	vector<vector<int>> dp(m + 1, vector<int>(gg, INT_MAX/2));
	dp[0][0] = 0;
	rip(i, m, 0) {
		rip(j, gg, 0) {
			dp[i + 1][j] = dp[i][j];
		}
		rip(j, gg, 0) {
			dp[i + 1][j | da[i]] = min(dp[i][j]+cost[i], dp[i+1][j|da[i]]);
		}
	}
	if (dp[m][gg - 1] == INT_MAX / 2) {
		cout << -1 << endl;
		return 0;
	}
	cout << dp[m][gg - 1] << endl;
}

Measured memory_bytes: 16384
import sys
sys.setrecursionlimit(2<<28)

h, w = [int(i) for i in input().split()]
g = [list(input()) for _ in range(h)]
MOD = 10**9 + 7


def dfs(y, x):
    if not (0 <= y < h and 0 <= x < w):
        return 0
    elif g[y][x] == "#":
        return 0
    elif y == h - 1 and x == w - 1:
        return 1
    elif isinstance(g[y][x], int):
        return g[y][x]
    else:
        ret = 0
        for dy, dx in ((1, 0), (0, 1)):
            ret += dfs(y+dy, x+dx) % MOD
            ret %= MOD
        ret %= MOD
        g[y][x] = ret
        return ret


print(dfs(0, 0))


Measured memory_bytes: 173524
// finish date: 2019/2/28

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


//足し算
int add(int a, int b) {
    return (int) (((ll) a + b + bigmod) % bigmod);
}

//引き算
int sub(int a, int b) {
    return (int) (((ll) a - b + bigmod) % bigmod);
}

//掛け算
int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int main() {
    int N;
    string S;
    cin >> N >> S;
    vi cnt(26, 0);
    rep(i, N) {
        cnt[S[i] - 'a']++;
    }

    int ans = 0;
    rep(i, 26) {
        if (cnt[i] == 0) continue;
        ans = add(ans,mul(ans, cnt[i]));
        ans = add(ans, cnt[i]);
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 512
function main(input){
        const lines = input.split(/\n/);
        const coin500 = parseInt(lines[0]);
        const coin100 = parseInt(lines[1]);
        const coin50 = parseInt(lines[2]);
        const goal = parseInt(lines[3]);
        var count = 0;
        for(var i = 0; i <= coin500; i++){
            for(var j = 0; j <= coin100; j++){
                for(var k = 0; k <= coin50; k++){
                    if(i * 500 + j * 100 + k * 50 === goal){
                        count++;
                    }
                }   
            }
        }
        console.log(count);
    }
    main(require('fs').readFileSync('/dev/stdin','utf-8'));

Measured memory_bytes: 7372
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		
		final int AB = sc.nextInt();
		final int BC = sc.nextInt();
		final int AC = sc.nextInt();
		
		final int area = AB * BC / 2;
		
		System.out.println(area);
	}

}


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

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

    int n;
    cin >> n;


    map<pair<string, int>, int> mp;
    vector<pair<string, int>> A(n);
    for(int i = 0; i < n; i++){
        string s;
        int a;
        cin >> s >> a;
        mp[{s, -a}] = i + 1;
        A[i] = {s, -a};
    }

    for(auto x : mp){
        cout << x.second << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a[5];
    int ans=0;
    for(int i=0;i<5;i++)
    {
    	cin>>a[i];
    }
    for(int i=0;i<5;i++)
    {
    	if(a[i]==0)
        {
        	ans=i+1;
        	break;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main()
{
    map<char, int> count;

    string str;
    while( getline(cin, str) )
    {
        for(size_t i = 0; i < str.length(); i++)
        {
            if(isupper(str[i])){ str[i] = tolower(str[i]); }
            count[str[i]]++;
        }
        
    }

    for(char c = 'a'; c <= 'z'; c++)
    {
        cout << c << " : " << count[c] << endl;
    }

    return 0;
}

Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); 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 (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    ll n; cin >> n;
    ll k; cin >> k;
    ll h[100000]; for(ll i=0; i<n; i++) cin >> h[i];
    ll dp[100000]; for(ll i=0; i<100000; i++) dp[i] = INF;

    dp[0] = 0;
    for(ll i=1; i<n; i++){
        
        for(ll j=1; j<=k; j++){
            if (i-j<0) continue;
            //cout << "i:" << i <<",j:" << j << endl;
            chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }

    cout << dp[n-1] << endl;


    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MAX 100000
typedef long long ll;
typedef pair<ll,int> P;

int check[110000];
ll dp[110000];

int main(){
  int W,H,x,y,ans;
  cin>>W>>H>>x>>y;
  if(2*x==W && 2*y==H) ans=1;
  else ans=0;
  cout<<(double)W*H/2<<" "<<ans<<endl;
}


Measured memory_bytes: 256