akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define long long long
#define ull unsigned long long
#define up(i,a,b) for (int i=a; i<=b; i++)
#define down(i,a,b) for (int i=a; i>=b; i--)
#define endl '\n'
#define pb push_back
#define X first
#define Y second
#define II pair<int, int>
#define III pair<int, pair<int, int> >
#define V vector
#define debug(X) cerr<< #X << " = " <<X << endl
#define debug2(X,Y) cerr<< #X << " = " <<X << ","<<#Y<<" = "<<Y<<endl
#define show(X,a,b) {cerr << #X << " = "; up(__,a,b) cerr << X[__] << ' '; cerr << endl;}
#define gc getchar
#define pc putchar

using namespace std;

inline void read(int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for (;((c<48 || c>57) && c != '-') ;c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}
inline void writeln(int x){

         char buffor[21];
         register int i=0;
         int neg=0; if (x<0) {neg=1; x= -x;}
         do{
               buffor[i++]=(x%10)+'0';
               x/=10;
            } while(x);
           i--;
           if (neg) pc('-');
           while(i>=0) pc(buffor[i--]);
           pc('\n');
       }
const int oo= 1e6;
int m,n;

V<int> a[210];
//s=0, row= i, col= m+ j, t= m+n+1
int sz;
bool vis[210];
int trace[210];
int f[210][210],c[210][210];
void addedge(int u,int v ,int cc)
{
    a[u].pb(v); c[u][v]= cc;
    a[v].pb(u); c[v][u]= cc;
}
void input()
{
    cin>>m>>n; sz= m+n+2;
    up(i,1,m)
     up(j,1,n)
      {
      	char c; cin>>c;
      	if (c=='o') addedge(i,j+m,1);
      	else if (c=='S')
		{
			addedge(0,i,oo); addedge(0,j+m,oo);
		}
		else if (c=='T')
		{
			addedge(sz-1,i,oo); addedge(sz-1,j+m,oo);
		}

      };
}
bool bfs()
{
    fill(vis+0,vis+0+sz,0);
    queue<int> q;
    q.push(0); vis[0]= true;
    while (!q.empty())
	{
		int u= q.front(); q.pop();
		for (auto v: a[u])
		{
			if (!vis[v] and f[u][v]< c[u][v])
			{
				trace[v]= u; vis[v]= true;
				if (v== sz-1) return true;
				q.push(v);
			}
		}
	}
	return false;
}
void incflow()
{
    int v= sz-1; int minf= oo;
    while (v!=0)
	{
		minf= min(minf, c[ trace[v]][v]- f[trace[v]][v] );
		v= trace[v];
	};
	v= sz-1;
	while (v!= 0)
	{
        f[trace[v]][v]+= minf; f[v][trace[v]]-= minf;
		v= trace[v];
	};

}

void calmincut()
{
    int res=0;
    up(u,0,sz-1)
     if (vis[u])
	 {
	 	for (auto v: a[u])
		  if (!vis[v]) res+= f[u][v];
	 }
    if (res>=oo) cout<<-1; else cout<<res;
}
void solve()
{
    while (bfs()) incflow();
	calmincut();
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);// don't use when interactive
    #define TASK "tmp"
   // freopen(TASK".inp","r",stdin);
   // freopen(TASK".out","w",stdout);

    input();
    solve();

    return 0;
}


Measured memory_bytes: 768
/*Author : Harsh AKA Codula*/

#include<iostream>
using namespace std;
#define ll long long
#define inp freopen("input.txt","r",stdin)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
 
//main class

class Solution
{
	public:
		void run()
		{
			ll t=1;//cin>>t;
			while(t--)
			{
				int n,x,p;
				cin>>n>>x>>p;
				if(x>n+1)cout<<p;
				else
				{
					int a;
					a=0;
					int cache=x;
					while(cache<n)
					{
						cache=cache+x;
						a=a+1;
					}
					cout<<(a+1)*p;
				}
				cout<<"\n";
			}
		}	
};
//driver func

int main()
{
	//fast;
	//inp;
	Solution MAIN1;
	MAIN1.run();
	return 0;
}


Measured memory_bytes: 3560
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll X, N;
    cin >> X >> N;
    VL p(N);
    rep(i,0,N)cin>>p[i];
    sort(ALL(p));
    
    ll ma=105;
    ll ans=0;
    ll d=abs(X-ans);
    rep(i,0,ma){
        ll flg=0;
        rep(j,0,N){
            if(p[j]==i){
                flg=1;break;
            }
        }
        if(flg==1)continue;
        if(abs(X-i)<d){ans=i;d=abs(X-i);}
    }

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


Measured memory_bytes: 3628
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	s := strings.Split(nextLine(), " ")
	a, _ := strconv.ParseFloat(s[0], 64)
	b, _ := strconv.ParseFloat(s[1], 64)
	x, _ := strconv.ParseFloat(s[2], 64)
	var result float64

	if hulf := a * a * b / 2; x < hulf {
		result = math.Atan(a*b*b/2/x) * 180 / math.Pi
	} else if x == hulf {
		result = 45
	} else {
		result = math.Atan((a*a*b-x)*2/a/a/a) * 180 / math.Pi
	}

	fmt.Println(result)
}


Measured memory_bytes: 640
//AtCoder Biginner Contest 173 A問題

#include <stdio.h>

int main(void) {
    int n, m;

    scanf("%d", &n);

    m = n % 1000;

    if (m == 0) {
        printf("%d", 0);
    } else {
        m = 1000 - m;
        printf("%d", m);
    }

    return 0;
}


Measured memory_bytes: 1736
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
      String[] split = input.split(" ");
        int totalPower = Integer.parseInt(split[0]);
        int power = Integer.parseInt(split[1]);
        int count =  (int) Math.ceil((double)totalPower/power);
        System.out.println(count);
    }
}

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

int n;
char s[200010];
int ans;
inline void solve(int T)
{
    cin >> s;
    n = strlen(s);
    rep(i, 0, n - 1) ans += s[i] - '0';
    puts(ans % 9 ? "No" : "Yes");
}

int main()
{
    // ios_base::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);
 
    int T = 1;
    // cin >> T;
    rep(i, 1, T) solve(i);
    
    // system("pause");
}

Measured memory_bytes: 3756
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;

//D
int main(){
int a,b; cin>>a>>b;
int ans = 0;

for(ans = 0;true;ans++){
  if((a-1)*(ans-1) + a >= b) {cout<<ans<<endl;break;}
}

    return 0 ;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
#include<string.h>
#include<sstream>
#include<limits.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;

//最大公約数
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;
}

//素数判定
bool isPrime(int x){
    if(x<2)return 0;
    else if(x==2)return 1;
    if(x%2==0)return 0;
    for(int i=3;i*i<=x;i+=2){
        if(x%i==0)return 0;
    }
    return 1;
}

//桁ごとの足し算
int digsum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}

//約数列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i=1;i*i<=n;++i){
        if(n%i==0){
            ret.push_back(i);
            if(i*i !=n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//累乗の計算とあまり,0で累乗そのまま出力
long long modpow(long long a,long long n,long long mod){
    if(mod==0)mod=__LONG_LONG_MAX__;
    long long res=1;
    while(n>0){
        if(n & 1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

int D,T,S;
int main(){
    cin>>D>>T>>S;
    if(D<=S*T)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3628
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.stdio;
import std.string;
import std.range;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

double distance(double x1, double y1, double x2, double y2) {
    double sq(double n) {
        return n * n;
    }

    return sqrt(sq(x1 - x2) + sq(y1 - y2));
}

void main() {
    auto xs = readln.split.map!(to!double).array;

    auto ans = distance(xs[0], xs[1], xs[2], xs[3]);
    writefln("%.6f", ans);
}

Measured memory_bytes: 2572
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int N, Q, A, B, C, cnt[100001];
	long long ans = 0;
	scanf("%d", &N);
	fill_n(cnt, 100001, 0);
	for (int i = 0; i < N; ++i) scanf("%d", &A), ++cnt[A], ans += A;
	scanf("%d", &Q);
	for (int i = 0; i < Q; ++i) {
		scanf("%d %d", &B, &C);
		ans += (C - B) * cnt[B];
		cnt[C] += cnt[B];
		cnt[B] = 0;
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2120
#include <stdio.h>

int main(int argc, char const *argv[])
{
  int n;
  int m;
  if (scanf("%d %d", &n, &m) == -1) {
    printf("Failed to read integer.\n");
  }
  
  int lr[2][m];

  int i = 0;
  for(i = 0;i < m;i++) {
    if (scanf("%d %d", &lr[0][i], &lr[1][i]) == -1) {
      printf("Failed to read integer.\n");
    }
  }
  int left = 1;
  int right = 1000000;
  for(i = 0;i < m;i++) {
    if (left < lr[0][i]) {
      left = lr[0][i];
    }
    if (right > lr[1][i]) {
      right = lr[1][i];
    }
  }
  if (right - left + 1 < 0) {
    printf("%d\n", 0);
    return 0;
  }
  printf("%d\n", right - left + 1);
  return 0;
}

Measured memory_bytes: 896
from collections import*
n,m,*t=map(int,open(0).read().split())
i,o,r=[0]*n,[[]for _ in'_'*n],[]
for a,b in zip(*[iter(t)]*2):
  o[a-1]+=b-1,
  i[b-1]+=1
q=deque(v for v in range(n)if i[v]<1)
while q:
  v=q.popleft()
  r+=v,
  for w in o[v]:
    i[w]-=1
    if i[w]==0:q+=w,
print(-(len(r)==n))

Measured memory_bytes: 3828
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
    lint a, b, c, d, e, n;
    cin >> n >> a >> b >> c >> d >> e;
    cout << lint(ceil(double(n) / min({a, b, c, d, e})) + 4) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int maxn = 200010;

int main()
{
    int R[maxn],n;

    while(cin>>n)
    {
        for(int i=0; i<n; i++)cin>>R[i];

        int maxv = 0x8f8f8f8f;
        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: 3864
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(){
  int N,T,L,B;
  while(1){
    cin >> N >> T >> L >> B;
    if(N==0&&T==0&&L==0&&B==0)break;
    int Lose[L];
    int Back[B];
    float P[T+1][N+1];
    float Stack[T+1][N+1];

    for(int i=0;i<L;++i){
      cin >> Lose[i];
    }
    for(int i=0;i<B;++i){
      cin >> Back[i];
    }
  
    
    for(int t=0;t<=T;++t){
      for(int n=0;n<=N;++n){
	P[t][n]=0.0;
	Stack[t][n]=0.0;
      }
    }
    P[0][0]=1.0;
    for(int t=0;t<T;++t){
      for(int n=0;n<=N;++n){

	if(Stack[t][n]>0) {
	  P[t+1][n]+=Stack[t][n];
	}
	
	if(n>6*(t+1)) break;
	else if(n==N)P[t+1][n]+=P[t][n];
	else if(P[t][n]!=0.0){
	  for(int s=1;s<=6;++s){
	    int proceed=s;
	    if(n+s>N) proceed=2*(N-n)-s;
	    if(binary_search(Back,Back+B,n+proceed)){
	      P[t+1][0]+=P[t][n]/6.0;
	    }
	    else if(binary_search(Lose,Lose+L,n+proceed)){
	      Stack[t+1][n+proceed]+=P[t][n]/6.0;
	    }
	    else P[t+1][n+proceed]+=P[t][n]/6.0;
	  }
	}
      }
    }
    cout << fixed <<  P[T][N] << endl;	
  }
}
      
  

Measured memory_bytes: 1320
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#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;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};


bool check(vector<int> &vec){
    for(int a = 0;a < vec.size();a++){
        if(vec.at(a)!=0)return false;
    }
    return true;
}
int main(){
    CIN(N);
    I vec;
    REP(a,N){
        CIN(b);
        vec.push_back(b);
    }
    int ans = 0;
    vec.push_back(0);
    while(!check(vec)){
        int s = -1,t = -1;
        for(int a = 0;a < N+1;a++){
            if(vec.at(a) != 0 && s == -1){
                s = a;
            }
            if(vec.at(a) == 0 && s != -1){
                t = a;
                break;
            }
        }
        for(int a = s ; a < t;a++){
            vec.at(a)--;
        }
        ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
H, W, K = gets.split.map(&:to_i)
c = H.times.map{gets.chomp.chars.map(&:to_i)}
c = c.reverse.transpose
i = 10
c.each{|cc| W.times{cc<<i; i+=1}}
c << (H*2).times.map{i+=1}
C = c
def fall
  @c.each{|cc| cc.compact!}
end
def vanish
  s = 0
  (0...H).each do |j|
    r = -1
    c = 0
    (0..W).each do |i|
      if @c[i][j]==r
        c += 1
      else
        begin
          (1..c).each{|l| s += @c[i-l][j]; @c[i-l][j] = nil} if c>=K
        rescue
        end
        r = @c[i][j]
        c = 1
      end
    end
  end
  fall
  s
end
ans = 0
(0...H).each do |j|
  (0...W).each do |i|
    su = 0
    @c = C.map{|cc| cc.dup}
    @c[i][j] = nil
    fall
    d = 1
    loop do
      f = vanish
      break if f==0
      su += d*f
      d *= 2
    end
    ans = su if ans < su
  end
end
p ans

Measured memory_bytes: 4988
import itertools

n=int(input())
a=list(int(input()) for i in range(n))
b=[]
a.sort()
ans=0

if n%2==1:
    x=2*sum(a[n//2+1:])-2*sum(a[:n//2+1])+sum(a[n//2-1:n//2+1])
    y=2*sum(a[n//2:])-sum(a[n//2:n//2+2])-2*sum(a[:n//2])
    print(max(x,y))

else:
    x=2*sum(a[n//2:])-(a[n//2]) -2*sum(a[:n//2])+a[n//2-1]
    print(x)
        
        
        




Measured memory_bytes: 53336
#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++)
const int INF = pow(2, 31) - 1;
int main(){
    int n, W;
    cin >> n >> W;
    vector<int> dp(W+1, 0);
    rep(i,n){
        int v, w, m;
        cin >> v >> w >> m;
        for(int k = 0; m > 0; k++){
            int num = min(m, 1<<k);
            m -= num;
            for(int j = W; j >= w*num; j--)dp[j] = max(dp[j], dp[j - w*num] + v*num);
            //cout << "num = " << num << endl;
            //rep(j,W+1)cout << dp[j] << ((j < W)? " " : "\n");
        }
    }

    vector<int>::iterator it = max_element(dp.begin(), dp.end());
    cout << *it << endl;
    return 0;
}


Measured memory_bytes: 3128
N,M,C=map(int,(input()).split())
List_B=[int(i) for i in (input()).split()]
t=0
for j in range(1,N+1):
  List_A=[int(k) for k in (input()).split()]
  if sum([x*y for (x,y) in zip(List_A,List_B)])>-C:
    t+=1
print(t)

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

int N;
int ts, xs, ys;
int tg, xg, yg;
int ans = true;

int main() {
	cin >> N;
	ts = 0, xs = 0, ys = 0;
	for (int i = 0; i < N; i++) {
		cin >> tg >> xg >> yg;
		int dt = tg - ts - (abs(xg - xs) + abs(yg - ys));
		if ( dt < 0 || dt% 2 != 0) {
			ans = false;
			break;
		}
	}

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

Measured memory_bytes: 256
def main():
    K = int(input())
    A, B = map(int, input().split())

    a = A // K
    a_mod = A % K
    if(a_mod == 0):
        print("OK")
    else:
        dist = K * (a+1)
        if(dist >= A and dist<= B):
            print("OK")
        else:
            print("NG")

main()

Measured memory_bytes: 61676
//
//  main.cpp
//  AtCoder - D.Restoring Road Network
//
//  Created by S M HEMEL on 3/2/18.
//  Copyright © 2018 Eastern University. All rights reserved.
//

#include <iostream>
#include <cstring>
#include <algorithm>
#define N 311
#define inf 1000000100
using namespace std;
int matrix[N][N];
int dis[N][N];
int main(){
    int n;
    cin >> n;
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            cin >> matrix[i][j];
   memset(dis,inf,sizeof(dis));
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            for(int k=0; k<n; k++)
                dis[i][j] = min(dis[i][j],matrix[k][j]+matrix[i][k]);
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            if(dis[i][j]!=matrix[i][j])
                return 0 * puts("-1");
    long long int ans = 0;
    for(int i=0; i<n; i++)
        for(int j=i+1; j<n; j++){
            bool flag = true;
            for(int k=0; k<n; k++){
                if((dis[i][j]==dis[i][k]+dis[k][j]) && dis[i][j]!=dis[i][k] && dis[i][j]!=dis[k][j])
                    flag = false;
            }
            if(flag) ans += dis[i][j];
        }
    cout << ans << endl;
    return 0;
}


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

int main(){
	long N;
	cin >> N;
	vector<string> S(N);
	for(long i=0; i<N; i++) cin >> S.at(i);

	vector<long> C(4,0);
	for(int i=0; i<N; i++){
		if(S.at(i) == "AC"){
			C.at(0)++;
		}else if(S.at(i) == "WA"){
			C.at(1)++;
		}else if(S.at(i) == "TLE"){
			C.at(2)++;
		}else if(S.at(i) == "RE"){
			C.at(3)++;
		}
	}

	cout << "AC x " << C.at(0) << endl;
	cout << "WA x " << C.at(1) << endl;
	cout << "TLE x " << C.at(2) << endl;
	cout << "RE x " << C.at(3) << endl;
}


Measured memory_bytes: 6424
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

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

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i; j < N; ++j) {
            if(i==j) continue;
            ans += d[i]*d[j];
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define IL inline
# define RG register
# define Fill(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
const int _(1e5 + 10);

IL ll Read(){
	RG char c = getchar(); RG ll x = 0, z = 1;
	for(; c < '0' || c > '9'; c = getchar()) z = c == '-' ? -1 : 1;
	for(; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x * z;
}

int n, k, ans, A[2010][2010], B[2010][2010];

IL int S(RG int opt, RG int x, RG int y, RG int xx, RG int yy){
	if(!opt) return A[xx][yy] - A[xx][y - 1] - A[x - 1][yy] + A[x - 1][y - 1];
	return B[xx][yy] - B[xx][y - 1] - B[x - 1][yy] + B[x - 1][y - 1];
}

int main(RG int argc, RG char* argv[]){
	n = Read(); k = Read(); RG int kk = k * 2;
	for(RG int i = 1, x, y, c; i <= n; ++i){
		x = Read() % kk + 1, y = Read() % kk + 1;
		RG char ch; scanf(" %c", &ch);
		c = ch == 'B'; A[x][y] += c; B[x][y] += c ^ 1;
	}
	for(RG int i = 1; i <= kk; ++i)
		for(RG int j = 1; j <= kk; ++j){
			A[i][j] += A[i - 1][j] + A[i][j - 1] - A[i - 1][j - 1];
			B[i][j] += B[i - 1][j] + B[i][j - 1] - B[i - 1][j - 1];
		}
	for(RG int i = 1; i <= k; ++i)
		for(RG int j = 1, cnt; j <= k; ++j){/*
			res=S(b,1,1,x,y) + S(b,x+k+1,1,K,y) + S(b,x+k+1,y+k+1,K,K) +
				S(b,1,y+k+1,x,K) + S(b,x+1,y+1,x+k,y+k) +
				S(w,x+1,1,x+k,y) + S(w,x+k+1,y+1,K,y+k) + S(w,x+1,y+k+1,x+k,K) + S(w,1,y+1,x,y+k);*/
			cnt = S(0, 1, 1, i, j) + S(0, i + k + 1, 1, kk, j);
			cnt += S(0, i + k + 1, j + k + 1, kk, kk) + S(0, 1, j + k + 1, i, kk) + S(0, i + 1, j + 1, i + k, j + k);
			cnt += S(1, i + 1, 1, i + k, j) + S(1, i + k + 1, j + 1, kk, j + k) + S(1, i + 1, j + k + 1, i + k, kk);
			cnt += S(1, 1, j + 1, i, j + k);
			ans = max(ans, max(cnt, n - cnt));
		}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 31744
function Main(input) {
  input = input.split("\n");
  var N = input[0];
  var H = input[1].split(" ").map(Number);
  var Maxcount = 0;
  var combo = 0;
  for( var i = 1 ; i < N ; i++){
    
    if(H[i] <= H[i-1]){
	combo ++;
      if(combo >=Maxcount){
        Maxcount = combo;
      }
  }else{
        combo = 0;
      }
  }
console.log(Maxcount);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 17816
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

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

int N, M;
int C[16], x[20000];
int dp[20001][256];
const int INF = 1000000000;

int main() {
  while(true) {
    cin >> N >> M;
    if(N == 0 && M == 0) break;
    rep(i, M) {
      cin >> C[i];
    }
    rep(i, N) {
      cin >> x[i];
    }
    rep(i, N+1) {
      rep(j, 256) {
        dp[i][j] = INF;
      }
    }
    dp[0][128] = 0;
    for(int i = 0; i < N; i++) {
      for(int j = 0; j <= 255; j++) {
        for(int k = 0; k < M; k++) {
          int next = j + C[k];
          if(next < 0) next = 0;
          if(next > 255) next = 255;
          dp[i+1][next] = min(dp[i+1][next], dp[i][j] + (x[i] - next) * (x[i] - next));
        }
      }
    }
    int ans = INF;
    rep(i, 256) {
      ans = min(ans, dp[N][i]);
    }
    cout << ans << endl;

  }
  return 0;
}


Measured memory_bytes: 23056
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;

using Graph = vector<vector<pair<int, int>>>;
Graph G;

vector<char> ans;

// v は現在見ている頂点, p は v の親
void dfs(int v, int p, char c) {
    // cout << "* " << v << endl;
    ans[v] = c;
    for (auto nv : G[v]) {
        // cout << "nv = " << nv.first << endl;
        if (ans[nv.first] != -1) continue;

        if (nv.second & 0x1) {
            dfs(nv.first, v, c == '0' ? '1' : '0');
        } else {
            dfs(nv.first, v, c);
        }
    }
}

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

    G.assign(N, vector<pair<int, int>>());
    ans.assign(N, -1);

    for (int i = 0; i < N - 1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        --u;
        --v;

        G[u].push_back({v, w});
        G[v].push_back({u, w});
    }

    int root = 0;
    ans[root] = '0';
    dfs(root, -1, '0');

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


Measured memory_bytes: 7936
import java.util.Scanner;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int a = sc.nextInt(), b = sc.nextInt();
        int x = b - a;
        int current = 0, prev = 1;
        for (int i = 2; i <= 999; i++) {
            current = prev + i;
            if (current - prev == x) {
                System.out.println(current - b);
                return;
            }
            prev = current;
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

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

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a,b;
int main() {
	ll n;
	cin>>n;
	cin>>a>>b;
	for(int i=1;i<n;i++){
		ll x,y;
		cin>>x>>y;
		ll X=(x+a-1)/x;
		ll Y=(y+b-1)/y;
		ll seki=max(X,Y);
		a=seki*x;
		b=seki*y;
	}
	cout << a+b;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var array = new int[n];
            var max = 0;
            for (var i = 0; i < n; i++)
            {
                array[i] = int.Parse(Console.ReadLine());
                max = Math.Max(array[i], max);
            }

            var total = 0;

            for (var i = 0; i < n; i++)
            {
                if (max == array[i])
                {
                    total += array[i] / 2;
                    max = 0;
                }
                else
                    total += array[i];
            }
            Console.WriteLine(total);
        }
    }
}

Measured memory_bytes: 11092
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a)
	fmt.Scan(&b)
	if a%2 == 1 && b%2 == 1 {
		fmt.Println("Odd")
	} else {
		fmt.Println("Even")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int s;
  cin >> s;
  vector<mint> dp(s+10, 1);
  dp[0] = 0;
  dp[1] = 0;
  dp[2] = 0;

  for (int i = 6; i <= s+3; ++i) {
    for (int j = 3; j < s; ++j) {
      if(i-j < 3) break;
      dp[i] += dp[i-j];
    }
  }

  cout << dp[s] << endl;

}


Measured memory_bytes: 3672
function Main(input) {
    var input  = input.split(' ');
    var n = input[0];
    var a = input[1];
    var b = input[2];
    var Sum = 0;
    for (j = 1; j <= n; j++) {
        if(0 <= j && j <= 9) {
            if(a <= j && j <= b) {
                Sum += j;
            }
        } else {
        var str = j.toString();
        var arr = str.split('').map(n => parseInt(n));
        var x = arr.reduce(function(prev, current, i, arr) {
                return prev+current;
            });
        };
        if(a <= x && x <= b) {
            Sum += j;
        }
    
    }
    console.log(Sum);

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

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

//順列を作成する


int main()
{
    int n;
    std::cin>>n;
    std::vector<std::pair<int,int>> a(n);
    for(int i=0;i<n;i++){
        int tmp1,tmp2;
        std::cin>>tmp1>>tmp2;
        a[i] = {tmp1,tmp2};
    }
    long double cnt = 0;
    std::sort(a.begin(),a.end());
    do{
        for(int i=1;i<n;i++){
            cnt += std::sqrt((a[i-1].first-a[i].first)*(a[i-1].first-a[i].first) + (a[i-1].second-a[i].second)*(a[i-1].second-a[i].second));
        }
    }while(next_permutation(a.begin(), a.end()));
    double nn=1;
    for(int i=1;i<=n;i++){
        nn*=i;
    }
    std::cout<<std::setprecision(10)<<cnt/nn<<std::endl;
}

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

using namespace std;
using lint = long long;
const auto MOD = (long long) 1e9 + 7;

int main() {
    lint N, K;
    cin >> N >> K;

    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        B[i] = A[i];
    }
    sort(B.begin(), B.end());

    lint ans = 0;
    lint cnt1 = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (A[i] > A[j]) cnt1++;
        }
    }
    ans += cnt1 * K % MOD;

    lint cnt2 = 0;
    lint t = K * (K - 1) / 2 % MOD;
    for (int i = 0; i < N; i++) {
        cnt2 += lower_bound(B.begin(), B.end(), A[i]) - B.begin();
        cnt2 %= MOD;
    }
    ans += cnt2 * t % MOD;
    ans %= MOD;

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


Measured memory_bytes: 256
import itertools
n, m, x = map(int, input().split())
num = []
for i in range(n):
    tmp = list(map(int, input().split()))
    num.append(tmp)

res = []
for i in range(1, len(num)+1):
    for conb in itertools.combinations(num, i):
        res.append(list(conb))
mini = float('inf')
for i in range(len(res)):
    tmp2 = [0] * (m+1)
    f = True
    for j in range(len(res[i])):
        for k in range(m+1):
            tmp2[k] += res[i][j][k]
    
    for l in range(len(tmp2)-1):
        if tmp2[l+1] < x:
            f = False
    if f == True and mini > tmp2[0]:
        mini = tmp2[0]

if mini == float('inf'):
    print('-1')
else:
    print(mini)

Measured memory_bytes: 9372
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 max = B/A;
        int result = C < max ? C : max;

        System.out.println(result);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
using namespace std;
int n, m;
int main(){
	int i, j, k;
	cin >> n >> m;
	if(n >= 10 || m >= 10){
		cout << -1 << endl;
		return 0;
	}
	cout << n * m;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define ll long long int
int main(){
    ll a,b,c,d;
    scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
    ll ans_a1 = a*c;
    ll ans_a2 = a*d;
    ll ans_b1 = b*c;
    ll ans_b2 = b*d;

    if (ans_a1>ans_a2&&ans_a1>ans_b1&&ans_a1>ans_b2){
        printf("%lld\n",ans_a1);
    }
    else if(ans_a2>ans_a1&&ans_a2>ans_b1&&ans_a2>ans_b2){
        printf("%lld\n",ans_a2);
    }
    else if(ans_b1>ans_a1&&ans_b1>ans_a2&&ans_b1>ans_b2){
        printf("%lld\n",ans_b1);
    }
    else{
        printf("%lld\n",ans_b2);
    }
    return 0;
}

Measured memory_bytes: 1708
n = int(input())
li = list(map(int, input().split()))

if 0 in li:
  print(0)
else:
  result = 1
  flag = True
  for i in range(n):
    result *= li[i]
    if result > 10 ** 18:
      flag = False
      print(-1)
      break
  if flag == True:
    print(result)

Measured memory_bytes: 21792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(int i=(n);i<(x);++i)
#define SORT(x) sort(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define setp(x) setprecision(x)
using ll = long long;

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

	vector<string> S = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
	rep(i, 0, S.size()) {
		if (S[i] == s) {
			cout << 7 - i << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(x...) cerr << __LINE__ << ": " << #x << " = "; DBG::_print(x)
#else
#define DEBUG(x...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;



int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int A, B, M;
   cin >> A >> B >> M;

   VI PA(A);
   REP(i, A)
      cin >> PA[i];

   VI PB(B);
   REP(j, B)
      cin >> PB[j];

   int res = *min_element(PA.begin(), PA.end()) +
             *min_element(PB.begin(), PB.end());

   REP(m, M) {
      int x, y, c;
      cin >> x >> y >> c;
      --x, --y;
      res = min(res, PA[x] + PB[y] - c);
   }
   
   cout << res << endl;

   return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i,a,b) for(int i=(a);i<=(b);++i)
#define FD(i,b,a) for(int i=(b);i>=(a);--i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;
LL inv(LL x, LL m) { return x > m ? inv(x % m, m) : x > 1 ? inv(m % x, m) * (m - m / x) % m : x; }
LL mpow(LL a, LL k, LL m) { LL r(1); for (a %= m; k; k >>= 1, a = a * a % m) if (k & 1)r = r * a % m; return r; }


int main() {
    int n;
    scanf("%d", &n);
    vector<int> A(n);
    int tot = 0;
    FI(i, 0, n - 1) scanf("%d", &A[i]), tot += A[i];
    double avg = double(tot) / n;
    vector<double> B(n);
    FI(i, 0, n - 1) B[i] = abs(avg - A[i]);
    cout << min_element(B.begin(), B.end()) - B.begin() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 	int N,T,cnt,c,bc=0;
  	
  	cin>>N>>T;
  
	while(N--){
  		cin>>c;
  		if(c-bc<T)cnt+=(c-bc);
   		else cnt+=T; 
		bc=c;
    }
	cout<<cnt+T<<endl;
}

Measured memory_bytes: 256
from collections import *
from itertools import *
import copy
from heapq import *


N,M,R=map(int,input().split())
Rlst=list(map(int,input().split()))
ABC=[list(map(int,input().split())) for i in range(M)]

data=[[100000*200+1 for i in range(N)] for i in range(N)]
for a,b,c in ABC:
    data[a-1][b-1]=c
    data[b-1][a-1]=c

for k in range(N):
    for i in range(N):
        for j in range(N):
            data[i][j] = min(data[i][j], data[i][k] + data[k][j])



value=[]
for lst in permutations([i for i in range(R)],R):
    nagasa=0
    for i in range(R-1):
        nagasa+=data[Rlst[lst[i]]-1][Rlst[lst[i+1]]-1]
    value.append(nagasa)
print(min(value))


Measured memory_bytes: 50520
#include<bits/stdc++.h>
using namespace std;
long long n,m,h=0;
int main(){
    cin>>n>>m;
    cout<<min(n,m/2)+max(m-n*2,h)/4;//为什么要跟h比较，因为h是0，也是long long类型。而它们不能跟0比较，因为0默认是int类型。
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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


Measured memory_bytes: 26108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split();
        if(n[0][n[0].Length - 1] == n[1][0] && n[1][n[1].Length - 1] == n[2][0])
            WriteLine("YES");
        else
            WriteLine("NO");
    }
}


Measured memory_bytes: 17504
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Tarek
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CConnectCities solver = new CConnectCities();
        solver.solve(1, in, out);
        out.close();
    }

    static class CConnectCities {
        static boolean[] vis;
        static ArrayList<Integer>[] graph;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int ans = 0;
            vis = new boolean[n + 1];
            graph = new ArrayList[n + 1];
            for (int i = 1; i <= n; i++) graph[i] = new ArrayList<Integer>();
            while (m-- > 0) {
                int a = in.nextInt();
                int b = in.nextInt();
                graph[a].add(b);
                graph[b].add(a);
            }
            for (int i = 1; i <= n; i++) {
                if (!vis[i]) {
                    ans++;
                    dfs(i);
                }
            }
            out.println(ans - 1);
        }

        public void dfs(int start) {
            vis[start] = true;
            for (int k : graph[start]) {
                if (!vis[k]) {
                    dfs(k);
                }
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 70640
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
#define PI acos(-1)
using namespace std;
int main(){
  int n,tmp;
  int sum;
  int max;
  bool han=true;
  cin>>n>>tmp;
  sum=max=tmp;
  rep(i,n){
    int tmp1;
    cin>>tmp>>tmp1;
    sum+=tmp-tmp1;
    if(max<sum)max=sum;
    if(sum<0){han=false;break;}
  }
  if(han==true)cout<<max<<endl;
  else cout<<0<<endl;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<cstdlib>
#define re register
#define LL long long
#define N 2005
#define Maxn 4000000
using namespace std;
const int Mod=1e9+7;
int n,k,koiu=0;
LL f[N][N],fac[Maxn+5],inv_fac[Maxn+5];
inline LL C(int n,int m)
{
    return (((fac[m]*inv_fac[n])%Mod)*inv_fac[m-n])%Mod;
}
LL power(LL x,int P)
{
    LL ans=1,m=x;
    while(P)
    {
        if(P&1) (ans*=m)%=Mod;
        P>>=1;(m*=m)%=Mod;
    }
    return ans;
}
int main()
{
    scanf("%d%d",&n,&k);
    if(k==1)
    {
        printf("%d\n",1);
        return 0;
    }
    fac[0]=1; for(re int i=1;i<=Maxn;++i) fac[i]=(fac[i-1]*i)%Mod;
    inv_fac[Maxn]=power(fac[Maxn],Mod-2); for(re int i=Maxn-1;i>=0;--i) inv_fac[i]=(inv_fac[i+1]*(i+1))%Mod;
    f[0][0]=1;
    for(re int i=1;i<=n;++i)
    {
        for(re int j=0;j<=i;++j)
        {
            f[i][j]=f[i-1][j];
            if(!j) continue;
            (f[i][j]+=f[i][j-1]*(n-j+1)%Mod*C(k-2,n-i+(n-j+1)*(k-1)-1)%Mod)%=Mod;
        }
    }
    printf("%lld\n",f[n][n]);
    return 0;
}

Measured memory_bytes: 94080
use proconio::input;

fn main() {
    input! {
        a: usize,
        b: usize,
    }

    if a == b {
        println!("{}", a.to_string().repeat(b))
    } else if a > b {
        println!("{}", b.to_string().repeat(a))
    } else {
        println!("{}", a.to_string().repeat(b))
    }
}


Measured memory_bytes: 2144
N = int(input())
A = [int(a) for a in input().split()]

def GCD(a, b):
    a, b = max(a, b), min(a, b)
    while a % b != 0:
        a, b = b, a%b
    return b

Ans = GCD(A[0], A[1])
for i in range(2, N):
    Ans = GCD(Ans, A[i])
print(Ans)

Measured memory_bytes: 14224
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int  n, q;
	while (cin >> n >> q, n | q){
		vector<pair<int, pair<int, string>>> data(n);
		REP(i, n){
			cin >> data[i].second.second;
			int len;
			cin >> len;
			cin >> data[i].second.first;
			data[i].first = data[i].second.first - len + 1;
		}
		SORT(data);
		REP(i, q){
			int year;
			cin >> year;
			REP(i, n){
				if (data[i].first <= year&&year <= data[i].second.first){
					cout << data[i].second.second <<" "<< year - data[i].first + 1 << endl;
					goto end;
				}
				if (data[i].first > year){
					cout << "Unknown" << endl;
					goto end;
				}
			}
			cout << "Unknown" << endl;
		end:
			continue;
		}

	}
}

Measured memory_bytes: 3192
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;

#define PB push_back
#define MP make_pair

#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORD(prom, a, b) for(int prom = (a); prom > (b); prom--)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define R1(a) do{scanf("%d", &(a));}while(0)
#define R2(a, b) do{scanf("%d%d", &(a), &(b));}while(0)
#define R3(a, b, c) do{scanf("%d%d%d", &(a), &(b), &(c));}while(0)
#define SV(vec) do{int s_v_;scanf("%d", &(s_v_));vec.PB(s_v_);}while(0)
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF 1000000007

int x, y, z;

int main ()
{
  R3(x, y, z);
  swap(x, y);
  swap(x, z);
  printf("%d %d %d\n", x, y, z);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  cout<<(n-1)*(n)/2<<endl;
  return 0;
}


Measured memory_bytes: 256
n,k,j;
long dp[2<<17],mod=1e9+7;
main(a)
{
	scanf("%*d%d",&k);
	for(dp[k]=1;~scanf("%d",&a);)
	{
		for(j=k;j--;)dp[j]+=dp[j+1];
		for(j=0;j<k;j++)dp[j]=(dp[j]-dp[j+a+1])%mod;
	}
	printf("%ld",*dp);
}

Measured memory_bytes: 896
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-9;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first
int n, m;
char B[510][510];
int X[1 << 24];
int D[2][1 << 20];
bitset <510> A[510];

int main() {
	while (1) {
		scanf("%d%d", &n, &m);
		if (n == 0 && m == 0) break;
		rep(i, n) scanf("%s", B[i]);
		int ans = 0;
		if (m > 30) {
			int t[510] = {};
			rep(i, 1 << n) {
				int c = 0;
				rep(j, m) t[j] = 0;
				rep(j, n) if (1 << j & i) {
					++c;
					rep(k, m) t[k] ^= (B[j][k] - '0');
				}
				int ok = 1;
				rep(j, m) if (t[j] != 0) { ok = 0; break; }
				if (ok == 1) { ans = max(ans, c); }
			}
			printf("%d\n", ans);
		}
		else if (n <= 24) {
			X[0] = 0;
			int A[510] = {};
			rep(i, n) rep(j, m) A[i] |= (B[i][j] - '0') << j;
			rep(i, n) X[1 << i] = A[i];
			for (int i = 1; i < 1 << n; i++) {
				int t = (i & -i);
				if (i > t) X[i] = X[i - t] ^ X[t];
			}
			rep(i, 1 << n) if (X[i] == 0) ans = max(ans, __builtin_popcount(i));
			printf("%d\n", ans);
		}
		else {
			int A[510] = {};
			rep(i, n) rep(j, m) A[i] |= (B[i][j] - '0') << j;
			rep(i, 1 << m) D[1][i] = D[0][i] = -1;
			D[0][0] = 0;
			for (int i = 0; i < n; i++) {
				int t = !(i & 1);
				for (int j = 0; j < 1 << m; j++) if (D[!t][j] != -1) {
					D[t][j] = max(D[t][j], D[!t][j]);
					D[t][j ^ A[i]] = max(D[t][j ^ A[i]], D[!t][j] + 1);
				}
				rep(j, 1 << m) D[!t][j] = -1;
			}
			printf("%d\n", D[n & 1][0]);
		}
	}
	return 0;
}

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

typedef    long long          ll;
typedef    vector<long long>    vi; 
typedef    vector<vi>         vvi; 
typedef    pair<long,long>      ii; 
#define    sz(a)              long((a).size()) 
#define    pb                 push_back 
#define    mp                   make_pair
#define    all(c)             (c).begin(),(c).end() 
#define    tr(c,i)            for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define    present(c,x)       ((c).find(x) != (c).end()) 
#define    cpresent(c,x)      (find(all(c),x) != (c).end())  
#define    input(v,n)           for(ll i = 0 ; i<n ; i++) cin>>v[i]
#define    output(v,n)          for(ll i = 0 ; i<n ; i++) cout<<v[i]<<" "


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


  ll n,k;
  cin>>n>>k;
  double p=0,temp;
  for(ll i=1;i<=n;i++)
  {ll j=i;
    temp= 1.0/n;
    while(j<k)
    {
      j*=2;
      temp*=0.5;
    }
    p+=temp;
  }

  cout<<fixed<<setprecision(12)<<p;


  return 0;
 }

Measured memory_bytes: 256