akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int 
#define pb push_back
#define xx first
#define yy second


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll t;
	t=1;
	while(t--)
	{
	    ll n,m,tar,i,ans1=0,ans2=0;
	    cin>>n>>m>>tar;
	    unordered_map <ll,ll> mpr,mpc;
	    map < pair<ll,ll> , ll> mp;
	    
	    while(tar--)
	    {
	        ll x,y;
	        cin>>x>>y;
	        mpr[x-1]++;
	        mpc[y-1]++;
	        mp[{x-1,y-1}]=1;
	    }
	    

	    
    	    ll mx=INT_MIN,xans,yans,mn=INT_MAX;
    	    for(auto d: mpr)
    	    {
    	        if(d.yy>mx )
    	        {
    	            mx=d.yy;
    	            xans=d.xx;
    	        }
    	    }
    	    mx=INT_MIN;
    	    for(auto d: mpc)
    	    {
    	        if(d.yy>mx)
    	        {
    	            ll temp=d.yy-1;
    	            if(mp[{xans,d.xx}]==1)
    	            mx=temp;
    	            else
    	            mx=d.yy;
    	            yans=d.xx;
    	        }
    	    }
    	    
    	    //ans++;
    	    //cout<<xans<<" "<<yans<<endl;
    	    for(i=0;i<m;i++)
    	    {
    	        if(mp[{xans,i}]==1)
    	            ans1++;
    	            //cout<<ans<<endl;
    	    }
    	    
    	    for(i=0;i<n;i++)
    	    {
    	        if(mp[{i,yans}]==1 && i!=xans)
    	            ans1++;
    	    }
    	    
	    

	         mx=INT_MIN,mn=INT_MAX;
	        for(auto d: mpc)
    	    {
    	        if(d.yy>mx )
    	        {
    	            mx=d.yy;
    	            yans=d.xx;
    	        }
    	    }
    	    mx=INT_MIN;
    	    for(auto d: mpr)
    	    {
    	        
    	        if(d.yy>mx)
    	        {
    	            ll temp=d.yy-1;
    	            if(mp[{d.xx,yans}]==1)
    	            mx=temp;
    	            else
    	            mx=d.yy;
    	            xans=d.xx;
    	        }
    	    }
    	    
    	    
    	    
    	    //ans++;
    	    //cout<<xans<<" "<<yans<<endl;
    	    for(i=0;i<m;i++)
    	    {
    	        if(mp[{xans,i}]==1)
    	            ans2++;
    	            //cout<<ans<<endl;
    	    }
    	    
    	    for(i=0;i<n;i++)
    	    {
    	        if(mp[{i,yans}]==1 && i!=xans)
    	            ans2++;
    	    }
    	    
    	    cout<<max(ans1,ans2);
	}
}

Measured memory_bytes: 123672
#include<iostream>

using namespace std;

int main(){
    int n;
    cin>>n;
    int R[n];
    int answer,mini;
    for(int i=0;i<n;i++){
        cin>>R[i];
        if(i==0){
            mini=R[i];
        }else{
            if(mini>R[i-1])mini=R[i-1];
        }
        if(i==1){
            answer=R[i]-mini;
        }else{
            if(answer<R[i]-mini)answer=R[i]-mini;
        }
    }
    cout<<answer<<endl;
    return 0;
}



Measured memory_bytes: 3888
import java.util.Scanner;
import java.util.ArrayList;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    sc.nextLine();
    String allSlime = sc.nextLine();
    String tmpSlime[] = allSlime.split("");
    ArrayList<String> slimes = new ArrayList<>();

    for(int i=0; i<N; i++){
        slimes.add(tmpSlime[i]);
    }

    if(slimes.size() == 1){
        System.out.println(1);
        return;
    }

    int i=0;
    while(slimes.size() > i+1){
        String target = slimes.get(i);
        String target_next = slimes.get(i+1);
        if (target.equals(target_next))
            slimes.remove(i+1);
        else
            i++;
    }

    System.out.println(slimes.size());
  }
}

Measured memory_bytes: 31828
XKD = input().split()

X = int(XKD[0])
K = int(XKD[1])
D = int(XKD[2])
mini_X = X
count = 0
flag = 0

div_ans = abs(X) // D
if X < 0:
    if X + K*D <= 0:
        ans = X + K*D
        print(abs(ans))
        flag = 1
    else:
        pass
elif X > 0:
    if X -K*D >= 0:
        ans = X -K*D
        print(abs(ans))
        flag = 1
    else:
        pass
if flag == 0:
    K -= div_ans #K is K>1
    X = abs(X) - div_ans*D 
    X_kari = abs(X - D)
    if X > X_kari:
        K -= 1
        if K % 2 == 0:
            ans = X_kari
        else:
            ans = X
    else: #X <= X_kari:
        if K % 2 == 0:
            ans = X
        else:
            ans = X_kari
    print(ans)



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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}
	public static void Ans() {

			var inputArray = retreiveStringArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var S = inputArray[0];

			var count = 0;
			var max = 0;
			for (int i = 0; i < 3; i++) {
				var tenki = S[i];

				if (tenki =='R') {
					count++;
					max = Math.Max(max, count);
				}
				else {
					count = 0;
				}

			}

			//答えの出力
			var ans = max;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


Measured memory_bytes: 25960
s = input()
d =dict()

for c in s:
    if not c in d:
        d[c] = 1
    else:
        d[c] += 1

message = ""
for v in d.values():
    if v >=2:
        message = "no"
        break

if message == "no":
    print(message)
else:
    print("yes")


Measured memory_bytes: 2940
#include<iostream>
#include<bits/stdc++.h>
#define LL long long int
using namespace std;
LL div(LL n)
{
	LL count=0;
	for(LL i=1; i<=sqrt(n); i++)
	{
		if(n%i==0)
		{
			count++;
			if(n/i!=i)
			count++;
		}
	}
	return count;
}
int main()
{
//	ios_base::sync_with_stdio(false);
  //  cin.tie(NULL);
    vector<LL>v;
    v.push_back(0);
	LL n;
	cin>>n;
	LL count=0;
	n--;
	LL r=sqrt(n);
	for(LL i=1; i<=r; i++)
	{
		count+=n/i;	
	}
	count=count*2;
	count-=r*r;
	cout<<count<<"\n";
	
	
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
const ll MAXN=1000000+1;

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

vector<int>p;
bool spf[MAXN];
void sieve() 
{ 
    spf[1] = false; 
    for (int i=2; i<MAXN; i++)
        spf[i] = true; 
  
    p.pb(2);
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = false; 
  
    for (int i=3; i<MAXN; i++) 
    { 
        if (spf[i]) 
        { 
            p.pb(i);
            for (int j=2*i; j<MAXN; j+=i)
                    spf[j] = false; 
        } 
    } 
    return ;
} 
 
int main()
{
    IOS
    ll a,b;
    cin>>a>>b;
    ll g=gcd(a,b);
    sieve();
    ll ans=0;
    for(ll x:p)
    {
        if(g%x==0)
        {
            ans++;
        }
        while(g%x==0)
        {
            g/=x;
        }
    }
    if(g!=1)
    ans++;
    cout<<ans+1<<endl;
    return 0;
}

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

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

  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int ans = max(a*b, c*d);

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


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll MAX_N = ll(1e5 + 5);
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i,n) for (int i = n; i >=0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

ll gcd(ll a, ll b){
    if(b==0)return a;
    else return gcd(b,a%b);
}

int main() {
    ll n, m, g;
    string s, t;
    cin >> n >> m >> s >> t;
    g = gcd(n,m);
    bool ok = true;
    REP(i,g){
        if(s[i*n/g] != t[i*m/g]){
            ok = false;
            break;
        }
    }
    if(ok){
        cout << n*m/g << endl;
    }
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 512
using namespace std;
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#define w(x) int x;cin>>x;while(x--)

#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define ll long long

void abc()
{
	FIO;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int mod = 1000000007;
vector<double> v;
vector<vector<double>> dp;
int n;







int main()
{
	abc();

	cin >> n;
	v.resize(n);
	dp.resize(n + 1, vector<double>(n + 1, 0));
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

	dp[0][0] = 1;

	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= i; j++) {

			if (j == 0) {
				dp[i][j] = (1 - v[i - 1]) * dp[i - 1][j];
			} else {
				dp[i][j] = (v[i - 1]) * dp[i - 1][j - 1] + (1 - v[i - 1]) * dp[i - 1][j];
			}

		}
	}

	double ans = 0;

	for (int i = (n / 2) + 1; i <= n; i++) {

		ans += dp[n][i];
	}

	cout << setprecision(10) << ans;



}

Measured memory_bytes: 73660
#include <stdio.h>

int main(void)
{
	int kinds_of_sweets, number_of_nusuke;
	int having_sweets, not_having_sweet;
	int nusuke[100];
	int number_of_sweet[100];
	int i, j, k, l;

	scanf("%d%d", &number_of_nusuke, &kinds_of_sweets);

	for (k = 0; k < number_of_nusuke; k++)
	{
		nusuke[k] = 1;
	}

	/* お菓子の種類ごとに、そのお菓子を持っているぬすけくんを入力させる */
	for (i = 0; i < kinds_of_sweets; i++)
	{
		scanf("%d", &number_of_sweet[i]);
		for (j = 0; j < number_of_sweet[i]; j++)
		{
			scanf("%d", &having_sweets);
			nusuke[having_sweets - 1] = 0;
		}
		
	}

	not_having_sweet = 0;

	for (l = 0; l < number_of_nusuke; l++)
	{
		if (nusuke[l] == 1)
		{
			not_having_sweet++;
		}
	}
	
	printf("%d\n", not_having_sweet);

	return 0;

}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#include <limits.h>
#include <algorithm>  
#include <numeric>
#include <sys/resource.h>
 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define endl '\n'
using ll = long long;
 
const int precision = 15;
const int modulo =  1000000007; // 10^9 + 7
const ll lmodulo =  1000000007; // 10^9 + 7
 
const double EPS = 1e-9;
const ll inf = 1e18;


void increaseStack() {
	const rlim_t kStackSize = 50 * 1024 * 1024;   // min stack size = 16 MB
	   struct rlimit rl;
	   int result;

	   result = getrlimit(RLIMIT_STACK, &rl);
	   if (result == 0)
	   {
	       if (rl.rlim_cur < kStackSize)
	       {
	           rl.rlim_cur = kStackSize;
	           result = setrlimit(RLIMIT_STACK, &rl);
	           if (result != 0)
	           {
	               fprintf(stderr, "setrlimit returned result = %d\n", result);
	           }
	       }
	   }
}


void solve () {
	increaseStack();

	int n, k; cin >> n >> k;
	vector<int> a(n);
	for (auto &it : a) cin >> it;

	// vector<int>memo(k + 1, -1);

	// memo[0] = 0;
	// function<bool(int)> won = [&](int cur) -> bool {
	// 	if(cur == 0) {
	// 		return false;
	// 	}

	// 	if (memo[cur] != -1)  return memo[cur];

	// 	for (auto i : a) {
	// 		if ((cur - i) < 0) continue;
	// 		if (!won(cur - i)) {
	// 			memo[cur] = 1;
	// 			return true;
	// 		}
	// 	}
	// 	memo[cur] = false;
	// 	return false;
	// };
	// if (won(k)) {
	// 	cout << "First";
	// } else {
	// 	cout << "Second";
	// }

	vector<int> dp(k + 1);
	dp[0] = 0;
	for (auto i = 1; i <= k; ++i) {
		for (auto v : a) {
			if(i - v >= 0 and dp[i - v] == 0) {
				dp[i] = 1;
				break;
			}
		}
	}

	if (dp[k] == 1) {
		cout << "First";
	} else {
		cout << "Second";
	}
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.precision(precision);
  cout.setf(ios_base::fixed);
  solve();
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cstring>
int main()
{
	int n,k;
	while(std::cin>>n>>k,n|k){
		int memo[100002];
		memset(memo,0,sizeof(memo));
		for(int i=0; i<k; i++){
			int a; std::cin>>a;
			memo[a]=1;
		}
		int cnt=0;
		int flag=0;
		int ans = 0;
		int tmp = -1;
		std::vector<int> v;
		for(int i=1; i<=n+1; i++){
			if      ( memo[i] ){
				memo[i]+=memo[i-1],cnt++;
				if( ans<memo[i] )ans=memo[i];
				flag=1;
			}else if( flag ){
				memo[ i-memo[i-1] ] = memo[i-1];
				flag=0;
			}
			if( memo[0] && !memo[i] && memo[i-1] && memo[i+1] ){
				v.push_back(i);
			}
			if( cnt==k && tmp==-1 )tmp=i;
			if( cnt==k && tmp<i )break;
		}
		for(int i=0; i<v.size() && memo[0]; i++){
			if( ans<memo[v[i]-1]+memo[v[i]+1]+1 )
				ans = memo[v[i]-1]+memo[v[i]+1]+1;
		}
		/*
		for(int i=0; i<=n; i++){
			printf("%d,",memo[i]);
		}
		puts("");
		*/
		printf("%d\n",ans);
	}
	return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

int main() {
    string s,t;
    cin>>s>>t;
    int MAX=-1;

    if(s.size()<t.size()){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }

    rep(i,s.size()-t.size()+1){
        bool jdg=true;
        rep(j,t.size()){
            if(s[i+j]!=t[j]&&s[i+j]!='?'){
                jdg=false;
                break;
            }
        }
        if(jdg){
            MAX=i;
        }
    }

    if(MAX==-1){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }

    rep(i,t.size()){
        s[MAX+i]=t[i];
    }

    rep(i,s.size()){
        if(s[i]=='?'){
            s[i]='a';
        }
    }

    cout<<s<<endl;

}



Measured memory_bytes: 256
local n = io.read("*n")
local x, y, z = io.read("*n", "*n", "*n")
local mma = math.max
for i = 2, n do
  local a, b, c = io.read("*n", "*n", "*n")
  x, y, z = mma(y, z) + a, mma(x, z) + b, mma(x, y) + c
end
print(mma(x, mma(y, z)))


Measured memory_bytes: 760
#include <stdio.h>

int main(void)
{
	int i, n;
	
	while (scanf("%d", &n) != EOF){
		for (i = 1; i <= 512; i *= 2){
			if (n % (i * 2) != 0){
				printf("%d", i);
				n -= i;
				
				if (n != 0){
					printf(" ");
				}
			}
			
			if (n == 0){
				puts("");
				break;
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 612
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char
import Data.List
import Data.Maybe
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS
import qualified Data.IntMap.Strict as IntMap
import Control.Monad
import Control.Monad.ST
import Data.STRef

type Weight = Int
type Tree = IntMap.IntMap (U.Vector (Int,Weight))

data GrowableVector s a = GV {-# UNPACK #-} !Int !(U.MVector s a)

buildTree :: U.Vector (Int,Int,Weight) -> IntMap.IntMap (U.Vector (Int,Weight))
buildTree edges = runST $ do
  let insert' key val m = do
        case IntMap.lookup key m of
          Nothing -> do
            vec <- UM.new 1
            UM.write vec 0 val
            ref <- newSTRef (GV 1 vec)
            return $ IntMap.insert key ref m
          Just ref -> do
            GV len vec <- readSTRef ref
            vec' <- if len < UM.length vec then return vec else UM.grow vec len
            UM.write vec' len val
            writeSTRef ref $! GV (len+1) vec'
            return m
      adjust ref = do
        GV len mvec <- readSTRef ref
        vec <- U.unsafeFreeze mvec
        return (U.take len vec)
  m <- U.foldM' (\m (u,v,w) -> insert' v (u,w) m >>= insert' u (v,w)) IntMap.empty edges
  mapM adjust m

main = do
  n <- readLn
  edges <- U.replicateM (n-1) $ do
    [u,v,w] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (u-1, v-1, w)
  let tree :: Tree
      tree = buildTree edges
  let result = U.create $ do
        vec <- UM.replicate n (-1)
        -- white: 0, black: 1
        let dfs !i !color = do
              x <- UM.read vec i
              when (x == -1) $ do
                UM.write vec i color
                let Just t = IntMap.lookup i tree
                U.forM_ t $ \(j,w) -> do
                  dfs j ((color + w) `rem` 2)
        dfs 0 0
        return vec
  U.mapM_ print result


Measured memory_bytes: 87548
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, A, B; 
	cin >> N >> A >> B; 
	if((long long) N > (long long) A * B){
		cout << -1 << endl; return 0; 
	}
	if(N < A + B - 1){
		cout << -1 << endl; return 0; 
	}
	int num[300010] = {}; 
	int start[300010] = {}; 
	num[0] = A; int tmp = N - B - A + 1; 
	for(int i = 1; i < B; i++){
		num[i] ++; 
		num[i] += min(A-1, tmp); 
		tmp -= min(A-1, tmp); 
	}
	start[B-1] = 1; 
	for(int i = B-2; i >= 0; i--){
		start[i] = start[i+1] + num[i+1]; 
	}
	for(int i = 0; i < B; i++){
		for(int j = 0; j < num[i]; j++){
			cout << start[i] + j << " "; 
		}
	}
	cout << endl; 
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int X;
    cin >> X;
    while (true) {
        int cnt = X;
        bool prime = true;
        for(int i = 2; i*i <= cnt; i++) {
            if(cnt%i == 0) {
                prime = false;
            }
        }
        if(prime) {
            cout << cnt << endl;
            break;
        }
        X++;
    }
}


Measured memory_bytes: 3632
#include <iostream>
#define LL long long
using namespace std;

LL A,B,C;

int main(){
    cin >> A >> B >> C;

    if (A%2==0 || B%2==0 || C%2==0) cout << 0 << "\n";
    else cout << min(A*B,min(B*C,A*C)) << "\n";

    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int a, b;
	cin >> a >> b;
	cout << max({a + b, a- b, a * b}) << endl;
    
    return 0;
}



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

int main()
{
  long N;
  cin >> N;
  long tmpN = N;
  map<long, int> primes;
  for (int i = 2; i <= sqrt(N); i++)
  {
    if (tmpN % i != 0) continue;
    int count = 0;
    while (tmpN % i == 0)
    {
      tmpN /= i;
      count++;
    }
    primes[(long)i] = count;
  }
  if (tmpN != 1) primes[tmpN] = 1;
  int ans = 0;
  for (auto x : primes)
  {
    int index = 1;
    while (x.second - index >= 0)
    {
      ans++;
      x.second -= index;
      index++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3728
using System;

namespace ABC056_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var num = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var w = num[0];
            var a = num[1];
            var b = num[2];

            if (Math.Abs(b - a) <= w)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(Math.Abs(a - b) - w);
            }
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
using namespace std;
int lt, N, lx, ly, t, x, y;
int abs(int x) { return x < 0 ? -x : x; }
int main()
{
    cin>>N;
    lt = 0;
    lx = 0;
    ly = 0;
    for(int i = 1; i <= N; i++){
        cin>>t>>x>>y;
        int dis = abs(x - lx) + abs(y - ly);
        if(t - lt == 0 && dis == 0){
            cout<<"No"<<endl;
            return 0;
        } else if(t - lt < dis){
            cout<<"No"<<endl;
            return 0;
        } else if( (t - lt - dis) & 1){
            cout<<"No"<<endl;
            return 0;
        }
        lt = t;
        lx = x;
        ly = y;
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

double cost(int a, int b)
{
    // a -> b
    return double(abs(a - b)) / double(a);
}

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

    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
        cin >> a[i];
    vector<vector<double>> dp(N, vector<double>(200001, INF));
    // div[i] := i の約数
    vector<vector<int>> div(200001);
    for (int i = 1; i <= 200000; i++)
    {
        for (int j = 1; j * j <= i; j++)
        {
            if (i % j)
                continue;
            div[i].push_back(j);
            if (i != j * j)
                div[i].push_back(i / j);
        }
        sort(div[i].begin(), div[i].end());
    }
    for (int j = 1; j <= 200000; j++)
    {
        dp[0][j] = cost(a[0], j);
    }
    for (int i = 1; i < N; i++)
    {
        for (int j = 1; j <= 200000; j++)
        {
            double c = cost(a[i], j);
            for (auto v : div[j])
            {
                dp[i][j] = min(dp[i][j], max(dp[i - 1][v], c));
            }
        }
    }
    double res = INF;
    for (int i = 1; i <= 200000; i++)
    {
        res = min(res, dp[N - 1][i]);
    }
    cout << fixed << setprecision(10) << res << endl;
}



Measured memory_bytes: 53748
S=input()
while(len(S)>=5):
    if(len(S)>=7 and S[len(S)-7:len(S)]=='dreamer'):
        S=S[:len(S)-7]
    elif(len(S)>=6 and S[len(S)-6:len(S)]=='eraser'):
        S=S[:len(S)-6]
    elif(S[len(S)-5:len(S)]=='dream' or S[len(S)-5:len(S)]=='erase'):
        S=S[:len(S)-5]
    else:
        print("NO")
        exit()
if(len(S)!=0):
    print("NO")
else:
    print("YES")

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

using namespace std;

struct CWW{
    CWW(){
	ios::sync_with_stdio(false);cin.tie(0);
    }
}cww;





int A,B,K;
#define ARAI(x) (x)
#define arai(x) (A+x)
#define S (A+B)
#define G (S+1)

struct edge{
    int flow,to,rev,cost;
};
typedef vector<edge> E;
typedef vector<E> Graph;

void addedge(Graph &g,int from,int to,int f,int cost){
    int n=g[from].size();
    int m=g[to].size();
    g[from].push_back(edge{f,to,m,cost});
    g[to].push_back(edge{0,from,n,-cost});
}

namespace _ssc{
    #define SZ 500
    int h[SZ];
    int d[SZ];
    int pV[SZ];
    int pE[SZ];
};
struct ssc{
    int *h,*d,*pV,*pE;
    ssc(int V):h(_ssc::h),d(_ssc::d),pV(_ssc::pV),pE(_ssc::pE){
	fill(h,h+V,0);
    }	  
};
const int INF=114514;
int min_cost_flow(int s,int t,int f,Graph &g,ssc& info){
    using P=tuple<int,int>;

    const int V=g.size();
    int res=0;
    while(f>0){
	priority_queue<P> que;
	fill(info.d,info.d+V,INF);
	info.d[s]=0;
	que.push(P(0,s));
	while(que.size()){
	    auto p=que.top();que.pop();
	    int cost,v;tie(cost,v)=p;cost=-cost;
	    if(info.d[v]<cost)continue;
	    for(int i=0,sz=g[v].size();i<sz;i++){
		auto &e=g[v][i];
		if(e.flow>0&&info.d[e.to]>info.d[v]+e.cost+info.h[v]-info.h[e.to]){
		    info.d[e.to]=info.d[v]+e.cost+info.h[v]-info.h[e.to];
		    info.pV[e.to]=v;
		    info.pE[e.to]=i;
		    que.push(P(-info.d[e.to],e.to));
		}
	    }
	}
	if(info.d[t]==INF)return -1;
	
	for(int v=0;v<V;v++)info.h[v]+=info.d[v];
	int d=f;
	for(int v=t;v!=s;v=info.pV[v])
	    d=min(d,g[info.pV[v]][info.pE[v]].flow);
	f-=d;
	res+=d*info.h[t];
	for(int v=t;v!=s;v=info.pV[v]){
	    auto &e=g[info.pV[v]][info.pE[v]];
	    e.flow-=d;
	    g[v][e.rev].flow+=d;
	}
    }
    return res;
}
int main(){
    cin>>A>>B>>K;
    int V=A+B+2;
    Graph g(V);
    ssc info(V);
    for(int i=0;i<A;i++)addedge(g,S,ARAI(i),1,0);
    for(int i=0;i<B;i++)addedge(g,arai(i),G,1,0);
    vector<vector<int>> R(A,vector<int>(B,0));
    for(int i=0;i<A;i++){
	string s;
	cin>>s;
	for(int j=0;j<B;j++)if(s[j]=='1')R[i][j]++;			       
    }
    for(int i=0;i<B;i++){
	string s;
	cin>>s;
	for(int j=0;j<A;j++)if(s[j]=='1')R[j][i]++;			       
    }
    for(int i=0;i<A;i++)
	for(int j=0;j<B;j++)
	    addedge(g,ARAI(i),arai(j),1,R[i][j]);
    int res=0,cost,allcost=0;
    while((cost=min_cost_flow(S,G,1,g,info))!=-1){
	allcost+=cost;
	if(allcost<=K)res++;
	else break;
    }
    cout<<res<<endl;
}

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

int main() {
  string w;
  cin >> w;
  map<char,int> mp;
  rep(i,w.size()) mp[w[i]]++;
  
  bool ok = true;
  rep(i,mp.size()) {
    if (mp[i]%2==1) ok = false;
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 2000000000LL
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll a[100005];
ll fact[100005];
int b[100005];
int c[100005];

int main(void){
	scanf("%d",&n);
	fact[0]=1;
	for(ll i=1;i<=n;i++){
		fact[i]=fact[i-1]*i%MOD;
	}
	int len=0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(i>0 && a[i]-a[i-1]==1)len++;
		b[i]=len;
		int l=-1,r=n-1;
		while(r-l>1){
			int mid=(l+r)/2;
			int val=2*(i-mid)+1;
			if(a[i]>=val)r=mid;
			else l=mid;
		}
		c[i]=r;
	}
	ll res=1,turn=0,rest=0;
	for(int i=0;i<n;i++){
		if(c[i]<=turn){
			rest++;
		}else{
			while(c[i]>turn){
				turn++;
				res=res*(rest+1)%MOD;
				rest--;
			}
			rest++;
		}
	}
	res=res*fact[rest]%MOD;
	printf("%lld\n",res);
	/*
	b[n]=114514;
	for(int i=0;i<n;i++){
		printf("%d ",b[i]);
	}
	printf("\n");
	ll res=1;
	int emp=a[0];
	int j=0;
	for(int i=0;i<n-1;i++){
		printf("%d %d\n",len,emp);
		int g=upper_bound(b,b+n,emp)-b;
		res=(ll)res*(g-i)%MOD;
		emp=a[i+1];
		printf("%d\n",res);
	}
	printf("%lld\n",res);
	printf("%lld\n",fact[n-1]*12LL%MOD);
	*/
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main(){
	char a[100], b[100], c[100];
	int d = 1, e = 0, f = 0, g = 0;
	cin >> a;
	cin >> b;
	cin >> c;
	for (int i = 0; i < 1;){
		switch (d){
		case 1:
			if (a[e] == 'a')d = 1;
			else if (a[e] == 'b')d = 2;
			else if (a[e] == 'c')d = 3;
			else { cout << "A" << endl; i = 1; }
			e++;
			break;
		case 2:
			if (b[f] == 'a')d = 1;
			else if (b[f] == 'b')d = 2;
			else if (b[f] == 'c')d = 3;
			else { cout << "B" << endl; i = 1; }
			f++;
			break;
		case 3:
			if (c[g] == 'a')d = 1;
			else if (c[g] == 'b')d = 2;
			else if (c[g] == 'c')d = 3;
			else { cout << "C" << endl; i = 1; }
			g++;
			break;
		default:
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b , c = MAP()
if a + b + c == 17:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 5712
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

int vet[100005],dp[100005];

long long rec (long long a,long long b,long long c){
    if(dp[a]>-1) return dp[a];
    if(a==b-1) return dp[b-1]=0;
    long long k=1000000007;
    for(long long i=0;i<c and a+i+1<b;i++){
        k=min(k,abs(vet[a]-vet[a+1+i])+rec(a+1+i,b,c));
    }
    return dp[a]=k;
}
 
int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    long long n,m,i,j;
    cin>>n>>m;
    memset(dp,-1,sizeof(dp));
    for(i=0;i<n;i++) cin>>vet[i];
    cout<<rec(0,n,m)<<endl;
}

Measured memory_bytes: 12140
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <cmath>
# include <functional>
# include <utility>
# include <queue>
# include <stack>
# include <deque>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

int main() {
	ll n = 0, k = 0, counter = 0, ans = 0;
    pair<ll, ll>pairs[100001];
	string str;
	cin >> n >> k;
	ll a = 0, b = 0;
	rep(i, n) {
    cin >> a >> b;
	pairs[i]=make_pair(a, b);
	}
	sort(pairs, pairs + n);
	rep(i, n) {
		counter +=pairs[i].second;
		if (counter >= k && ans == 0) { ans = pairs[i].first; break; }
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#N,Tの取得
l = list(map(int, input().split()))
N = l[0]
T = l[1]

#秒のリストを取得
tl = list(map(int, input().split()))

bt = 0 #直前のスイッチを押した時間
gt = T #秒数総和
for t in tl[1:]:
    if t - bt > T:
        gt += T #スイッチオフの時はT秒追加
    else:
        gt += t - bt #スイッチがオンのとき、前回からの経過時間を加算
    bt = t
        

print(str(gt))

Measured memory_bytes: 26708
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace contest_Csharp
{
    class Program
    {
        public static (long m,long s)[,] dp;

        static void Main(string[] args)
        {
            checked
            {
                var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
                Console.SetOut(sw);

                var vals = Console.ReadLine().Split(' ').
                    Select(x => int.Parse(x)).ToList();

                var N = vals[0];
                //var K = vals[1];
                //var B = vals[2];
                var A= Console.ReadLine().Split(' ').
                    Select(x => long.Parse(x)).ToList();
                dp = new (long,long)[N + 1, 2];
                dp[0, 0] = (1000, 0);
                dp[0, 1] = (1000, 0);
                for (int i = 0; i < N; i++)
                {
                    if (dp[i,0].m>=dp[i,1].m+dp[i,1].s*A[i])
                    {
                        dp[i + 1, 0] = dp[i, 0];
                    }
                    else
                    {
                        dp[i + 1, 0] = (dp[i, 1].m + dp[i, 1].s * A[i],0);
                    }
                    if (dp[i,0].m / A[i] > dp[i,1].s+ dp[i, 1].m / A[i] ||
                        (dp[i, 0].m / A[i] == dp[i, 1].s + dp[i, 1].m / A[i] && dp[i, 0].m % A[i] >= dp[i, 1].m % A[i]))
                    {
                        dp[i + 1, 1] = (dp[i, 0].m %A[i] , dp[i, 0].m / A[i]);
                    }
                    else
                    {
                        dp[i + 1, 1] = (dp[i, 1].m % A[i], dp[i,1].s+dp[i, 1].m / A[i]);
                    }
                }

                Console.WriteLine(dp[N,0].m);







                Console.Out.Flush();
            }




        }
    }
}




Measured memory_bytes: 28128
#include <iostream>
#include <iomanip>
#include <algorithm>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    int h[n];
    repi(i, n, 0)
    {
        cin >> h[i];
    }
    int left = 0;
    int ans = 0;
    while (left < n)
    {
        // repi(i, n, 0)
        // {
        //     cout << h[i] << " ";
        // }
        // cout << endl;
        int m = INF;
        int right = left;
        if (h[left] == 0)
        {
            left++;
        }
        else
        {
            while (h[right] != 0 && right < n)
            {
                m = min(m, h[right]);
                right++;
            }

            repi(i, right, left)
            {
                h[i] -= m;
            }
            ans += m;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
int N,M,S,T;
vector<pair<int,int> >G[1<<17];
long mod=1e9+7,a[1<<17],b[1<<17],c[1<<17],d[1<<17];
priority_queue<pair<long,int> >P;
void calc(int S,long*d,long*w)
{
	for(int i=w[S]=1;i<=N;)d[i++]=-1e18;
	P.push({d[S]=0,S});
	while(P.size())
	{
		long c=P.top().first,u=P.top().second;
		P.pop();
		if(d[u]==c)for(pair<int,int>p:G[u])
		{
			long v=p.first,nxt=c-p.second;
			if(d[v]<nxt)w[v]=w[u],P.push({d[v]=nxt,v});
			else if(d[v]==nxt)(w[v]+=w[u])%=mod;
		}
	}
}
main()
{
	cin>>N>>M>>S>>T;
	for(int i=0;i<M;i++)
	{
		int u,v,d;cin>>u>>v>>d;
		G[u].push_back({v,d});
		G[v].push_back({u,d});
	}
	calc(S,a,b);
	calc(T,c,d);
	long ans=b[T]*b[T],dt=a[T];;
	for(int i=0;i++<N;)
	{
		if(2*a[i]==dt)ans-=b[i]*b[i]%mod*d[i]%mod*d[i]%mod;
		for(pair<int,int>p:G[i])
		{
			int v=p.first;
			if(2*a[i]>dt&&2*a[v]<dt&&a[i]+c[v]-p.second==dt)ans-=b[i]*b[i]%mod*d[v]%mod*d[v]%mod;
		}
	}
	cout<<(ans+mod)%mod<<endl;
}


Measured memory_bytes: 14448
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

#define MAX_N 300

int nSize;
int frame[MAX_N][MAX_N];

int maxSum;
int rowSum[MAX_N][MAX_N+1];
int colSum[MAX_N][MAX_N+1];

int RowSum(int i, int s, int e){return rowSum[i][e+1] - rowSum[i][s];}
int ColSum(int j, int s, int e){return colSum[j][e+1] - colSum[j][s];}

void InitSum(){
    for(int i=0;i<nSize;i++){
        rowSum[i][0]=0;
        colSum[i][0]=0;
        for(int k=1;k<=nSize;k++){
            rowSum[i][k]=rowSum[i][k-1]+frame[i][k-1];
            colSum[i][k]=colSum[i][k-1]+frame[k-1][i];
        }
    }
}

void Solve(){
    InitSum();

    for(int i=0;i<nSize;i++){
        for(int j=i;j<nSize;j++){
            maxSum = max(RowSum(i, i, j), maxSum);
            if(i==j)continue;
            int colMax = ColSum(0,i,j);
            for(int k=1;k<nSize;k++){
                int col = ColSum(k,i,j);
                maxSum = max(maxSum,max(colMax+col,col));
                colMax = max(colMax+frame[i][k]+frame[j][k],col);
            }
        }
    }
    cout<<maxSum<<endl;
}

int main(){

    scanf("%d", &nSize);
    for(int i=0;i<nSize;i++){
        for(int j=0;j<nSize;j++){
            scanf("%d", &frame[i][j]);
        }
    }
    Solve();

    return 0;
}


Measured memory_bytes: 4276
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ls x<<1
#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-8;
const ull hashp=131;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=998244353;
const int maxn=2e5+100;

void solve(){
	ll a,b,n;
	cin>>a>>b>>n;
	ll nxt=n-n%b-1;
	if(nxt<0)nxt=0;
	printf("%lld",max(a*n/b-a*(n/b),a*nxt/b-a*(nxt/b)));
}
int main(){
    //IOS;
    //freopen("in.txt","r",stdin);
    //freopen("D:\\data.txt","w",stdout);
    solve();
    
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;                                             ;;
	;;         ;;            ;;;;;;;;;       ;;    ;;
	;;        ;; ;;        ;;                ;;    ;;
	;;       ;;   ;;       ;;                ;;    ;;
	;;      ;;;;;;;;;      ;;                ;;    ;;
	;;     ;;       ;;     ;;                      ;;
    ;;    ;;         ;;      ;;;;;;;;;       ;;    ;;
    ;;                                             ;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    return 0;
}

Measured memory_bytes: 3152
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = sc.nextIntArray(n);
        Arrays.sort(a);
        int ans = 0;
        for(int i = 0; i < k; i++){
            ans += a[i];
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

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

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

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

Measured memory_bytes: 25932
seq = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input()) - 1
print(seq[K])

Measured memory_bytes: 3060
n,k = map(int,input().split())

def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p

ans = [0] * k
for i in range(k):
     ans[i] = comb(k-1,i,10**9+7)*comb(n-k+1,i+1,10**9+7)%(10**9+7)

for i in range(k):
     print(ans[i])

Measured memory_bytes: 3444
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N, K := getInt(), getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
		// out(strconv.FormatInt(int64(a[i]), 2))
	}

	c := make([]int, 40)
	for i := 0; i < N; i++ {
		n := a[i]
		idx := 0
		for n > 0 {
			c[idx] += n % 2
			n /= 2
			idx++
		}
	}

	cnt := 0
	k := K
	for k > 0 {
		cnt++
		k /= 2
	}
	// out(cnt)

	x := 0
	for i := cnt - 1; i >= 0; i-- {
		// out("i", i, c[i], N-c[i])
		if c[i] < N-c[i] {
			x += 1 << uint(i)
		}
		if x > K {
			x -= 1 << uint(i)
		}
	}
	// out(c)
	// out(x, strconv.FormatInt(int64(x), 2))
	ans := 0
	for i := 0; i < N; i++ {
		ans += a[i] ^ x
	}
	out(ans)
}


Measured memory_bytes: 3072
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static Reader;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];
        int[] penalty = new int[n];
        bool[] isAC = new bool[n];
        var res = 0;
        for (int i = 0; i < m; i++)
        {
            var ps = Console.ReadLine().Split();
            var p = int.Parse(ps[0]) - 1;
            if (isAC[p]) continue;
            if (ps[1] == "WA")
                penalty[p]++;
            else
            {

                isAC[p] = true;
                res += penalty[p];
            }
        }
        Console.WriteLine($"{isAC.Count(x => x)} {res}");
    }
}


static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = BUF_SIZE - 1;
    static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; } }

    public static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; while (Buffer[ptr] < 48) Move();
            do { res = res * 10 + (int)(Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res;
        }
    }
}

Measured memory_bytes: 17740
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N;
	static int[] count = new int[30];
	static ArrayList<Person> ps = new ArrayList<Person>();

	public static void main(String[] args) throws Exception {
		while (true) {
			N = sc.nextInt();
			if (N == 0) break;
			Arrays.fill(count, 0);
			ps.clear();
			for (int i = 0; i < N; ++i) {
				Person p = new Person();
				p.name = sc.next();
				int m = sc.nextInt();
				p.d = new int[m];
				for (int j = 0; j < m; ++j) {
					p.d[j] = sc.nextInt();
					++count[p.d[j]];
				}
				ps.add(p);
			}
			Collections.sort(ps);
			System.out.println(ps.get(0).val() + " " + ps.get(0).name);
		}
	}

	static class Person implements Comparable<Person> {
		String name;
		int[] d;

		public int compareTo(Person o) {
			if (this.val() != o.val()) {
				return this.val() < o.val() ? -1 : 1;
			}
			return this.name.compareTo(o.name);
		}

		int val() {
			int ret = 0;
			for (int t : this.d) {
				ret += N - count[t] + 1;
			}
			return ret;
		}

	}
}

Measured memory_bytes: 13000
Option Strict On
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim s As String = NextString()

        Dim best As Integer = 0
        Dim cnt As Integer = 0
        Dim flg As Boolean = False

        For Each v As Char In s
            If v = "A"c Then flg = True
            If flg Then cnt += 1
            If flg AndAlso v = "Z"c Then best = cnt
        Next

        WriteLine(best)
    End Sub

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 24284
#include <bits/stdc++.h>
#include <iostream>
#define ll long long
#define mem(f, x) memset(f, x, sizeof(f))
#define INF 0x3f3f3f3f
using namespace std;
const int M = 2*1e5 + 5;
const int N = 1e4 + 5;
char s[M];
ll ret[N];
ll n, p;

int main( ){
    while( scanf( "%lld %lld %s", &n, &p, s ) != EOF ){
        ll sum = 0, x = 1, y = 0;
        if( p == 2 || p == 5 ){
            for( int i = 0; i < n; i++ ){
                if( ( s[i] -'0' ) % p == 0 )
                    sum += ( i + 1 );
            }
        }
        else{
            mem( ret, 0 );
            ret[0] = 1;
            for( int i = n - 1; i >= 0; i-- ){
                y = ( ( s[i]-'0')*x + y ) % p;
                x = x*10%p;
                sum += ret[y];
                ret[y]++;
            }
        }
        printf( "%lld\n", sum );
    }
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int l = 0;
    int r = n - 1;
    int ans = 0;
    while (l < r)
    {
        while (l < n and s[l] != 'W')
            l++;
        while (r >= 0 and s[r] != 'R')
            r--;
        if (l >= r) break;
        swap(s[l], s[r]);
        ans++;
        l++;
        r--;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3656
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        
        double x = Math.PI;
        
        Scanner sc = new Scanner(System.in);
        
        double r = sc.nextDouble();
        System.out.println(String.format("%.6f",r*r*x) + " "+ String.format("%.6f",2*r*x));
    }
}



Measured memory_bytes: 28324
import queue
n = int(input())

tree = [[] for i in range(n)]
edges = []

for i in range(n-1):
    a,b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
    edges.append((a-1,b-1))


ncol = max([len(tree[i]) for i in range(n)])
usedcol = [-1 for i in range(n)]
colour = [dict() for i in range(n)]


visited = [False for i in range(n)]
def bfs(v):
    q = queue.Queue(0)
    q.put(v)
    while not q.empty():
        v = q.get()
        visited[v] = True
        u = usedcol[v]
        col = 0
        # colour each edge and add neighbours
        for i in range(len(tree[v])):
            nv = tree[v][i]
            if not visited[nv]:
                col += 1; col += 1 if col==u else 0
                usedcol[nv] = col
                colour[v][nv] = col; colour[nv][v] = col
                q.put(nv)

bfs(1)
print(ncol)
for (a,b) in edges:
    print(colour[a][b])

Measured memory_bytes: 117276