akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const long long int MOD = 1000003;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

struct Exam {
	long long int enemy, l, r;
	bool operator <(const Exam&e)const {
		return r * (K - enemy) + l * enemy < e.l*e.enemy + e.r*(K - e.enemy);
	}
	long long int getfull() {
		return r * (K - enemy) + l * enemy;
	}
	long long int get(long long int num) {
		if (num <= enemy) {
			return num * l;
		}
		else return  enemy*l + (num - enemy)*r;
	}
};


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

	cin >> N >> K;
	vector<Exam>exam(N);
	for (auto &i : exam) {
		cin >> i.enemy >> i.l >> i.r;
	}
	long long int ret = 0;
	sort(exam.begin(), exam.end());
	reverse(exam.begin(), exam.end());
	long long box = 0;
	for (auto i : exam) {
		box -= i.l*i.enemy;
	}
	L = -1;
	R = K * N;
	while (R - L > 1) {
		long long int mid = (R + L) / 2;
		long long int sum = box;
		for (int i = 0; i < mid / K; i++) {
			sum += exam[i].getfull();
		}
		if (mid%K) {
			long long int add = 0;
			for (int i = 0; i < N; i++) {
				if (i < mid / K) {
					long long int tmp = exam[mid / K].getfull();
					tmp -= exam[i].getfull();
					tmp += exam[i].get(mid%K);
					add = max(add, tmp);
				}
				else {
					add = max(add, exam[i].get(mid%K));
				}
			}
			sum += add;
		}
		//	cout <<mid<<" "<< sum << endl;
		if (sum < 0)L = mid;
		else R = mid;
	}
	cout << R << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
	double a, b, c, d, e, f;
	while (cin >> a >> b >> c >> d >> e >> f)
		cout << fixed << setprecision(3) << (c * e - b * f) / (a * e - b * d) + 0.00001 << ' ' << (c * d - a * f) / (b * d - a * e) + 0.00001 << endl;
}


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

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S, T;
  int ans;
  ans = 0;
  cin >> S;
  cin >> T;
  rep(i, 3){
    if (S[i] == T[i]) ans += 1;
  }


  cout << ans << endl;

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    void Run()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        string[] s = new string[n];
        var tailA = new HashSet<int>();
        var headB = new HashSet<int>();
        int ab = 0;
        for (int i = 0; i < n; i++)
        {
            s[i] = sc.NextString();
            if (s[i][0] == 'B') headB.Add(i);
            if (s[i][s[i].Length - 1] == 'A') tailA.Add(i);
            for (int j = 1; j < s[i].Length; j++)
                if (s[i].Substring(j - 1, 2) == "AB") ab++;
        }
        var joined = tailA.Intersect(headB).ToList();
        var freeA = tailA.Except(joined).ToList();
        var freeB = headB.Except(joined).ToList();

        int res = 0;
        int a = freeA.Count;
        int b = freeB.Count;
        res += ab;
        if (joined.Count > 0)
        {
            res += Math.Max(joined.Count - 1, 0);
            if (a > 0)
            {
                res++;
                a--;
            }
            if (b > 0)
            {
                res++;
                b--;
            }
        }
        res += Math.Min(a, b);

        Console.WriteLine(res);
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 17248
N=int(input())
T,A=1,1
for _ in range(N):
    t,a = map(int,input().split())
    kt=(T-1)//t + 1
    ka=(A-1)//a + 1
    if ka*t<T:
        k=kt
    elif kt*a<A:
        k=ka
    elif t<a:
        k=kt
    else:
        k=ka
    T=k*t
    A=k*a
print(A+T)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
const int N=2010;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
vector<int>e[N];
int f[N][N],fa[N],g[N];
int D,T;
const int mod=1e9+7;
inline void dfs(int k,int d) {
	if (d>D) D=d,T=k;
	for (int t:e[k]) if (t!=fa[k]) fa[t]=k,dfs(t,d+1);
}
inline void dp(int k,int fa,int d) {
	if (e[k].size()==1)
		for (int i=0;i<=D;i++)
			f[k][D+i]=f[k][D-i]=i<=d;
	else {
		for (int t:e[k]) if (t!=fa) dp(t,k,d-1);
		for (int i=0;i<=D*2;i++) {
			f[k][i]=1;
			for (int t:e[k])
				if (t!=fa)
					f[k][i]=1LL*f[k][i]*((i?f[t][i-1]:0)+(i==D*2?0:f[t][i+1]))%mod;
		}
	}
}
int main()
{
	int i,k,a,b,n=gi(),ans=0;
	for (i=1;i<n;i++) {
		a=gi(),b=gi();
		e[a].push_back(b);
		e[b].push_back(a);
	}
	D=0;dfs(1,0);
	fa[T]=0;D=0;dfs(a=T,0);
	if (D&1) {
		for (a=T,i=(++D)/=2;i--;a=fa[b=a]);
		dp(a,b,D);
		dp(b,a,D-1);
		for (i=0;i<=D*2;i++) ans=(ans+1LL*f[a][i]*f[b][i+1]+1LL*f[a][i+1]*f[b][i])%mod;
		dp(a,b,D-1);
		dp(b,a,D);
		for (i=0;i<=D*2;i++) ans=(ans+1LL*f[a][i]*f[b][i+1]+1LL*f[a][i+1]*f[b][i])%mod;
		dp(a,b,D-1);
		dp(b,a,D-1);
		for (i=0;i<=D*2;i++) {
			ans=(ans-2LL*f[a][i]*f[b][i])%mod;
			ans=(ans-1LL*f[a][i]*f[b][i+2])%mod;
			ans=(ans-1LL*f[a][i+2]*f[b][i])%mod;
		}
		if (ans<0) ans+=mod;
	} else {
		for (k=T,i=D/=2;i--;k=fa[k]);
		dp(k,0,D);
		for (i=0;i<=D*2;i++) (ans+=f[k][i])%=mod;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int n ;
    cin >> n;
    int ac=0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    for(int i=0;i<n;i++)
    {
        string s;
        cin >> s;
        if(s=="WA")
            wa++;
        if(s=="AC")
            ac++;
        if(s=="TLE")
            tle++;
        if(s=="RE")
            re++;

    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl; 
    return 0;
}

Measured memory_bytes: 3628
import sys
def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    H = [int(h) for h in input().split()]
    Good = [True] * N
    for _ in range(M):
        a, b = map(int, input().split())
        if H[a-1] > H[b-1]: Good[b-1] = False
        elif H[a-1] < H[b-1]: Good[a-1] = False
        else: Good[a-1] = Good[b-1] = False
    print(Good.count(True))

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 20312
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    string n;
    string ans ="No";
    cin >> n;
    for(int i=0;i<n.length();i++){
        if(n.substr(i,1)=="9"){
            ans = "Yes";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		int n=nextInt();
		int a[]=new int[n+1];
		long ans=0;
		for(int i=1;i<=n;i++)
			a[i]=nextInt();
		for(int i=1;i<=n;i++)
		{
			ans+=a[i]/2;
			a[i]=a[i]%2;
			if(a[i]==1 && i!=n && a[i+1]>0)
			{
				ans++;
				a[i]=0;
				a[i+1]--;
			}
		}
		out.println(ans);
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 37084
#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int i;
    int a[200005];
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    if (n > 1)
    {
        for (i = n - 1; i >= 0; i -= 2)
            printf("%d ", a[i]);
        if (i == -1)i = 0;
        else i = 1;
        for (; i < n - 2; i += 2)
            printf("%d ", a[i]);
        printf("%d\n", a[i]);
    }
    else
        printf("%d\n", a[0]);
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

string tostr(int x, int y){
    string strx = to_string(x);
    string stry = to_string(y);

    while(strx.size() < 6){
        strx = '0' + strx;
    }
    while(stry.size() < 6){
        stry = '0' + stry;
    }
    return (strx + stry);
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    // year, city number
    vector<pair<int, int> > pyears[n+1];
    for(int i=0;i<m;i++){
        int p, y; cin >> p >> y;
        pyears[p].push_back(make_pair(y, i));
    }
    vector<string> ans(m);
    for(int i=1;i<=n;i++){
        if(pyears[i].size() == 0) continue;
        sort(pyears[i].begin(), pyears[i].end());
        int cnt = 1;
        for(auto p: pyears[i]){
            ans[p.second] = tostr(i, cnt);
            cnt++;
        }
    }
    for(int i=0;i<m;i++) cout << ans[i] << endl;
}

Measured memory_bytes: 12416
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();

    if n == 1 || n == 2 || (n % 4 == 0 && n.count_ones() == 1) {
        println!("No");
        return;
    } else if n == 3 {
        println!("Yes");
        println!("1 2");
        println!("2 3");
        println!("3 4");
        println!("4 5");
        println!("5 6");
        return;
    }

    let w = (n + 1) / 4 * 4 - 1;
    let mut used = vec![false; n];
    let mut ans = vec![];
    let mut row = vec![];
    row.push(w);
    row.push(1);
    if w != 3 {
        row.push(3);
    }
    row.push(2);
    if n % 4 == 0 {
        let mut head = 0;
        let mut tail = 0;
        for i in 0..30 {
            if (1 << i) & n != 0 {
                used[1 << i] = true;
                row.push(1 << i);
                if head == 0 {
                    head = 1 << i;
                }
                tail = 1 << i;
            }
        }
        ans.push((head, n));
        ans.push((tail, n + n));
    }
    for i in 4..w {
        if used[i] {
            continue;
        }
        row.push(i);
    }
    let s = row.len();
    for i in 1..s {
        ans.push((row[i - 1], row[i]));
        ans.push((row[i - 1] + n, row[i] + n));
    }

    ans.push((row[s - 1], row[0] + n));
    if w + 2 <= n {
        ans.push((w + 1, 1));
        ans.push((w + 1, w + 2));

        ans.push((w + 2 + n, 1));
        ans.push((w + 2 + n, w + 1 + n));
    }
    if w + 3 <= n {
        ans.push((w + 3, w + 1));
        ans.push((w + 3 + n, 3));
    }

    println!("Yes");
    for (i, j) in ans.into_iter() {
        println!("{} {}", i, j);
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 13428
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include<cmath>

#define mod 1000000007

long long fact(long long a) {
    long long r = 1;
    for(long long i = 2; i <= a; i++) {
        r *= i;
        r %= mod;
    }

    return r%mod;
}

long long calc(long long n, long long m) {
    return (fact(n)*fact(m))%mod;
}

int main() {
    long long n, m; std::cin >> n >> m;

    long long ans;

    if(std::abs(n-m) > 1) {
        ans = 0;
    } else if(n == m) {
        ans = 2*calc(n, m);
    } else {
        ans = calc(n, m);
    }

    std::cout << ans%mod << std::endl;
}

Measured memory_bytes: 3612
# 結局は木+1辺
from collections import defaultdict
import heapq as hq

N = int(input())
P = list(map(lambda x:int(x)-1,input().split()))
D = [0]*N
for p in P:
  D[p] += 1

child_L = defaultdict(list)

S = [p for p in range(N) if D[p] == 0]
L = [None]*N

while S:
  n = S.pop()

  q = child_L[n]
  del child_L[n]

  hq.heapify(q)
  i = 0
  while q:
    t = hq.heappop(q)
    if i < t:
      break
    else:
      i += (i==t)
  
  L[n] = i
  m = P[n]
  child_L[m].append(i)
  D[m] -= 1
  if D[m] == 0:
    S.append(m)

# cycle check
try:
  start = D.index(1)
except ValueError:
  print('POSSIBLE')
  exit()

def helper(n):
  q = child_L[n]
  del child_L[n]
  
  hq.heapify(q)
  i = 0
  while q:
    t = hq.heappop(q)
    if i < t:
      break
    else:
      i += (i==t)

  j = i+1
  while q:
    t = hq.heappop(q)
    if j < t:
      break
    else:
      j += (j==t)

  return (i,j)


s1,s2 = helper(start)
G = []
n = P[start]
while n != start:
  G.append(helper(n))
  n = P[n]


del N,P,D,child_L,S,L


# 可能な初期値をそれぞれシミュレート
# 1
n = s1
for g in G:
  if g[0] == n:
    n = g[1]
  else:
    n = g[0]
if n != s1:
  print('POSSIBLE')
  exit()

# 2
n = s2
for g in G:
  if g[0] == n:
    n = g[1]
  else:
    n = g[0]
if n == s1:
  print('POSSIBLE')
  exit()

print('IMPOSSIBLE')

Measured memory_bytes: 30292
#!/usr/bin/env python3



# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    # Failed to predict input format
    INF = 10000000

    H,W = map(int,input().split())
    maze = [input() for i in range(H)]

    d = [[INF]*W for i in range(H)]

    from collections import deque
    q = deque()

    q.appendleft([0,0])
    d[0][0] = 0

    dx = [[-1,0], [1,0], [0,1], [0,-1]]

    while(len(q)):
        i,j = q.pop()

        for di,dj in dx:
            if(0 <= i+di < H and 0 <= j+dj < W and d[i+di][j+dj] == INF and maze[i+di][j+dj] == '.'):
                q.appendleft([i+di,j+dj])
                d[i+di][j+dj] = d[i][j]+1

    # print(d[H-1][W-1])
    if(d[H-1][W-1] == INF):
        print(-1)
    else:
        print(sum([i.count('.') for i in maze]) - d[H-1][W-1] - 1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
// ABC 118 B
#include<bits/stdc++.h>

using namespace std;
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define PB(a) push_back(a)
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  int n,m;
  str ans="";
  int num[] = {2,5,5,4,5,6,3,7,6};
  cin  >> n >> m;
  VI dp(n+1,-1e9);
  VI a(m);
  REP(i,m){
    cin >> a[i]; 
  }
  RSORT(a);
  dp[0]=0;
  FOR(i,1,n+1){
    REP(j,m){
      int tmp = num[a[j]-1];
      if(i-tmp>=0 && dp[i-tmp]>=0){
       dp[i]=max(dp[i],dp[i-tmp]+1) ;
      }
    }
  }
  while(n>0){
    REP(j,m){
      int tmp=num[a[j]-1];
      if(dp[n-tmp]==dp[n]-1&&n-tmp>=0){
        ans += to_string(a[j]);
        n-=tmp;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
'use strict';
const x = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = x.split(/\n/);

for (let i = 0; i < lines.length ; i++) {
  const arr = lines[i].split(/\s/).map(Number);
  if ((arr[0]===0)&&(arr[1]===0)) break;

  for (let i = 0; i < arr[0]; i++){
    if (i%2===0) {
      for (let j=0; j < arr[1]; j++){
        if (j%2===0) process.stdout.write('#');
        else process.stdout.write('.');
      }
      console.log();
    } else {
      for (let j=0; j < arr[1]; j++){
        if (j%2===0) process.stdout.write('.');
        else process.stdout.write('#');
      }
      console.log();
    }
  }
  console.log();
}




Measured memory_bytes: 34252
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string.h>
using namespace std;
int main(void){
     int n;
 
    int k,m,l;
    string o,e,p;
    cin>>o>>e;;
 
    n=o.size();
    k=e.size();
    l=0,m=0;
    p="";
    for(int i=1;i<=n+k;i++)
    {
        if(i%2==0)
        {
            p=p+e.at(m);
            m++;
        }
        else
        {
            p=p+o.at(l);
            l++;
        } 
    }
    cout<<p;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll S;
  cin>>S;
  ll A=S/100;
  ll B=S%100;
  bool a,b;
  a=false;
  b=false;
  if(0<A&&A<13) {
a=true;
  }
  if(0<B&&B<13) {
b=true;
  }
  
  if(a&&b) {
cout<<"AMBIGUOUS"<<endl;
  }
  else if(a) {
cout<<"MMYY"<<endl;
  }
  else if(b) {
cout<<"YYMM"<<endl;
  }
  else {
cout<<"NA"<<endl;
  }
}
  


Measured memory_bytes: 3640
N = int(input())
A = list(map(int, input().split()))
ans = sum(map(int, input().split()))
C = list(map(int, input().split()))
A_before=0
for i in range(N):
  if A_before != 0 and A[i] == A_before+1:
    ans+=C[A_before-1]
  A_before = A[i]
print(ans)


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define maxn 100009
#define inf 999999999999
using namespace std;

ll dp1[10009];
ll dp2[10006];
char s[25];

int num[105];

int main()
{
    int n,m,x,y;
    while(scanf("%d",&n)!=EOF)
    {
        if(n==0)break;
        for(int i=0; i<n; i++)
            scanf("%d",&num[i]);
        sort(num,num+n);
        for(int i=1;i<=10000;i++)dp2[i]=-inf;
        dp2[0]=0;
        memset(dp1,0,sizeof dp1);
        scanf("%d",&m);
        bool flag=0;
        for(int i=0; i<m; i++)
        {
            scanf("%s",s);
            scanf("%d",&x);
            scanf("%s",s);
            scanf("%d",&y);
            if(x==0&&y>0)flag=1;
//        printf("%d %d\n",x,y);
            if(s[0]=='S')
            {
                for(int j=x; j<=10000; j++)
                    dp1[j]=max(dp1[j],dp1[j-x]+y);//single
            }
            else
            {
                for(int j=x; j<=10000; j++)
                    dp2[j]=max(dp2[j],dp2[j-x]+y);//all
            }
        }
        if(flag)
        {
            puts("0");
            continue;
        }
        ll ans=inf,sum;
        for(int i=0; i<10001; i++)
        {
            if(dp2[i]<0)continue;
            sum=i;
            for(int j=0; j<n; j++)
                sum+=lower_bound(dp1,dp1+10000,num[j]-dp2[i])-dp1;
            ans=min(ans,sum);
        }
        printf("%lld\n",ans);
    }
    return 0;
}

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

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

    int ans = 0;

    for (int i = 0; i < S.size()-1; ++i) {
        vector<bool> alpL(26), alpR(26);
        int cnt = 0;
        for (int j = 0; j < i+1 ; ++j) alpL[(int)S[j] - 'a'] = true;
        for (int k = i+1; k < S.size(); ++k) alpR[(int)S[k] - 'a'] = true;
        
        for (int l = 0; l < 26; ++l) {
            if (alpL[l] && alpR[l]) cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<long long> ar(n,0);
    bool flag = false;
    for(int i=0;i<n;i++)
    {
        cin >> ar[i];
        if(ar[i] == 0)
            flag = true;
    }
    if(flag == true)
    {
        cout << 0 << endl;
        return 0;
    }
    long long prod = 1;
    for(int i=0;i<n;i++)
    {
        if(ar[i] <=1000000000000000000/ prod)
        {
            prod *= ar[i];
        }
        else
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << prod << endl;
    return 0;
}


Measured memory_bytes: 4048
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Console;

namespace ABC171
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var sw = new StreamWriter(OpenStandardOutput()) {AutoFlush = false};
            SetOut(sw);
            SolveD();
            Out.Flush();
        }

        static void SolveD()
        {
            ReadLine();
            var aList = ReadLine().Split(' ').Select(long.Parse);
            long sum = 0;
            var aDic = new Dictionary<long, long>();
            foreach (var a in aList)
            {
                if (!aDic.ContainsKey(a))
                {
                    aDic.Add(a, 1);
                }
                else
                {
                    aDic[a]++;
                }

                sum += a;
            }

            var q = int.Parse(ReadLine());
            for (var i = 0; i < q; i++)
            {
                var bc = ReadLine().Split(' ').Select(int.Parse);
                if (aDic.ContainsKey(bc.First()))
                {
                    sum -= bc.First() * aDic[bc.First()];
                    sum += bc.Last() * aDic[bc.First()];
                    var tmp = aDic[bc.First()];
                    aDic.Remove(bc.First());
                    if (!aDic.ContainsKey(bc.Last()))
                    {
                        aDic.Add(bc.Last(), tmp);
                    }
                    else
                    {
                        aDic[bc.Last()] += tmp;
                    }
                }

                WriteLine(sum);
            }
        }
    }
}

Measured memory_bytes: 48628
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#include <vector>
#include <queue>
#include <stack>
  
using namespace std;
  
typedef long long ll;
typedef string ss;

#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

const int N = 1e2 + 5, INF = int(2e9) + 1;

ss s;

int ans, cnt;

int main(){
	speed;
	cin >> s;
	for(int i = 0; i <= s.size(); i++){
		if(s[i] == 'A'){
			ans++;
		}
		else if(s[i] == 'B'){
			cnt++;
		}
	}
	if(cnt == 2 or ans == 2){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
}

Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
li=list(map(int,input().split()))
min=100000000
ans=-1
for i in range(n):
    if min>abs(t-li[i]*0.006-a):
        min=abs(t-li[i]*0.006-a)
        ans=i+1
print(ans)
        
    
        

Measured memory_bytes: 3060
void main(){
	auto val = _scanln().sort!("a>b");
	(val[0]*10 + val[1] + val[2]).writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2664
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();
		int d = sc.nextInt();

		System.out.println(Math.min(a, b) + Math.min(c, d));
		
		sc.close();

	}

}


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

using namespace std;

int main()
{
    long long int a,b,ar[3];
    cin>>a>>b;
    if (a==b){

        cout<<(2*a)<<endl;

    }
    else{

        ar[0]=a+(a-1);
        ar[1]=b+(b-1);
        ar[2]=a+b;
        sort(ar,ar+3);

        cout<<ar[2]<<endl;

    }

    return 0;


}


Measured memory_bytes: 256
def main():
  n=int(input())
  s=input()
  dp=[[0]*(n+1) for i in range(n+1)]
  for i in reversed(range(n)):
    for j in reversed(range(i+1,n)):
      if s[i]==s[j]:
        dp[i][j]=dp[i+1][j+1]+1
  
  ans=0
  for i in range(n):
    for j in range(i+1,n):
      ans=max(ans,min(j-i,dp[i][j]))
  print(ans)
        

if __name__=='__main__':
  main()

Measured memory_bytes: 270232
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    cout << max({ a + b, a - b, a * b }) << endl;

    return 0;
}

Measured memory_bytes: 256
"use strict"

const solver = (n, as, q, ms) => {
  const patterns = []
  for (let bit = 0; bit < (1<<n); bit++) {
    let v = 0
    for (let i = 0; i < n; i++) {
      if (bit & (1 << i)) {
        v = v + as[i]
      }
    }
    if (v !== 0) {
      patterns.push(v)
    }
  }
  const result = []
  for (let i = 0; i < q; i++) {
    if (patterns.indexOf(ms[i]) !== -1) {
      result.push("yes")
    } else {
      result.push("no")
    }
  }
  return result
}

let rows = 0
let n = 0
let as = null
let q = 0
let ms = null
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
})
reader.on("line", (line) => {
  rows++
  if (rows === 1) {
    n = Number(line)
  } else if (rows === 2) {
    as = line.trim().split(" ").map(a => Number(a))
  } else if (rows === 3) {
    q = Number(line)
  } else {
    ms = line.trim().split(" ").map(m => Number(m))
    const result = solver(n, as, q, ms)
    for (let i = 0; i < result.length; i++) {
      console.log(result[i])
    }
    process.exit(0)
  }
})



Measured memory_bytes: 45840
#include <bits/stdc++.h>
#define N 505
using namespace std;
int n,m,q,c[N][N],f[N][N],l,r;
int main(){
    cin>>n>>m>>q;
    for(int i=1;i<=m;i++)cin>>l>>r,c[l][r]++;
    for(int i=1;i<=n;i++)f[i][i]=c[i][i];
    for(int i=1;i<=n-1;i++)
        f[i][i+1]=c[i][i+1]+f[i+1][i+1]+f[i][i];
    for(int k=2;k<=n-1;k++)
        for(int i=1;i<=n-k;i++)
            f[i][i+k]=c[i][i+k]+f[i][i+k-1]+f[i+1][i+k]-f[i+1][i+k-1];
    for(int i=1;i<=q;i++)cin>>l>>r,cout<<f[l][r]<<endl;
    return 0;
}

Measured memory_bytes: 5568
import math

a,b,h,m = map(int,input().split())

h_hand = (m+(h*60))*0.5
m_hand = m*6

degree = abs(h_hand - m_hand)

cos_x = math.cos(math.radians(degree))

sq = a**2 + b**2 -2*a*b*cos_x

print(math.sqrt(sq))

Measured memory_bytes: 9512
#include <stdio.h>
#include <string.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	int n, i;
	int A[200000];
	int S[200000]={0};
	A[0]=-1;
	
	scanf("%d", &n);
	
	for(i=1; i<n; i++){
		scanf("%d", &A[i]);
		S[A[i]-1]++;
    }
	
	lop(i, n){
		printf("%d\n", S[i]);
	}
	
return 0;
}

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

int main() {
  
  int n;
  cin >> n;
  
  string s, t;
  cin >> s >> t;
  
  for (int i=0; i<n; i++) {
    cout << s.at(i) << t.at(i);
  }
  
  cout << endl;
}

Measured memory_bytes: 256
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)

int main()
{
    ll i,n,t,k,j,m;
    string str;
    cin>>n>>str;
    m = n*(str[0]-48);
    ll x = (str[2]-48)*10;
    x+= str[3] - 48;
    m+= (n*x)/100;
    cout<<m<<endl;
    return 0;
}



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

using namespace  std;

int main(void)
{
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    sort(A.begin(), A.end(), greater<int>());
    
    unsigned long long  int ans = 0;
    for(int i = 1; i < N; i++){
        ans += A[i/2];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4000
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
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; }

void solve(long long N, long long M, std::vector<long long> A){
    ll sum = 0; REP(i, M) sum+=A[i];
    cout<<( N>=sum?(N-sum):-1)<<endl;
}

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


Measured memory_bytes: 3260
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class b{
    public static void Main(){
        int[] num = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int k = int.Parse(Console.ReadLine());
        int a = num[0];
        int b = num[1];
        int c = num[2];
        int cnt = 0;
        while(a >= b){
            b *= 2;
            cnt++;
        }
        while(b >= c){
            c *= 2;
            cnt++;
        }
        string ans = "No";
        if(k >= cnt){
            ans = "Yes";
        }
        Console.WriteLine(ans);
    }
}


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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

//constexpr long long MOD = 1000000007;
constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;


number GCD(number a, number b) {
    return b != 0 ? GCD(b, a % b) : a;
}
number LCM(number a, number b) {
    return a * (b / GCD(a, b));
}

int main() {
    int N; cin >> N;
    vll T(N);
    rep(i, N) cin >> T[i];
    if (N == 1) {
        cout << T[0] << endl;
        return 0;
    }
    ll ans = LCM(T[0], T[1]);
    for (int i = 2; i < N; i++) {
        ans = LCM(ans, T[i]);
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (ll)1000000007

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

Measured memory_bytes: 256
n,m,c=map(int,input().split())
B=list(map(int,input().split()))
ans=0
for i in range(n):
  A=list(map(int,input().split()))
  tmp=0
  for j in range(m):
    tmp+=A[j]*B[j]
  if tmp+c>0:
    ans+=1
print(ans)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
    	String s = ns();

    	int n = s.length();

    	int cnt = 0;

    	for (int i=0; i<n; i++) {
    		if (s.charAt(i) == 'p') cnt++;
    	}

    	n /= 2;

    	out.println(n - cnt);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
   double a;cin>>a;
   double ans=0.0;
   for(int i=1;i<=a;i++){
       if(i%2!=0)ans++;
   }
   cout<<1.00*ans/a<<endl;

   
}

 
    

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

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 2e5 + 5;
int a[N], b[N];
priority_queue<pair<int, int> > Q;

int main()
{
	int n = read();
	for (int i = 1; i <= n; ++i) a[i] = read();
	for (int i = 1; i <= n; ++i) b[i] = read(), Q.push({b[i], i});
	
	long long ans = 0;
	while (!Q.empty())
	{
		int i = Q.top().second;
		Q.pop();
		if (b[i] == a[i]) continue;
		
		int pre = i == 1 ? n : i - 1;
		int nxt = i == n ? 1 : i + 1;
		if (b[i] - b[pre] - b[nxt] < a[i]) return puts("-1"), 0;
		
		ans += (b[i] - a[i]) / (b[pre] + b[nxt]);
		b[i] = a[i] + (b[i] - a[i]) % (b[pre] + b[nxt]);
		if (a[i] != b[i]) Q.push({b[i], i});
	}
	printf("%lld\n", ans);
	return 0;
}


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

int main(){
    int n;
    double d;
    cin >>n>>d;
    int ans = 0;
    for(int i=0;i<n;i++){
        long long x, y;
        cin >> x >> y;
        long double temp = sqrt((long double)(x*x+y*y));
        if(temp<=d) ans++;

    }
    cout << ans << endl;
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const long long MOD = 1e9 + 7;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    int N; cin >> N;
    vector<string> S;
    S.push_back("a");
    REP(i,N - 1){
        vector<string> newS;
        REP(j,S.size()){
            string s = S[j];
            char maxc = 'a' - 1;
            REP(k,s.length()){
                chmax(maxc,s[k]);
            }

            char tmp = 'a';
            while(tmp <= maxc + 1){
                newS.push_back(s + tmp);
                tmp++;
            }
        }
        S = newS;        
    }

    REP(i,S.size()){
        cout << S[i] << "\n";
    }
}

Measured memory_bytes: 10908
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,avx2,fma,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(0),cin.tie(0), cout.tie(0)
typedef long long ll;


ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

//#######################################


int main(){
  boost;
  
  ll n;
  cin>>n;
  vector<ll> a(n,0);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  // vector<int> v=a;
  map<int,int> m;
  for(int i=0;i<a.size();i++){
    m[a[i]]++;
  }
  sort(a.begin(),a.end());
  vector<ll>::iterator ip;
  ip=unique(a.begin(),a.end());
  a.resize(distance(a.begin(),ip));
  
  int count=0;
  for(int i=0;i<a.size();i++){
    for(int j=i+1;j<a.size();j++){
      for(int k=j+1;k<a.size();k++){
        if(a[i]+a[j]>a[k])
        count+=(m[a[i]]*m[a[j]]*m[a[k]]);
      }
    }
  }
  cout<<count;
}



Measured memory_bytes: 3660
x = []
for i in range(5):
  a = int(input())
  x.append(a)
def kiriage(n):
  if n%10 == 0:
    return n
  else:
    return (n//10 + 1)*10
ans = 0
m = 0
for xi in x:
  kx = kiriage(xi)
  ans += kx
  if kx-xi > m:
    m = kx -xi
print(ans-m)


Measured memory_bytes: 3060
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double d;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    ll a,b;
    cin>>a>>b;
    if(min(a,b)==1){
        cout<<1;
    }
    else cout<<a*b/2+(a*b)%2;
    return 0;
}


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

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

    int N, K; cin >> N >> K;

    double res = 0.0;

    rep(i, 1, N+1) {
        int denom = 1;
        int curScore = i;
        while (curScore < K) {
            curScore *= 2;
            denom *= 2;
        }
        res += 1.0 / (double)denom;
    }

    printf("%.15lf\n", res / (double)N);
}

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

int main(){
    int n;
    cin >>n;
    vector<string> blue(n);
  for(int i=0;i<n;i++){
    cin >>blue[i];
     }
   
  int ans=n;
  for(int i=0;i<n;i++){
    int stop =0;
    if(i>0){ 
     for(int j=0;j<i;j++){
       if(blue[i]==blue[j]){stop=1; break;}
     }
   }
    if(stop==1){ans--;}
  
  }
  
  cout << ans<<endl;
  
}


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

int N, M;
vector<P> ab;
vector<vector<int>> edge(51);
bitset<51> used;
int stop1, stop2;

void rec(int prev = -1, int corrent = 1, int cnt = 0){
    if(cnt == N) return;
    if(used[corrent]) return;
    if((prev == stop1 && corrent == stop2) || (prev == stop2 && corrent == stop1)) return;
    used[corrent] = true;
    for(auto next : edge[corrent]) if(next != prev) rec(corrent, next, cnt + 1);
    return;
}

int main(void){
    
    scanf("%d %d", &N, &M);
    for(int i = 0; i < M; ++i){
        int a, b; scanf("%d %d", &a, &b);
        ab.push_back(make_pair(a, b));
        edge[a].push_back(b), edge[b].push_back(a);
    }
    
    int ans = 0;
    for(int i = 0; i < M; ++i){
        stop1 = ab[i].first, stop2 = ab[i].second;
        used.reset();
        rec();
        if(used.count() != N) ++ans;
    }
    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    long long X;
    cin >> X;
    int x=0;
    int i=0;
    while(x<X){
        i++;
        x+=i;
    }
    cout  << i << endl;



}


Measured memory_bytes: 256
def printRectangle(h, w) : 
    for i in range(0, h) : 
        for j in range(0, w) : 
            print("#",end="") 
        print('')
    print('')
for j in range(30):
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    else:
        printRectangle(h, w)


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

bool is_prime(int n){
	for(int i=2;i*i<=n;i++){
		if(n%i==0) return false;
	}
	return n!=1;
}

int main(){
	int n,ans=0,a;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		if(is_prime(a)) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int main()
{
	long int n;
	cin>>n;
	long int min=0,i,height=0,x;
	for(i=0;i<n;i++)
	{
		cin>>x;
		if(min > x)
		{
			height=height+min-x;
		}
		else
			min=x;
	}
	cout<<height<<endl;
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int n, k, ans;
char s[305];
int dp[305][305][305];
int dfs(int l, int r, int x) {
	if(l >= r) {
		return r - l + 1;
	}
	if(dp[l][r][x] != -1) {
		return dp[l][r][x];
	}
	int ret = max(dfs(l + 1, r, x), dfs(l, r - 1, x));
	if(s[l] == s[r]) {
		ret = max(ret, dfs(l + 1, r - 1, x) + 2);
	} else if(x) {
		ret = max(ret, dfs(l + 1, r - 1, x - 1) + 2);
	}
	return dp[l][r][x] = ret;
}
int main() {
	memset(dp, -1, sizeof(dp));
	scanf("%s%d", s + 1, &k);
	n = strlen(s + 1);
	for(int i = 1; i <= n; ++i) {
		for(int j = i; j <= n; ++j) {
			ans = max(ans, dfs(i, j, k));
		}
	} 
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 111104