akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;
//set<int>::iterator it;



int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a,b,k,i,t=0;
	cin>>a>>b>>k;
	for(i=1000;i>0;i--){
//		cout<<i<<k<<endl;
		if(a%i==0&&b%i==0)t++;
		if(k==t){
			cout<<i<<endl;
			return 0;
		}
	}
	
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <complex>
using namespace std;

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

  complex<double> v[100];
  for(int i=0;i<n;i++){
    double x,y;
    cin >> x >> y;
    v[i]=complex<double>(x,y);
  }

  double s=0.0;
  for(int i=1;(i+1)<n;i++){
    s+=(conj(v[i]-v[0])*(v[i+1]-v[0])).imag()/2;
  }

  cout << fixed << setprecision(1) << s << endl;

  return 0;
}

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

int main() {
  int n; cin >> n;
  string w, pw; cin >> pw;
  map<string, int> wmap; wmap[pw] = 1;
  for (int i = 1; i < n; i++) {
    string w; cin >> w;
    if (wmap[w] or pw.back() != w.at(0)) {
      cout << "No" << endl;
      return 0;
    }
    wmap[w] = 1;
    pw = w;
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream> 
#include<string>
#include<sstream>
#include<fstream>
#include<vector>
using namespace std;

int main(){
 int H,W,h,w;

 cin>>H;
 cin>>W;
 cin>>h;
 cin>>w;
 
 printf("%d",H*W-h*W-w*H+h*w);




}


Measured memory_bytes: 256
#include	<stdio.h>
//	大の月なら 20、小の月なら 19 を返す関数 （y	=	年、 m	=	月）
int	ndm(int	y,	int	m)
{
		//	3 で割り切れる年は全て大の月。また、奇数月も大の月。
		if(y	%	3	==	0	||	m	%	2)	return	20;
		else	return	19;
}
//	1000 年 1 月 1 日までの日数を求める
int	calc(int	y,	int	m,	int	d)
{
		int	days; //	日数計算に用いる変数
		int	i;
		days	=	ndm(y,	m)	- d; //	まず、月末までの日数を数える
		for(i=m+1;	i<=10;	i++) //	年末までの日数を数える
				days	+=	ndm(y,	i);
		for(i=y+1;	i<=999;	i++) //	999 年末までの日数を数える
				days	+=	(i	%	3)?195:200; //	3 で割り切れない年は 195 日,	割り切れる年は 200 日
		days++; //	求めるのは 1000 年 1 月 1 日までの日数なので１増やす
		return	days;
}
int	main()
{
		int	n,	y,	m,	d,	i;
		scanf("%d",	&n); //	n	=	データセット数
		for(i=0;	i<n;	i++){
				scanf("%d	%d	%d",	&y,	&m,	&d); //	年月日の読み込み
				printf("%d\n",	calc(y,m,d)); //	日数を求めてプリント
		}
}


Measured memory_bytes: 2616
#include<bits/stdc++.h>
using namespace std;
long long int f(vector<long long int>&v,long int k,vector<long long int>&dp)
{
  long long int s=0,a,b;
  if(k==v.size()-1)
    return 0;
  a=v[k]>v[k+1]?v[k]-v[k+1]:v[k+1]-v[k];
  if(k==v.size()-2)
    return a;
  if(dp[k]!=-1)
    return dp[k];
  b=v[k]>v[k+2]?v[k]-v[k+2]:v[k+2]-v[k];
  s+=min(f(v,k+1,dp)+a,f(v,k+2,dp)+b);
  dp[k]=s;
  return s;
}
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long int n;
  cin>>n;
  vector<long long int>v(n),dp(n,-1);
  for(long long int i=0;i<n;i++)
    cin>>v[i];
  cout<<f(v,0,dp);
  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n, 0);
    float sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    int ave = round(sum / n);

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += (a[i] - ave) * (a[i] - ave);
    }

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

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;


int main() {
  long long X;
  long long K;
  long long D;
  cin >> X;
  cin >> K;
  cin >> D;
  
  long long x = abs(X);
  long long k = K;
  
    long long t = (x / D);
    if(t > k){
      t = k;
    }
    x -= D * t;
    k -= t;
  
  
      if(k % 2 == 1){
          x -= D;
      }
  cout << abs(x) << endl;
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int x = 0;
  int max = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'I') {
      x++;
      if (max < x) max = x;
    }
    else x--;
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
const int N=100+10;
char a[N][15];
int main()
{
	int n;
	bool pd=true;
	cin>>n;
	memset(a,0,sizeof(a));
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n-1;i++)
	{
		int l=strlen(a[i]);
		if(a[i][l-1]!=a[i+1][0])
		{
			cout<<"No";
			pd=false;
			break;
		}
		for(int j=i+1;j<n;j++)
		{
			if(strcmp(a[i],a[j])==0)
			{
				cout<<"No";
				pd=false;
				break;
			}
		}
	}
	if(pd)
	cout<<"Yes";
//    return 0；
}


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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 1e5 + 5;



int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int l; cin >> l;

    double x = double(l) / 3.0;
    cout << fixed << setprecision(10) << x * x * x << endl;



    return 0;
%>

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	vector<int> l(n);
	rep(i, n)cin>>l[i];

	ll ans = 1e9;
	for(int mask = 0; mask < (1 << 2 * n); mask++){
		int A = 0, B = 0, C = 0;
		ll tmp = mask;
		int synthetic = 0;
		rep(i,n){
			int now = tmp % 4;
			if(now == 0) ;// not use
			else synthetic++;
			if(now == 1) A += l[i];
			if(now == 2) B += l[i];
			if(now == 3) C += l[i];
			tmp /= 4;
		}
		if(A != 0 && B != 0 && C != 0){
			chmin(ans, (ll)(abs(a-A)+abs(b-B)+abs(c-C)+10*(synthetic-3)));
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <vector>
#include <string.h>

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

/*
int gcd(int a,b) {
  if(a < b) gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
*/

int gcd(int a, int b)
{
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    while (b != 0) {
        a %= b;
        if (a == 0) return b;
        b %= a;
    }
    return a;
}



void solve(){
  int n;
  cin >> n;
  vector<int> number;
  rep(i,n){
    int k;
    cin >> k; 
    number.emplace_back(k); 
  }
  vector<int> a(1);
  vector<int> b(1);
  a[0]=number[0];
  b[0]=number[n-1];
  //cout << a[0] << " " << b[0] << endl;
  for(int i=1; i<n; i++){
    int j, k;
    j = gcd(a[i-1], number[i]);
    k = gcd(b[i-1], number[n-i-1]);
    a.emplace_back(j);
    b.emplace_back(k);
    //cout << i << endl;
    //cout << j << ":j" << endl;
    //cout << k << ":k" << endl;
  }
  int m;
  vector<int> x;
  x.push_back(b[n-2]);
  rep(i,n-2){
    x.push_back(gcd(a[i], b[n-i-3])); 
  }
  x.push_back(a[n-2]);
  rep(i,n){
    m = max(m, x[i]); 
  }
  cout << m << endl;
  
}

int main(){
  solve();
  return 0;
}


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

int main(){
  int N,X,sum = 0;
  cin >> N >> X;
  int a[N];
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  sort(a,a+N);
  for(int j=0; j<N; j++){
    sum += a[j];
  }
  cout << (X-sum)/a[0] + N << endl;        
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main() {
    cin>>N;
    vec x(N), y(N);
    rep(i,N) cin>>x[i]>>y[i];
    typedef struct{
        ll a, b, cost;
    } edge;
    vector<edge> E(N*2 - 2);

    vec ord(N);
    rep(i,N) ord[i] = i;
    sort(ord.begin(), ord.end(), [&](ll p, ll q){
        return x[p] < x[q];
    });
    reps(i,1,N){
        edge e = {ord[i], ord[i-1], x[ord[i]] - x[ord[i-1]]};
        E[i - 1] = e;
    }

    rep(i,N) ord[i] = i;
    sort(ord.begin(), ord.end(), [&](ll p, ll q){
        return y[p] < y[q];
    });
    reps(i,1,N){
        edge e = {ord[i], ord[i-1], y[ord[i]] - y[ord[i-1]]};
        E[N - 1 + i - 1] = e;
    }

    vec e_ord(N*2 - 2);
    rep(i,N*2 - 2) e_ord[i] = i;
    sort(e_ord.begin(), e_ord.end(), [&](ll p, ll q){
        return E[p].cost < E[q].cost;
    });
    ll ans = 0;
    class union_find{
            vector<long> parent, tree_size;
        public:
            union_find(unsigned long _n) : parent(_n), tree_size(_n, 1){
                for(unsigned long i = 0; i < _n; ++i)parent[i] = i;
            }
            ll find(ll x){
                while(parent[x] != x)x = parent[x] = parent[parent[x]];
                return x;
            }
            void merge(ll a, ll b){
                a = find(a);
                b = find(b);
    	    if(a==b) return;
                if(tree_size[a] < tree_size[b])swap(a, b);
                tree_size[a] += tree_size[b];
                parent[b] = a;
                return;
            }
    	bool same(ll a, ll b){
    	    a = find(a);
    	    b = find(b);
    	    return a == b;
    	}
        };
    //uf.mergeのように使う
    //ufはMAX_N+1でとるか、代入時に0-indexedにする
    union_find uf(N);
    rep(i,N*2 - 2){
        edge e = E[e_ord[i]];
        if(!uf.same(e.a, e.b)){
            ans += e.cost;
            uf.merge(e.a, e.b);
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 10368
#include<iostream>
#include<string>
using namespace std;
int main(){
	int t,p,r,team,program,time;
	int solved[50],penalty[50],pp[50][10];
	string message;
	while(true){
	cin>>t>>p>>r;
	if(t==0&&p==0&&r==0)
		break;
	for(int i=0;i<t;i++){
		solved[i]=0;
		penalty[i]=0;
		for(int j=0;j<p;j++)
			pp[i][j]=0;
	}
	for(int i=0;i<r;i++){
		cin>>team>>program>>time>>message;
		if(message=="CORRECT"){
			solved[team-1]++;
			penalty[team-1]+=pp[team-1][program-1]+time;
		}
		if(message=="WRONG"){
			pp[team-1][program-1]+=1200;
		}
	}
	int junni[50];
	for(int i=0;i<t;i++)
		junni[i]=i+1;
	for(int i=0;i<t-1;i++){
		for(int j=t-1;j>i;j--){
			if(solved[j]>solved[j-1]||(solved[j]==solved[j-1]&&penalty[j]<penalty[j-1])){
				int tmp=junni[j];
				junni[j]=junni[j-1];
				junni[j-1]=tmp;
				tmp=solved[j];
				solved[j]=solved[j-1];
				solved[j-1]=tmp;
				tmp=penalty[j];
				penalty[j]=penalty[j-1];
				penalty[j-1]=tmp;
			}
		}
	}
	for(int i=0;i<t;i++)
		cout<<junni[i]<<" "<<solved[i]<<" "<<penalty[i]<<endl;
	}
	return 0;
}

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

using namespace std;
#define ll long long
#define int long long

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
	#define lcout(a) cout << a;
	#define lcoutln(a) cout << a << endl;
	#define lcerr(a) cerr << a;
	#define lcerrln(a) cerr << a << endl;
#else
	#define lcout(a) 
	#define lcoutln(a) 
	#define lcerr(a) 
	#define lcerrln(a) 
#endif

#define MOD 1000000007

signed main()
{
	string s;
	cin >> s;
	int l = s.length();
	vector<int> v;
	rep(i, l) {
		if (s[i] == 'B') {
			if (v.size() != 0) v.erase(v.end()-1, v.end());
		}
		else v.PB(s[i]-'0');
	}
	for (int x : v) cout << x;
	cout << endl;
		
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
x=int(input())

ans=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k==x:
        ans+=1
      
print(ans)


Measured memory_bytes: 3060
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math

N,M=map(int,input().split())
xyz=[list(map(int,input().split())) for m in range(N)]
dp=[[[0,0] for i in range(M)] for i in range(N)]
if M==0:
    print(0)
    exit()
num=0
for a in [-1,1]:
    for b in [-1,1]:
        for c in [-1,1]:
            dp=[[None for m in range(M)] for i in range(N)]
            for i in range(0,N):
                x,y,z=xyz[i]
                A=x*a+y*b+z*c
                #print(dp)
                if i==0:
                    dp[i][0]=A
                else:
                    for m in range(0,M):
                        if m==0:
                            dp[i][m]=max(dp[i-1][m],A)
                        else:
                            if dp[i-1][m]:
                                dp[i][m]=max(dp[i-1][m-1]+A,dp[i-1][m])
                            elif dp[i-1][m-1]:
                                dp[i][m]=dp[i-1][m-1]+A
                            else:
                                break
            if dp[-1][-1]:
                num=max(dp[-1][-1],num)
print(num)


Measured memory_bytes: 169352
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 1001;
ll DP[N+10][N+10], n, ma, mb, a, b, c;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  Fill(DP, linf);
  DP[0][0] = 0;
  cin >> n >> ma >> mb;
  FOR(i, 0, n){
    cin >> a >> b >> c;
    FORR(j, N-1, 0)FORR(k, N-1, 0) mins(DP[j+a][k+b], DP[j][k] + c);
  }
  ll sma = 0, smb = 0, ans = linf;
  while(sma < N && smb < N){
    sma += ma;
    smb += mb;
    mins(ans, DP[sma][smb]);
  }
  cout << (ans < linf ? ans : -1) << endl;
  return 0;
}

Measured memory_bytes: 8192
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<cstdlib>
#include<ctime>
#include<cctype>
#include<stack>
#include<queue>
#include<deque>
#include<list>

using namespace std; 

string s;
int ans = 0;
int main()
{
	cin >> s;
	int l = 0; 
	int r = s.size()-1;
	while(l <= r)
	{
		if(s[l] != s[r])
		{
			ans++;
			//cout << l << " " << r << endl;
		}
		l++;
		r--;
	}
	cout << ans << endl; 
	return 0;
} 

Measured memory_bytes: 256
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

int main() {
	int n, k;
	string s;
	cin >> n >> k >> s;
	cout << s.substr(0, k - 1);
	if (s.substr(k - 1, 1) == "A") {
		cout << "a";
	}
	else if (s.substr(k - 1, 1) == "B") {
		cout << "b";
	}
	else {
		cout << "c";
	}
	cout << s.substr(k, n - k) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
const int mod=924844033;
ll g[2005][2005][4],f[4005],t[4005],F[2005];
int n,K,m;
ll quick_pow(ll a,ll b){
	ll ans=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1) ans=ans*a%mod;
	return ans;
}
ll add(ll a,ll b){
	return a+b>=mod?a+b-mod:a+b;
}
ll dft(ll *a,int sig){
	for(int i=0;i<m;i++){
		int p=0,g=m>>1,j=i;
		while(g) p=p<<1|(j&1),j>>=1,g>>=1;
		if(p<i) swap(a[p],a[i]);
	}
	ll w,wn;
	for(int b=2;b<=m;b<<=1){
		int half=b>>1;
		wn=quick_pow(5,sig==1?(mod-1)/b:mod-1-(mod-1)/b);
		for(int i=0;i<m;i+=b){
			w=1;
			for(int j=0;j<half;j++){
				ll u=a[i+j],v=a[i+j+half]*w%mod;
				a[i+j]=add(u,v);
				a[i+j+half]=add(u,mod-v);
				w=w*wn%mod;
			}
		}
	}
	ll inv=quick_pow(m,mod-2);
	if(sig==-1) for(int i=0;i<m;i++) a[i]=a[i]*inv%mod;
}
int main(){
	scanf("%d%d",&n,&K);
	g[0][0][1]=1;
	for(int i=1;i<=n;i++){
		for(int p=0;p<=i;p++){
			for(int j=0;j<4;j++){
				if(j&2){
					if(p) g[i][p][j]=add(g[i-1][p-1][(j&1)<<1|1],g[i-1][p-1][(j&1)<<1]);
				}else{
					g[i][p][j]=add(g[i-1][p][(j&1)<<1|1],g[i-1][p][(j&1)<<1]);
					if(p) g[i][p][j]=add(g[i][p][j],g[i-1][p-1][(j&1)<<1]);
				}
			}
		}
	}
	f[0]=1;
	m=1;
	while(m<=n) m<<=1;
	dft(f,1);
	for(int i=1;i<=K&&i<=n;i++){
		memset(t,0,sizeof(t));
		int tot=0;
		for(int p=i;p<=n;p+=K) tot++;
		t[0]=1;
		for(int p=i,pos=1;p<=n;p+=K,pos++){
			for(int j=0;j<2;j++) t[pos]=add(t[pos],g[tot][pos][j]);
		}
		dft(t,1);
		for(int p=0;p<m;p++) f[p]=f[p]*t[p]%mod;
	}
	dft(f,-1);
	ll ans=0;
	F[0]=1;
	for(int i=1;i<=n;i++) F[i]=F[i-1]*i%mod;
	for(int p=0,op=1;p<=n;p++,op=-op){
		ans=(ans+f[p]*F[n-p]*op)%mod;
	}
	printf("%lld",(ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 123904
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    if (n == m) cout << "Yes\n";
    else cout << "No\n";
}   


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <set>

using namespace std;

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

    set<int> st;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >>tmp;
        st.insert(tmp);
    }

    if(st.size() == n){
        printf("YES\n");
    }else{
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 9600
def kaibun(n):
  p=list(str(n))
  for i in range(len(p)//2):
    if p[i]!=p[len(p)-i-1]:
      return 0
  return 1
a,b=map(int,input().split())
count=0
for i in range(a,b+1):
  if kaibun(i):
    count+=1
print(count)

Measured memory_bytes: 3060
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Integer,Integer> map = new HashMap<Integer,Integer>();
        long sum = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            Integer x = map.get(a);
            if (x == null) {
                map.put(a, 1);
            } else {
                map.put(a, x.intValue() + 1);
            }
            sum += a;
        }

        int q = sc.nextInt();
        int[] b = new int[q];
        int[] c = new int[q];
        for (int i = 0; i < q; i++) {
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }

        for (int i = 0; i < q; i++) {
            Integer x = map.get(b[i]);
            if (x != null) {
                Integer y = map.get(c[i]);
                if (y == null) {
                    y = 0;
                    map.put(c[i], x.intValue());
                } else {
                    map.put(c[i], x.intValue() + y.intValue());
                }
                map.remove(b[i]);
                sum += (c[i] - b[i]) * x.intValue();
            }
            System.out.println(sum);
        }
    }
}


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

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 2 * N, mod = 1e9 + 7;

int n, k;
int h[N], e[M], ne[M], idx;
int fact[N], infact[N];
vector<int> depth[N];

void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

int qp(int a, int b)
{
	int res = 1;
	while (b)
	{
		if (b & 1) res = (LL)res * a % mod;
		a = (LL)a * a % mod;
		b >>= 1;
	}
	return res;
}

void init()
{
	memset(h, -1, sizeof h);
	fact[0] = infact[0] = 1;
	for (int i = 1; i < N; i ++ )
	{
		fact[i] = (LL)fact[i - 1] * i % mod;
		infact[i] = (LL)infact[i - 1] * qp(i, mod - 2) % mod;
	}
}

void dfs(int u, int fa, int d)
{
	int cnt = 0;
	for (int i = h[u]; ~i; i = ne[i])
	{
		int j = e[i];
		if (j == fa) continue;
		
		cnt ++ ;
		dfs(j, u, d + 1);
	}
	depth[d + 1].PB(cnt);
}

int main()
{
	init();
	
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n - 1; i ++ )
	{
		int a, b;
		scanf("%d%d", &a, &b);
		add(a, b), add(b, a);
	}
	
	dfs(1, -1, 1);
	
	int res = k;
	for (int i = 2; i <= n; i ++ )
		for (auto u : depth[i])
			if (i == 2) res = (LL)res * fact[k - 1] % mod * infact[k - 1 - u] % mod;
			else res = (LL)res * fact[k - 2] % mod * infact[k - 2 - u] % mod;
			
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 12288
#include <iostream>
#include <algorithm>
#include <string>

typedef long long ll;

#define FOR(i,a,b) for(ll i = (a);i < (b);++i)
#define REP(i,n) FOR(i,0,n)

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int main(void){

  string str1,str2;
  cin >> str1 >> str2;


  sort(str1.begin(),str1.end());
  sort(str2.begin(),str2.end(),greater<int>());

  if(str1.compare(str2) < 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
    
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(c - a) <= d || abs(b - a) <= d && abs(c - b) <= d) cout << "Yes" << endl;
    else cout << "No" << endl;
}



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

int main() {
  int N,Y;
  cin >> N;
  Y == 0;
  for (int i; i < N; i++){
    string C;
    cin >> C;
    
    if (C == "Y" && Y == 0){
      Y++;
    }
    
  }
  
  if (Y == 0){
    cout << "Three" << endl;
  }
  
  else{
    cout << "Four" << endl;
  }
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,K,x;
int a=0;
int main(){
  cin>>N>>K;
  for(int i=0;i<N;i++){
    cin>>x;
    a=a+(K-x<x?K-x:x)*2;
  }
  cout<<a<<endl;
}

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

int n, m, a, b;

int main() {
  cin >> n >> m;
  vector<int> road(n, 0);
  rep (i, m) {
    cin >> a >> b;
    road[a-1]++;
    road[b-1]++;
  }
  rep (i, n) {
    cout << road[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include<iomanip>
#include <numeric>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

typedef long long ll;

//static const ll MOD = 1000000007;

int main() {
    int A, B;
    int answer = 0;

    // input
    cin >> A >> B;

    // process
    int sum = 1;
    while (1) {
        if (sum < B) {
            sum += A - 1;
            answer++;
        } else {
            break;
        }
    }

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,N) for(int i=0; i<N; i++){    ;
int main() {
int N;
cin>>N;
vector<int>L(N);
int count=0;
int max=0;
rep(i,N)
cin>>L.at(i);
count+=L.at(i);
if(max<L.at(i)){
    max=L.at(i);
}
}
if(count-max>max){
    cout<<"Yes"<<endl;
}
else
cout<<"No"<<endl;
}

Measured memory_bytes: 256
/*
      author : Nishikawa
      created: 10.08.2020 20:05:37
*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;


int main(){
    int a;
    ll b,n;
    cin >> a >> b >> n;
    ll x;
    x = min(b-1, n);
    cout << floor(a*x/b) - a*floor(x/b) << endl;
    return 0;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
//define
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define elif else if
//vectordefine
#define vint vector<int>
#define vc vector<char>
#define vtr vector<string>
#define pb(n) push_back(n)
//queuedefine
#define qint queue<int>
#define qc queue<char>
#define qstr queue<str>
//mapdefine
#define mint map<int>
#define mc map<char>
//pairdefine
#define pint pair<int,int>
#define pis pair<int,str>
#define pic pair<int,char>
#define pci pair<char,int>
#define mod 100000007
//main
signed main(){
  int D,N,M,O,P,count=0,count2=mod,count3=0,stack=0;
  str S,T;
  double l,s;
  cin>>N;
  vint a(N);
  rep(0,N){cin>>a[i];count+=a[i];}
  cout<<count-N<<endl;
}


Measured memory_bytes: 256
H, W, K = map(int, input().split())

mod = 10 ** 9 + 7


def Fib(n):
    a, b = 0, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n - 2):
            a, b = b, a + b
        return b


dp = [[0 for j in range(W + 5)] for i in range(H + 5)]  # dp[h][k]
dp[0][1] = 1
for i in range(1, H + 1):
    for j in range(1, W + 1):
        for t in [-1, 0, 1]:
            if 1 <= j + t <= W:
                used = [0 for _ in range(W + 1)]
                for y in [j, j - 1, j + t, j + t - 1]:
                    if y >= 0:
                        used[y] = 1
                l = -(used[0] == 0)
                for x in used:
                    if x == 0:
                        l += 1
                    else:
                        break
                r = -(used[W] == 0)
                for x in used[::-1]:
                    if x == 0:
                        r += 1
                    else:
                        break
                dp[i][j] += Fib(l + 3) * Fib(r + 3) * dp[i - 1][j + t]
                dp[i][j] %= mod
print(dp[H][K])

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

int main(void){
  long long a, b, r,tmp;
  long long x;
  cin>>a>>b;
  x = a * b;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

cout<<x/b<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int ans = a+b;

		System.out.println(ans < 10 ? ans : "error");
	}
}


Measured memory_bytes: 20948
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$cnt = 0;
$tgt = $key->A[0];
$res = floor($tgt / 11);
$m = $tgt % 11;
if ($m == 0) {
  $h = 0;
}
else {
  if ($m <= 6) {
    $h = 1;
  }
  else {
    $h = 2;
  }
}
printf("%d\n",$res*2+$h);


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

int uc(int, int);
int main(void){
	int x, y;
	cin >> x >> y;
	cout << uc(x, y) << endl;
	return 0;
}

int uc(int x, int y){
	if(x%y == 0){
		return y;
	}
	else{
		return uc(y, x%y);
	}

}



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

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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

typedef long long ll;

#define MAX_N 10000
#define ORD_MONEY 1000000000000000

struct Edge {
    int to;
    ll cost;
    Edge(int t, int c)
        : to(t)
        , cost(c)
    {
    }
};
using Graph = vector<vector<int>>;
using Graph_e = vector<vector<Edge>>;

vector<int> dx = { 1, 0, -1, 0 };
vector<int> dy = { 0, 1, 0, -1 };
typedef pair<int, int> P; // first:最短距離，second:頂点番号

typedef pair<ll, ll> P_dij;

ll dijkstra(int s, int g, Graph_e G)
{
    ll d[110];
    fill(d, d + 110, INF_64);
    d[s] = 0;

    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        ll v = p.second;
        if (d[v] < p.first)
            continue;
        for (auto e : G.at(v)) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }

    if (d[g] != INF_64) {
        return d[g];
    } else {
        return -1;
    }
}

int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<int>> c(10, vector<int>(10));
    rep(i, 10)
    {
        rep(j, 10)
        {
            cin >> c.at(i).at(j);
        }
    }

    vector<vector<int>> A(H, vector<int>(W, -1));
    rep(i, H)
    {
        rep(j, W)
        {
            cin >> A.at(i).at(j);
        }
    }

    // 各数字について1に変えるまでの最短距離をワーシャルフロイドで求める
    // これにはcが使える
    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                c.at(i).at(j) = min(c.at(i).at(j), c.at(i).at(k) + c.at(k).at(j));
            }
        }
    }

    ll ans = 0;
    rep(i, H)
    {
        rep(j, W)
        {
            if (A.at(i).at(j) == -1)
                continue;
            ans += c.at(A.at(i).at(j)).at(1);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

#define MAX 100010

int N, L;
int a[MAX] = {};
int dp[MAX];

int rec(int i) {
	if (dp[i] != -1)return dp[i];
	dp[i] = L - a[i];
	int add = 0;
	if (i != 0 && a[i - 1] > a[i])add = rec(i - 1);
	if (i != N - 1 && a[i + 1] > a[i])add = max(add, rec(i + 1));
	dp[i] += add;
	return dp[i];
}

signed main() {
	memset(dp, -1, sizeof(dp));
	cin >> N >> L;
	rep(i, 0, N)cin >> a[i];
	rep(i, 0, N)rec(i);
	cout << *max_element(dp, dp + N) << endl;
	return 0;
}

Measured memory_bytes: 5216
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b; cin >> a >> b;
    int ans = a + b;
    if (ans > 9) cout << "error" << endl;
    else cout << ans << endl;
    return 0;
}

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

using namespace std;

void addedge(vector<long long int> vec[],long long int x,long long int y)
{
   vec[x].push_back(y); 
}
void DFS_util(vector<long long int> vec[],vector<long long int> &dp,vector<long long int> &visited,long long int v)
{
    visited[v]=1;
    for(long long int i=0;i<vec[v].size();i++)
    {
        if(visited[vec[v][i]]==0)
         DFS_util(vec,dp,visited,vec[v][i]);
         
        dp[v]=max(dp[v],dp[vec[v][i]]+1);
        
    }
}
long long int DFS(vector<long long int> vec[],long long int n)
{
    vector<long long int> dp(n+1,0);
    vector<long long int> visited(n+1,0);
    for(long long int i=1;i<=n;i++)
    {
        if(visited[i]==0)
        {
            DFS_util(vec,dp,visited,i);
        }
    }
    return *max_element(dp.begin(),dp.end());
}
int main()
{
  long long  int m=0;
  long long int n=0;
  cin>>n;
  cin>>m;
  long long int x=0;
  long long int y=0;
  vector<long long int> vec[n+1];
  for(int i=0;i<m;i++)
  {
      cin>>x;
      cin>>y;
      //cout<<"hii"<<endl;
      addedge(vec,x,y);
  }
  
  int longest_path=DFS(vec,n);
  cout<<longest_path<<endl;
  return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> X(M);
    REP(i,M) cin >> X[i];
    sort(X.begin(), X.end());
    vector<int> dif(M-1);
    REP(i,M-1){
        dif[i] = X[i+1] - X[i];
    }
    sort(dif.begin(), dif.end());
    ll ans = 0;
    if(N >= M) cout << ans << endl;
    else{
        REP(i,M-N) ans += dif[i];
        cout << ans << endl;
    }
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define UP(i,a,b) for(int i=(a); i<=(b); ++i)
#define DOWN(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) UP(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/

/**********************************/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    lng N, K;
    cin >> N >> K;
    cout << K*power(K-1, N-1) << endl;
}


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

const ll MOD = 1e9 + 7;

struct matrix {
    int n;
    vector<vector<ll>> M;

    matrix(vector<vector<ll>> &entries) {
        M = entries;
        n = entries[0].size();
    }

    matrix operator*(const matrix &o) {
        vector<vector<ll>> ans(n, vector<ll>(n));
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                ll entry = 0;
                for(int k = 0; k < n; k++) {
                    entry = (entry + M[i][k] * o.M[k][j]) % MOD;
                }
                ans[i][j] = entry;
            }
        }
        return matrix(ans);
    }
};

matrix mexp(matrix M, ll k) {
    if(k == 1)
        return M;
    if(k % 2)
        return M * mexp(M, k - 1);
    matrix X = mexp(M, k/2);
    return X * X;
}

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<vector<ll>> adj(n, vector<ll>(n));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            cin >> adj[i][j];
        }
    }
    matrix adjm = matrix(adj);
    adjm = mexp(adjm, k);
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            ans = (ans + adjm.M[i][j]) % MOD;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2816
eval'N,A,B='+`dd`.split*?,
A*=t=(A+B).pow(-2+M=10**9+7,M)
a=A.pow(N,M)
B*=t
b=B.pow(N,M)
[g=1,*(1...N).map{g=g*_1%M}].map{$.=($.+(g*_1).pow(M-2,M)*(a+b)*100*g*t=t*N%M)%M
N+=1
a=a*B%M
b=b*A%M}
p$.

Measured memory_bytes: 23016
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int K, X;
	cin >> K >> X;

	string output = "";

	for (int i = -K + 1; i < K; i++) {
		if (X + i >= -1000000 && X + i <= 1000000) {
			output += to_string(X + i) + " ";
		}
	}

	if (output.length() > 0) {
		output.replace(output.length() - 1, 1, "");
	}

	cout << output << endl;

	return 0;
}


Measured memory_bytes: 256
N,Y = map(int,input().split())
x,y,z=-1,-1,-1
for i in range(N+1):
    for j in range(i+1):
        if 10000 * (N-i) + 5000 * j + 1000 * (i-j) == Y:
            x,y,z=N-i,j,i-j
print(x,y,z)


Measured memory_bytes: 3060
# E
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


def SumArea(r, l, a2):
    return a2[l]-a2[r]

def judge(cand, a, k):
    m_list = [i%cand for i in a]
    m_list.sort()
    p_list = [cand-r for r in m_list]
    
    # 累積和
    b=list(range(1,30))
    m2=[0]
    p2=[0]
    for i in m_list:m2.append(m2[-1]+i)
    for i in p_list:p2.append(p2[-1]+i)
        
    length = len(a)
    for i in range(length):
        m_total  = SumArea(0, i, m2)
        p_total = SumArea(i, length, p2)
        if m_total == p_total and p_total <= k:
            return True
    return False
    
        
n,k = map(int, input().split())
a = list(map(int, input().split()))
pflag = True
# 候補はsum(a)の正約数。
total = sum(a)
length = len(a)
candidate = make_divisors(total)
candidate.sort(reverse = True)
for cand in candidate:
    if judge(cand, a, k):
        print(cand)
        pflag = False
        break
if pflag:
    print(1)

Measured memory_bytes: 43100
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<double,double> P;
typedef complex<double> CP;
typedef long long ll;


vector <P> a;
char t;
int num[110]={0};
/*
bool operator<(P a,P b){
	return (a.S<b.S);
}
*/
int main(){
	double x,y;
	while(cin>>x>>t>>y,!(x==0&&y==0)){
		P tmp;
		tmp.F=y; tmp.S=x;
		a.PB(tmp);
	}
	sort(ALL(a));
	//rep(i,a.size()) cout<<a[i].F<<" "<<a[i].S<<endl;
	int m=a[a.size()-1].F;
	int co=1;
	rep(i,a.size()){
		if(a[a.size()-1-i].F==m){
			num[a.size()-1-i]=co;
			//cout<<a.size()-1-i<<endl;
		}
		else{
			m=a[a.size()-1-i].F;
			//cout<<m<<endl;
			num[a.size()-1-i]=++co;
		}
	}
	//rep(i,a.size()) cout<<a[i].F<<" "<<a[i].S<<" "<<num[i]<<endl;
	int b;
	while(cin>>b){
		rep(i,a.size()){
			if(a[i].S==b){
				cout<<num[i]<<endl;
				break;
			}
		}
	}
	
	
	return 0;
}
	

Measured memory_bytes: 1236
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;

int main() {
	ll n,l;
	cin >> n >> l;
	ll res = 0;
	if (l > 0) {
		for (ll i = 2; i < n + 1; i++)res += l + i - 1;
	}
	else if (l + n - 1 < 0) {
		for (ll i = 1; i < n; i++)res += l + i - 1;
	}
	else {
		for (ll i = 1; i < n + 1; i++)res += l + i - 1;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]
delJ = []
for j in range(W):
    judge = True
    for i in range(H):
        if A[i][j] == "#":
            judge = False
            break
    if judge:
        delJ.append(j)

output = []
for i in range(H):
    if "#" in A[i]:
        B = ""
        for j in range(W):
            if j not in delJ:
                B += str(A[i][j])
        output.append(B)

for i in output:
    print(i)

Measured memory_bytes: 3188
#include <stdio.h>
//0,1,/b
//jika 0 taro di kanan
//jika 1 taro di kanan
//jika /b kalo ksoog gpp,kalo ada remove


int main(){
char s[15]; // untuk cek 
scanf("%s",s);
int idx = 0; //diset array ke 0 dulu
char s2[15]; //untuk nampung array baru
	for(int i=0;s[i] != '\0';i++){
		if(s[i] == '0'){
			s2[idx] = '0'; //tambah 0 di s2[0] nanti tmbh idx seiring loop
			idx++;  //kalau sudah  nambah index array
		}
		else if (s[i] == '1'){
			s2[idx] = '1';
			idx++;
		}
		else if (s[i] == 'B'){
			if(idx != 0){ //kalau indexnya tidak kosong maka
				idx--;	//mundur ke  index sblmnya
				s2[idx] = '\0';  //hapus index sblmnya			
			}
		}
	}
	printf("%s",s2);
	return 0;
}

Measured memory_bytes: 2128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> pipii;
typedef long long ll;
typedef pair<ll,ll> pll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
const ll MOD=1e9+7;
struct edge{
    int to;
    int cost;
};
int main(){
    int N;cin>>N;
    vector<int> A(N+1),B(N);
    for(int i=0;i<=N;++i) cin>>A[i];
    for(int i=0;i<N;++i) cin>>B[i];
    ll ans=0;
    for(int i=0;i<N;++i){
        int num=min(A[i],B[i]);
        ans+=num;
        A[i]-=num;
        B[i]-=num;
        num=min(A[i+1],B[i]);
        ans+=num;
        A[i+1]-=num;
        B[i]-=num;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4000
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	int n,d;
	cin >> n >> d;
	cout << (n+2*d+1-1)/(2*d+1) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int[] compare = new int[n];
		for(int i = 0;i<n;i++) {
			int temp = sc.nextInt();
			arr[i]=temp;
			compare[i] = temp;
		}
		int count = 0;
		Arrays.sort(compare);
		for(int i = 0;i<n;i++) {
			if(arr[i]!=compare[i])count++;
		}
		System.out.println(count>2?"NO":"YES");

	}

}


Measured memory_bytes: 20820
import Control.Applicative
import Control.Monad
import Data.Array
import Data.Array.ST
import Data.Char
import Data.List
import qualified Data.Map as M
import qualified Data.Set as S
import Text.Printf

readInts :: IO [Int]
readInts = map read . words <$> getLine

main :: IO ()
main = do
  w <- getLine
  s <- getContents
  print $ count w s

count :: String -> String -> Int
count w = length . filter (== (map toLower w)) . words . map toLower



Measured memory_bytes: 3644
#include <iostream>
#include <stdlib.h>

using namespace std;

int n;
int a[105];

int main(void)
{
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	int sum = 0;
	for(int i = 0; i < n; i++) sum += a[i];
	
	int ans = 1e9, ans_i;
	for(int i = 0; i < n; i++){
		if(abs(a[i]*n - sum) < ans){
			ans = abs(a[i]*n-sum);
			ans_i = i;
		}
	}
	cout << ans_i << endl;
	
	return 0;
}

Measured memory_bytes: 888