akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
inline int min(int x,int y,int z){return min(x,min(y,z));}
inline int max(int x,int y,int z){return max(x,max(y,z));}
inline int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
inline int add(int x,int y,int z){return add(add(x,y),z);}
inline int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
inline int mul(int x,int y){return 1LL*x*y%mod;}
inline int mul(int x,int y,int z){return mul(mul(x,y),z);}
#define N 605
int n,d1,d2;
int a[N][N],b[N][N];
int t[N][N],cnt[N];
void solve1()
{
	int d=d1,m=n,cnt=1;
	while(d%4==0) d/=4,m=(m+1)/2,cnt*=2;
	if(d%4==1)
	{
		for(int i=1;i<=m;i++)
		{
			for(int j=1;j<=m;j++) t[i][j]=(i+j)&1;
		}
	}
	else
	{
		for(int i=1;i<=m;i++)
		{
			for(int j=1;j<=m;j++) t[i][j]=i&1;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++) a[i][j]=t[(i+cnt-1)/cnt][(j+cnt-1)/cnt];
	}
//	for(int i=1;i<=m;i++)
//	{
//		for(int j=1;j<=m;j++) printf("%d ",t[i][j]);
//		cout<<"\n";
//	}
//	for(int i=1;i<=n;i++)
//	{
//		for(int j=1;j<=n;j++) printf("%d ",a[i][j]);
//		cout<<"\n";
//	}
}
void solve2()
{
	int d=d2,m=n,cnt=1;
	while(d%4==0) d/=4,m=(m+1)/2,cnt*=2;
	if(d%4==1)
	{
		for(int i=1;i<=m;i++)
		{
			for(int j=1;j<=m;j++) t[i][j]=(i+j)&1;
		}
	}
	else
	{
		for(int i=1;i<=m;i++)
		{
			for(int j=1;j<=m;j++) t[i][j]=i&1;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++) b[i][j]=t[(i+cnt-1)/cnt][(j+cnt-1)/cnt];
	}
//	for(int i=1;i<=m;i++)
//	{
//		for(int j=1;j<=m;j++) printf("%d ",t[i][j]);
//		cout<<"\n";
//	}
//	for(int i=1;i<=n;i++)
//	{
//		for(int j=1;j<=n;j++) printf("%d ",b[i][j]);
//		cout<<"\n";
//	}
}
signed main()
{
	cin>>n>>d1>>d2; n*=2;
	solve1(),solve2();
//	for(int i=1;i<=n;i++)
//	{
//		for(int j=1;j<=n;j++) printf("%d ",a[i][j]);
//		cout<<"\n";
//	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			int R=a[i][j]*2+b[i][j];
			cnt[R]++;
		}
	}
	int ans=0;
	for(int i=0;i<=3;i++) if(cnt[i]>cnt[ans]) ans=i;
	int _cnt=n*n/4;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			int R=a[i][j]*2+b[i][j];
			if(R==ans)
			{
				printf("%d %d\n",i-1,j-1);
				_cnt--;
				if(!_cnt) return 0;
			}
		}
	}
	assert(0);
	return 0;
}




Measured memory_bytes: 5248
a,b,q=map(int,input().split())
s=[]
t=[]
for i in range(a):
    s.append(int(input()))
for i in range(b):
    t.append(int(input()))
s.append(10**11)
t.append(10**11)

def bis(x,q):
    l=0
    r=len(q)-1
    while r-l>1:
        mid=(r+l)//2
        if q[mid]>=x:
            r=mid
        else:
            l=mid
    return q[l],q[r]

for i in range(q):
    x=int(input())
    ss=bis(x,s)
    tt=bis(x,t)
    ans=[]
    for i in ss:
        for j in tt:
            ans.append(abs(x-i)+abs(i-j))
            ans.append(abs(x-j)+abs(i-j))
    print(min(ans))

Measured memory_bytes: 74976
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int X[100];
int Y[100];
int H[100];
int main(){
  int i, j, k, m, x;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(X[Lj4PdHRW]);
      rd(Y[Lj4PdHRW]);
      rd(H[Lj4PdHRW]);
    }
  }
  for(i=0;i<101;i++){
    for(j=0;j<101;j++){
      k = -1073709056;
      for(x=0;x<N;x++){
        if(H[x]>0){
          m = H[x] + abs(i-X[x]) + abs(j-Y[x]);
          if(k==-1073709056){
            k = m;
          }
          if(k!=m){
            break;
          }
        }
      }
      if(x < N){
        continue;
      }
      for(x=0;x<N;x++){
        if(H[x]==0){
          if(k > abs(i-X[x]) + abs(j-Y[x])){
            break;
          }
        }
      }
      if(x < N){
        continue;
      }
      wt_L(i);
      wt_L(' ');
      wt_L(j);
      wt_L(' ');
      wt_L(k);
      wt_L('\n');
      return 0;
    }
  }
  return 0;
}
// cLay varsion 20190714-1

// --- original code ---
// int N, X[100], Y[100], H[100];
// {
//   int i, j, k, m, x;
//   rd(N,(X,Y,H)(N));
// 
//   rep(i,101) rep(j,101){
//     k = -int_inf;
//     rep(x,N) if(H[x]>0){
//       m = H[x] + abs(i-X[x]) + abs(j-Y[x]);
//       if(k==-int_inf) k = m;
//       if(k!=m) break;
//     }
//     if(x < N) continue;
//     
//     rep(x,N) if(H[x]==0){
//       if(k > abs(i-X[x]) + abs(j-Y[x])) break;
//     }
//     if(x < N) continue;
// 
//     wt(i,j,k);
//     return 0;
//   }
// }


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

using namespace std;

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

int main(){
    int i;
    //入力
    long n;
    cin>>n;
    string s;
    cin>>s;
    //処理
    long count=0;
    for(long i=0;i<n;i++){
        if(!(s[i]==s[i+1]))count++;
    }
    //出力
    cout<<count<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s;
    int num;
    cin >> num;
    int cr=0,cb=0;

        cin >> s;

    for(int i=0; i<num; i++){
        if(s[i] == 'B') cb++;
        if(s[i] == 'R') cr++;
    }


    if(cr > cb) cout << "Yes\n";
    else    cout << "No\n";
}

Measured memory_bytes: 256
Module Module1

    Sub Main()
        Dim number As String = Console.ReadLine()
        Dim N As Integer = CInt(number)

        Dim Ls() As String = Console.ReadLine.Split(" ")
        Dim L(199) As Integer
        For i As Integer = 0 To 2 * N - 1
            L(i) = Ls(i)
        Next

        Dim temp As Integer
        For i As Integer = 0 To 2 * N - 1
            For j As Integer = i + 1 To 2 * N - 1
                If L(i) > L(j) Then
                    temp = L(i)
                    L(i) = L(j)
                    L(j) = temp
                End If
            Next
        Next
        Dim sum As Integer = 0
        For i As Integer = 0 To 2 * N - 1 Step 2
            sum = sum + L(i)
        Next

        Console.WriteLine(CStr(sum))
    End Sub

End Module


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-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 main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll A,B,C;
    cin >> A >>B >>C;
    ll K;
    cin >> K;
    ll ans = 0;
    ll temp = min(K,A);
    ans += temp;
    K -= temp;
    temp = min(K,B);
    K -= temp;
    temp = min(K,C);
    ans -= temp;
    cout << ans << enld;
    return 0;
}


Measured memory_bytes: 3652
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int n = sc.nextInt();
			// L
			sc.nextInt();
			sc.nextLine();

			List<String> list = new ArrayList<String>();
			for (int i = 0; i < n; i++) {
				list.add(sc.nextLine());
			}
			Collections.sort(list);

			for (int i = 0; i < n; i++) {
				System.out.print(list.get(i));
			}
			System.out.println();

		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std ;
int const maxn=200;
int ar[maxn];
int main()
{
	string s;
	bool shargh=0,shomal=0,gharb=0,jonob=0;
	cin >> s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i] == 'E')
			shargh=1;
		else if(s[i] == 'W')
			gharb=1;
		else if(s[i] == 'N')
			jonob=1;
		else if(s[i] == 'S')
			shomal=1;
	}
	if(shargh==1 && gharb==1)
	{
		if(shomal==1 && jonob==1)
			cout << "Yes";
		else if(shomal==0 && jonob==0)
			cout << "Yes";
		else cout << "No";
	}
	else if(shomal==1 && jonob==1)
	{
		if(shargh==1 && gharb==1)
			cout << "Yes";
		else if(shargh==0 && gharb==0)
			cout << "Yes";
		else cout << "No";
	}
	else if(shargh==0 && shomal==0 && gharb==0 && jonob==0)
		cout << "Yes";
	else
		cout << "No";
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 512345
char s[N];

int main(){
	scanf("%s", s);
	int n = strlen(s);
	ll ans = 0;

	{
		int i = 0;
		while(i < n){
			int j = i;
			while(s[j] == '<') j++;
			int k = j;
			while(s[k] == '>') k++;

			DEBUG("%d, %d, %d\n", i, j, k);
			ll p = max(k-j, j-i), q = min(k-j, j-i);
			DEBUG(" => %lld %lld\n", p, q);
			ans += p * (p+1) / 2;
			ans += q * (q-1) / 2;

			i = k;
		}
	}

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


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N;
  cin >> N;
  map<string, ll> m;
  rep(i, N) {
    string s;
    cin >> s;
    m[s]++;
  }

  cout << "AC x " << m["AC"] << endl;
  cout << "WA x " << m["WA"] << endl;
  cout << "TLE x " << m["TLE"] << endl;
  cout << "RE x " << m["RE"] << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int n; cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  rep(i, n) cin >> s[i] >> t[i];
  string x; cin >> x;
  int ans = 0;
  rep(i, n) {
    ans += t[i];
    if(s[i] == x) break;
  }
  cout << (int)accumulate(ALL(t), 0) - ans << endl;
}

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

const int inf_= 1e5+5;
vector<vector<int>> edges(inf_);
int dist[inf_];
int degree[inf_] = {0};
bool visited[inf_] = {false};

void dfs(int a)
{
	visited[a] = true;
	for(auto b: edges[a])
	{
		dist[b] = max(dist[b],dist[a]+1);
		--degree[b];
		if(degree[b] == 0)
			dfs(b);
	}
}



int main()
{
	int n,m;
	cin>>n>>m;
	int a,b;
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		edges[a].push_back(b);
		degree[b]++;
		
	}

	for(int i=1;i<=n;i++)
	{
		if(!visited[i] && degree[i] == 0)
			dfs(i);
	}

	int ans = 0;
	for(int i=0;i<inf_;i++)
	{
		ans = max(ans, dist[i]);
	}
	cout<<ans<<" ";

}

Measured memory_bytes: 9728
import java.util.Scanner;
class Main{
  public static int[][] inkS(int x, int y, int paper[][]){
    paper[x+2][y+1] +=1;
    paper[x+1][y+2] +=1;
    paper[x+2][y+2] +=1;
    paper[x+3][y+2] +=1;
    paper[x+2][y+3] +=1;
    return paper;
  }

  public static int[][] inkM(int x, int y, int paper[][]){
    paper = inkS(x, y, paper);
    paper[x+1][y+1] +=1;
    paper[x+3][y+1] +=1;
    paper[x+1][y+3] +=1;
    paper[x+3][y+3] +=1;
    return paper;
  }

  public static int[][] inkL(int x, int y, int paper[][]){
    paper = inkM(x, y, paper);
    paper[x+2][y  ] +=1;
    paper[x  ][y+2] +=1;
    paper[x+4][y+2] +=1;
    paper[x+2][y+4] +=1;
    return paper;
  }

  public static int[][] ink(int x, int y, int size, int paper[][]){
    switch(size){
      case 1: paper = inkS(x, y, paper);
        break;
      case 2: paper = inkM(x, y, paper);
        break;
      case 3: paper = inkL(x, y, paper);
        break;
    }
    return paper;
  }

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[][] paper = new int[14][14];
    while (sc.hasNext()) {
      String str = sc.next();
      String[] strArr = str.split(",");
      int x = Integer.parseInt(strArr[0]);
      int y = Integer.parseInt(strArr[1]);
      int size = Integer.parseInt(strArr[2]);
      paper = ink(x, y, size, paper);
    }
    int max = 0;
    int white = 0;
    for (int i = 2; i < 12; i++) {
      for (int j = 2; j < 12; j++) {
        if (paper[i][j] == 0) {
          white++;
        }
        if (paper[i][j] > max) {
          max = paper[i][j];
        }
      }
    }
    System.out.println(white);
    System.out.println(max);
  }
}

Measured memory_bytes: 11000
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                bool oper(const ll& fst, const ll& snd){
                    return abs(fst) > abs(snd);
                }
                void solve(){
                    ll n, k;
                    cin>>n>>k;
                    vector<ll> pos, neg, vec(n);
                    for(int i = 0 ; i < n; i++){
                        ll num;
                        cin>>num;
                        vec[i] = num;
                        if(num >= 0)
                            pos.push_back(num);
                        else
                            neg.push_back(num);
                    }
                    ll ans = 1, temp = k;
                    sort(pos.begin(), pos.end(), oper);
                    sort(neg.begin(), neg.end(), oper);
                    ll posidx = 0, negidx = 0;
                    if(k%2 && posidx < pos.size()){
                        k--;
                        ans = pos[0];
                        posidx++;
                    }
                    while(k > 0){   // odd number of positive and even number of negative
                        ll fst = -1;
                        ll snd = -1;
                        if(posidx +1 < pos.size())
                            fst = pos[posidx]*pos[posidx+1];
                        if(negidx+1 < neg.size())
                            snd = neg[negidx]*neg[negidx+1];
                        // cout<<snd;

                        if(snd == -1 && fst == -1)
                            break;
                        if(fst >= snd){
                            ans *= (fst%mod);
                            posidx += 2;
                        }
                        else{
                            ans *= (snd%mod);
                            negidx += 2;
                        }
                        ans %= mod;
                        ans += mod;
                        ans %= mod;
                        k -= 2;
                    }
                    if(k == 0){
                        cout<<ans;
                        // cout<<ans;
                        return ;
                    }
                    sort(vec.begin(), vec.end(), oper);
                    reverse(vec.begin(), vec.end());
                    ans = 1;
                    for(int i = 0; i < temp; i++)
                        ans = ans*vec[i], ans = (ans+mod)%mod;
                    ans = (ans+mod)%mod;
                    cout<<ans;

                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //cout<<"Case #"<<i<<": ";
                                solve();
                         }
        return 0; 
}         
 
 

Measured memory_bytes: 6900
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>

using namespace std;
using ll = long long int; 

void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;

    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}


ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

ll keta(ll a){
  ll ans = 1;
  while(1){
    if(a/10 > 0){
      ans++;
      a = a/10;
    }
    if(a<10) break;
  }
  return ans;
}

const int MAX = 50;
const int MOD = 1000000007;

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

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

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

int main(void){

   string S, T;
   cin>>S>>T;

   map<char, char> m;
   map<char, char> mm;

   for(int i=0;i<S.size();i++){
     auto it = m.find(T[i]);
     auto itt = mm.find(S[i]);
     if(it==m.end() && itt == mm.end()){
       m[T[i]] = S[i];
       mm[S[i]] = T[i];
     }else{
       if(it -> second != S[i] || itt->second != T[i]){
         std::cout<<"No"<<std::endl;
         return 0;
       }
     }
   }
   std:cout<<"Yes"<<std::endl;



}

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

#define fi first
#define se second

const int N = 100100;

using namespace std;

int n;
int a[N];

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        cin >> n;
        for(int i = 1; i <= n; i++){
                cin >> a[i];
        }
        sort(a + 1, a + n + 1);
        vector < pair < int, int > >  res;

        int A = a[1], B = a[n];
        for(int i = 2; i < n; i++){
                if(a[i] < 0){
                        res.push_back({B, a[i]});
                        B = B - a[i];
                } else{
                        res.push_back({A, a[i]});
                        A = A - a[i];;
                }
        }
        res.push_back({B, A});
        cout << B - A << "\n";
        for(auto p: res){
                cout << p.fi << " " << p.se << "\n";
        }
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    int n;
    cin >> n;
    int num[10][10];
    REP(i, 10) REP(j, 10) num[i][j] = 0;

    REP(i, n+1) {
        int tmp = i;
        while(tmp >= 10) {
            tmp /= 10;
        }
        int shita = i % 10;
        num[tmp][shita]++;
    }
    int ans = 0;

    REPN(i, 1, 10) REPN(j, 1, 10) {
        ans += num[i][j] * num[j][i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
use std::io::{BufRead, BufWriter, Write};

fn main() {
    let stdin = std::io::stdin();
    let stdout = std::io::stdout();
    solve(&mut stdin.lock(), &mut BufWriter::new(stdout.lock()));
}

fn solve<R: BufRead, W: Write>(stdin: &mut R, stdout: &mut BufWriter<W>) {
    let (x, y): (u32, u32) = stdin.gets().split(' ').values();
    let mut ans = match x {
        1 => 300000,
        2 => 200000,
        3 => 100000,
        _ => 0,
    };
    ans += match y {
        1 => 300000,
        2 => 200000,
        3 => 100000,
        _ => 0,
    };
    if x == 1 && y == 1 {
        ans += 400000;
    }
    writeln!(stdout, "{}", ans).unwrap();
}

trait Gets { fn gets(&mut self) -> String; }
impl<T: std::io::BufRead> Gets for T {
    fn gets(&mut self) -> String { self.lines().next().unwrap().unwrap() } }

trait Values<T> { fn values(&mut self) -> T; }
impl<'a, I, T1, T2> Values<(T1, T2)> for I
    where I: Iterator<Item=&'a str>,
          T1: std::str::FromStr, T1::Err: std::fmt::Debug,
          T2: std::str::FromStr, T2::Err: std::fmt::Debug {
    fn values(&mut self) -> (T1, T2) {
        (self.next().unwrap().parse().unwrap(),
         self.next().unwrap().parse().unwrap())
    }
}


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

int get_score(int x, int y) {
  return std::abs(x - y);
}

int main(void) {
  int N, Z, W;
  std::cin >> N >> Z >> W;
  std::vector<int> deck(N);
  for (int i = 0; i < N; i++) {
    std::cin >> deck[N - i - 1];
  }
  
  int score = (W - deck[0]);
  if(score < 0) score *= -1;

  if(N > 1) score = std::max(score , get_score(deck[0], deck[1]));


  std::cout << score << std::endl;
  /*
  std::reverse(deck.begin(), deck.end());

  int X = Z;
  int Y = W;
  int score = get_score(X, Y);

  int turn = 0; //0 == X turn, 1 == Y turn

  int size = deck.size();
  int target_id = 0;
  while(size > 1) {
    for(int i = 0; i < size; i++) {
      int card = deck[i];
      if(turn == 0) {
        //X turn
        
      }
    }
    }*/
  return 0;
}


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

using namespace std;
using ll = long long int;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(auto &e: a) cin >> e;

    auto sgn = [](ll x) {
        if(!x) return x;
        return x / abs(x);
    };

    adjacent_difference(a.begin(), a.end(), a.begin());

    ll ps = 0, r = 1;
    for(ll i=1; i<n; i++) {
        ll s = sgn(a[i]);
        if(!s) continue;
        if(!ps) ps = s;
        if(ps == s) continue;
        ps = 0;
        r++;
    }
    cout << r << endl;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

signed main()
{
	int N;
	cin >> N;
	int n = N;
	int s = 0;
	while (n > 0)
	{
		s += n % 10;
		n /= 10;
	}
	YesNo(N % s == 0);
}



Measured memory_bytes: 3092
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: String = read();
    let v: Vec<char> = n.chars().collect();
    for i in 0..3 {
        if v[i] == '7' {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 2112
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 Q = sc.nextInt();

		String S = sc.next();

		int[] a = new int[N];

		Arrays.fill(a, 0);

		for(int i=1;i<N;i++) {

			if(S.charAt(i-1)=='A' && S.charAt(i)=='C') {

				a[i] = a[i-1] + 1;

			}else {

				a[i] = a[i-1];
			}

		}

		for(int i=0;i<Q;i++) {

			int l = sc.nextInt();

			int r = sc.nextInt();

			System.out.println(a[r-1]-a[l-1]);
		}

	}

}


Measured memory_bytes: 67068
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  char s[100001];
  scanf("%s",s);
  int n=0;
  while(s[n]!='\0') n++;
  int cnt[3];
  cnt[0]=cnt[1]=cnt[2]=0;
  int i;
  for(i=0;i<n;i++){
    cnt[s[i]-'a']++;
  }
  int min=MIN(cnt[0],MIN(cnt[1],cnt[2]));
  int max=MAX(cnt[0],MAX(cnt[1],cnt[2]));
  printf("%s\n",max-min<=1?"YES":"NO");
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 256
n = int(input())
ans = 0
s = []
ryotan = 0
atama = 0
oshiri = 0
for _ in range(n):
    _s = input()
    if _s[0] == "B" and _s[-1] == "A":
        ryotan += 1
    elif _s[0] == "B":
        atama += 1
    elif _s[-1] == "A":
        oshiri += 1
    A_flag = 0
    for c in _s:
        if c == "A" and A_flag == 0:
            A_flag = 1
        elif A_flag:
            if c == "B":
                ans += 1
                A_flag = 0
            elif c == "A":
                continue
            else:
                A_flag = 0
# print(ans)
# print(ryotan, atama, oshiri)
if ryotan > 1:
    ans += ryotan - 1
if ryotan > 0:
    if atama > 0:
        ans += 1
        atama -= 1
    if oshiri > 0:
        ans += 1
        oshiri -= 1
ans += min(atama, oshiri)
print(ans)

Measured memory_bytes: 9052
/* next_permutation()によって起こりうる全ての状態を生成できる。
始点が1 かつ全ての頂点を1度だけ訪れるようなパスは1 から始まる順列に対応しているので、
それぞれ条件を満たすかどうか判定する。
*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int g[10][10];

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

    int num[n];
    int ans = 0;
    for (int i = 0; i < n; i++) num[i] = i;
    do{
        if (num[0] != 0) break;
        bool possible = true;
        for (int i = 0; i < n - 1; i++){
            if (!g[num[i]][num[i + 1]]){
                possible = false;
                break;
            }
        }
        if (possible) ans++;
    }while(next_permutation(num, num + n));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

public class Sample26
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var x = int.Parse(line[1]);
            
            //バリデーション

            //終了処理
            if(n == 0 && x == 0)break;
            var count = 0;
            //処理
            for(int i = 1; i <= n; i++)
                for (int j = i + 1; j <= n; j++)
                {
                    var w = x - i - j;
                    if (w > j && w <= n) count++;
                }
            Console.WriteLine(count);
        }
    }
}


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

namespace AtCoder
{
	class Program
	{
		public static void Main()
		{
			var intArray = IO.ReadIntArray();
			var tastes = Enumerable.Range(1 , intArray[0]).Select(iIndex =>
			{
				return new
				{
					Index = iIndex,
					Taste = intArray[1] + iIndex - 1
				};
			})
			.OrderBy(iTaste => Math.Abs(iTaste.Taste))
			.ToList();
			tastes.RemoveAt(0);
			IO.Write(tastes.Sum(iTaste => iTaste.Taste));
		}
	}

	public static class IO
	{
		public static string   Read()							   { return Console.ReadLine(); }
		public static string[] ReadArray(char iSplitter = ' ')	   { return Read().Split(iSplitter); }
		public static int	   ReadInt()						   { return int.Parse(Read()); }
		public static int[]	   ReadIntArray(char iSplitter = ' ')  { return ReadArray().Select(iText => int.Parse(iText)).ToArray(); }
		public static long	   ReadLong()						   { return int.Parse(Read()); }
		public static long[]   ReadLongArray(char iSplitter = ' ') { return ReadArray().Select(iText => long.Parse(iText)).ToArray(); }
		public static char[]   ReadCharArray()					   { return Read().ToCharArray(); }

		public static void Write(string iValue)			  { Console.WriteLine(iValue); }
		public static void Write(int iValue)			  { Console.WriteLine(iValue); }
		public static void Write(IEnumerable<int> iValue) { Console.WriteLine(string.Join(" " , iValue)); }
		public static void Write(long iValue)			  { Console.WriteLine(iValue); }
		public static void Write(decimal iValue)		  { Console.WriteLine(iValue); }
		public static void Write(bool iValue)			  { Console.WriteLine(iValue ? "Yes" : "No"); }
	}

	public static class Util
	{
		public static long Gcd(long i0 , long i1) { return (i0 > i1) ? _Gcd(i0 , i1) : _Gcd(i0 , i1); }
		public static long Lcm(long i0 , long i1) { return (i0 * i1) / Gcd(i0 , i1); }
		public static long ModPow(long iBaseNumber , long iPow , long iModNumber)
		{
			var num = 1L;
			while(iPow != 0)
			{
				if((iPow & 0x1) != 0)
				{
					num = (num * iBaseNumber) % iModNumber;
				}
				iBaseNumber = (iBaseNumber * iBaseNumber) % iModNumber;
				iPow >>= 1;
			}
			return num;
		}

		private static long _Gcd(long i0 , long i1)	{ return (i1 == 0) ? i0 : _Gcd(i1 , i0 % i1); }
	}
}


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

namespace ABC157 {
    public class C {
        static void Main(string[] args) {
            var first = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var digit = first[0];
            var decideds = new int?[digit];


            var conds = new List<Tuple<int, int>>();
            for(int i = 0; i < first[1]; i++) {
                var accepted = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                var digitIdx = accepted[0] - 1;
                var digitNumber = accepted[1];

                if(decideds[digitIdx].HasValue && decideds[digitIdx].Value!= digitNumber) {
                    Console.WriteLine("-1");
                    return;
                }
                decideds[digitIdx] = digitNumber;
            }

            bool isAllowZero = (digit==1);
            int answer = 0;
            foreach(var decided in decideds) {
                if(!isAllowZero){
                    if (decided.HasValue && decided.Value == 0) {
                        Console.WriteLine("-1");
                        return;
                    }
                    answer = answer * 10 + (decided ?? 1);
                    isAllowZero = true;
                } else {
                    answer = answer * 10 + (decided ?? 0);
                }
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
#define all(obj) obj.begin(), obj.end()
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

using namespace std;

typedef unsigned long long ull;
typedef int long long ll;
constexpr ll bigNum = 1000000007;

signed main()
{
    fast;
    int n = 0;
    cin >> n;
    vector<int> a(n);
    REP(i, n)
    cin >> a[i];

    vector<int> b(n);
    REP(i, n)
    cin >> b[i];

    vector<int> c(n - 1);
    REP(i, n - 1)
    cin >> c[i];

    int ans = 0;

    for (int i = 0; i < n - 1; i++)
    {
        int tmp = a[i] - 1;
        if (a[i] + 1 == a[i + 1])
        {
            ans += (b[tmp] + c[tmp]);
        }
        else
        {
            ans += b[tmp];
        }
    }
    ans += b[a[n - 1] - 1];

    cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<map>
using namespace std;

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

	string str;
	map<string, int> mp;
	for(int i=0; i<N; i++){
		cin >> str;
		mp[str]++;
	}

	int M;
	cin >> M;

	for(int i=0; i<M; i++){
		cin >> str;
		mp[str]--;
	}

	int ret = 0;
	for(auto it=mp.begin(); it!=mp.end(); it++)
		ret = max(ret, it->second);

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

cnt1 = 0
for i in range(8):
  v1 = i * 400
  v2 = (i + 1) * 400 - 1
  for j in range(N):
    if v1 <= A[j] and A[j] <= v2:
      cnt1 += 1
      break

cnt2 = 0
for i in range(N):
  if A[i] >= 3200:
    cnt2 += 1

if cnt1 == 0:
  print(1, cnt2)
else:
  print(cnt1, cnt1 + cnt2)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
  long long int n,sum=0,ans=0,i;
  cin>>n;
  long long int a[n];
  for(i=0;i<n;i++)
  {
    cin>>a[i];
    sum=(sum+a[i]);
  }
  for(i=0;i<n;i++)
  {
      sum=(sum-a[i]);
    ans=(ans+((sum)%1000000007*a[i])%1000000007)%1000000007;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 5144
H, N = map(int, input().split())
inf = 10 ** 9
dp = [inf for i in range(H + 1)]
dp[0] = 0

for i in range(N):
    a, b = map(int, input().split())
    for j in range(H):
        nj = min(j + a, H)
        dp[nj] = min(dp[nj], dp[j] + b)

print(dp[H])


Measured memory_bytes: 43868
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

string lcs(string &s1, string &s2){
    int n = s1.size(), m = s2.size();
    if(n == 0 or m == 0)
        return 0;
    int dp[n+1][m+1];
    int prev[n+1][m+1][2];
    for(int i=0; i<=n; i++){
        dp[i][0] = 0;
        prev[i][0][0] = -1;
    }

    for(int j=0; j<=m; j++){
        dp[0][j] = 0;
        prev[0][j][0] = -1;
    }

    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++){
            if(s1[i-1] == s2[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
                prev[i][j][0] = i-1;
                prev[i][j][1] = j-1;
            }
            else{
                if(dp[i-1][j] > dp[i][j-1]){
                    dp[i][j] = dp[i-1][j];
                    prev[i][j][0] = prev[i-1][j][0];
                    prev[i][j][1] = prev[i-1][j][1];
                }
                else{
                    dp[i][j] = dp[i][j-1];
                    prev[i][j][0] = prev[i][j-1][0];
                    prev[i][j][1] = prev[i][j-1][1];
                }
            }
        }

    string ans;
    int i = prev[n][m][0], j = prev[n][m][1];
    while(i != -1){
        if(i == -1)
            break;
        ans.push_back(s1[i]);
        int newI = prev[i][j][0];
        int newJ = prev[i][j][1];
        i = newI;
        j = newJ;
    }
    reverse(ans.begin(), ans.end());
    return ans;
}

int main()
{
 string s, t;
 cin>>s>>t;
 string ans = lcs(s, t);
 cout<<ans;
 return 0;
}



Measured memory_bytes: 109148
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	long long k;
	string s;
	cin>>k>>s;
	if(s.length()<=k) cout<<s;
	else{
		for(int i=0;i<=k-1;i++) cout<<s[i];
		cout<<"...";
	}
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define per(i,x,y) for (int i=(x); i>=(y); i--)
#define ll long long
#define ull unsigned long long
#define ld long double
#define inf 1000000000
using namespace std;
#define N 1000005
#define mod 1000000007
int n,fac[N],inv[N],f[N],ans;
int ksm(int x,int p){
	int ret=1;
	for (; p; p>>=1,x=(ll)x*x%mod) if (p&1) ret=(ll)ret*x%mod;
	return ret;
}
int getinv(int x){ return ksm(x,mod-2); }
int C(int n,int m){ return (ll)fac[n]*inv[n-m]%mod*inv[m]%mod; }
int main(){
	scanf("%d",&n);
	fac[0]=1; rep (i,1,n) fac[i]=(ll)fac[i-1]*i%mod;
	inv[n]=getinv(fac[n]); per (i,n-1,0) inv[i]=(ll)inv[i+1]*(i+1)%mod;
	rep (i,(n+1)/2,n-1){
		f[i]=(ll)fac[i]*fac[n-1-i]%mod*C(2*i-n+(n-2-(2*i-n))/2,2*i-n)%mod;
		ans=(ans+(ll)(f[i]+mod-f[i-1])*i%mod)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9984
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}

int gcd(int x, int y) { return y ? gcd(y, x%y) : x; }
int lcm(int x, int y) { return x/gcd(x, y)*y; }
int mod_pow(int x, int y) { int res = 1; while (y > 0) { if (y & 1) { res = res * x % MOD; } x = x * x % MOD; y >>= 1; } return res; }
int comb(int n, int k) { k = min(k, n - k); int nnn = 1; for (int i = n - k + 1; i <= n; i++) { nnn *= i; nnn %= MOD; } int kkk = 1; for (int i = 1; i <= k; i++) { kkk *= i; kkk %= MOD; } return (nnn * mod_pow(kkk, MOD - 2)) % MOD; }
int to_int(string s) { int n = s.size(); int ans = 0; for (int i = 0; i < n; i++) { ans = ((ans * 10) + (s[i] - '0')) % MOD; } return ans; }
bool is_prime(int n) { for(int i = 2; i*i <= n; i++) { if (n % i == 0) return false; } return n != 1; }
int extgcd(int a, int b, int& x, int& y) { // ax+by = gcd(a,b) >> gcd(a, b)
    int d = a;
    if(d != 0) { d = extgcd(b, a%b, y, x); y -= (a/b)*x; }
    else { x = 1, y = 0; }
    return 0;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,k;
    cin>>n>>k;
    vector<double> p(n);
    REP(i,n) cin >> p[i];
    rep(i,n){
        p[i]=(p[i]+1)/2;
    }
    rep(i,n-1){
        p[i+1]+=p[i];
    }
    double ans=p[k-1];
    for(int i=k;i<n;i++){
        chmax(ans,p[i]-p[i-k]);
        //debug(p[i]-p[i-k]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cstdio> 
#include<cmath>
#include<vector>
using namespace std;

int main(){
string s;
int q;
cin >> s >> q;
int cnt = 0;
int last = 0;
for(int i=0;i<q;i++){
int t; cin >> t;
if(t == 1){
if(i > 0) cnt++;
}else if(t == 2){
last = i;
int f;
string c;
cin >> f >> c;
if(cnt % 2 == 0){
if(f == 1){
s.insert(0,c);
}else{
s += c;
}
}else{
if(f == 1){
s += c;
}else{
s.insert(0,c);
}
}
}
}
if(cnt % 2 != 0) reverse(s.begin(),s.end());
cout << s << endl;
return 0;
}


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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  ll H,W,N;
  cin >> H >> W >> N;
  ll a[N],b[N];
  map <pair<ll,ll>,bool> m;//(i,j)が塗られているかどうか
  vector<pair<ll,ll> > v;//調べるべき3*3盤面の左上の点
  rep(i,N){
    cin >> a[i] >> b[i];
    m[make_pair(a[i],b[i])] = 1;
    rep(y,3){
      rep(x,3){
        if(a[i]-y>=1 && b[i]-x>=1 && a[i]-y+2<=H && b[i]-x+2<=W){
          v.push_back(make_pair(a[i]-y,b[i]-x));
        }
      }
    }
  }

  sort(all(v));
  v.erase(unique(all(v)),v.end());

  ll ans[10] = {};
  ll sum=0;

  rep(i,v.size()){
    int cnt=0;
    rep(y,3){
      rep(x,3){
        if(m[make_pair(v[i].first+y,v[i].second+x)]){
          cnt++;//黒魔酢の数
        }
      }
    }
    ans[cnt]++;
    sum++;
  }
  ans[0] = (H-2)*(W-2)-sum;
  rep(i,10){
    cout << ans[i] << endl;
  }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,n){cout<<arr[i][j]<<" ";}cout<<endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;

    priority_queue<int, vector<P>, function<bool(P, P)>> q([](P a, P b)->int {
        return a.first>b.first;
    });
    cin>>n>>m;
    ll a,b;
    rep(i,n){
        cin>>a>>b;
        q.push(mp(a,b));
    }
    ll ans=0;

    ll count=0;
    while(count<m&&!q.empty()){
        P now = q.top();
        ll &price = now.fi;
        ll &limit = now.se;
        if(count+limit>=m){
            ans += price*(m-count);
            //break;
        }else{
            ans += price*limit;
        }
        count += limit;
//        dbg(count);
//        dbg(ans);
        q.pop();
    }

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


Measured memory_bytes: 2420
#include<iostream>                          
#include<vector>                    
 #include<bits/stdc++.h>

#define mod 998244353
#define pi 3.14159265358979
#define  PRE(x,p) cout<<setprecision(x)<<p; 
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define endl "\n"
#define high INT_MAX
#define low INT_MIN
#define ll long long int
using namespace std;
ll z;
ll a[500005],n;
vector<ll>v; 
// cout<<"CASE #"<<z<<": "<<""<<endl;
void solve() 
{ 
 string s,t;
 cin>>s;
 cin>>t;
 ll n1=s.size(),n2=t.size(),ans=high,i,j,k,here;
 for(i=0;i<=n1-n2;i++)
 {    k=0;
 here=0;
      for(j=i;k<n2;j++,k++)
      {
              if(s[j]!=t[k])
              here++;
              
      }
      ans=min(ans,here);
 }
 cout<<ans;
}
 
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll t=1;
//cin>>t;
for(z=1;z<=t;z++)
solve();
 
return 0;
}

Measured memory_bytes: 3656