akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()){
            int a = in.nextInt();
            int b = in.nextInt();
            if (a > 9 || b > 9){
                System.out.println(-1);
            } else {
                System.out.println(a*b);
            }
        }
    }
}


Measured memory_bytes: 23764
#include <stdio.h>
int main(){
  int a, b, c, d, p, sumx = 0, sumy = 0;
  scanf("%d %d %d %d %d", &a, &b, &c, &d, &p);
  sumx = a * p;
  if(c < p) sumy = b + d * (p - c);
  else sumy = b;
  if(sumx > sumy) printf("%d\n", sumy);
  else printf("%d\n", sumx);
  return 0;
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (300006)
#define local 0
string T;
ll q;
void myassert(bool b){
	if(b) return;
	vector<ll> v;
	FOR(i,1,1e18) v.pb(i);
	return;
}
ll editdist(string x,string y){
	ll n=x.size(), m=y.size();
	vector<vector<ll>> dp(n+1, vector<ll>(m+1,LLINF));
	dp[n][m]=0;
	FOR(i,0,n-1) dp[i][m]=n-i;
	FOR(j,0,m-1) dp[n][j]=m-j;
	DEC(i,n-1,0) DEC(j,m-1,0) {
		if(x[i] == y[j]) {
			dp[i][j]=dp[i+1][j+1];
		}else{
			dp[i][j]=min({dp[i+1][j+1], dp[i+1][j], dp[i][j+1]})+1;
		}
	}
	return dp[0][0];
}
ll ask(string S){
	myassert(++q <= 850);
	cout<<"? "<<S<<endl;
	ll x; 
	if(!local) cin>>x;
	else x=editdist(T,S), cout<<"Answer is: "<<x<<endl;
	return x;
}
void answer(string S){
	cout<<"! "<<S<<endl;if(local)assert(T==S),cout<<"used: "<<q<<endl;
	exit(0);
}
map<ll,char>mp;
ll co, len[62], total;
string repeat(char x){
	string ret="";
	FOR(i,1,128) ret+=x;
	return ret;
}
string repeat(char x,ll times){
	string S="";
	while(times--) S += x;
	return S;
}
string prefix(string S,ll sz){
	string X="";
	FOR(i,0,sz-1) X+=S[i];
	return X;
}
bool correct(string S){
	return ask(S) == total - S.size();
}
string concat(string a,string b,string c){
	return a+b+c;
}
vector<pi> order;
int main(){
	FAST
	if(local) {
		// FOR(i,1,64) T += 'a';
		// FOR(i,1,64) T += rand('b','r');
		// cout<<T<<endl;
		cin>>T;
	}
	FOR(i,'a','z') mp[co++]=char(i);
	FOR(i,'A','Z') mp[co++]=char(i);
	FOR(i,'0','9') mp[co++]=char(i);
	assert(co==62);
	for(auto i:mp) len[i.f]=128-ask(repeat(i.s)), total+=len[i.f], order.eb(len[i.f],i.f);
	sort(all(order),greater<pi>());
	string cfm="";
	for(auto i:order) if(i.f) {
		string now = repeat(mp[i.s], i.f);
		string small, big;
		if(cfm.size()>now.size()) big=cfm, small=now;
		else big=now,small=cfm;
		string res="";
		while(small.size()){
			ll st=-1, en=siz(big);
			while(en-st>1){
				ll mid=(st+en)>>1;
				if(correct(concat(res, prefix(big, mid+1), small)))st=mid;
				else en=mid;
			}
			++st;
			while(st--) res += big[0], big.erase(big.begin());
			res+=small[0];
			small.erase(small.begin());
		}
		FOR(i,0,siz(big)-1) res+=big[i];
		cfm=res;
	}
	answer(cfm);
}


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

const int MAXN = 55;
const int INF = 1<<28;

struct S {
  int t, c, in;
  bool operator < (const S &s) const {
    return t < s.t;
  }
  bool reached(int now) {
    return now - in >= t;
  }
};

int n;
S s[MAXN];

int main() {
  while (cin >> n && n) {
    for (int i = 0; i < n; ++i) {
      cin >> s[i].t >> s[i].c;
      s[i].in = 0;
    }
    sort(s, s + n);
    deque<S> que[2];
    for (int i = 0; i < n; ++i) que[0].push_back(s[i]);
    int t, finished;
    for (t = 1, finished = 0; finished < n; ++t) {
      for (int k = 0; k < 2; ++k) {
        vector<S> v;
        while (que[k].size() && que[k].front().reached(t)) {
          S s = que[k].front();
          que[k].pop_front();
          v.push_back(s);

        }
        sort(v.begin(), v.end());
        for (int i = 0; i < v.size(); ++i) {
          S &s = v[i];
          s.in = t;
          if (k == 1 && --s.c == 0) {
            finished += 1;
            continue;
          }
          que[1-k].push_back(v[i]);
        }
      }
    }
    cout << t - 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1232
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;
int tim[1111];
struct Date
{
  int m,in,id;
  Date(int mm,int inin,int idid) :
    m(mm),in(inin),id(idid) {}
};
vector<Date> date[13][33];
void clear()
{
  for(int i=1;i<=12;i++) {
    for(int j=1;j<=31;j++) {
      date[i][j].clear();
    }
  }
  memset(tim,0,sizeof(tim));
}
int Time(int i0,int o0,int i1,int o1)
{
  int i = max(i0,i1);
  int o = min(o0,o1);
  return o-i>0?o-i:0;
}
void solveDate(vector<Date> & dt)
{
  vector<int> in[1111];
  vector<int> out[1111];
  for(int i=0;i<dt.size();i++) {
    if(dt[i].in) in[dt[i].id].push_back(dt[i].m);
    else out[dt[i].id].push_back(dt[i].m);
  }
  for(int i=1;i<1000;i++) {
    for(int j=0;j<in[i].size();j++) {
      for(int k=0;k<in[0].size();k++) {
        tim[i]+=Time(in[0][k],out[0][k],in[i][j],out[i][j]);
      }
    }
  }
}
int main() { ///Problem:A
#ifdef LOCAL
freopen("./../in","r",stdin);
//freopen("./../out","w",stdout);
#endif
  int n;
  while(scanf("%d",&n)==1&&n) {
    int mm,dd,h,m,id;
    char in;
    clear();
    for(int i=0;i<n;i++) {
      scanf("%d/%d %d:%d %c %d",&mm,&dd,&h,&m,&in,&id);
      date[mm][dd].push_back(Date(h*60+m,in=='I',id));
    }
    for(int i=1;i<=12;i++) {
      for(int j=1;j<=31;j++) {
        if(!date[i][j].empty()) {
          solveDate(date[i][j]);
        }
      }
    }
    printf("%d\n",*max_element(tim,tim+1000));
  }
  return 0;
}

Measured memory_bytes: 1404
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		sc.close();
		int cnt = 0;
		for(int X = 0;X <= K;X++) {
			for(int Y = 0;Y <= K;Y++) {
				if(S - X - Y <= K && S - X - Y >= 0) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21712
//============================================================================
// 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

//============================================================================
#define succ(x) ((x)+1)
#define pred(x) ((x)-1)
//============================================================================
void enter()
{
    long a,b; float f;

    scanf("%d", &a);
    scanf("%d", &b);
    printf("%d ", a/b);
    printf("%d ", a%b);
    printf("%.5f\n", (double)a/(double)b);
}
//============================================================================
int main(void)
{
    enter();
    return 0;
}
//============================================================================

Measured memory_bytes: 640
/*input
3 0
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

void run() {
	int n, m, i, x;
	cin >> n >> m;
	vector<int> used(n, -1);
	for(i=0; i<m; i++) {
		int s, c;
		cin >> s >> c;
		if(used[n - s] > -1 && used[n - s] != c) {
			cout <<"-1" << endl;
			return;
		}
		// if(s == n && n > 1 && c == 0) {
		// 	cout <<"-1" << endl;
		// 	return;
		// }
		used[n - s] = c;
	}
	int start, end;
	if(n == 1) {
		if(m == 0) {
			cout <<"0" << endl;
			return;
		}
		start = 0;
		end = 9;
	}
	else if(n == 2) {
		if(m == 0) {
			cout <<"10" << endl;
			return;
		}		
		start = 10;
		end = 99;
	}
	else {
		if(m == 0) {
			cout <<"100" << endl;
			return;
		}		
		start = 100;
		end = 999;
	}
	if(n == 1 && used[0] >= 0) {
		cout <<used[0] << endl;
		return;
	}
	for(x=start; x <= end; x++) {
		int xx = x;
		vector<int> z;
		while(xx > 0) {
			z.emplace_back(xx % 10);
			xx /= 10;
		}
		// reverse(z.begin(), z.end());
		if(z.size() != n) {
			continue;
		}
		bool valid = true;
		for(i=0; i<n; i++) {
			if(used[i] >=0 && (used[i] != z[i]))
				valid = false;
		}
		if(valid) {
			cout << x << endl;
			return;
		}
	}
	cout <<"-1" << endl;

}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);		
	int t = 1;
	// cin >> t;
	while(t--) {
		run();
	}
}


Measured memory_bytes: 256
//Night's template
//orzakyrt
#include <bits/stdc++.h>
#define R register
#define LL long long
#ifdef __DEBUG__
	#define Debug (fprintf(stderr,"orzyrt\n"),fflush(stderr))
	#define debug(__a...) (fprintf(stderr,__a),fflush(stderr))
#else
	#define Debug ('orzyrt')
	#define debug(__a...) ('orzyrt')
#endif
inline void Compile(R char *s){
	char com[111];
	sprintf(com,"g++ %s.cpp -lm -o %s",s,s);
	system(com);
}
inline void setfile(R char *s){
	char inname[111],outname[111];
	sprintf(inname,"%s.in",s);
	sprintf(outname,"%s.out",s);
	freopen(inname,"r",stdin);
	freopen(outname,"w",stdout);
}
#ifdef __DEBUG__
	#define setfile(__a) (1)
#endif
template<class TT>inline TT Max(R TT a,R TT b){return a<b?b:a;}
template<class TT>inline TT Min(R TT a,R TT b){return a<b?a:b;}
template<class TT>inline TT Abs(R TT a){return a<0?-a:a;}
template<class TT>inline TT cmin(R TT &a,R TT b){(b<a)&&(a=b);}
template<class TT>inline TT cmax(R TT &a,R TT b){(a<b)&&(a=b);}
using namespace std;
template<class TT>inline void read(R TT &x){
	x=0;R bool f=false;R char c=getchar();
	for(;c<48||c>57;c=getchar())f|=(c=='-');
	for(;c>47&&c<58;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	(f)&&(x=-x);
}
//end template

namespace Night{
	int n;
	int x[1111],y[1111];
	vector<int>ans;
	int main(){
		read(n);
		for(R int i=1;i<=n;++i){
			read(x[i]);read(y[i]);
			if(abs(x[i])+abs(y[i])&1^abs(x[1])+abs(y[1])&1){
				cout<<-1;
				return 0;
			}
		}
		//for(R int i=0;i<31;++i)ans.push_back(1<<i);
		for(R int i=31;i--;)ans.push_back(1<<i);
		if(abs(x[1])+abs(y[1]) &1 ^1)ans.push_back(1);
		//sort(ans.begin(),ans.end(),greater<int>());
		printf("%ld ",ans.size());
		for(R auto i=ans.begin();i!=ans.end();++i)printf("%d ",*i);
		puts("");
		for(R int i=1;i<=n;++i){
			for(R auto iter=ans.begin();iter!=ans.end();++iter){
				R int j=*iter;
				if(Abs(x[i])>Abs(y[i])){
					if(x[i]>0){
						x[i]-=j;
						putchar('R');
					}else{
						x[i]+=j;
						putchar('L');
					}
				}else{
					if(y[i]>0){
						y[i]-=j;
						putchar('U');
					}else{
						y[i]+=j;
						putchar('D');
					}
				}
			}
			puts("");
		}
		return 0;
	}
}
int main(){
	return Night::main();
}

Measured memory_bytes: 256
N, M = map(int, raw_input().split(" "))
frs = {}
tos = {}
for m in xrange(M):
  fr, to = map(int, raw_input().split(" "))
  if fr == 1:
    if to in tos:
      print "POSSIBLE"
      break
    frs[to] = 1
  elif to == N:
    if fr in frs:
      print "POSSIBLE"
      break
    tos[fr] = 1
else:
  print "IMPOSSIBLE"


Measured memory_bytes: 22128
def main():

    Counter = 0
    Text_W = input()
    while True:
        Text_T = input()
        if "END_OF_TEXT" in Text_T:
            temp = Text_T.lower().split()
            for i in range(len(temp)):
                Counter += 1 if Text_W == temp[i] else 0
            break
        else:
            temp = Text_T.lower().split()
            for i in range(len(temp)):
                Counter += 1 if Text_W == temp[i] else 0

    print (Counter)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5564
from itertools import accumulate

n = int(input())
s = list(input())

false_black = [0] * n
false_white = [0] * n
for i, x in enumerate(s):
    if s[i] == "#":
        false_black[i] = 1
    else:
        false_white[i] = 1

# 累積和
ac_fb = [0] + false_black
ac_fb = list(accumulate(ac_fb))
ac_fw = [0] + false_white
ac_fw = list(accumulate(ac_fw))

ans = 10 ** 6
for i, x in enumerate(s):
    tmp_ans = ac_fb[i] + (ac_fw[-1] - ac_fw[i])
    ans = min(ans, tmp_ans)
    
# このままだと全て白、黒の場合に失敗するので
print(min(ans, ac_fw[-1], ac_fb[-1]))

Measured memory_bytes: 26768
#include<stdio.h>
#include<set>

using namespace std;

int main(){
  int n,a;
  set<int> si;
  bool r;

  scanf("%d", &n);
  for(int i=0;i<n;++i){
    scanf("%d", &a);
    r = si.insert(a).second;
    if(!r) si.erase(a);
  }
  printf("%ld\n",si.size());
  return 0;
}


Measured memory_bytes: 4864
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
//#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
int power(int x, unsigned int y)
{
    int res = 1;

    x = x;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);

        y = y>>1;
        x = (x*x);
    }
    return res;
}
bool isprime(int x)
{
      if(x<2)
        return false;
    for(int i=2;i*i<=x;i++)
     {
        if (x%i==0)
            return false;
    }
    return true;
}
vector<int>primeFactors(int n)
{
    vector<int>v;
    int x=0;
    while (n % 2 == 0)
    {
        x++;
        n = n/2;
        v.pb(2);
    }
    //if(x>0)
    //v.pb({2,x});
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        int y=0;
        while (n % i == 0)
        {
            y++;
            n = n/i;
            v.pb(i);
        }
        //if(y>0)
        //v.pb({i,y});
    }
    if (n > 2)
        v.pb(n);
    return v;
}

void solve()
{
int n;
cin>>n;
int a[n];
int ans=0;
for(int i=0;i<n;i++)
{
    int x=i+1;
    cin>>a[i];
    if(x%2==1&&a[i]%2==1)
        ans++;
}
cout<<ans<<endl;
}

signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
//cin>>t;
t=1;
while(t--)
{
solve();
}
}



Measured memory_bytes: 3612
#include <stdio.h>
#define N 100
int main(){

  int n,flag,i,j,temp,A[N],count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  flag=1;
  while(flag){
    flag=0;
    for(j=0;j<=n-1;j++){
      if(A[j]<A[j-1]){
	temp=A[j];
	A[j]=A[j-1];
	A[j-1]=temp;
	flag=1;
	count++;
      }
    }

  }
  for(j=0;j<n;j++){
    printf("%d",A[j]);
    if(j==n-1) break;
    printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 604
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int compare1(const void *x,const void *y){
    const char *c1=(const char *)x;
    const char *c2=(const char *)y;
    return *c2-*c1;
}
int compare2(const void *x,const void *y){
    const char *c1=(const char *)x;
    const char *c2=(const char *)y;
    return *c1-*c2;
}
int main(void){
    int i,n,m1,m2,a[4];
    char c1[5],c2[5];
    while(1){
        go:
        scanf("%d",&n);
        a[0]=n%10;
        a[1]=(n/10)%10;
        a[2]=(n/100)%10;
        a[3]=(n/1000)%10;
        if(a[0]==a[1] && a[0]==a[2] && a[0]==a[3]){
            if(a[0]==0 && a[1]==0 && a[2]==0 && a[3]==0){
                return 0;
            }else{
                printf("NA\n");
                goto go;
            }
        }
        for(i=1; ;i++){
            sprintf(c1,"%d%d%d%d",a[0],a[1],a[2],a[3]);
            strcpy(c2,c1);
            qsort(c1,4,sizeof(char),compare1);
            qsort(c2,4,sizeof(char),compare2);
            m1=atoi(c1);
            m2=atoi(c2);
            if(m1-m2==n){
                break;
            }
            n=m1-m2;
            a[0]=n%10;
            a[1]=(n/10)%10;
            a[2]=(n/100)%10;
            a[3]=(n/1000)%10;
        }
        printf("%d\n",i-1);
    }
    return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<stdio.h>

using namespace std;

int main()
{
	int a[10] = {0};
	int n, lcm;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	lcm = a[0];
	for (int i = 0; i < n; i++)
	{
		int A = lcm, B = a[i];
		while (1)
		{
			if (A < B)swap(A, B);
			A -= (A / B)*B;
			if (A == 0)break;
		}
		lcm = (lcm*a[i]) / B;
	}
	cout << lcm << endl;
	return 0;
}

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

int main()
{
  int N, T, A;
  cin >> N >> T >> A;

  A *= 1000;
  T *= 1000;

  int h, idx, diff;
  for (int i = 0; i < N; i++) {
    cin >> h;
    const int c = T - (h * 6);
    const int td = abs(A - c);
    if (i == 0 || td < diff) {
      diff = td;
      idx = (i+1);
    }
  }

  cout << idx << endl;
}


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

const int B = 500;


int main(){
    int64_t K;
    cin >> K;

    const int M = 600;

    int64_t C[M+1][8];
    C[0][0] = 1;
    for(int i=1; i<=M; i++) for(int j=0; j<=7; j++){
        C[i][j] = C[i-1][j];
        if(j) C[i][j] += C[i-1][j-1];
    }
    bool start = false;
    vector<int64_t> num;
    for(int i=M; i>=7; i--){
        int64_t q = K / C[i][7];
        if(start || q){
            start = true;
            K -= C[i][7] * q;
            num.push_back(q);
        }
    }
    reverse(num.begin(), num.end());
    string ans;
    cerr << num.size() << endl;
    for(int a : num){
        ans.append("FESTIVA");
        while(a--) ans.push_back('L');
    }
    cout << ans << endl;
    cerr << ans.size() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<int> h(n+1);
  for(int i=0; i<n; i++) cin >> h[i];

  vector<ll> dp(n,INF);
  dp[0]=0,dp[1]=abs(h[1]-h[0]);
  for(int i=2;i<n; i++){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }

  cout << dp[n-1] << endl;


  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int N; cin >> N;

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

    vector<int64_t> sum(1 << N, 0);
    for (int mask = 0; mask < (1 << N); ++mask)
        for (int i = 0; i < N; ++i)
            if ((1 << i) & mask)
                for (int j = i + 1; j < N; ++j)
                    if ((1 << j) & mask)
                        sum[mask] += A[i][j];

    vector<int64_t> dp(1 << N, 0);
    for (int mask = 0; mask < (1 << N); ++mask)
        for (int submask = mask; submask; submask = ((submask - 1) & mask))
            dp[mask] = max(dp[mask], dp[mask - submask] + sum[submask]);

    cout << dp.back() << "\n";
}


Measured memory_bytes: 1280
def resolve():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    exp_table = [0] * 200002
    curr_sum = 0
    for i in range(1, 200002):
        curr_sum += i
        exp_table[i] = curr_sum / float(i)
    curr_sum = 0
    max_v = float('-inf')
    for i in range(len(p)):
        if i+1 < K:
            curr_sum += exp_table[p[i]]
        elif i+1 == K:
            curr_sum += exp_table[p[i]]
            max_v = max(max_v, curr_sum)
        else:
            curr_sum = curr_sum - exp_table[p[i-K]] + exp_table[p[i]]
            max_v = max(max_v, curr_sum)
        # print(curr_sum, max_v, p[i], exp_table[p[i]])
    print(max_v)
resolve()

Measured memory_bytes: 71792
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int a[100001];

int main() {

	int n;

	cin>>n;

	for(int i=1; i<n+1; i++){
		cin>>a[i];
	}
	int total=0;
	int o=1;
	for(int i=1; i<n+1; i++){
		if(o==2){
			break;
		}else{
			total++;
			o=a[o];
		}
	}
	if(total>=n){
		cout<<"-1"<<endl;
	}else{
	cout<<total<<endl;
	}
	return 0;
}


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

using namespace std;
int main()
{
    int r,d,x,i,res;

    cin>>r;
    cin>>d;
    cin>>x;

    for(i=0;i<10;i++){
        res=(r*x)-d;
        x=res;

        cout<<x<<endl;
    }

}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  cin>>S;
  bool ans=false;
  for(int i=0;i<3;++i){
    if(S.at(i)==S.at(i+1)){
      ans=true;
    }
  }
 
  if(ans){cout<<"Bad"<<endl;}
  else{cout<<"Good"<<endl;}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	

using namespace std;
#define int_max 2147483647

int main() {
	vector<int> w;
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		w.push_back(a);
	}
	pair<int, int> T;
	T = make_pair(0, 0);
	for (int i = 0; i < N; ++i) {
		T.first += w[i];
	}
	int minA = int_max;
	for (int i = 0; i < N; ++i) {
		T.first -= w[i];
		T.second += w[i];
		minA = min(minA, abs(T.first - T.second));
	}
	cout << minA << endl;



	return 0;
}

Measured memory_bytes: 256
/* ITP1_2_D */
#include <iostream>
#define ORIGIN 0

struct Rectangle
{
    int width   = 0;
    int height  = 0;
};

struct Circle
{
    int x = 0;
    int y = 0;
    int r = 0;
};

int main(void){
    /* input */
    Rectangle rectangle;
    Circle circle;
    
    std::cin >> rectangle.width >> rectangle.height >> circle.x >> circle.y >> circle.r;
    
    /* judge */
    if( ((circle.x - circle.r) < ORIGIN )      /* left side   */
     || ((circle.y - circle.r) < ORIGIN )      /* bottom side */
     || ((circle.x + circle.r) > rectangle.width)   /* right side  */
     || ((circle.y + circle.r) > rectangle.height) )/* upper side  */
    {
        std::cout << "No" << std::endl;    /* area over */
    }
    else
    {
        std::cout << "Yes" << std::endl;
    }
    
    return 0;
}


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

int main() {
    vector<vector<int>> a(3,vector<int>(3));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> a.at(i).at(j);
        }
    }
    int n;
    cin >> n;
    for(int t = 0; t < n; t++){
        int b;
        cin >> b;
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                if(a.at(i).at(j) == b)a.at(i).at(j) = 0;
            }
        }
    }
    bool ans = false;
    for(int i = 0; i < 3; i++){
        if(a.at(i).at(0) == 0 && a.at(i).at(1) == 0 && a.at(i).at(2) == 0)ans = true;
        if(a.at(0).at(i) == 0 && a.at(1).at(i) == 0 && a.at(2).at(i) == 0)ans = true;
    }
    if(a.at(0).at(0) == 0 && a.at(1).at(1) == 0 && a.at(2).at(2) == 0)ans = true;
    if(a.at(2).at(0) == 0 && a.at(1).at(1) == 0 && a.at(0).at(2) == 0)ans = true;
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long 
signed main()
{
	int ans=0;
	int h,a;cin>>h>>a;
	while(a--){
		int x;cin>>x;
		h-=x;
	}
	if(h<=0)puts("Yes");
	else puts("No");


	getchar();getchar();
	
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  cout << (double)w * h / 2 << " ";
  if ((double)w / 2 == (double)x && (double)h / 2 == (double)y) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

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

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

ll dp[64][64];

ll comb(ll a, ll b) {
  return b < 0 ? 0 : dp[a][b];
}

void solve(ll N, ll A, ll B, vector<ll> v) {
  dp[0][0] = 1;
  REP(i,60) REP(j,60) {
    dp[i+1][j] += dp[i][j];
    dp[i+1][j+1] += dp[i][j];
  }
  sort(v.rbegin(), v.rend());
  if (v[0] == v[A-1]) {
    int num = 0;
    REP(i,N) if (v[i] == v[0]) ++num;
    ll res = 0;
    for (int i = A; i <= B; ++i) res += comb(num, i);
    cout << ld(v[0]) << endl;
    cout << res << endl;
  }
  else {
    int num1 = 0, num2 = 0;
    REP(i,N) if (v[i] > v[A-1]) ++num1;
    REP(i,N) if (v[i] == v[A-1]) ++num2;
    cout << ld(accumulate(begin(v), begin(v) + A, 0LL)) / A << endl;
    ll res = comb(num2, A - num1);
    cout << res << endl;
  }
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	ll B;
	ll A;
	scanf("%lld", &N);
	vector<ll> v(N-1+1);
	scanf("%lld", &A);
	scanf("%lld", &B);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &v[i]);
	}
	solve(N, A, B, v);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

ll calcNumOfCombination(ll n, ll r){
	ll num = 1;
	for(ll i = 1; i <= r; i++){
		num = num * (n - i + 1) / i;
	}
	return num;
}

int main(){
	int n;
	cin >> n;
	map<int, int> m;
	vector<int> a(n);
	rep(i, n){
		int in;
		cin >> in;
		a.at(i) = in;
		m[in]++;
	}
	ll all = 0;
	for(auto p : m){
		all += calcNumOfCombination(p.second, 2);
	}
	rep(i, n){
		int now = a.at(i);
		ll ans = all;
		ans -= calcNumOfCombination(m[now], 2);
		ans += calcNumOfCombination(m[now]-1, 2);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 8320
#include<stdio.h>
int main()
{
  int a,b;
  scanf("%d%d",&a,&b);
  if(a>b)
  {
    int i;
    for(i=1;i<=a;i++)
      printf("%d",b);
  }
  else 
  {
    int i;
    for(i=1;i<=b;i++)
      printf("%d",a);
  }
  return 0;
}    

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)
#define ll long long
const ll mod=1e9+7;

char in[120];
pair<pair<string,int>,int> p[110];

int main(){
int a;scanf("%d",&a);
for(int i=0;i<a;i++){
int t;scanf("%s%d",in,&t);
string tmp=in;
p[i]=make_pair(make_pair(in,-t),i);
}
std::sort(p,p+a);
for(int i=0;i<a;i++)printf("%d\n",p[i].second+1);

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
const ll INF = 1e16+1;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}

int N;

int main() {
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    vector<ll> left(N), right(N);
    left[0] = a[0];
    for (int i = 1; i < N; i++) {
        left[i] = left[i-1] + a[i];
    }
    right[N-1] = a[N-1];
    for (int i = N-2; i >= 0; i--) {
        right[i] = right[i+1] + a[i];
    }
    ll res = INF;
    for (int i = 0; i < N-1; i++) {
        chmin(res,abs(right[i+1]-left[i]));
    }
    cout << res << endl;

    



}

Measured memory_bytes: 4992
num, dim = gets.chomp.split(" ").map{|s| s.to_i}

axs_arr = []
num.times do
  axs_arr << gets.chomp.split(" ").map{|s| s.to_i}
end

count = 0
axs_arr.each_with_index do |axs, i|
  axs_arr[(i+1)..-1].each do |axs_add|
    sum = 0
    dim.times do |i|
      sum += (axs[i] - axs_add[i]) ** 2
    end
    count += 1 if Math.sqrt(sum) % 1 == 0.0
  end
end

p count

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
    int i,j;
    string s;
    int k;
    cin >> s >> k;
    rep(i,min(k,(int)s.size()))if(s[i] != '1'){
        cout << s[i] << endl;
        return 0;
    }
    cout << 1 << endl;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

#import math
#import numpy as np
#import operator
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
	a,b=map(int,input().split())
	if a<=9 and b<=9:
		print(a*b)
	else:
		print(-1)
	




if __name__ == '__main__':
	main()

Measured memory_bytes: 2940
#include <iostream>
#include<algorithm>
#include<map>
//#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb emplace_back
#define mp make_pair
#define MOD (int) 1e9+7
#define for0(i, n) for (int i = 0; i < n; i++)
#define ff first
#define ss second
#define endl "\n"
#define bits(n) __builtin_popcount(n)
#define ini(a, i) memset(a, i, sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	// cin >> t;
	t  = 1;
	while (t--)
	{
		ll n;
		cin >> n;
		ll arr[n];
		map<ll, ll> mp;
		ll sum = 0;
		for (ll i = 0; i < n; i++)
		{
			cin >> arr[i];
			mp[arr[i]]++;
			sum += arr[i];
		}
		ll q;
		cin >> q;
		while (q--)
		{
			ll a, b;
			cin >> a >> b;
			ll cc = mp[a];
			mp[a] = 0;
			sum -= cc * a;
			sum += cc * b;
			mp[b] += cc;
			cout << sum << endl;
		}

	}
	return 0;
}


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

int main(){
	int X,Y,A,B,C;
	cin >> X >> Y >> A >> B >> C;
	vector<long long> p(A);
	vector<long long> q(B);
	vector<long long> r(C);
	for(auto &i:p)cin >> i;
	for(auto &i:q)cin >> i;
	for(auto &i:r)cin >> i;
	sort(p.begin(),p.end(),greater<long long>());
	sort(q.begin(),q.end(),greater<long long>());
	sort(r.begin(),r.end(),greater<long long>());
	
	priority_queue<long long,vector<long long>,greater<long long>> P;
	priority_queue<long long,vector<long long>,greater<long long>> Q;
	
	for(int i=0;i<X;i++)P.push(p[i]);
	for(int i=0;i<Y;i++)Q.push(q[i]);
	
	long long ans=accumulate(p.begin(),p.begin()+X,0LL)+accumulate(q.begin(),q.begin()+Y,0LL);
	
	for(int i=0;i<C;i++){
		long long Pmin=P.top(),Qmin=Q.top();
		if(r[i]<min(Pmin,Qmin))break;
		if(Pmin<Qmin){
			P.pop();
			P.push(r[i]);
			ans+=r[i]-Pmin;
		}else{
			Q.pop();
			Q.push(r[i]);
			ans+=r[i]-Qmin;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4852
#include <bits/stdc++.h>
#define lli long long int
#define DBG false
using namespace std;

int main() {
  lli r=0,g=0,b=0;
  int n;
  string s;
  cin >> n >> s;
  for (int p = 0; p < n; p++){
    if(s[p] == 'R')	r++;
    if(s[p] == 'G')	g++;
    if(s[p] == 'B')	b++;
  }
  lli ans = r * g * b;
  for (int i = 0; i < n; i++){
    for (int j = i + 1; j < n; j++) {
      int k = j+j-i;
      if(k >= n){
        break;
      }
      if(s[i] != s[j] && s[k] != s[j] && s[k] != s[i]){
        ans--;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

const int mod = 1000000007;

struct mint {
    ll x;
    mint (ll x = 0) : x(x % mod) {}
    mint& operator += (const mint a) { // コンストラクタの、modで割った余りがくる
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator -= (const mint a) {
        if ((x += -a.x + mod) >= mod) x -= mod;
        return *this;
    }
    mint& operator *= (const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator + (const mint a) const {
        mint res(*this);
        return res += a; // ?
    }
    mint operator - (const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator * (const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const { // mint(a).pow(t) tは余りとったりしたらあかん
        if (t == 0) return 1;
        mint a = pow(t >> 1); // 再帰
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    
    // 逆元
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator /= (const mint a) { // invを利用
        return (*this) *= a.inv();
    }
    mint operator / (const mint a) const {
        mint res(*this);
        return res /= a;
    }
    friend ostream &operator<<(ostream &s, mint a) { return s << a.x; }
};


enum {A, B, C};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
   
    string str;
    cin >> str;
    
    mint dp[100001][4] = {0};
    // ...A...B...C...
    dp[0][0] = 1;
    
    rep(i, sz(str)) {
        
        if (str[i] == 'A' || str[i] == '?') {
            rep(j, 4) dp[i + 1][j] += dp[i][j];
            dp[i + 1][1] += dp[i][0];
        }
        if (str[i] == 'B' || str[i] == '?') {
            rep(j, 4) dp[i + 1][j] += dp[i][j];
            dp[i + 1][2] += dp[i][1];
        }
        if (str[i] == 'C' || str[i] == '?') {
            rep(j, 4) dp[i + 1][j] += dp[i][j];
            dp[i + 1][3] += dp[i][2];
        }
    }
    
    out(dp[sz(str)][3]);
    // rep(i, sz(str) + 1) { rep(j, 4) cout << dp[i][j] << " "; cout << endl; }
}




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

using namespace std;
using ll = long long;

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

int main() {
  char c;
  cin >> c;
  char a = c + 1;
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a_lst = list(map(int, input().split()))
max_ = max(a_lst)
min_ = min(a_lst)
res = 0
for num in range(min_, max_+1):
  cost = 0
  for a in a_lst:
    cost += (a - num) ** 2
  if res != 0:
    res = min(res, cost)
  else:
    res = cost
print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

vector<int> V1[200001], V2[200001];
int D[200001], T[200001];
map<pair<int, int>, int> MAP;

void douro(int A, int B) {
	if (D[A] == 0) {
		D[A] = B;
		for (auto itr : V1[A]) douro(itr, B);
	}
}

void tetudou(int A, int B) {
	if (T[A] == 0) {
		T[A] = B;
		MAP[mp(D[A], T[A])]++;
		for (auto itr : V2[A]) tetudou(itr, B);
	}
}

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

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

	rep(i, K) {
		int p, q;
		cin >> p >> q;
		V1[p].pb(q);
		V1[q].pb(p);
	}
	rep(i, L) {
		int p, q;
		cin >> p >> q;
		V2[p].pb(q);
		V2[q].pb(p);
	}

	rep1(i, N) douro(i, i);
	rep1(i, N) tetudou(i, i);


	rep1(i, N) {
		cosp(MAP[mp(D[i], T[i])]);
	}
	cout << endl;
	Would you please return 0;
}

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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define debug(x) cerr<<#x << " := " << x << endl;
#define bug cerr<<"-----------------------"<<endl;



typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 0x3f3f3f3f;
const ll inff = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9+7;
/**********showtime************/
            const int maxn = 4009;
            ll mp[maxn][maxn];
            ll c(int n, int m) {
                if(n == m || m == 0) return 1;
                if(n < m) return 0;
                if(n == 0) return 0;
                if(mp[n][m]) return mp[n][m];
                return mp[n][m] = (c(n-1,m) + c(n-1, m-1)) % mod;
            }
int main(){
            int n,k;
            scanf("%d%d", &n, &k);
            for(int i=1; i<=k; i++) {
                printf("%lld\n", c(k-1, i-1) * c(n-k+1, i) % mod);
            }
            return 0;
}


Measured memory_bytes: 62080
#include<iostream>
#include<string>
#include<set>
using namespace std;

int main() {
  int H, W, K; cin >> H >> W >> K;
  bool C[H][W];
  for (int i = 0; i < H; i++) {
    string s; cin >> s;
    for (int j = 0; j < W; j++) {
      C[i][j] = (s[j] == '#');
    }
  }
  int c = 0;
  for (int bh = 0; bh < (1<<H); bh++) {
    for (int bw = 0; bw < (1<<W); bw++) {
      int black = 0;
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          black += (bh>>i) & (bw>>j) & C[i][j];
        }
      }
      c += (black == K);
    }
  }
  cout << c << endl;
}

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

int main(){
    int n;  cin >> n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b,b+n);

    int d(0);
    for(int i=0;i<n;i++){
        if(a[i]!=b[i])  d++;
    }

    if(d==0){
        cout << 0 << endl;
        return 0;
    }

    int q;  cin >> q;

    for(int i=1;i<=q;i++){
        int x,y;
        cin >> x >> y;

        if(a[x-1]!=b[x-1])  d--;

        if(a[y-1]!=b[y-1])  d--;

        swap(a[x-1],a[y-1]);

        if(a[x-1]!=b[x-1])  d++;

        if(a[y-1]!=b[y-1])  d++;

        if(d==0){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}


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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  vector<ll>t(2),a(2),b(2);
  rep(i,0,2)cin>>t[i];
  rep(i,0,2)cin>>a[i];
  rep(i,0,2)cin>>b[i];
  ll d=abs(a[0]*t[0]+a[1]*t[1]-b[0]*t[0]-b[1]*t[1]);
  if(d==0){
    cout<<"infinity"<<endl;
    return 0;
  }
  if(a[0]<b[0]){
    swap(a[0],b[0]);
    swap(a[1],b[1]);
  }
  if(a[0]*t[0]+a[1]*t[1]>b[0]*t[0]+b[1]*t[1]){
    cout<<0<<endl;
    return 0;
  }
  ll d1=(a[0]-b[0])*t[0];
  cout<<1+(d1-1)/d*2+(d1%d==0)<<endl;
  return 0;
}

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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

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

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Die{
	char face[6];
	Die():face{}{}
	Die(char f,char b,char r,char l,char u,char d):face{f,b,r,l,u,d}{}
	void Rotate(int a,int b,int c,int d){
		tie(face[a],face[b],face[c],face[d])=make_tuple(face[b],face[c],face[d],face[a]);
	}
	enum{F,B,R,L,U,D};
	void TurnX(int n=1){rep(i,n) Rotate(U,R,D,L);} // x軸中心に半時計回り
	void TurnY(int n=1){rep(i,n) Rotate(U,B,D,F);} // y軸中心に半時計回り
	void TurnZ(int n=1){rep(i,n) Rotate(F,L,B,R);} // z軸中心に半時計回り
};
bool operator==(const Die& a,const Die& b){
	rep(i,6) if(a.face[i]!=b.face[i]) return false;
	return true;
}
bool operator!=(const Die& a,const Die& b){
	return !(a==b);
}
bool operator<(const Die& a,const Die& b){
	rep(i,6) if(a.face[i]!=b.face[i]) return a.face[i]<b.face[i];
	return false;
}

bool operator<(const tuple<Die,int,int,int>& a,const tuple<Die,int,int,int>& b){
	if(get<0>(a)!=get<0>(b)) return get<0>(a)<get<0>(b);
	if(get<1>(a)!=get<1>(b)) return get<1>(a)<get<1>(b);
	if(get<2>(a)!=get<2>(b)) return get<2>(a)<get<2>(b);
	if(get<3>(a)!=get<3>(b)) return get<3>(a)<get<3>(b);
	return 0;
}

int main()
{
	for(int w,h;cin>>w>>h && w|h;){
		vs grid(h);
		rep(i,h) cin>>grid[i];
		string order; cin>>order;
		
		queue<tuple<Die,int,int,int,int>> q; // (die,i,j,visit,step)
		set<tuple<Die,int,int,int>> vis;
		
		rep(i,h) rep(j,w) if(grid[i][j]=='#'){
			grid[i][j]='w';
			Die d('m','g','b','y','r','c');
			q.emplace(d,i,j,0,0);
			vis.insert(make_tuple(d,i,j,0));
		}
		
		int x=-1;
		while(q.size()){
			Die d; int i,j,v,s; tie(d,i,j,v,s)=q.front(); q.pop();
			//dump(mp(string(d.face,d.face+6),vi({i,j,v,s})));
			if(v==6){
				x=s;
				break;
			}
			rep(k,4){
				int ni=i+"\xff\x1\0\0"[k],nj=j+"\0\0\xff\x1"[k];
				if(ni<0 || h<=ni || nj<0 || w<=nj || grid[ni][nj]=='k') continue;
				Die nd=d;
				if(k==0) nd.TurnY(3);
				if(k==1) nd.TurnY(1);
				if(k==2) nd.TurnX(1);
				if(k==3) nd.TurnX(3);
				int nv=v;
				if(grid[ni][nj]!='w'){
					if(grid[ni][nj]!=order[nv]) continue;
					if(grid[ni][nj]!=nd.face[Die::U]) continue;
					nv++;
				}
				if(vis.insert(make_tuple(nd,ni,nj,nv)).second)
					q.emplace(nd,ni,nj,nv,s+1);
			}
		}
		if(x!=-1)
			cout<<x<<endl;
		else
			cout<<"unreachable"<<endl;
	}
}

Measured memory_bytes: 5264
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <deque>
#include <utility>
using namespace std;
typedef long long ll;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define INF (1LL << 60)

ll A[100010];
ll ans[100010];

void solve()
{
    ll N;
    cin >> N;
    for1(i,N) {
        cin >> A[i];
    }
    ll total = 0;
    for1(i,N) {
        total += A[i];
    }
    ll even = 0;
    for3(i,0,N-1,2) {
        even += A[i];
    }
    even *= 2;
    ans[N-1] = total - even;
    ans[0] = A[N-1] * 2 - ans[N-1];
    for2(i,1,N-1) {
        ans[i] = A[i-1] * 2 - ans[i-1];
    }
    for1(i,N) {
        if (i != 0) {
            cout << " ";
        }
        cout << ans[i];
    }

    cout << endl;
}

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


Measured memory_bytes: 2944
#include <iostream>
using namespace std;
int main ()
{
	int n,r;
	while(cin>>n>>r)
	{
		int sum;
		if(n<10)
		{
			sum=r+100*(10-n);
			cout<<sum<<endl;
		}
		else
		{
			cout<<r<<endl;
		}
	}
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
	
   
    int main(){
      char buf[18];
      scanf("%s", buf); 
      int i;

      for(i=0;i<=18;i++){
         if (buf[i] == ','){
            putchar(' ');
         }else{
            putchar(buf[i]);
         }
      }printf("\n");
    }

Measured memory_bytes: 128