akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int maxn = 1e5 + 5;
int n, mod;
vector<int> e[maxn];
ll ways[maxn];
ll mul(ll x, ll y) {
  return (x * y) % mod;
}
ll fastpow(ll x, ll y) {
  ll cur = x;
  ll ans = 1;
  while (y > 0) {
    if (y % 2 == 1) ans = mul(ans, cur);
    cur = mul(cur, cur);
    y /= 2;
  }
  return ans;
}
void precomp(int v, int pre) {
  ways[v] = 1;
  for (int u : e[v]) {
    if (u == pre) continue;
    precomp(u, v);
    ways[v] = mul(ways[v], 1 + ways[u]);
  }
}

ll ans[maxn];
void solve(int v, int pre, ll up) {
  ans[v] = mul(ways[v], 1 + up);
  vector<ll> pref, suff;
  suff.push_back(1);
  for (int i = e[v].size() - 1; i >= 0; i--) {
    if (e[v][i] == pre) continue;
    suff.push_back(mul(suff.back(), 1 + ways[e[v][i]]));
  }
  ll cur = 1 + up;
  int j = suff.size() - 2;
  for (int u : e[v]) {
    if (u == pre) continue;
    solve(u, v, mul(cur, suff[j]));
    cur = mul(cur, 1 + ways[u]);
    j--;
  }
}

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

  cin >> n >> mod;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  precomp(1, 0);
  solve(1, 0, 0);
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << '\n';
  }

  return 0;
}

Measured memory_bytes: 19584
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << max(0, a - b) << "\n";
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
//#include <bits/stdc++.h>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007


#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(int a,int b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 

 
int main() {
    string S;
    long ans=999;
    long input;
    cin >> S;

    input=stol(S);

    FOR(i,0,S.size()-3){

      long tmp = input/ pow(10,i);
      tmp=tmp%1000;
      long kari;
      if(tmp>=753){
        kari=tmp-753;
      }else{
        kari=753-tmp;
      }

      if(kari<ans){ans=kari;}

    }

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





Measured memory_bytes: 384
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        char s[] = sc.next().toCharArray();
        Arrays.sort(s);
        System.out.println(s[0]=='a'&&s[1]=='b'&&s[2]=='c'?"Yes":"No");
    }
}


Measured memory_bytes: 22228
from fractions import gcd

def lcm(a,b):
  return a*b//gcd(a,b)

N,M = map(int,input().split())
A = [int(i) for i in input().split()]

a = 0
b = A[0]
while b % 2 == 0:
  a += 1
  b = b//2
  
for i in range(1,N):
  if A[i] % (2**a) != 0 or A[i] % (2**(a+1)) == 0:
    print(0)
    exit()

c = A[0]
for i in range(N-1):
  c = lcm(c,A[i+1])

print((M+c//2)//c)

Measured memory_bytes: 16340
// Problem : A - Kenken Race
// Contest : AtCoder - AtCoder Grand Contest 034
// URL : https://atcoder.jp/contests/agc034/tasks/agc034_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	a--,b--,c--,d--;
	string s;
	cin>>s;
	bool ans=true;
	l00p(i,a,c)
	if(s[i]=='#'&&s[i+1]=='#')
		ans=false;
	l00p(i,b,d)
	if(s[i]=='#'&&s[i+1]=='#')
		ans=false;
	if(c<d)
	{
		if(ans)
		cout<<"Yes"<<nl;
		else
		cout<<"No"<<nl;
		return 0;
	}
	l00p(i,b,min(n-1,d+1))
	{
		    if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.') {
               cout << "Yes" << endl;
               return 0;
             }
	}
	cout<<"No"<<nl;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3776
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define sLLd(x) scanf("%LLd",&x)
#define pd(x) printf("%d\n",x)
#define pLLd(x) printf("%LLd\n",x)
#define rep(i,a,b) for(int i = a ; i <= b ; i++)
#define per(i,a,b) for(int i = b ; i >= a ; i--)
#define mem(a) memset(a,0,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const LL INF = 1e18;
const int mod = 2010;
const int maxn = 2e5 + 7;

LL n,m,a[maxn];
LL dp[70][70];
LL dfs(LL pos,LL pre,LL limit,LL lead)
{
    if(!pos)return 1;
    if(!limit&&!lead&&~dp[pos][pre])
        return dp[pos][pre];
    LL up=limit?a[pos]:9,ans=0;
    for(LL i=0;i<=up;i++)
    {
        if(abs(i-pre) > 1 && !lead)continue;

        ans+=dfs(pos-1,i,limit&&i==up,i==0&&lead);
    }
    if(!limit&&!lead)
        return dp[pos][pre]=ans;
    return ans;
}
LL solve(LL num)
{
    LL cnt=0;
    while(num)
    {
        a[++cnt]=num%10;
        num/=10;
    }
    memset(dp,-1,sizeof dp);
    return dfs(cnt,0,1,1);
}

int main() {
    LL k;
    while(~scanf("%lld",&k)) {
        LL l = 1 , r = INF;
        LL ans = 0;
        while(l <= r) {
            LL mid = (l + r + 1LL) >> 1LL;
            if(solve(mid) - 1 >= k) {
                ans = mid;
                r = mid - 1;
            } else {
                l = mid + 1;
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, m, h[112345];
    vector<int> g[112345];

    cin >> n >> m;
    for (int i = 0; i < n; i++)
        cin >> h[i + 1];

    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;

        g[a].push_back(b);
        g[b].push_back(a);
    }

    int res = 0;

    for (int i = 1; i <= n; i++)
    {
        bool ok = true;
        for (int j : g[i])
            if (h[i] <= h[j])
            {
                ok = false;
                break;
            }

        res += ok;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 9476
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
typedef double dl;
#define pb push_back
#define ins insert
#define pll pair<ll,ll>
#define fi first
#define se second
#define mpr make_pair
#define vtr vector
#define itor iterator 
#define N ll(1e9+7)
#define endl '\n'
#define cont continue
using namespace std;
//ll power(ll a,ll b,ll mod)
//{
//	if(b==0)return 1;
//	ll ans=1;
//	while(b>0)
//	{
//		if(b&1)ans=(ans*a)%mod;
//		a=(a*a)%mod;
//		b>>=1;
//	}
//	return ans;
//}

int main()
{
	ios;
	ll n,i,j;
	cin>>n;
	vtr<ll> a(n);
	for(i=1;i<=n;i++)
	{
		cin>>a[i-1];
	}
	sort(a.begin(),a.end());
	ll ans=0;
	ans+=a[n-1];
	for(i=n-2;i>=0;i--)
	{
		if(2+2*(n-2-i)>=n)break;
		ans+=a[i];
		if(3+2*(n-2-i)>=n)break;
		ans+=a[i];
	}
	cout<<ans;
}

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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define bs(v,val) binary_search(v.begin(),v.end(),val)
#define mod (int)1e9+7
#define ff first
#define ss second
#define fi(n) for(int i=0;i<n;i++)
#define fj(n) for(int j=0;j<n;j++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define m_p make_pair
#define endl '\n'

struct custom_hash {    // anti-hack for unordered_map. To declare: unordered_map<long long, int, custom_hash> safe_map;
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll power(ll x, ll y, ll p)
{  
    ll res = 1;
    x = x % p;  
    if (x == 0) return 0;
    while (y > 0){  
        if (y & 1)  res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p); 
}
// ********** CODE STARTS HERE ****************//

void solve()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll res = -1e18-1;
    res = max(res,max(max(a*c,a*d),max(b*c,b*d)));
    cout << res;

}


int main()
{
	fastio;
    int T;
    // cin>>T;
    // while(T--)
        solve();
	return 0;
}

Measured memory_bytes: 3636
S = input()
f = int(S[:2])
b = int(S[2:])
if (not 0 < f <= 12) and 0 < b <= 12:
    print('YYMM')
elif (not 0 < b <= 12) and 0 < f <= 12:
    print('MMYY')
elif 0 < f <= 12 and 0 < b <= 12:
    print('AMBIGUOUS')
else:
    print('NA')


Measured memory_bytes: 9128
import java.io.IOException;
import java.util.Scanner;

class Main {
    public static void main(String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int c[] = new int[n];
        int dp[] = new int[n];
        for(int i=0;i<n;i++) {
            c[i] = sc.nextInt();
        }
        for(int i = n-1 ;i>=0;i--) {
            if(i == n-1) dp[i] = 0;
            else {
                int cn = Integer.MAX_VALUE;
                int cnn = Integer.MAX_VALUE;
                if((i+1) < n) cn = Math.abs((c[i] - c[i+1])) + dp[i+1];
                if((i+2) < n) cnn = Math.abs((c[i] - c[i+2])) + dp[i+2];
                //System.out.println("i "+ i + " cn " + cn + " cnn " + cnn);
                dp[i] = Math.min(cn, cnn);
            }
        }
        //for(int i=0;i<n;i++) System.out.print(dp[i] + " ");
        System.out.println(dp[0]);
    }
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
    {
       cin>>v[i];
    }
    vector<int>dp(n);
    dp[0]=v[0],dp[1]=abs(v[1]-v[0]);
    for(int i=2;i<n;i++)
    {
        int x,y;
        x=dp[i-1]+abs(v[i]-v[i-1]);
        if(i==2)
        {
            y=abs(v[i]-v[i-2]);
        }
        else{
        y=dp[i-2]+abs(v[i]-v[i-2]);
        }
        dp[i]=min(x,y);
    }
    cout<<dp[n-1]<<endl;
}


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

int main(void) {
	
	int N,s1,s2,min,co;
	vector<int>::iterator p;

	cin >> N;
	vector<int>W(N,0);
	p = W.begin();
	for (p = W.begin(); p < W.end(); p++) {
		cin >> *p;
	}

	s2 = 0;
	p = W.begin();
	s1 = *p;
	for (p = W.begin()+1; p < W.end(); p++) {
		s2 += *p;
	}
	if (s1 >= s2) {
		min = s1 - s2;
	}
	else {
		min = s2 - s1;
	}
	s1 = 0;
	s2 = 0;
	for (int t = 1; t < N - 1; t++) {
		for (p = W.begin(); p <= W.begin()+t; p++) {
			s1 += *p;
		}
		for (p = W.begin()+(t+1); p < W.end(); p++) {
			s2 += *p;
		}
		if (s1 >= s2) {
			co = s1 - s2;
		}
		else {
			co = s2 - s1;
		}
		if (co < min) {
			min = co;
		}
		s1 = 0;
		s2 = 0;
		

	}

	cout << min;
	
}

Measured memory_bytes: 256
#include<iostream>
#include <set> 
#include <iterator> 
using namespace std;
int main () {
   string s;cin>>s;
   long long int l=s.length(),k,count=0;
   k=l/2;
   k--;
   for (long long int i=0;i<=k;i++) {
       if (s[i]!=s[l-1-i]) count++;
   }
   cout<<count<<endl;
}

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

int main() {
	int n, h, w, ans = 0;
	cin >> n >> h >> w;

	for(int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;

		if(x >= h and y >= w) ans++;
	}

	cout << ans << endl;
}

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

void Selectionsort(vector<int> A){
    int count=0;
    int N=A.size();
    for(int i=0;i<N-1;i++){
        int min=i;
        for(int j=i+1;j<N;j++){
            if(A.at(j)<A.at(min)){
                min=j;
            }
        }
        swap(A.at(i),A.at(min));
        if(i!=min) count++;
    }
    for(int i=0;i<A.size();i++){
        if(i) cout << " ";
        cout << A.at(i);
    }
    cout << endl;
    cout << count << endl;
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A.at(i);
    }
    Selectionsort(A);
}


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

using ll = long long;

template <int M, bool IsPrime = false>
class modulo {
    using ll = long long;
public:
    modulo() : n(0) {}
    modulo(int m) : n(m) {
        if(n >= M) {
            n %= M;
        } else if(n < 0) {
            n = (n % M + M) % M;
        }
    }
    modulo(ll m) : modulo(int(m % M)) {}

    explicit operator int() const { return n; }
    explicit operator ll() const { return n; }

    bool operator==(modulo const& a) const {
        return n == a.n;
    }

    modulo& operator+=(modulo const& a) {
        n += a.n;
        if(n >= M) {
            n -= M;
        }
        return *this;
    }
    modulo& operator-=(modulo const& a) {
        n -= a.n;
        if(n < 0) {
            n += M;
        }
        return *this;
    }
    modulo& operator*=(modulo const& a) {
        n = (ll(n) * a.n) % M;
        return *this;
    }
    modulo operator^(int n) const {
        if(n == 0) {
            return modulo(1);
        }
        const modulo a = *this;
        modulo res = (a * a) ^ (n / 2);
        return n % 2 ? res * a : res;
    }

    typename std::enable_if<IsPrime, modulo>::type operator/(modulo const& a) const {
        return *this * modulo(inv(ll(a), M));
    }

private:
    ll n;
    static typename std::enable_if<IsPrime, ll>::type inv(ll a, ll p) {
        return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
    }
};

template <int M, bool IsPrime>
modulo<M, IsPrime> operator+(modulo<M, IsPrime> lhs, modulo<M, IsPrime> const& rhs) {
    return lhs += rhs;
}
template <int M, bool IsPrime>
modulo<M, IsPrime> operator-(modulo<M, IsPrime> lhs, modulo<M, IsPrime> const& rhs) {
    return lhs -= rhs;
}
template <int M, bool IsPrime>
modulo<M, IsPrime> operator*(modulo<M, IsPrime> lhs, modulo<M, IsPrime> const& rhs) {
    return lhs *= rhs;
}

constexpr int MOD = 1000000007;

// sw == false -> inv
template <int M = MOD>
modulo<M, true> fact(int n, bool sw = true) {
    static std::vector<modulo<M, true>> v1 = {1}, v2 = {1};
    if(n >= (int)v1.size()) {
        const int from = v1.size(), to = n + 1024;
        v1.reserve(to);
        v2.reserve(to);
        for(int i = from; i < to; ++i) {
            v1.push_back(v1.back() * modulo<M, true>(i));
            v2.push_back(v2.back() / modulo<M, true>(i));
        }
    }
    return sw ? v1[n] : v2[n];
}

template <int M = MOD>
modulo<M, true> comb(int a, int b) {
    if(b < 0 || b > a) {
        return fact<M>(0);
    }
    return fact<M>(a, true) * fact<M>(b, false) * fact<M>(a - b, false);
}

using mod = modulo<MOD, true>;

int main() {
    int n;
    cin >> n;
    if(n == 2) {
        cout << 1 << endl;
    } else if(n == 3) {
        cout << 4 << endl;
    } else if(n == 4) {
        cout << 16 << endl;
    } else {
        mod ans = 0;
        mod cur = 0;
        for(int k = (n + 1) / 2; k <= n - 1; ++k) {
            mod t = comb(k - 1, n - 1 - k) * fact(k) * fact(n - 1 - k);
            ans += (t - cur) * mod(k);
            cur = t;
        }
        cout << (ll)ans << endl;
    }
}


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

using namespace std;

// #define int long long
#define MP make_pair
#define F first
#define S second
#define pi pair<int,int> 
#define sz(s) ((int)s.size())

const unsigned mod = 1e9 + 7;
const unsigned N = 2e3 + 4;

int dist[N], a[N];
bool vis[N];
int ans[N];
vector<int> g[N];
queue<int> q;

void bfs(int node) {
	memset(vis, 0, sizeof vis);
	memset(dist, 0, sizeof dist);
	q.push(node);
	dist[node] = 0;
	vis[node] = 1;
	while (!q.empty()) {
		int x = q.front();
		q.pop();
		for (auto it: g[x]) {
			if (!vis[it]) {
				q.push(it);
				vis[it] = 1;
				dist[it] = 1 + dist[x];
			}
		}
	}
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  int x, y;
  cin >> x >> y;
  for (int i = 1; i < n; ++i) {
  	int u = i, v = i + 1;
  	g[u].push_back(v);
  	g[v].push_back(u);
  }
  int u = x, v = y;
	g[u].push_back(v);
	g[v].push_back(u);
	for (int i = 1; i <= n; ++i) {
		bfs(i);
		for (int j = i + 1; j <= n; ++j)
			ans[dist[j]]++;	
	}
 	for (int i = 1; i < n; ++i) {
 		cout << ans[i] << '\n';
 	}  
  return 0;
}


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

int main(){

    int N;
    cin >> N;

    vector<double> v(N, 0);
    for(int i = 0; i < N; i++){
        cin >> v.at(i);
    }

    double item;
    for(int i = 0; i < N - 1; i++){
        sort(v.begin(), v.end());

        item = 0.5 * (v.at(0) + v.at(1));
        v.insert(v.begin(), item);
        v.erase(v.begin() + 1);
        v.erase(v.begin() + 1);
    }

    cout << fixed << setprecision(10) << v.at(0) << endl;

    return 0;
}

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

#define for0(i, n) for (int i = 0; i < (int)(n); ++i) 
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) 
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) 
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) 
#define forrc(i,l,r) for (int i= (int)(r); i>= (int)(l); --i)

#define pb push_back
#define fi first
#define se second
#define mp make_pair

#define all(x) (x).begin(), (x).end() 
#define rall(x) (x).rbegin, (x).rend() 


#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)


#define present(c,x) ((c).find(x) != (c).end())


#define cpresent(c,x) (find(all(c),x) != (c).end())

#define sz(a) int((a).size())

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;
typedef long long ll;
typedef unsigned long long int ull;

int MOD=1000000007;

int main(){
  fastio; 
  
  int n,k;
  cin >> n >> k;
  vi dp(k+1);
  vi a(n);
  for0(i,n){
    cin >> a[i];
  }
  int flag;
  for0(i,k+1){
    if(i==0){
      dp[i]=0;
      continue;
    }
    flag=0;
    for0(j,n){
      if(i-a[j]>=0 && dp[i-a[j]]==0){
        dp[i]=1;
        flag=1;
        break;
      }
    }
    if(flag==0){
      dp[i]=0;
    }
  }
  if(dp[k]==0){
    cout << "Second";
  }else{
    cout << "First";
  }
}

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

int main()
{
	string scin;
	string s;
	while (cin >> scin)
	{
		s += scin;
	}
	transform(s.begin(), s.end(), s.begin(), ::tolower);
	map<char, int> m;
	for (char i = 'a'; i < 'z' + 1; i++)
	{
		m[i] = 0;
	}

	for (int i = 0; i < s.size(); i++)
	{
		m[s[i]]++;
	}
	for (auto i : m)
	{
		if (i.first < 'a')
		{
			continue;
		}
		cout << i.first  << " : " << i.second << endl;
	}
	return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int x = min(b, c);
  int ans = x * 2;
  c -= x;
  b -= x;
  x = min(a, c);
  ans += x;
  c -= x; a -= x;
  if (c > 0) ans++;
  ans += b;
  cout << ans << 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 K = sc.nextInt();
		String S = sc.next();
		sc.close();
		if(S.length() <= K) {
			System.out.println(S);
		} else {
			System.out.println(S.substring(0, K) + "...");
		}
	}
}

Measured memory_bytes: 27004
#include <bits/stdc++.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++)e;

int main()
{
    char c;
    cin >> c;
    if (c =='a' 
    || c =='e' 
    || c =='i' 
    || c =='o' 
    || c =='u')
        cout << "vowel" << endl;
        else
            cout << "consonant" << endl;
}


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

const long long int d7 = 1000000007;

int irrel(int n) {
    if (n <= 0) {
        return 1;
    } else {
        return irrel(n-1) + irrel(n-2);
    }
}

void solve(int h, int w, int k, std::vector<std::vector<long long int>> &f) {
  f[0][1] = 1;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= std::min(w, i + 1); j++) {
      int dd = irrel(j - 2) * irrel(w - j - 1);
      int dl = irrel(j - 3) * irrel(w - j - 1);
      int dr = irrel(j - 2) * irrel(w - j - 2);
      f[i][j] = ((f[i - 1][j] % d7) * (dd % d7) % d7 +
                 ((f[i - 1][j - 1] % d7) * (dl % d7)) % d7 +
                 ((f[i - 1][j + 1] % d7) * (dr % d7)) % d7) %
                d7;
    }
  }
};

int main() {
  int h, w, k;
  std::cin >> h >> w >> k;
  std::vector<std::vector<long long int>> f(
      h + 2, std::vector<long long int>(w + 2, 0));
  solve(h, w, k, f);
  std::cout << f[h][k] << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>

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

int main(){

    ll n,k,dgt=0; cin >> n >> k;

    while(n!=0){
        n=n/k;
        dgt++;
    }

    cout << dgt << endl;

     return 0;
}

Measured memory_bytes: 256
use proconio::*;
use proconio::marker::Usize1;

#[fastout]
fn run() {
    input! {
        n: usize,
        m: usize,
        e: [(Usize1, Usize1); m],
    }
    let mut g = vec![vec![]; n];
    for (a, b) in e {
        g[a].push(b);
        g[b].push(a);
    }
    let mut prev = vec![n; n];
    prev[0] = 0;
    let mut q = std::collections::VecDeque::new();
    q.push_back(0);
    while let Some(v) = q.pop_front() {
        for &u in g[v].iter() {
            if prev[u] == n {
                prev[u] = v;
                q.push_back(u);
            }
        }
    }
    println!("Yes");
    for p in prev.iter().skip(1) {
        println!("{}", *p + 1);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 16044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> pll;
const int maxv = 16;
int V,E;

struct Edge{
    int to;
    int cost;
    Edge(int a, int b){
        to = a;
        cost = b;
    }
};
vector<vector<ll> > G;

vector<vector<ll> > dp(1LL<<maxv, vector<ll>(maxv, -1));

ll rec(ll S, int v){
    if(S == 0){
        if(v == 0){
            dp[S][v] = 0;
            return 0;
        }
        else{
            dp[S][v] = INF;
            return INF;
        }
    }

    if((S & (1<<v)) == 0) return INF; //Sにvが含まれなくなってしまった場合の終了処理

    ll &ret = dp[S][v];
    if(ret != -1) return ret; //0の理由:
    if((S & (1<<v)) != 0){
        ret = INF;
        for(int u = 0; u < V; u++){
            if(G[u][v] != INF){
                ret = min(ret, rec(S^(1<<v), u) + G[u][v]);
            }
        }
        return ret;
    }
}


int main(){
    //cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);

    cin >>V>>E; //Vは頂点数,Eは辺
    G.resize(V,vector<ll>(V,INF));
    REP(i,E){
        ll s,t,d; cin>>s>>t>>d;
        G[s][t] = d;
    }
    
    cout << (rec((1<<V)-1,0) != INF ? rec((1<<V)-1,0) : -1) << endl;
}


Measured memory_bytes: 13556
#include<iostream>
using namespace std;
int main(){
    int m,f,r;
    char c;
    while(1){
    cin>>m>>f>>r;
    if(m==-1&&f==-1&&r==-1)break;
    if(m==-1||f==-1) c='F';
    else if(m+f>=80) c='A';
    else if(m+f>=65) c='B';
    else if(m+f>=50||m+f>=30&&r>=50) c='C';
    else if(m+f>=30) c='D';
    else c='F';
    cout<<c<<endl;
    }
}

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

int main(){
    int N;
    cin >> N;
    int A[2][N];
    for(int i = 0; i < 2; ++i){
        for(int j = 0; j < N; ++j) cin >> A[i][j];
    }
    int tmp[2][N];
    tmp[0][0] = A[0][0];
    tmp[1][0] = A[0][0] + A[1][0];
    for(int i = 1; i < N; ++i){
        tmp[0][i] = tmp[0][i-1] + A[0][i];
        tmp[1][i] = max(tmp[1][i-1] + A[1][i], tmp[0][i] + A[1][i]);
    }
    cout << tmp[1][N-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(){
	int n;
	map<string,int> cnt;
	string s;
	cin >> n;
	for (int i=0; i<n; i++){
		cin >> s;
		sort(s.begin(), s.end());
		cnt[s]++;
	}
	
	long ans = 0;

	for (auto mp : cnt){
//		cout << mp.first << " " << mp.second << endl;
		ans += (long long)mp.second * (mp.second - 1) / 2;
	}

	cout << ans << endl;
}



Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1 << 29;
const int MOD = 1000000007;

int main() {
    long long x;
    cin >> x;

    // (A, B) ( -118 <= A <= 119, -119 <= B <= 118 を全探索すればよいことが分かる)
    for (int a = -118; a < 120; a++) {
        for (int b = -119; b < 119; b++) {
            if (pow(a, 5) - pow(b, 5) == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 4044
#include<stdio.h>
#include<math.h>

int main(){
        char s[8], ans[8];
        scanf("%s", s);
        int n[4];
        for(int i=0; i<4; i++){
                n[i] = s[i] - '0';
                ans[i*2] = s[i];
        }

        for(int i=0; i<8; i++){
                int cnt = n[0];
                for(int j=0; j<3; j++){
                        cnt += n[j+1] * pow(-1, (i>>j)&1);
                        ans[j*2+1] = 44 + pow(-1, !((i>>j)&1));
                }
                if(cnt==7) break;
        }
        printf("%s=7\n", ans);
        return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

ll N, K;

ll walk_even(ll node, vector<ll> es[], ll depth, vector<bool> use){
	use[node] = true;
	ll ret = 0;
	for(ll next : es[node]){
		if(!use[next]) ret += walk_even(next, es, depth+1, use);
	}
	if(depth > K) ret++;
	return ret;
}


signed main(){
	cin >> N >> K;
	vector<P> es_odd;
	vector<ll> es_even[N];
	rep(N-1){
		ll from, to;
		cin >> from >> to;
		from--; to--;
		es_odd.push_back(P(from, to));
		es_even[from].push_back(to);
		es_even[to].push_back(from);
	}

	vector<ll> ans;
	if(K % 2 == 0){
		K /= 2;
		rep(N){
			ans.push_back(walk_even(i, es_even, 0, vector<bool>(N, false)));
		}
	}else{
		K = (K-1)/2;
		for(P e : es_odd){
			vector<bool> use(N, false);
			use[e.second] = true;
			ll tmp1 = walk_even(e.first, es_even, 0, use);
			use[e.second] = false; use[e.first] = true;
			ll tmp2 = walk_even(e.second, es_even, 0, use);
			//cout << tmp1 << " " << tmp2 << endl;
			ans.push_back(tmp1 + tmp2);
		}
	}
	cout << *min_element(all(ans));
}



Measured memory_bytes: 1296
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var d = new Dictionary<string, int>();
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 1; i <= n; i++)
        {
            var its = i.ToString();
            var k = "" + its[0] + its[its.Length - 1];
            if (d.ContainsKey(k)) d[k]++;
            else d[k] = 1;
        }
        getAns(n, d);
    }
    static void getAns(int n, Dictionary<string, int> d)
    {
        var ans = 0;
        foreach (var x in d)
            if (x.Key[x.Key.Length - 1] != '0')
            {
                var nk = "" + x.Key[x.Key.Length - 1] + x.Key[0];
                if (d.ContainsKey(nk)) ans += x.Value * d[nk];
            }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 17348
import bisect
n,m,v,p = map(int,input().split())
lst1 = list(map(int,input().split()))

lst1.sort(reverse=True)

def func(u):
    score = lst1[u] + m
    cost1 = max(0,v-(n-u))*m
    all_score = (p-1)*m
    for i in range(p-1,u):
        if score-lst1[i] < 0:
            all_score = -1
            break
        all_score += score-lst1[i]
    if all_score >= cost1:
        return True
    else:
        return False  


def binary_search(n): #2分探索
    ok = p-1
    ng = len(lst1)
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if func(mid):
            ok = mid
        else:
            ng = mid

    return ok

print(binary_search(n)+1)

Measured memory_bytes: 62576
from sys import stdin
N = int(stdin.readline().rstrip())
X = [int(_) for _ in stdin.readline().rstrip().split()]
ans = float('inf')
for i in range(1, 100):
    a = 0
    for x in X:
        a += (x-i)*(x-i)
    ans = min(ans, a)
print(ans)

Measured memory_bytes: 3060
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase

def ii():  return int(input())
def si():  return input()
def mi():  return map(int,input().strip().split(" "))
def li():  return list(mi())

def main():
    x = ii()

    if x == 1:
        print(0)
    elif x == 0:
        print(1)
    # pass


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 9396
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N = 100010;
int d[N], n;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &d[i]);
	sort(d, d + n);
	int ans = d[n / 2] - d[n / 2 - 1];
	printf("%d\n", ans);
}



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

int main(){
    int A, B, C, K;
    cin >> A >> B >> C;
    cin >> K;
    int max_num = max({A, B, C});
    int ans = A + B + C - max_num;
    ans += max_num * pow(2, K);
    cout << ans << endl;
    return 0;
}

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

int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	multiset<int> ms;
	for(int i=0; i<n; i++) {
		cin >> a[i];
		ms.insert(a[i]);
	}
	for(int i=0; i<n; i++) {
		auto it = ms.find(a[i]);
		ms.erase(it);
		cout << *ms.rbegin() << '\n';
		ms.insert(a[i]);
	}
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n;
string s;
int ans[100002];

int main() {
	cin >> n >> s;
	s[n + 0] = s[0];
	s[n + 1] = s[1];
	
	bool flag = false;
	inc(a, 4) {
		ans[0] = a / 2;
		ans[1] = a % 2;
		inc(i, n) {
			ans[i + 2] = ( ((ans[i + 1] + ans[i]) % 2 == 0) == (s[i + 1] == 'o') ); 
		}
		
		if(ans[0] == ans[n] && ans[1] == ans[n + 1]) { flag = true; break; }
	}
	
	if(flag) {
		inc(i, n) {
			cout << (ans[i] == 1 ? "S" : "W");
		}
		cout << endl;
	} else {
		cout << -1 << endl;
	}
	
	return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

struct Sieve {
  vector<bool> isprime;

  void init(size_t max){
    if(max+1 > isprime.size()){     // resizeで要素数が減らないように
        isprime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    }
    isprime[0] = false; // 0は素数ではない
    isprime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(isprime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                isprime[i*j] = false;      // 素数ではない
  }
};


int main () {
  cin.tie(0);
  cout << setprecision(10);

  Sieve s;
  s.init(1300000);

  vi p(100000), su(100000);
  p[0] = 2;
  su[0] = 0;
  int j = 1;
  FOR(i, 3, 1300000) {
    if(s.isprime[i]) {
      j++;
      p[j] = i;
      su[j] = i - p[j-1];
    }
  }

  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    if(s.isprime[n]) {
      cout << 0 << endl;
      continue;
    }
    REP(i, 100000) {
      if(p[i] > n) {
        cout << su[i] << endl;
        break;
      }
    }
  }
  
}



Measured memory_bytes: 3704
#include<stdio.h>

#define INFTY 2000000000
#define MAX_S 500000

int count=0;
void merge(int *S,int left,int mid,int right){

  int L[MAX_S/2+2],R[MAX_S+2];
  int i,j,k;
  int n1,n2;
  n1 = mid - left;
  n2 = right - mid;
  for(i=0;i<n1;i++)
    L[i]=S[left+i];
  
  for(i=0;i<n2;i++)
    R[i]=S[mid+i];
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=j=0;
  for(k=left;k<right;k++){
    count++;
    if(L[i]<=R[j]){
      S[k]=L[i];
    i+=1;
    }
    else{
      S[k]=R[j];
      j+=1;
    }
  }
}

void mergeSort(int *S,int left,int right){
  int mid;

  if(left+1< right){
    mid = (left+right)/2;
    mergeSort(S,left,mid);
    mergeSort(S,mid,right);
    merge(S,left,mid,right);
  }
}
    

int main(){

  int S[MAX_S];
  int n,i;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  
  mergeSort(S,0,n);

  for(i=0;i<n;i++){
    if(i){
      printf(" ");
    }
    printf("%d",S[i]);
  }
  printf("\n%d\n",count);
  
  return 0;
}

Measured memory_bytes: 4512
/*
    Author  : Malisetti Samrat 
    Date    : 2020-05-02 17:45:43 
 */


//Optimisation Flags
#pragma GCC optimize ("O3")
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC optimize("Ofast")

#include   <bits/stdc++.h>
//#include   <ext/pb_ds/assoc_container.hpp>
//#include   <ext/pb_ds/tree_policy.hpp>
#include   <algorithm>
#include   <queue>
#include   <list>
#include   <map>
#include   <math.h>
#include   <numeric>
using      namespace        std;
#define    endl             '\n'
#define    FAST             ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define    ipfile           ifstream cin ("input.txt");std::cin.rdbuf(std::cin.rdbuf())
#define    pb(x)            push_back(x)
#define    int              long long int
#define    itn              unsigned long long int
#define    db               long double
#define    vll              vector<int>
#define    all(v)           v.begin(),v.end()
#define    rall(v)          v.rbegin(),v.rend()
#define    GCD(m,n)         __gcd(m,n)
#define    LCM(m,n)         m*(n/GCD(m,n))
#define    REVVEC(v)        reverse(v.begin(),v.end())
#define    REVARR(a)        reverse(a,a+n)
#define    maxc(v)          max_element(all(v))
#define    minc(v)          min_element(all(v))
#define    inputarr(a,n)    for(int xxx=0;xxx<n;++xxx) cin>>a[xxx]
#define    outputarr(a,n)   for(int xxx=0;xxx<n;xxx++) cout<<a[xxx]<<" "
#define    rep(i,m, n)      for(int i = m; i < (n); ++i)
#define    sp               setprecison(10)
#define    sz(a)            (int)a.size()
#define    erase(vec,val)   vec.erase(std::remove(vec.begin(), vec.end(), val), vec.end()); //deleting specific value element in vector
#define    PI               (db)3.141592653589793238462643383279502884197169399375105820974944
#define    inf              (int)1000000000
#define    mod              (int)1000000007
#define    mem(a,b)          memset(a,b,sizeof(a));
#define    w(x)              int T;cin>>T;while(T -- > 0)
#define    ff                first
#define    ss                second
#define    pqueue            priority_queue< int >
#define    pdqueue           priority_queue< int,vll ,greater< int > >

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

clock_t time_p = clock();

void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}

void solveTC(){

     int k;
     cin>>k;

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

     for(int i=A;i<=B;i++)
     {
        if(i%k==0){
            cout<<"OK\n";
        return;}
     }

     cout<<"NG\n";
}

int32_t main()
{

    FAST

 //   w(x){

        solveTC();

   // }

    time();

    return 0;

}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s,t;cin >> s >> t;
  int sum = 0;
  rep(i,3) if(s[i] == t[i])++sum;
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// solution 
use std::cmp;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        X: usize,
        Y: usize,
    }

    let mut rest = Y / X;
    let mut count = 0;

    while rest > 0 {
        rest >>= 1;
        count += 1;
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
n, x, y = map(int, input().split())
d = [0] * (n-1)
d[0] = 1
for i in range(1, n-1):
  for j in range(i+1, n+1):
    tmp = min(j-i, abs(y - j) + abs(x - i) + 1)
    d[tmp-1] += 1
    
for ans in d:
  print(ans)


Measured memory_bytes: 3444
int main(){
  int n,p[8],q[8],a=1,s1=0,d1,s2=0,d2;
  scanf("%d\n",&n);
  for(int i=0;i<n;i++){
    scanf("%d\n",&p[i]);
    a*=i+1;
  }
  for(int i=0;i<n;i++){
    scanf("%d\n",&q[i]);
  }
  d1=d2=a;
  for(int i=0;i<n-1;i++){
    d1/=n-i;
    s1+=d1*(p[i]-1);
    for(int j=i+1;j<n-1;j++){
    if(p[i]<p[j]) p[j]--;
  	}
  }
  for(int i=0;i<n-1;i++){
    d2/=n-i;
    s2+=d2*(q[i]-1);
    for(int j=i+1;j<n-1;j++){
    if(q[i]<q[j]) q[j]--;
  	}
  }
  if(s1>s2) printf("%d\n",s1-s2);
  else printf("%d\n",s2-s1);
  return 0;
}

Measured memory_bytes: 128