akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict
A, B, C, D, E, F = [int(x) for x in input().split()]
A *= 100
B *= 100
d = defaultdict(lambda: False)
d2 = defaultdict(lambda: False)
dd2 = defaultdict(lambda: False)

ret = [0, min(A, B), 0]

def dp2(w, s):
  global ret
  total_weight = w + s
  if dd2[(w, s)] != False:
    return d2[(w, s)]
  else:
    dd2[(w, s)] = True
  if (s / w) > E / 100:
    d2[(w, s)] = 0
    return 0
  else:
    d2[(w, s)] = 100 * s / (s + w)
    if d2[(w, s)] > ret[0]:
      ret = [d2[(w, s)], w + s, s]
  if total_weight + C <= F:
    dp2(w, s + C)
  if total_weight + D <= F:
    dp2(w, s + D)
  
def dp(w):
  if d[w]:
    return 0
  dp2(w, 0)
  d[w] = True
  if w + A <= F:
    dp(w + A)
  if w + B <= F:
    dp(w + B)
  return 0

dp(min(A, B))
print(ret[1],ret[2])

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

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    
    bool ans = false;
    for (int i = a; i <= b; i++) {
        if (i % k == 0)
            ans = true;
    }
    
    if (ans)
        cout << "OK";
    else
        cout << "NG";
}


Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
"""
B - Exponential
https://beta.atcoder.jp/contests/abc097/tasks/abc097_b

"""
import sys
from sys import stdin
input = stdin.readline


def solve(X):
    ans = 1
    for i in range(1, X+1):
        for j in range(2, X+1):
            t = i**j
            if t <= X:
                ans = max(ans, t)
            else:
                break
    return ans


def main(args):
    X = int(input())
    ans = solve(X)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
from decimal import Decimal

n, k = map(int, input().split())
p = list(map(int, input().split()))
p = list(map(lambda x: x+1, p))

cur = sum(p[:k])
res = cur

for i in range(k, n):
    cur += p[i] - p[i-k]
    res = max(res, cur)

d = Decimal(res.numerator) / Decimal(2*res.denominator)
print(d)


Measured memory_bytes: 27460
Q = int(input())
INF = 10 ** 9

queries = []
for _ in range(Q):
    queries.append(input())

from bisect import insort_left
from heapq import heappush, heappop

absum, bsum, c = 0, 0, 0
# left, right = -INF, INF
lefts, rights = [INF], [INF]
for query in queries:
    if query[0] == '2':
        # absum = sum(abs(a - ary[(c-1)//2]) for a in ary)
        # absum = asum - (c//2 + 1) * ary[(c-1)//2]
        # print(' '.join(map(str, (ary[(c-1)//2], absum + bsum))))
        # print(str(ary[(c-1)//2]) + ' ' + str(absum + bsum))
        print(-lefts[0], absum + bsum)
    else:
        _, a, b = map(int, query.split())
        if c % 2 == 0:
            if -lefts[0] <= a <= rights[0]:
                heappush(lefts, -a)
                heappush(rights, a)
                absum += 0
            elif a < -lefts[0]:
                heappush(lefts, -a)
                heappush(rights, -lefts[0])
                absum += -lefts[0] - a
            else:
                heappush(rights, a)
                heappush(lefts, -rights[0])
                absum += a - rights[0]
        else:
            if a < -lefts[0]:
                absum += -lefts[0] - a
                heappop(lefts)
                heappush(lefts, -a)
            else:
                absum += a - rights[0]
                heappop(rights)
                heappush(rights, a)
        # left, right = ary[(c-1)//2], ary[c - (c-1)//2 - 1]        
        bsum += b
        c += 1


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

using namespace std;

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

	int n, l;
	cin >> n >> l;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s.begin(), s.end());
	for (string &st : s) {
		cout << st;
	}
	cout << '\n';

	return 0;
}



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

int main() {
    int n, x,y, a[20],p, q, ans=0, count=0;
    cin >> n;
    vector<vector<pair<int, int>>> data(15, vector<pair<int, int>>(15));
    pair<int, int> u;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        for(int j=0; j<a[i]; j++) {
            cin >> x >> y;
            data.at(i).at(j)=make_pair(x, y);
        }
    }
    for(int tmp=0; tmp<(1<<n); tmp++) {
        bitset<15> s(tmp);
        bool flag1=false;
        bool flag2=false;
        for(int i=0; i<n; i++) { 
            if(s[i]==1) {
                for(int j=0; j<a[i]; j++) {
                    u=data.at(i).at(j);
                    p=u.first;
                    q=u.second;
                    if(s[p-1] != q) {
                        flag1=true;
                        break;
                    }
                }
            }
            if(flag1) {
                flag2=true;
                break;
            }
            
        }
        if(!(flag2))  {
            count=s.count();
            ans=max(ans, count);
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
// AOJ Volume 1 Problem 0106

// A 200g \380  1000g \1520
// B 300g \550  1200g \1870
// C 500g \850  1500g \2244


#include <stdio.h>

int min_price;

void buy(int soba, int price)
{
	if (price > min_price){
		return;
	}
	
	if (soba < 0){
		return;
	}
	if (soba == 0){
		if (min_price > price){
			min_price = price;
		}
		return;
	}
	
	buy(soba - 1500, price + 2244);
	buy(soba - 1200, price + 1870);
	buy(soba - 1000, price + 1520);
	buy(soba -  500, price +  850);
	buy(soba -  300, price +  550);
	buy(soba -  200, price +  380);
}

int main(void)
{
	int soba;
	
	while (1){
		scanf("%d", &soba);
		if (soba == 0){
			break;
		}
		
		min_price = 99999;
		buy(soba, 0);
		
		printf("%d\n", min_price);
	}

	return (0);
}

Measured memory_bytes: 408
object Main extends App {
  import scala.io.StdIn._

  val n = readInt()
  val perm = readLine.trim.split(' ').map(_.toInt)
  println(
    (1 until n - 1).count(i => perm(i) < math.max(perm(i + 1), perm(i - 1)) && perm(i) > math.min(perm(i + 1), perm(i - 1)))
  )
}

Measured memory_bytes: 27084
#include <iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#define ll long long
using namespace std;
int main(void){
    // Your code here!
ll n,ans=0;
cin>>n;
map<ll,ll> mp;
for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    mp[a]++;
   // cout<<mp[a]<<endl;
}

for(auto it=mp.begin();it!=mp.end();it++){
   // cout<<it->first<<" "<<it->second<<endl;
    if(it->first > it->second)
        ans+=it->second;
    else{
        ans+=(it->second- it->first);
    }
}
    
cout<<ans;    
}


Measured memory_bytes: 9040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//変数//
		String s;		//入力
		String ans;		//出力
		Scanner scan = new Scanner(System.in);
		
		//入力//
		s = scan.next();
		
		scan.close();
		
		//処理//
		ans = s.replaceAll(",", " ");
		
		//結果//
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 10192
#include <iostream>
 
int main() {
	std::string c, res;
  
  	std::cin >> c;
  
  if (c=="a" || c=="i" || c=="u" || c=="e" || c=="o" ) {
  	res = "vowel";
  } else {
    res = "consonant";
  }
  
  std::cout << res << std::endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int DP[3005][3005],s1,s2;
string a,b;
int dp(int i,int j)
{
	if(i==s1||j==s2)return 0;
	else if(DP[i][j]>-1)return DP[i][j];
	else
	{
		int best=0;
		if(a[i]==b[j])
		{
			best=1+dp(i+1,j+1);
		}
		else
		{
			best=max(dp(i+1,j),dp(i,j+1));
		}
		return DP[i][j]=best;
	}
}
void backtrack(int i,int j)
{
	if(i==s1||j==s2)
	{
		return ;
	}
	else
	{
		int best=0;
		if(a[i]==b[j])
		{
			cout<<a[i];
			backtrack(i+1,j+1);
		}
		else
		{
			if(DP[i+1][j]>DP[i][j+1])
			{
				backtrack(i+1,j);
			}
			else
			{
				backtrack(i,j+1);
			}
		}
	}
}
int main()
{
	cin>>a>>b;
	s1=a.length();
	s2=b.length();
	for(int j=0;j<s1;j++)
	{
		for(int i=0;i<s2;i++)
		{
			DP[j][i]=-1;
		}
	}
	dp(0,0);
	backtrack(0,0);
	cout<<endl;
}

Measured memory_bytes: 35712
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, T;
	int sum = 0;
	vector<int> t;
	
	cin>>N>>T;
	
	t.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>t[i];
	}
	
	sort(t.begin(), t.end());
	
	for(int i = 0, now = -INF; i < N; i++){
		
		if(now <= t[i]){
			sum += T;
			now = t[i]+T;
		} else {
			sum += t[i] + T - now;
			now = t[i]+T;
		}
	}
	
	cout<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 1792
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main{
	int W,H,N,a,b;
	public void solve() {
		W = nextInt();
		H = nextInt();
		N = nextInt();

		int ans = 0;
		a = 1;
		b = 1;
		for(int i = 0;i < N;i++){
			int p = nextInt();
			if(p==0)a++;
			else b++;

			if(a <= W-1){
				if(a == b)ans++;
			}else if(a == W){
				continue;
			}else if(W + 1 <= a && a <= W + H - 2){
				if(a - 2 == b)ans++;
			}else if(a == W + H - 2 + 1){
				continue;
			}else if(a >= W + H){
				if(a - 4 == b)ans++;
			}
		}
		out.println(ans);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 24448
#include<iostream>


using namespace std;

int main(){
  int A,B;

  cin >> A;
  cin >> B;

  if(A==1 && B == 1){
    cout << "Draw";
  }else if(A == 1 && B != 1){
    cout << "Alice";
  }else if(A != 1 && B == 1){
    cout << "Bob";
  }else{
    if(A>B){
      cout << "Alice";
    }else if (A == B){
      cout << "Draw";
    }else{
      cout << "Bob";
    }
  }
  return 0;
}

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

typedef long long ll;

const int N = 1e5;
int n, res;
int dp[N], a[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (i > 0 && a[i] <= a[i - 1]) {
            dp[i] = dp[i - 1] + 1;
            res = max(res, dp[i]);
        }
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 4384
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
int v;
map<int,int> even;
map<int,int> odd;
pair<int,int> evenArray[100010];
pair<int,int> oddArray[100010];
int main(){ _;
  int n;cin>>n;
  REP(i,n){
    cin>>v;
    if(i%2==0){
      even[v]++;
    }else{
      odd[v]++;
    }
  }

  if(even.size()==1&&odd.size()==1&&even.begin()->first==odd.begin()->first){
    cout<<n/2<<endl;
    return 0;
  }
  int index=0;
  for(auto it:even)
    evenArray[index++]=make_pair(it.second,it.first);
  sort(evenArray,evenArray+index,greater<pair<int,int>>());
  index=0;
  for(auto it:odd)
    oddArray[index++]=make_pair(it.second,it.first);
  sort(oddArray,oddArray+index,greater<pair<int,int>>());

  if(evenArray[0].second!=oddArray[0].second)
    cout<<n-(evenArray[0].first+oddArray[0].first)<<endl;
  else
    cout<<n-max(evenArray[0].first+oddArray[1].first,
		evenArray[1].first+oddArray[0].first)<<endl;
}


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

typedef long long ll;
ll mod = 1000000007;

int main() {
    cout << fixed << setprecision(8);
    double a,b,x; cin >> a >> b >> x;
    double ans;
    if (x <= a * a * b / 2) {
        double alp = x * 2 / (a * b);
        double res =  M_PI / 2 - atan(alp / b); 
        ans = res * 180 / M_PI;
    } else {
        x -= a * a * b / 2;
        double alp = x * 2 / (a * a);
        double res = atan((b - alp) / a);
        ans = res * 180 / M_PI;
    }
    cout << ans << "\n";
}

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

#define FOR(i,x,y) for(int i = (x);i < (y);i++)
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) (int) (x).size()
typedef long long ll;

int A,B;

int main()
{
	scanf("%d%d",&A,&B);
	if(A <= 0 && B >= 0){
		printf("Zero\n");
		return 0;
	}
	if(A > 0 && B > 0){
		printf("Positive\n");
		return 0;
	}
	if(A < 0 && B < 0){
		if((B - A + 1) % 2 == 0){
			printf("Positive\n");
		}
		else{
			printf("Negative\n");
		}
	}

	return 0;
}


Measured memory_bytes: 256
from collections import Counter
def get_primes(targ):
    '''
    素因数分解
    '''
    primes = Counter()

    target = targ
    i = 2
    cnt = 0

    while (i * i) <= target:
        while(target % i) == 0:
            target //= i
            primes[i] += 1
        i += 1

    if target > 1:
        primes[target] += 1

    return primes;

def ABC142D_DisjointSetOf():
    A, B = list(map(int, input().strip().split()))

    prA = get_primes(A)
    prB = get_primes(B)

    ans = 0
    for i in prA.keys():
        if i in prB.keys():
            ans += 1

    print(ans + 1)



def main():
    ABC142D_DisjointSetOf()

if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}


	public void run() {
		Scanner sc = new Scanner(System.in);
		long k = sc.nextLong();

		int n = 50;

		long sum = k/n;
		long amari = k%n;

		long a[] = new long[50];
		for(int i=0; i<n; i++) {
			a[i]=i+sum;
		}
		for(int i=0; i<amari; i++) {
			a[n-1-i]++;
		}
		System.out.println(n);
		for(int i=0; i<n; i++) {
			System.out.print(a[i] + (i==n-1 ? "\n" : " "));
		}
		sc.close();
	}


}



Measured memory_bytes: 23124
// 1 21

#include <iostream>

using namespace std;

string itoa(int n){
	string ret = "";

	while (n != 0){
		ret = (char)(n%10 + '0') + ret;
		n /= 10;
	}
	return ret;
}

int main(){
	string a, b;
	cin >> a >> b;

	string ab = a + b;

	for (int i = 1; ; ++i){
		if (i*i > 100100)
			break;

		string square = itoa(i*i);

		// cout << square << endl;

		if (ab == square){
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <algorithm>
#include <vector>
#include <bitset>
#include <map>
#include <stack>

#define REP(i, b) for (int i = 0 ; i < b ; i++ )
typedef long long ll;
using namespace std;

int main() {
    int N;
    int M;
    cin >> N;
    vector<vector<int>> graph(N);
    map<pair<int, int>, int> edge_index;
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
        edge_index[make_pair(a, b)] = i;
        edge_index[make_pair(b, a)] = i;
    }
    cin >> M;
    vector<bitset<50>> edges;
    REP(i, M) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        vector<int> prev(N, -1);
        prev[v] = 0;
        stack<int> dfs;
        dfs.push(v);
        while (!dfs.empty()) {
            int now = dfs.top();
            dfs.pop();
            for (auto nxt: graph[now]) {
                if (prev[nxt] == -1) {
                    dfs.push(nxt);
                    prev[nxt] = now;
                }
            }
        }
        int now = u;
        bitset<50> pathBit;
        while (now != v) {
            int p = prev[now];
            int ind = edge_index[make_pair(p, now)];
            pathBit[ind] = true;
            now = p;
        }
        edges.push_back(pathBit);
    }
    ll ans = 0;
    for (ll i = 1; i < (1L << M); i++) {
        int cnt = 0;
        bitset<50> tmp;
        for (int v = 0; v < M; v++) {
            if (1L << v & i) {
                cnt += 1;
                tmp |= edges[v];
            }
        }
        if (cnt % 2 == 0) {
            ans -= 1L << (N - 1 - tmp.count());
        } else {
            ans += 1L << (N - 1 - tmp.count());
        }
    }
    cout << (1L<<(N-1))- ans << endl;
}


Measured memory_bytes: 256
// ABC088D Grid Repainting
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String[] masu = new String[h];
        for (int i = 0; i < h; i++) {
            masu[i] = sc.next();
        }
        // それぞれの場所の移動回数最小値を出していく
        int[][] cnt = new int[h + 2][w + 2];
        int siro = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (masu[i].charAt(j) == '#') {
                    cnt[i + 1][j + 1] = -1;
                } else {
                    cnt[i + 1][j + 1] = 0;
                    siro++;
                }
            }
        }
        // 枠の操作
        for (int i = 0; i < w + 2; i++) {
            cnt[0][i] = -1;
            cnt[h + 1][i] = -1;
        }
        for (int i = 0; i < h + 2; i++) {
            cnt[i][0] = -1;
            cnt[i][w + 1] = -1;
        }
        cnt[1][1] = 1;

        int dx[] = { 0, 1, 0, -1 };
        int dy[] = { 1, 0, -1, 0 };
        point pos = new point(1, 1);
        LinkedList<point> queue = new LinkedList<point>();
        queue.add(pos);
        /*
         * for (int i = 0; i < h + 2; i++) { for (int j = 0; j < w + 2; j++) {
         * System.out.print(cnt[i][j]); System.out.print("  "); } System.out.println();
         * }
         */
        while (!queue.isEmpty()) {
            point nowpos = queue.removeFirst();
            for (int i = 0; i < 4; i++) {
                int nx = nowpos.x + dx[i];
                int ny = nowpos.y + dy[i];
                if (cnt[ny][nx] == 0) {
                    cnt[ny][nx] = cnt[nowpos.y][nowpos.x] + 1;
                    point npos = new point(nx, ny);
                    queue.add(npos);
                }
            }
        }
        if (cnt[h][w] != 0 && cnt[h][w] != -1) {
            System.out.println(siro - cnt[h][w]);
        } else {
            System.out.println(-1);
        }
    }
}

class point {
    public int x;
    public int y;

    point(int x, int y) {
        this.x = x;
        this.y = y;
    }
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{

	int X;
	cin >> X;
	for (int x = -200; x <= 200;x++) {
		for (int y = -200; y <= 200;y++) {
			if ((ll)pow(x,5)-(ll)pow(y,5)==X) {
				doublece(x, y);
				return 0;
			}
		}
	}
    return 0;
}



Measured memory_bytes: 3976
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
long long mod = 1000000007;
long long modpow(long long m,long long n){
    long long res = 1;
    if(n > 0){
        res = modpow(m,n / 2);
        if(n % 2 == 0){
            res = (res * res) % mod;
        }
        else{
            res = (((res * res) % mod) * m) % mod;
        }
    }
    return res;
}

int main(){
  ll k;
  cin >> k;
  string s;
  cin >> s;
  ll size = 0;
  size = s.size();
  ll res = 0;
  vector<ll> fac(2000001);
  fac[0] = 1;
  for(int i = 1;i < 2000001;i++){
    fac[i] = fac[i - 1] * i;
    fac[i] %= mod;
  }
  ll sizecon = 0;
  sizecon = modpow(fac[size - 1],mod - 2);
  for(int i = size - 1;i <= k + size - 1;i++){
    ll now = 1;
    now *= fac[i];
    now *= sizecon,now %= mod;
    now *= modpow(fac[i - size + 1],mod - 2),now %= mod;
    now *= modpow(25,i + 1 - size),now %= mod;
    now *= modpow(26,size + k - i - 1),now %= mod;
    res += now;
    //cout << i << " " << now << endl;
    res %= mod;
  }
  cout << res << endl;
}

Measured memory_bytes: 19932
n, m = (int(i) for i in input().split())
mise = []
for i in range(n):
  tmp = [int(i) for i in input().split()] 
  mise.append(tmp)
mise.sort()
hon = 0
kin = 0
for i in range(n):
  nokori = m - hon
  if nokori > mise[i][1]:
    hon += mise[i][1]
    kin += mise[i][0] * mise[i][1]
  else:
    hon += nokori
    kin += mise[i][0] * nokori
    break
print(kin)
  
  
#一番安い店で買う
#足りたら終わり
#次に安い店で買う

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> b(n);
    rep(i,n) cin >> b[i];
    vector<int> c(n-1);
    rep(i,n-1) cin >> c[i];
    int ans = 0;
    rep(i,n) --a[i];
    rep(i,n) {
        ans += b[a[i]];
    }
    rep(i,n-1){
        if(a[i]==a[i+1]-1){
            ans+=c[a[i]];
        }
    }
    cout << ans << endl;
    return 0;
}

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

int ans[SIZE][SIZE];

void solve(int n,int m)
{
	if(n<m)
	{
		solve(n,n);
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				ans[i][j]=ans[i][j%n];
			}
		}
	}
	else if(n>m)
	{
		solve(m,m);
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				ans[i][j]=ans[i%m][j];
			}
		}
	}
	else
	{
		if(n==1) ans[0][0]=0;
		else
		{
			solve(n/2,m/2);
			for(int i=0;i<n;i++)
			{
				for(int j=0;j<m;j++)
				{
					if(i<n/2||j<m/2) ans[i][j]=ans[i%(n/2)][j%(m/2)];
					else ans[i][j]=1-ans[i%(n/2)][j%(m/2)];
				}
			}
		}
	}
}
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	solve(1<<n,1<<m);
	for(int i=0;i<(1<<n)-1;i++)
	{
		for(int j=0;j<(1<<m)-1;j++)
		{
			printf("%d",(ans[i+1][j+1]^ans[i][j]^ans[i+1][j]^ans[i][j+1]));
		}
		puts("");
	}
	return 0;
}
	

Measured memory_bytes: 9472
import itertools

H,W,K = input().split()
H,W,K = int(H),int(W),int(K)

data = list()
for i in range(H):
    data.append(input())

list_H = [i for i in range(1,H+1)]
list_W = [i for i in range(1,W+1)]

taple_list_H = list()
taple_list_W = list()

for n in range(H+1):
    for x in itertools.combinations(list_H, n):
        taple_list_H.append(x)

for n in range(W+1):
    for x in itertools.combinations(list_W, n):
        taple_list_W.append(x)


res = 0
count = 0

for num_H in taple_list_H:
    copied = data.copy()
    for num in num_H:
        copied[num-1] = '.' * W


    for num_W in taple_list_W:
        copied2 = copied.copy()

        for num in num_W:
            for i in range(H):
                tmp = copied2[i][:num-1] + '.' + copied2[i][num:]
                copied2[i] = tmp
    
        for i in range(H):
            for j in range(W):
                if copied2[i][j] == '#':
                    count += 1
            
        if count == K:
            res += 1
    
        count = 0

print(res)

Measured memory_bytes: 9264
#include<bits/stdc++.h>
#include<vector>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MAX_N = 200000;
const int MOD = 1000000007;

int N;
int A[MAX_N];
ll B[MAX_N + 1];

void solve();

int main(){

    B[0] = 0;
    cin >> N;
    for(int i=0; i<N ; i++){
       cin >> A[i];
       B[i + 1] = B[i] + A[i]; 
    }

    solve();

    return 0;
}

void solve(){

    long ans = 0;

    // iについて全探索する
    for(int i=0; i<N; i++){
        //累積和を使って A[i+1] + ... + A[N] を求める
        ll sum = (B[N] - B[i+1]) % MOD;

        ans += A[i] * sum;
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 5988
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    if A[i]<B[i]:
        B[i]-=A[i]
        ans+=A[i]
        A[i] = 0
        if A[i+1]<B[i]:
            ans+=A[i+1]
            A[i+1] = 0
            
        else:
            ans+=B[i]
            A[i+1]-=B[i] 
    else:
        ans+=B[i]
print(ans)
            

Measured memory_bytes: 18624
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;

    if (a > b)
    {
        cout << (2 * a - 1) << endl;
    }
    else if (a == b)
    {
        cout << (2 * a) << endl;
    }
    else
    {
        cout << (2 * b - 1) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define TE 2e6+5
using namespace std;
using ll = long long;
using ldb = long double;

long long mypow(long long k, long long n) {
	long long temp = 1;

	k = k % DIV;
	while (n) {
		if (n % 2) temp = temp * k % DIV;
		k = k * k % DIV;
		n = n / 2;
	}
	return temp % DIV;
}

ll mmod(ll a, ll b) {
	if (a < 0)a += DIV; if (b < 0) b += DIV;
	a %= DIV, b %= DIV;
	return a * b % DIV;
}

int main() {
	ll r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;
	vector<ll> f(TE + 1), invf(TE + 1);
	f[0] = 1, invf[0] = 1;
	for (int i = 1; i <= TE; i++) {
		f[i] = mmod(f[i - 1], i);
		invf[i] = mypow(f[i], DIV - 2);
		//cout << i << endl;
	}

	ll ans = 0;
	for (int k = r1; k <= r2; k++) {
		ll temp = mmod(mmod(f[k + c2 + 1], invf[c2]), invf[k + 1]);
		temp -= mmod(mmod(f[k + c1], invf[c1 - 1]), invf[k + 1]);
		temp += DIV;
		temp %= DIV;
		ans = (ans + temp) % DIV;
		//cout << ans << endl;
	}
	cout << ans << endl;
}



Measured memory_bytes: 34408
from collections import defaultdict
import heapq

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

es = [[] for _ in range(N)]
counts = defaultdict(int)
for i in range(M):
    x,y,z = map(int, input().split())
    es[x-1].append(y-1)
    es[y-1].append(x-1)
    counts[x-1] += 1
    counts[y-1] += 1


q = []

for k in counts.keys():
    heapq.heappush(q, (-counts[k], k))

visited = [False] * N
stack = []
cnt = 0
while q:
    _, curr = heapq.heappop(q)
    if visited[curr]:
        continue
    cnt += 1
    stack.append(curr)
    while stack:
        ns = stack.pop()
        if visited[ns]:
            continue
        visited[ns] = True
        for nns in es[ns]:
            if not visited[nns]:
                stack.append(nns)

print(visited.count(False) + cnt)

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

int main() {
    int64_t N, D;
    cin >> N >> D;
    D = D * D;
    int ans = 0;
    for(int i = 0; i < N; ++i) {
        int64_t x, y;
        cin >> x >> y;
        if(x*x + y*y <= D) ans++;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3628
N = int(input())
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

a = make_divisors(N)
if len(a)%2 == 1:
  print(2*int(math.sqrt(N))-2)
if len(a)%2 == 0:
  b = a[int(len(a)/2)-1]
  c = a[int(len(a)/2)]
  print(b+c-2)

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

int main() {
  string s;
  cin >> s;
  bool c = false,f = false;
  rep(i,0,s.size()){
    if(s[i] == 'C') c = true;
    if(s[i] == 'F' && c) f = true;
  }
  if(c&&f) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
int n;
string s;
cin >> n >> s;
int x=0;
int ans=0;
for(int i=0;i<n;i++){
    if(s[i]=='I'){
        x++;
        ans=max(ans,x);
    }
    else x--;
}
cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<utility>
#include<cstdio>
#include<map>
#include<vector>
#include<set>
#define pb push_back
#define st first
#define nd second
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long lo;
const int mod=1000000007,N=500005;
lo a,b,c,d,e,g=1,arr[N],h[N];

void solve(){
	cin >> a >> b >> c;
	cout << a+b+c-max(a,max(b,c)) << endl;
}

int main(){
	// freopen("in.txt","r",stdin);
	// freopen("out.txt","w",stdout);
	// cin >> g;
	while(g--) solve();
}

Measured memory_bytes: 3608
S = input()
m = 0
count = 0
for s in S:
  if "A" in s:
    count += 1
  elif "C" in s:
    count += 1
  elif "G" in s:
    count += 1
  elif "T" in s:
    count += 1
  else:
    count = 0
  m = max(m, count)
print(m)


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

typedef long long ll;
typedef vector< ll > vi;
typedef vector< vi > vvi;
typedef pair< ll,ll > ii;
#define pb push_back
#define mp make_pair
#define all(c) ((c).begin(), (c).end)
#define sz(a) int((a).size())
#define tr(c,i) for(typeof(c).begin() i = (c).begin();it!=(c).end();it++)
#define present(c,x) ((c).find(x)!=(c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end)
#define cp(s,c) copy(all(c),(s).begin())
// note that data is copied from C --> S's reference

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

    int n, m;
    cin >> n >> m;
    int l = 1, r = m + 1;
    while (l < r)
        cout << l++ << ' ' << r-- << endl;
    l = m + 2, r = m * 2 + 1;
    while (l < r)
        cout << l++ << ' ' << r-- << endl; 
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

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

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/

int main(){
    ll N;
    cin >> N;
    string S;
    cin >> S;
    vector<ll> east(N + 1);
    east[0] = 0;
    rep(i,N){
        if(S[i] == 'E')east[i + 1]++;
    }
    rep(i,N){
        east[i + 1] += east[i];
    }
    ll ans = INF;
    for(ll i = 1;i <= N;i++){
        ans = min(ans,i - 1 - east[i - 1] + east[N] - east[i]);
    }
    cout << ans << endl;
}

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

const int MAX=10005;
int state[MAX],N,D[MAX];
vector<pair<int,int>> S[MAX];
priority_queue<pair<int,int>> Q;

void dijkstra(){
    int cnt=1;
    for(int i=0;i<N;i++){
        state[i]=0;
        D[i]=10000000;
    }
    state[0]=1;
    D[0]=0;
    for(int i=0;i<S[0].size();i++){
        Q.push(make_pair(-S[0][i].second,S[0][i].first));
        D[S[0][i].first]=min(D[S[0][i].first],D[0]+S[0][i].second);
    }
    while(1){
        int a=Q.top().second;
            if(state[a]==0){
            Q.pop();
            state[a]=1;
            for(int i=0;i<S[a].size();i++){
                if(state[S[a][i].first]==0){
                    Q.push(make_pair(-(D[a]+S[a][i].second),S[a][i].first));
                    D[S[a][i].first]=min(D[S[a][i].first],D[a]+S[a][i].second);
                }
            }
                cnt++;
        }
        else Q.pop();
        if(cnt==N) break;
    }
    return;
}


int main(){

    cin>>N;
    for(int i=0;i<N;i++){
        int l,a;cin>>l>>a;
        for(int j=0;j<a;j++){
            int b,c;cin>>b>>c;
            S[i].push_back(make_pair(b,c));
        }
    }
    dijkstra();
    for(int i=0;i<N;i++){
        cout<<i<<" "<<D[i]<<endl;
    }
}



Measured memory_bytes: 9844
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  map<string,int> m;
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int t,x;
    string s;
    cin>>t>>s;
    if(t==0) cin>>x;
    if(t==0) m[s]=x;
    if(t==1) cout<<m[s]<<endl;
    if(t==2) m.erase(s);
  }
  return 0;
}



Measured memory_bytes: 27764
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    while(N != 0){
        vector<vector<pair<ll,ll>>> G(N);
        for(int i=0; i<N; i++){
            int k;
            cin >> k;
            for(int j=0; j<k; j++){
                int a,b;
                cin >> a >> b;
                G[i].emplace_back(a,b);
            }
        }
        ll dp[N+1][15][N];
        for(int i=0; i<N; i++){
            for(int j=0; j<G[i].size(); j++){
                for(int k=0; k<=M; k++){
                    dp[i][j][k] = INF; 
                }
            }
        }
        for(int i=0; i<G[0].size(); i++){
            dp[0][i][0] = 0;
        }
        for(int i=0; i<G[1].size(); i++){
            dp[1][i][1] = 0;
        }
        for(int i=0; i<N-1; i++){
            for(int j=0; j<G[i].size(); j++){
                for(int k=0; k<=M; k++){
                    for(int l=0; l<G[i+1].size(); l++){
                        ll cost = G[i][j].second + G[i+1][l].second;
                        ll sa = abs(G[i][j].first - G[i+1][l].first);
                        chmin(dp[i+1][l][k],dp[i][j][k]+cost*sa);
                    }
                    if(i+2<N and k<M){
                        for(int l=0; l<G[i+2].size(); l++){
                            ll cost = G[i][j].second + G[i+2][l].second;
                            ll sa = abs(G[i][j].first - G[i+2][l].first);
                            chmin(dp[i+2][l][k+1],dp[i][j][k]+cost*sa);
                        }
                    }
                }
            }
        }
        // for(int i=0; i<N; i++){
        //     for(int j=0; j<G[i].size(); j++){
        //         for(int k=0; k<=M; k++){
        //             cout << "check:" << i << " " << j << " " << k << " " << dp[i][j][k] << enld;
        //         }
        //     }
        // }
        ll ans = INF;
        for(int i=0; i<G[N-2].size(); i++){
            for(int j=0; j<M; j++){
                chmin(ans,dp[N-2][i][j]);
            }
        }
        for(int i=0; i<G[N-1].size(); i++){
            for(int j=0; j<=M; j++){
                chmin(ans,dp[N-1][i][j]);
            }
        }
        cout << ans << enld;
        cin >> N >> M;
    }
    return 0;
}



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

int main(){
  int L;
  cin >> L;

  vector<int> A(L);
  for(auto& x: A){
    cin >> x;
  }

  // sum of A[0: i)
  vector<long long> A_sum(L + 1), A_turn_sum(L + 1), A_go_sum(L + 1);
  for(int i = 0; i < L; i++){
    A_sum[i + 1] = A_sum[i] + A[i];
    
    A_turn_sum[i + 1] = A_turn_sum[i];
    if(A[i] == 0){
      A_turn_sum[i + 1] += 2;
    }else{
      A_turn_sum[i + 1] += A[i] % 2;
    }

    A_go_sum[i + 1] = A_go_sum[i] + ((A[i] + 1) % 2);
  }

  vector<int> best_left(L + 1), best_right(L + 1, L);
  for(int s = 1; s <= L; s++){
    if(A_sum[best_left[s - 1]] + (A_turn_sum[s] - A_turn_sum[best_left[s - 1]]) <= A_sum[s]){
              best_left[s] = best_left[s - 1];      
    }else{
      best_left[s] = s;
    }
  }
  for(int e = L - 1; e >= 0; e--){
    if((A_sum[L] - A_sum[best_right[e + 1]]) + (A_turn_sum[best_right[e + 1]] - A_turn_sum[e]) <= (A_sum[L] - A_sum[e])){
      best_right[e] = best_right[e + 1];
    }else{
      best_right[e] = e;
    }
  }
  /*
  for(int i = 0; i <= L; i++){
    cout << "i: " << i << ", best_left: " << best_left[i] << ", best_right: " << best_right[i] << endl;
  }
  */

  long long ans = 1e18;
  int best_end = L;
  for(int s = L; s >= 0; s--){
    long long best_end_cost =
      A_sum[best_left[s]] +
      (A_turn_sum[s] - A_turn_sum[best_left[s]]) +
      (A_go_sum[best_end] - A_go_sum[s]) +
      (A_turn_sum[best_right[best_end]] - A_turn_sum[best_end]) +
      (A_sum[L] - A_sum[best_right[best_end]]);
    long long start_end_equal_cost =
      A_sum[best_left[s]] +
      (A_turn_sum[best_right[s]] - A_turn_sum[best_left[s]]) +
      (A_sum[L] - A_sum[best_right[s]]);
    if(start_end_equal_cost <= best_end_cost){
      best_end = s;
    }
    //cout << "start: " << s << ", cost: " << min(start_end_equal_cost, best_end_cost) << endl;
    //cout << start_end_equal_cost << endl;
    //cout << best_end << ", " << best_end_cost << endl;
    ans = min(ans, min(start_end_equal_cost, best_end_cost));
  }
  cout << ans << endl;
}


Measured memory_bytes: 7296
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int N;
vector<string> va;
int num[26];

int main(){
	for(;;){
		cin >> N;
		if(N == 0) break;
		va.resize(N);
		for(int i = 0; i < N; i++) cin >> va[i];
		fill(num, num + 26, -1);
		int cnt = 0;
		vector<int> vb;
		vector<vector<int> > vc(N);
		for(int i = 0; i < 10; i++) vb.push_back(i); 
		for(int i = 0; i < N; i++){
			for(int j = 0; j < va[i].length(); j++){
				if(num[va[i][j] - 'A'] == -1){
					num[va[i][j] - 'A'] = cnt;
					vc[i].push_back(cnt);
					cnt++;
				}else{
					vc[i].push_back(num[va[i][j] - 'A']);
				}
			}
		}
		int res = 0;
		do{
			bool flag = true;
			int sum1 = 0, sum2 = 0;
			for(int i = 0; i < N; i++){
				if(vb[vc[i][0]] == 0 && vc[i].size() > 1) flag = false;
				int num2 = 0;
				for(int j = 0; j < vc[i].size(); j++){
					num2 *= 10;
					num2 += vb[vc[i][j]];
				}
				if(i != N - 1) sum1 += num2;
				else sum2 = num2;
			}
			if(sum1 == sum2 && flag) res++;
		}while(next_permutation(vb.begin(), vb.end()));
		for(int i = 1; i <= 10 - cnt; i++) res /= i;
		cout << res << endl;
		va.clear();
	}
	return 0;
}


Measured memory_bytes: 3072
#include <bits//stdc++.h>
using namespace std;
int main() {
	int n,q,k,i; cin >> n;
	vector<int> a(n);
	for (int& i : a) cin >> i;
	cin >> q;
	for (i = 0; i < q; ++i) {
		cin >> k;
		cout << lower_bound(a.begin(), a.end(), k) - a.begin() << endl;
	}
}


Measured memory_bytes: 3116
#include <iostream>
#include <bits/stdc++.h>
#define int long long
#define sc(x) scanf("%lld",&(x));
#define sci(x) scanf("%d",&(x));
#define si signed
#define P pair<int,int>
#define fi first
#define se second

using namespace std;
int n,m;

si main() {

    sc(n)sc(m)
    int ans = (n)*(n-1)/2+(m)*(m-1)/2;
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math


def main():
  A, B, C, D = map(int, input().split())
  a = math.ceil(C / B)
  b = math.ceil(A / D)

  if b < a:
    print('No')
  else:
    print('Yes')


if __name__ == '__main__':
  main()


Measured memory_bytes: 61992
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        Map<Character, Integer> map = new HashMap<Character, Integer>();
        for (char c = 'a'; c <= 'z'; c++) {
            map.put(c, 0);
        }
        while (input.hasNext()) {
            char[] cs = input.nextLine().toCharArray();
            for (int i = 0; i < cs.length; i++) {
                if ('A' <= cs[i] && cs[i] <= 'Z') cs[i] -= 'A' - 'a';
                if ('a' <= cs[i] && cs[i] <= 'z') map.put(cs[i], map.get(cs[i]) + 1);
            }
        }
        for (char c = 'a'; c <= 'z'; c++) {
            System.out.println(String.format("%c : %d", c, map.get(c)));
        }
    }
}

Measured memory_bytes: 17200
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    string s, t;
    cin >> s >> t;
    if (s[0] == t[2] && s[1]==t[1] && s[2]==t[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    //cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	int n,i,m=0;
	scanf("%d",&n);
    char a[100];
    getchar();
    gets(a);
    for(i=0;i<n-2;i++)
    {
    	if(a[i]=='A'&&a[i+1]=='B'&&a[i+2]=='C')
    	m=m+1;
	}
	printf("%d",m);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

ll a[110];

int main(void){
	int i;

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

	int N;
	cin >> N;
	ll s=0;
	for(i=1;i<=N;i++){
		cin >> a[i];
		s+=a[i];
	}

	ll x=s/N,y=(s+N-1)/N;
	ll A=0,B=0;
	for(i=1;i<=N;i++) A+=(a[i]-x)*(a[i]-x);
	for(i=1;i<=N;i++) B+=(a[i]-y)*(a[i]-y);

	cout << min(A,B) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a[5];
	int i,j,tmp;
	
	scanf("%d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4]);
	for(i=0;i<5;i++)
	{
		for(j=5-1;j>i;j--)
		{
			if(a[i]<a[j])
			{
				tmp=a[i];
				a[i]=a[j];
				a[j]=tmp;
			}
		}
	}
	printf("%d %d %d %d %d\n",a[0],a[1],a[2],a[3],a[4]);

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define ri register int
typedef long long ll; 
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// input a letter
	template <class I>
	inline void get (I &x) {
		for (c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		x = c;
	}
	// input a string
	inline void read (char *s){
		for(c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		for(; c >= 'A' && c <= 'Z'; c = gc()) *++s = c;
		*++s = '\0';
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: gi;
using io :: get;
using io :: read;
using io :: putc;
using io :: print;
const int N=5005;
const ll inf=1e18;
int p[N],f[N],a[N][N];
ll dp[N];
inline int query(ri x1,ri x2,ri y1,ri y2){
	return x1<=x2&&y1<=y2?a[x2][y2]-a[x1-1][y2]-a[x2][y1-1]+a[x1-1][y1-1]:0;
}
int main(){
	ri n,A,B,i,j;
	gi(n);gi(A);gi(B);
	for(i=1;i<=n;++i) gi(p[i]),a[i][p[i]]=1;
	for(i=1;i<=n;++i)
		for(j=1;j<=n;++j)
			a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1];
	p[n+1]=n+1;
	for(i=1;i<=n+1;++i){
		dp[i]=inf;
		for(j=i-1;j>=0;--j)
			if(p[j]<p[i])
				dp[i]=min(dp[i],dp[j]+(ll)A*query(j+1,i-1,p[i]+1,n)+(ll)B*query(j+1,i-1,1,p[i]-1));
	}
	printf("%lld\n",dp[n+1]);
	return 0;
}

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

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

    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++) {
        if(i % 2 == 0) {
            if(s[i] == 'L') {
                cout << "No";
                return 0;
            }
        } else {
            if(s[i] == 'R') {
                cout << "No";
                return 0;
            }
        }

    }
    cout << "Yes";
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    double r;
    cin >> r;
    double a, b;
    a = r * r * M_PI;
    b = 2 * r * M_PI;
    cout << fixed << setprecision(5) << a << ' ' << fixed << setprecision(5) << b << endl;

    return 0;
}


Measured memory_bytes: 3252