akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();
			long n = s.length;

			long[] a = new long[26];
			for (char c : s) {
				a[c-'a']++;
			}

			long ans = n * (n-1) / 2;
			for (long l : a) {
				ans -= l * (l-1) / 2;
			}
			out.println(ans + 1);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public int[] nextIntArray1Index(int n) {
			int[] res = new int[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public long[] nextLongArray1Index(int n) {
			long[] res = new long[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextLong();
			}
			return res;
		}

		public double[] nextDoubleArray(int n) {
			double[] res = new double[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextDouble();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 25372
import javax.management.monitor.CounterMonitor;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //
        //Euclid e1=new Euclid();//ユークリッドの互除法
        //Compute c1=new Compute();//累積和，
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        //int answer=0;
        String answer = "NA";
        //StringBuilder answer=new StringBuilder();
        //List<Integer> list = new ArrayList<>();
        //int array[] = new int[];

        //入力
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int s = Integer.parseInt(S);
        int ss = Integer.parseInt(S.substring(2, 3)) * 10 + Integer.parseInt(S.substring(3, 4));
        int sss = Integer.parseInt(S.substring(0, 1)) * 10 + Integer.parseInt(S.substring(1, 2));
        //System.err.println(sss);
        //System.err.println(ss);
        if (sss <= 12 && sss > 0 && ss <= 12 && ss > 0)
        {
            answer = "AMBIGUOUS";
        } else if (sss > 12 || sss==0)
        {
            if (ss <= 12 && ss>0)
            {
                answer = "YYMM";
            } else {
                answer = "NA";
            }
        }else if(sss<=12 && sss>0)
        {
            answer="MMYY";
        }else
        {
            answer="NA";
        }
        //出力
        //System.err.println();//標準エラー出力
        System.out.println(answer);
    }
}

Measured memory_bytes: 22612
s=input()
t=input()
ans=float('inf')

for i in range(len(s)-len(t)+1):
  x=s[i:i+len(t)]
  cnt=0
  for j in range(len(t)):
    if x[j]!=t[j]:
      cnt+=1
      
  ans=min(ans,cnt)
  
 
print(ans)

Measured memory_bytes: 67684
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.c
 * Author: Ivan
 *
 * Created on July 9, 2018, 3:45 PM
 */

#include <stdio.h>
#include <stdlib.h>
#define MAX 100005
#define NIL -1

typedef struct { 
    int parent, left, right;
}Node;

Node Tree[MAX];
int num, H, Depth[MAX];

int getDepth(int u);
void print(int u);

int main(int argc, char** argv) {
  int index, depth, child, l, size;
  scanf("%d", &size);
  
  //Initialize binary tree
  for (int i = 0; i < size; i++ ) Tree[i].parent = Tree[i].left = Tree[i].right = NIL;

  for (int ix = 0; ix < size; ix++ ){
    scanf("%d %d", &index, &depth);
    for (int j = 0; j < depth; j++ ){
      scanf("%d", &child);
      if ( j == 0 ) Tree[index].left = child;
      else Tree[l].right = child;
      l = child;
      Tree[child].parent = index;
    }
  }
  
  H = 0;
  for (int i = 0; i < size; i++ ){
    Depth[i] = getDepth(i);
    if ( Depth[i] > H ) H = Depth[i];
  }

  for (int i = 0; i < size; i++ ) print(i);
  return 0;
}

int getDepth(int u)
{
    int i = 0;
    for(; Tree[u].parent != NIL ; i++) u = Tree[u].parent;
    return i;
}

void print(int u)
{
    int c;
    printf("node %d: ", u);
    printf("parent = %d, ", Tree[u].parent);
    printf("depth = %d, ", Depth[u]);

    if ( Tree[u].parent == NIL ) printf("root, ");
    else if ( Tree[u].left == NIL ) printf("leaf, ");
    else printf("internal node, ");

    printf("[");
    for(int i = 0, c = Tree[u].left; c != NIL; i++, c = Tree[c].right)
    {
        if (i) printf(", ");
        printf("%d", c);
    }
    printf("]\n");
}




Measured memory_bytes: 3416
#include<bits/stdc++.h>
using namespace std;
#include<array>
array<int,100005>dp;
int a[100005];
void memo(int i,int n,int k)
{
	if(i>n) return;
	for(int m=1;m<=k;m++)
	{
		dp[i+m] = min(dp[i+m],dp[i]+abs(a[i+m]-a[i]));
	}
	memo(i+1,n,k);
}
int main()
{
	int n,k;cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	dp.fill(INT_MAX);
    dp[1] = 0;
    memo(1,n,k);
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
def expand(x):
  s = x[0]
  if (s == '0'):
    e = ['0', '1']
  elif (s == '9'):
    e = ['8', '9']
  else:
    e = [str(int(s) + (i-1)) for i in range(3)]
  y = [i+x for i in e]
  return y


Y      = [str(i) for i in range(10)]
result = Y.copy()

for _ in range(10):
  tmp = []
  for i in Y:
    tmp += expand(i)
  result.extend(tmp)
  Y = tmp
  
iY = set(map(int, result))
iY = sorted(list(iY))

X = int(input())
print(iY[X])

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

int x,ans;

int main()
{
	cin>>x;
	if(x<600) ans=8;
	else if(x<800) ans=7;
	else if(x<1000) ans=6;
	else if(x<1200) ans=5;
	else if(x<1400) ans=4;
	else if(x<1600) ans=3;
	else if(x<1800) ans=2;
	else ans=1;
	cout<<ans;
}

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

int main(){
    int64_t n, T;
    cin >> n >> T;
    int64_t t[200010];
    for(int i=0; i<n; i++){
        cin >> t[i];
    }
    int64_t ans = 0;
    for(int i=1; i<n; i++){
        if(t[i]-t[i-1] <= T){
            ans += t[i]-t[i-1];
        }else{
            ans += T;
        }
    }
    cout << ans+T << endl;
    return 0;
}

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

int a[1000][1000], dp[1000][1000], b[1000][1000];
int main() {
	int h, w, n;
	while (scanf("%d%d%d", &h, &w, &n), h) {
		rep(i, h)rep(j, w) {
			scanf("%d", &a[i][j]); b[i][j] = a[i][j];
		}
		memset(dp, 0, sizeof(dp));
		dp[0][0] = n - 1;
		rep(i, h)rep(j, w) {
			if (i) {
				if (a[i - 1][j])dp[i][j] += dp[i - 1][j] / 2;
				else dp[i][j] += (dp[i - 1][j] + 1) / 2;
			}
			if (j) {
				if (a[i][j - 1])dp[i][j] += (dp[i][j - 1] + 1) / 2;
				else dp[i][j] += dp[i][j - 1] / 2;
			}
			if (dp[i][j] & 1)b[i][j] = !b[i][j];
		}
		int x = 0, y = 0;
		while (x < h&&y < w) {
			if (b[x][y])y++;
			else x++;
		}
		printf("%d %d\n", x + 1, y + 1);
	}
}

Measured memory_bytes: 14904
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

int main()
{
    int N, M, X;
    int A[100] = {0}, tmp, ans1 = 0, ans2 = 0;

    cin >> N >> M >> X;
    for (int i = 0; i < M; i++) {
        cin >> tmp;
        A[tmp-1]++;
    }

    for (int i = X-1; i < N; i++) {
        if (A[i]) ans1++;
    }

    for (int i = X-1; i >= 0; i--) {
        if (A[i]) ans2++;
    }
    
    cout << min(ans1, ans2) << endl;

    return 0;
}


Measured memory_bytes: 256
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int a[10101];
int main()
{
	int n,m;
	cin>>n>>m;
	int i;
	int s=0;
	for(i=0;i<m;i++){
		cin>>a[i];s+=a[i];
	}
	if(s>n){
		cout<<-1;
	}
	else{
		cout<<n-s<<endl;
	}
	return 0;
}


Measured memory_bytes: 3672
#pragma region Template
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define COL(x) cout << x << endl
#define CO(x) cout << x
//#define int long long

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = INT64_MAX >> 1;
const int INF = INT_MAX >> 1;

inline int sqr(int x) { return (x * x); }
inline void printd(double x) { printf("%.10lf\n", x); }
inline void upsort(VI& x) { sort((x).begin(), (x).end()); }
inline void downsort(VI& x) { sort((x).begin(), (x).end(), greater<int>()); }
inline int absdiff(int a, int b) { return (a - b) * (static_cast<int>(a > b)*2 - 1); }
int gcd(int a, int b) { // 最大公約数
	if (a < b) return gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
inline int lcm(int a, int b) { return a * b / gcd(a, b); } // 最小公倍数
#pragma endregion

signed main()
{	
	int N, M;
	cin >> N >> M;
	VI H(N);
	rbf(h, H) cin >> h;

	int a, b;
	VI lose(N, 0);
	rep(i, M) {
		cin >> a >> b;
		if (H[a - 1] == H[b - 1]) {
			lose[a - 1]++;
			lose[b - 1]++;
		}
		else if (H[a - 1] > H[b - 1]) {
			lose[b - 1]++;
		}
		else {
			lose[a - 1]++;
		}
	}

	int sum = 0;
	rbf(l, lose) {
		if (l == 0) sum++;
	}

	COL(sum);
	return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {
  std::string A, B; std::cin >> A >> B;
  if ( A.size() > B.size() ) {
    std::cout << "GREATER" << std::endl;
    return 0;
  }
  if ( A.size() < B.size() ) {
    std::cout << "LESS" << std::endl;
    return 0;
  }

  if ( A.size() == B.size() ) {
    for(int i=0; i<A.size(); i++) {
      if ( A[i] > B[i] ) {
        std::cout << "GREATER" << std::endl;
        return 0;
      }
      if ( A[i] < B[i] ) {
        std::cout << "LESS" << std::endl;
        return 0;
      }
    }
    std::cout << "EQUAL" << std::endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	float max, min, high, sa;
	
	scanf("%f", &high);
	max = high;
	min = high;
	
	while(scanf("%f", &high) != EOF){
		if(max < high)	max = high;
		if(min > high)	min = high;
	}
	
	sa = max - min;
	
	printf("%.1f\n", sa);
	
	return 0;
}

Measured memory_bytes: 648
import heapq
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

N = int(sys.stdin.readline())
ABC = [list(map(int, sys.stdin.readline().split())) for _ in range(N - 1)]
Q, K = list(map(int, sys.stdin.readline().split()))
X, Y = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(Q)]))


def dijkstra(graph, start):
    """
    TODO: start していしなかったときに全部の距離を知りたい

    マイナスの辺があっちゃダメ
    scipy.sparse.csgraph.dijkstra は内部で使われてるフィボナッチヒープが一部のケースでめっちゃ遅いのであんまり使わないほうがよさげ
    https://atcoder.jp/contests/soundhound2018-summer-qual/submissions/5311823

    :param list of (list of (int, int)) graph:
        graph[from_index]: (to_index, weight)
    :param int start:
    :return:
    """
    dist = [float('inf') for _ in range(len(graph))]
    dist[start] = 0
    heap = []
    heapq.heappush(heap, (0, start))

    while len(heap) > 0:
        w, v = heapq.heappop(heap)
        if w > dist[v]:
            continue
        for u, dw in graph[v]:
            if w + dw < dist[u]:
                dist[u] = w + dw
                heapq.heappush(heap, (w + dw, u))
    return dist


#: :type: list of (list of (int, int))
graph = [[] for _ in range(N + 1)]
for a, b, c in ABC:
    graph[a].append((b, c))
    graph[b].append((a, c))

dists = dijkstra(graph, K)

for x, y in zip(X, Y):
    print(int(dists[x] + dists[y]))


Measured memory_bytes: 125020
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef priority_queue<int> Pr; typedef vector<int> Vi; typedef vector<Pi> Vp;
typedef map<int,int> MPi; typedef pair<Int,Int> Pl; typedef vector<Int> VI;
const int mod = 1000000007; const Int INF = 1145141919810893931;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    int n; cin>>n; Int x[n],y[n],h[n];
    for (int i = 0; i < n; i++){
        cin>>x[i]>>y[i]>>h[i];
    }
    for (int i = 0; i <= 100; i++){
        for (int j = 0; j <= 100; j++){
            Int xs=i,ys=j,hs;
            bool key=true;
            for (int k = 0; k < n; k++){
                if(h[k]){hs=h[k]+abs(xs-x[k])+abs(ys-y[k]); break;}
            }
            for (int k = 0; k < n; k++){
                if(max(0LL,hs-abs(xs-x[k])-abs(ys-y[k]))!=h[k]){key=false; break;}
            }
            if(key){cout<<xs<<' '<<ys<<' '<<hs<<'\n'; return 0;}
        }
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <iostream>
#include <sstream>
using namespace std;
const int N=10,INF=0x3f3f3f3f;
long long k,a,b;
int main()
{
    while(~scanf("%lld%lld%lld",&k,&a,&b)){
        if(a<=b){
            if(a<k) printf("-1\n");
            else printf("1\n");
        }
        else {
            if(a>=k){
                printf("1\n");
            }
            else {
                long long sum=k/(a-b);
                while(sum*(a-b)+a>k){
                        sum--;
                }
                while(sum*(a-b)+a<k){
                        sum++;
                }
                    printf("%lld\n",sum*2+1);


            }
        }


    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N;
    cin>>N;
    int H[N];
    int number =0;
    for(int i=0;i<N;i++){
        cin>>H[i];
    }
    for(int j = 0; j < N; j++){
        
        
        
       int wrong =0;
    for (int i = 0; i < j+1; i++) {
      
        if(H[i] > H[j]){
            wrong++;
        }
        
    }
        if(wrong == 0){
            number++;
        }
        
        
        
    }
    cout<<number<<endl;
    return 0;
    }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c;
	d=100*a+10*b+c;
	if(d%4==0)cout<<"YES"<<endl;
	if(d%4!=0)cout<<"NO"<<endl;
	return 0;
	
} 

Measured memory_bytes: 256
#include <cstdio>
int main(){
	int a, b;
	scanf("%d %d",&a,&b);
	for (int i = 1; i <= 3; i++){
		if ((a * b * i) % 2 == 1){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
using namespace std;


int main(){
	int x;
    int a, b;

    cin >> x;
    if(x == 1) cout << "Hello World" << endl;
    if(x == 2){
        cin >> a >> b;
        cout << a + b << endl;
    }
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

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

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

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

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};

vector<vector<Edge>> g;
vector<int> ans;
const int MN = 15;
vector<int> searched(MN, 0);
vector<int> color(MN, -1);

int main() {
    int n; cin >> n;
    int ans = 0;
    vector<vector<pair<int,int>>> vvp(n);
    for (int i=0;i<n;i++) {
        int a;cin >> a;
        rep(j,a) {
            int x,y; cin >> x >> y;
            vvp[i].push_back({x,y});
        }
    }
    for (int i=1; i < 1 << n; i++) {
        bool ok = true;
        int count = 0;
        for (int j=0; j<n;j++) {
            if (!(i & (1 << j))) {
                continue;
            }
            //審議判定
            rep(k, vvp[j].size()) {
                if (((i >> (vvp[j][k].first-1)) & 1) ^ vvp[j][k].second) {
                    ok = false;
                }
            }
            count++;
        }
        if (ok) ans = max(ans,count);
//        cout << i << endl;

    }

    cout << ans << endl;
}


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

int main() {
    int N; cin>>N;
    vector<int>a(N);
      bitset<8>b;
      int cnt=0;
    rep(i,N){
        cin>>a[i];
        if(a[i]>=3200){
            cnt++;
            continue;
        }
        b.set(a[i]/400);
    }
    int bb =b.count();
    if(bb>0){
    cout<<bb<<" ";
    }
    else cout<<1<<" ";
     cout<<bb+cnt<<endl;
    }
 




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

abc = 'abcdefghijklmnopqrstuvwxyz'

ans = 0
for i in range(1, N):
  abcdict = {c:0 for c in abc}
  A = S[:i]
  B = S[i:]
  for ai in A:
    if ai in B:
      abcdict[ai] = 1
  now = 0
  for c in abc:
    now += abcdict[c]
  ans = max(ans, now)
  
print(ans)



Measured memory_bytes: 3064
using System;

namespace ConsoleApplication36
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string s = Console.ReadLine();
                string[] ss = s.Split(' ');
                int H = int.Parse(ss[0]);
                int W = int.Parse(ss[1]);
                int j;
                int x;
                if (H == 0 && W == 0)
                {
                    break;
                }
                else
                {
                    for (x = 0; x < H; x++)
                    {
                        for (j = 0; j < W; j++)
                        {
                            Console.Write("#");
                        }
                        Console.WriteLine("");
                    }
                    Console.WriteLine("");
                }
            }
        }
    }
}

Measured memory_bytes: 8780
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  ll ret = 1;
  for(ll i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}

ll dfs(string t,int x){
  ll ret=0;
  int len=t.size();
  if(t.size()<x){
    return 0LL;
  }
  if(x==0 || t.size()==0)return 1;
  string temp="";
  rep(i,t.size()){
    if(i!=0)temp+=t[i];
  }  
  if(t[0]=='0'){
    return dfs(temp,x);
  }
  if(t.size()==1 && x==1){
    return (ll)(t[0]-'0');
  }
  ll te=1;
  rep(i,x)te*=9;
  ret+=te/9*binomial(len-1,x-1)*(t[0]-'0'-1);
  ret+=te*binomial(len-1,x);
  return ret+dfs(temp,x-1);
}

int main(){
  string s;
  cin >> s;
  int k;
  cin >> k;
  ll ans=1;
  rep(i,k)ans*=9;
  ll n=s.size();
  cout << dfs(s,k) << endl;
return 0;}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int op(int r, int w){
	return max(r, w);
}

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

	int w = 0, r = count(all(s), 'R');
	int ans = op(r, w);
	rep(i, n)
	{
		if(s[i] == 'W')
		{
			w++;
		} else
		{
			r--;
		}
		ans = min(ans, op(r, w));
	}
	cout << ans << endl;

	return 0;
}

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

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

    int x;
    int min = INT_MAX;
    int max = INT_MIN;
    long sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> x;
        if (x < min) {
            min = x;
        }
        if (x > max) {
            max = x;
        }
        sum += x;
    }
    cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define pii   pair<int,int>
#define hell  1000000007
#define rep(i,a,b)  for (__typeof(b) i=(a)-((a)>(b));i!=(b)-((a)>(b));i+=1-2*((a)>(b)))
#define boost ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define pb  push_back
#define all(a)      (a).begin(),(a).end()

typedef long long  ll;
using namespace std;

const ll INF=(1LL<<60)-1;
const int N=1e5+20;

int main(){
   
    boost;
    
    int n,m; cin >> n >> m;
    
    vector<pii> v;
    
    rep(i,0,m){
    	int a,b; cin >> a >> b;
    	v.pb({b,a});
	}
	
	sort(all(v));
	
	int mn, mx, cnt = 1;
	int oo = v[0].first;
	
	rep(i,1,m){
	   if(v[i].second >= oo){
	   	  cnt++;
	   	  oo = v[i].first;
	   }	
	}
	
	cout << cnt;
   	return 0;
}

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

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

  vector<int> a;
  for (int i=0; i<n; i++) {
    int num;
    cin >> num;
    a.push_back(num);
  }

  vector<long long> diff;
  for (int i=0; i<n-1; i++) {
    if ((a[i+1] - a[i]) != 0) {
      diff.push_back(a[i+1] - a[i]);
    }
  }

  int cnt=1;
  for (int i=1; i<(int)diff.size(); i++) {
    if (diff[i]*diff[i-1]<0) {
      i++;
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 1784
N = int(input())
A = [dict() for _ in range(N)] 
for i in range(N):
  a = int(input())
  for j in range(a):
    x, y = map(int, input().split())
    x -= 1
    A[i][x] = y

# print(A)
res = 0
for i in range(1,2 ** N):
  i_bin = bin(i)[2:]
  i_bin = i_bin.zfill(N)
  p = [0] * N
  for j in range(N):
    p[j] = int(i_bin[j])
  isPossible = True
  for j in range(N):
    x = i_bin[j]
    if x == '1':
      for k, v in A[j].items():
        if p[k] != v:
          isPossible = False
          break
  if isPossible:
    res = max(res, sum(p))

print(res)

Measured memory_bytes: 46172
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <set>

using namespace std;

int main()
{
    int n, k, q;
    cin >> n;
    cin >> k;
    cin >> q;
    vector<int> aa(n, k - q);

    for (int i = 0; i < q; ++i)
    {
        int t;
        cin >> t;
        t--;
        aa[t]++;
    }

    for (int i = 0; i < n; ++i)
    {
        if (aa[i] > 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
N, M, Q = map(int, input().split())

S = [[0]*(N+1) for _ in range(N+1)]
for _ in range(M):
    l, r = map(int, input().split())
    S[l][r] += 1

C = [[0]*(N+1) for _ in range(N+1)]
for i in range(1, N+1):
    for j in range(1, N+1):
        C[i][j] = C[i-1][j] + C[i][j-1] + S[i][j] - C[i-1][j-1]

for _ in range(Q):
    l, r = map(int, input().split())
    print(C[r][r] - C[r][l-1] - C[l-1][r] + C[l-1][l-1])



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

typedef long long lli;

const int MAXR = 10;
const int MAXC = 10;
const int DPSIZE = 60000;
const lli MOD = 100000007LL;


int R, C;
int G[MAXR][MAXC];

int three[MAXC+1];
lli dp[2][3][DPSIZE]; // pos, need from left, need from top

void init() {
  three[0] = 1;
  for(int i = 1; i < MAXC+1; ++i) {
    three[i] = three[i-1] * 3;
  }
}

int main() {
  init();
  while(cin >> R >> C) {
    for(int i = 0; i < R; ++i) {
      for(int j = 0; j < C; ++j) {
        char c;
        cin >> c;
        if(c == '.') G[i][j] = 0;
        else G[i][j] = c - '0';
      }
    }

    fill(dp[0][0], dp[2][0], 0LL);
    dp[0][0][0] = 1LL;
    for(int i = 0; i < R; ++i) {
      for(int j = 0; j < C; ++j) {
        int p = (i*C+j) % 2;
        int q = 1-p;
        for(int l = 0; l < 3; ++l)
          for(int b = 0; b < three[C]; ++b)
            dp[q][l][b] = 0LL;

        for(int l = 0; l < 3; ++l) {
          for(int b = 0; b < three[C]; ++b) {
            if(dp[p][l][b] == 0LL) continue;
            int t = b % 3;
            if(G[i][j] == 0) {
              int k = l;
              if(j+1 == C && k != 0) continue;
              int u = t;
              if(k * u != 0) continue;
              int nb = ( b + three[C] * u ) / 3;
              dp[q][k][nb] = ( dp[q][k][nb] + dp[p][l][b] ) % MOD;
            } else {
              int r = G[i][j] - (l + t);
              if(r < 0) continue;
              for(int k = 0; k <= 2; ++k) {
                if(j+1 == C && k != 0) break;
                int u = r-k;
                if(u < 0 || u > 2) continue;
                int nb = ( b + three[C] * u ) / 3;
                dp[q][k][nb] = ( dp[q][k][nb] + dp[p][l][b] ) % MOD;
              }
            }
          }
        }
      }
    }
    cout << dp[R*C%2][0][0] << endl;
  }
  return 0;
}

Measured memory_bytes: 3968
S = input()
s_list = list(S)
n = len(s_list)

for i in range(1,n):
    a = s_list[:-i]
    if len(a)%2 == 0:
        half = a[:int(len(a)/2)]
        
        if half + half == a:
            break
    
print(len(a))

Measured memory_bytes: 38256
#include <atcoder/dsu>

#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
int main()
{
	int N,Q;
  	cin >> N >> Q;
  	dsu D(N);
  	//for (int i=0; i<N; ++i) parent[i]=i;
  	while (Q--)
    {
      	int type, node1, node2;
      	cin >> type >> node1 >> node2;
      	if (type==0) D.merge(node1, node2);
      	else cout << D.same(node1, node2) << "\n";
    }
}

Measured memory_bytes: 3884
S = list(input())
T = list(input())

count = 0
SA = []
ans = [0]

for i in range( (len(S)-len(T)) + 1):
    SA = S[i:i+len(T)]
    for j in range(len(T)):
        if (SA[j] == T[j]) == True:
            count += 1
    ans.append(count)
    count = 0

print(len(T) - max(ans))

Measured memory_bytes: 9148
#include <cstdio>
#include <algorithm>
#include <cmath>
#define Rint register int
#define LL long long
#define F(x,y,z) for(Rint x=y;x<=z;++x)
using namespace std;
inline LL R(){
    char c='!';LL x=0,z=1;
    for( ; c>'9'||c<'0';c=getchar()) if(c=='-')z=-1;
    for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';
    return x*z;
}
int anss=100000000,n,m;
char s[1000010];
int s1,s2;

int main(){
	n=R();
	scanf("%s",s);
	F(i,1,n-1) s2+=s[i]=='E';
	F(i,0,n-1){
		anss=min(anss,s1+s2);
		s2-=s[i+1]=='E';
		s1+=s[i]=='W';
	}
	printf("%d\n",anss);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cassert>
//#define NDEBUG

int include3(int i, int x){	/* どこかの桁に3が含まれているか判定 */
	using namespace std;
	do{
		if ( x % 10 == 3 ){	/* 10で割ってあまり3のとき */
			cout << " " << i;
			break;
		}
		x /= 10;			/* 10で割る(1桁右にシフト) */
	}while(x != 0);			/* 0でないなら、 再度判定 */
	return 0;
}

int main(void){
	using namespace std;
	static const int INPUT_N_MIN = 3;				/* 前提条件 */
	static const int INPUT_N_MAX = 10000;
	
	int n = 0;
	cin >> n;										/* 入力の整数n */
	assert (INPUT_N_MIN <= n && n <= INPUT_N_MAX);	/* 前提条件 */
	
	int i = 1;
	int x;
	do{
		x = i;
		
		if ( x % 3 == 0 ){		/* 3の倍数のとき出力 */
			cout << " " << i;
		}
		else {
			include3(i, x);		/* 10の倍数+3のとき出力 */
		}
	}while ( ++i <= n );
	cout << endl;
	return 0;
}
	


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const int MAX = 1e6 + 10;
const int MOD = 1e9 + 7;
const int oo = 1e9;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	#define endl '\n'
	string s; cin >> s;
	int n = s.size();
	int b = 1, e = n;
	while(b < e){
		int m = (b + e) / 2;
		bool pos = true;
		int rd = 0, ru = m;
		int phase = 1;
		for(int i = 0; i < n; i++){
			if(s[i] == '0'){
				rd--; ru--;
			}
			else if(s[i] == '1'){
				rd++, ru++;
			}
			else{
				rd--; ru++;
			}
			if(rd < 0)rd += phase;
			if(ru > m) ru -= phase;
			if(ru < rd){
				pos = false; break;
			}
			if(ru == rd && phase == 1)phase = 2;
		}
		if(pos) e = m;
		else b = m + 1;
	}
	cout << b << endl;

}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  string ans="";
  while(n) {
    ll id=(n-1)%26;
    ans=char('a'+id)+ans;
    if(n==26) break;
    n--;
    n/=26;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

bool valid(int N, int K, int x) {
  int wsum = 1;
  for (int i = 1; i < x; ++i) {
    int n = (wsum+K-1) / K;
    wsum += n;
    if (wsum > N) return false;
  }
  return wsum <= N;
}

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

  int lb = 1;
  int ub = N+1;
  while (ub-lb > 1) {
    int mid = (lb+ub) >> 1;
    (valid(N, K, mid)? lb:ub) = mid;
  }
  printf("%d\n", lb);
}



Measured memory_bytes: 2688
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),m=sc.nextInt();
        int[] p = new int[m];
        String[] q = new String[m];
        boolean[] check = new boolean[n+1];
        int[] count = new int[n+1];
        int countAC = 0;
        int countWA = 0;
        for(int i = 0 ; i<m;i++){
            p[i] = sc.nextInt();
            q[i] = sc.next();
            if(q[i].equals("AC")){
                check[p[i]] = true;
            } else {
                if(!check[p[i]]){
                    count[p[i]] ++;
                }
            }
        }
        for(int i = 1;i<=n;i++){
            if(check[i]){
                countAC ++;
                countWA += count[i];
            }
        }
        System.out.println(countAC+" "+countWA);
    }
}

Measured memory_bytes: 71648
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
//Variables End


void solve(){
	int n,m;cin>>n>>m;
	int a=1,b;
	if(n&1){
		b=2*m-1;
		for(int i=1;i<=m;i++){
		
			cout<<a<<" "<<a+b<<"\n";
			a++;b-=2;
		}
	}
	else{
		int st1,st2;
		if(m&1)st1=m,st2=m-1;
		else st1=m-1,st2=m;
		a=n;
		for(;st1>0;st1-=2){
			cout<<a<<" "<<a-st1<<"\n";
			a--;
		}
		a=1;
		for(;st2>0;st2-=2){
			cout<<a<<" "<<a+st2<<"\n";
			a++;
		}
	}
	
}
int main()
{
    ios
    int ti=1;
    //cin>>ti;
    for(int i=1;i<=ti;i++)
    {
		solve();        
    }
    return 0;
        
}


Measured memory_bytes: 3664
n = int(input())
all = {key:[i for i in range(1, 14)] for key in ("S", "H", "C", "D")}

for _ in range(n):
    mark, num = iter(input().split())
    all[mark].remove(int(num))
    
for key in all:
    for num in all[key]:
        print("{} {}".format(key, num))


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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;
	int a[2][3];
	cin >> a[0][0] >> a[0][1] >> a[0][2];
	for(int i = 1; i < n; i++){
		cin >> a[1][0] >> a[1][1] >> a[1][2];
		
		a[1][0] += max(a[0][1], a[0][2]);
		a[1][1] += max(a[0][0], a[0][2]);
		a[1][2] += max(a[0][0], a[0][1]);

		a[0][0] = a[1][0];
		a[0][1] = a[1][1];
		a[0][2] = a[1][2];
	}

	cout << max(a[0][0], max(a[0][1], a[0][2]));

	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int64_t> a(n);
	for (auto &i : a) {
		cin >> i;
	}
	int64_t x = *max_element(a.begin(), a.end()), y = 1ll << 60;
	for (auto &i : a) {
		if (i == x) {
			continue;
		}
		if (abs(x * 0.5 - i) < abs(x * 0.5 - y)) {
			y = i;
		}
	}
	cout << x << ' ' << y << endl;
	return 0;
}

Measured memory_bytes: 1024
function main(input) {
  const args = input.split('\n');
  const A = parseInt(args[0], 10);
  const B = parseInt(args[1], 10);
  const C = parseInt(args[2], 10);
  const X = parseInt(args[3], 10);

  const patArray=[];
  for(var a=0; a<=A; a++){
    for(var b=0; b<=B; b++){
      for(var c=0; c<=C; c++){
        patArray.push(500*a+100*b+50*c);
      }
    }
  }
console.log(patArray.filter(function(x){return x==X}).length);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 10956
#include<iostream>
using namespace std;
int main()
{int n;
 cin>>n;
 if(n%10==3)
   cout<<"bon";
 else if(n%10==1||n%10==6||n%10==8||n%10==0)
   cout<<"pon";
 else cout<<"hon";
 return 0;
}

Measured memory_bytes: 3640
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Sun Feb  2 15:07:45 2020
//
package main

import "fmt"

const MOD = 1e9 + 7

var H, A int

func main() {
	fmt.Scan(&H, &A)
	fmt.Println((H + A - 1) / A)
}


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





int main()
{

    static std::string btn[][8] = {
        {" "},
        {"'", ",", ".", "!", "?"},
        {"a", "b", "c", "A", "B", "C"},
        {"d", "e", "f", "D", "E", "F"},
        {"g", "h", "i", "G", "H", "I"},
        {"j", "k", "l", "J", "K", "L"},
        {"m", "n", "o", "M", "N", "O"},
        {"p", "q", "r", "s", "P", "Q", "R", "S"},
        {"t", "u", "v", "T", "U", "V"},
        {"w", "x", "y", "z", "W", "X", "Y", "Z"}
    };
    static int size[10] = {1, 5, 6, 6, 6, 6, 6, 8, 6, 8};

    std::string str;
    while (std::cin >> str) {

        std::string res = "";
        char b = '*';
        int t, idx, ct = 0;
        bool isPressed0 = true;

        for (unsigned long i = 0; i < str.size(); i++) {
            if (isPressed0) {
                if (str[i] == '0') {
                    ct++;
                    continue;
                }
                //else set next btn
                if (ct > 0) {
                    while (ct > 0) {
                        res += " ";
                        ct--;
                    }
                }

                b = str[i];
                t = 0;
                isPressed0 = false;
            }
            else if (!isPressed0) {
                if (str[i] == '0') {
                    ct = 0;
                    idx = int(b - '0');
                    res += btn[idx][t % size[idx]];
                    t = 0;
                    isPressed0 = true;
                } else {
                    if (str[i] == b) {
                        t++;
                    } else {
                        idx = int(b - '0');
                        res += btn[idx][t % size[idx]];
                        t = 0;
                        b = str[i];
                    }
                }
            }
        }
        if (!isPressed0) {
            idx = int(b - '0');
            res += btn[idx][t % size[idx]];
        }
        std::cout << res << std::endl;

    }

    return 0;
}



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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

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

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

double dp[305][305][305];
int n;

double rec(int i, int j, int k){
  if(dp[i][j][k]>0) return dp[i][j][k];
  if(i==0 && j==0 && k==0){
    return 0.0;
  }
  if(i>0) dp[i][j][k]+=rec(i-1,j,k)*i;
  if(j>0) dp[i][j][k]+=rec(i+1,j-1,k)*j;
  if(k>0) dp[i][j][k]+=rec(i,j+1,k-1)*k;
  dp[i][j][k]+=n;
  dp[i][j][k]/=(double)(i+j+k);
  return dp[i][j][k];
}

int main(){
  cin>>n;
  int a=0, b=0, c=0;
  rep(i,n){
    int x; cin>>x;
    if(x==1) a++;
    if(x==2) b++;
    if(x==3) c++;
  }
  
  coutd(rec(a, b, c));
}

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

int main(void){
	
	int a[3];
	for(int i=0;i<3;i++){
		cin>>a[i];
	}
	int max=0;
	int total=0;
	for(int i=0;i<3;i++){
		if(max<a[i]){
			max=a[i];
		}
		total+=a[i];
	}
	if(max==(total-max)){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}

	
	return 0;
}


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

int main(){
  ll n,a,b;
  ll ans =0;

  cin>>n>>a>>b;
  
  vector<int> x(n);

  for(int i=0; i<n; i++)cin>>x[i];

  for(int i=0; i<n-1; i++){
    ans += min(b,a*(x[i+1]-x[i]));
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cassert>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	double R;
	cin >> R;
	double ans = 2 * R * PI;
	printf("%.10f", ans);
}

Measured memory_bytes: 3776
from itertools import product
N=int(input())
a=0
for i in range(3,10):
    l=list(product([3,5,7],repeat=i))
    for j in l:
        if 3 in j and 5 in j and 7 in j:
            t=0
            for k in range(i):
                t+=j[k]*10**k
            if t<=N:
                a+=1
print(a)

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

using namespace std;
static const int MAX = 200000;

int main(void) {
  int R[MAX], n;
  cin >> n;
  for (int i=0;i<n;i++) cin >>R[i];
  int maxv = -2000000000;
  int minv = R[0];

  for(int i=1;i<n;i++) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }
  cout << maxv << endl;
  return 0;
}



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

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == 7 || b == 7 || c == 7)&&(a == 5 || b == 5 || c == 5)) {
		if ((a + b + c) == 17) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef unsigned long long ll;
int N, n, M, K;

bool MONTH(int a){
    if(a >0 && a < 13) return true;
    else return false;
}

int main(){
    cin >> N;
    int a = N/100;
    int b = N- 100*a;
    if(MONTH(a) && MONTH(b)){
        cout << "AMBIGUOUS";
        return 0;
    }
    if(MONTH(a) && !MONTH(b)){
        cout << "MMYY";
        return 0;
    }
        if(!MONTH(a) && MONTH(b)){
        cout << "YYMM";
        return 0;
    }
    cout << "NA";
    return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;

}

vector<ll> G[100001];
vector<ll> used(100001, 0);
vector<ll> dist(100001, -INF);
vector<vector<ll>> dp(100001, vector<ll>(2, 0));

void solve(ll n, ll prev) {
	if (used[n]) {
		return;
	}

	used[n] = 1;
	dist[n] = dist[prev] + 1;
	dp[n][0] = 1;
	dp[n][1] = 1;

	REP(i, G[n].size()) {
		solve(G[n][i], n);

		if (dist[G[n][i]] <= dist[prev]) {
			continue;
		}

		dp[n][0] = (dp[n][0] * ((dp[G[n][i]][0] + dp[G[n][i]][1]) % MOD)) % MOD;
		dp[n][1] = (dp[n][1] * dp[G[n][i]][0]) % MOD;
	}
}

signed main() {
	ll n, x, y;

	cin >> n;

	REP(i, n - 1) {
		cin >> x >> y;
		G[x].push_back(y);
		G[y].push_back(x);
	}

	dist[0] = -1;
	solve(1, 0);

	cout << (dp[1][0] + dp[1][1]) % MOD << endl;
}

Measured memory_bytes: 18304
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
    int num[4];
    int l, s;
    int n;

    scanf("%1d%1d%1d%1d", &num[0], &num[1], &num[2], &num[3]);
    while (num[0] != 0 || num[1] != 0 || num[2] != 0 || num[3] != 0) {
        
        if (num[0] == num[1] && num[1] == num[2] && num[2] == num[3]) {
            printf("NA\n");
        } else {
            int ans = 0;
            n = num[0] * 1000 + num[1] * 100 + num[2] * 10 + num[3];
            
            while (n != 6174) {
                sort(num, num + 4, greater<int>());
                l = num[0] * 1000 + num[1] * 100 + num[2] * 10 + num[3];
                sort(num, num + 4);
                s = num[0] * 1000 + num[1] * 100 + num[2] * 10 + num[3];

                n = l - s;
                num[0] = n / 1000;
                num[1] = (n / 100) % 10;
                num[2] = (n / 10 ) % 10;
                num[3] = n % 10;


                ans++;
            }

            printf("%d\n", ans);
        }

        scanf("%1d%1d%1d%1d", &num[0], &num[1], &num[2], &num[3]);
    }
    
    return 0;
}



Measured memory_bytes: 3236
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    if(n < 1000)
        cout << "ABC" << endl;
    else
        cout << "ABD" << endl;

    return 0;
}


Measured memory_bytes: 256
N, K = map(int,input().split())
from itertools import accumulate
A = [0] + list(accumulate(list(map(lambda x:(int(x)+1)/2,input().split()))))
M = 0
for x in range(N - K +  1):
    M = max(M,A[x + K] - A[x])
print(M)


Measured memory_bytes: 78728
from math import log2
n = int(input())
a = list(map(int, input().split()))
ans = 0

for _a in a:
    if _a%2 == 0:
        cnt =0
        while _a%2 == 0:
            _a //= 2
            cnt += 1
        ans += cnt

print(int(ans))

Measured memory_bytes: 4148