akhauriyash/Code-Regression huggingface dataset:
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int j = i; j < n; j++) {
      sum += a[j]; 
      v.push_back(sum);
    }
  }
  sort(v.rbegin(), v.rend());
  int ans = 0;
  for (int b = 61; b >= 0; b--) {
    if ((v[0] & (int)pow(2, b)) == 0) {
      continue;
    }
    if ((v[k - 1] & (int)pow(2, b)) == 0) {
      int nt = (int) pow(2, 62) - 1 - (int) pow(2, b);
      for (int i = 0; i < sz(v); i++) {
        v[i] &= nt;
      }
      sort(v.rbegin(), v.rend());
    } else {
      ans += (int) pow(2, b);
    }
  }
  cout << ans << "\n";
}



Measured memory_bytes: 6512
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

struct ei {
	int val,idx;
};

bool operator< (const ei &a, const ei &b) {
	return a.val<b.val;
}

int main () {
	int n;
	scanf("%d",&n);
	int cnt=0;
	vector<ei> tbl(n);
	int x;
	for (int i=0;i<n;i++) {
		scanf("%d",&x);
		tbl[i].val=x;
		tbl[i].idx=i+1;
	}
	sort(tbl.begin(),tbl.end());
	for (int i=0;i<n;i++) {
		tbl[i].val=i+1;
		if (i%2&&tbl[i].idx%2!=(i+1)%2) cnt++;
	}
	printf("%d\n",cnt);	
	return 0;
}


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

double a, b, h, m;

const double PI = acos(-1.0), DPI = PI * 2;

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

	cin >> a >> b >> h >> m;
	double x = (h * 60 + m) / 720 * DPI, y = m / 60 * DPI;
	double cx = a * cos(x), cy = b * cos(y), sx = a * sin(x), sy = b * sin(y);
	double z = sqrt((cx - cy) * (cx - cy) + (sx - sy) * (sx - sy));
	cout << fixed << setprecision(12) << z << '\n';

	return 0;
}

Measured memory_bytes: 4092
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    vl a(n); rep(i,n) cin >> a[i];
    bool flg = true;
    int cnt = 0;
    rep(i,n) {
        while(a[i]%2==0) {
            cnt++;
            a[i]/=2;
        }
    }
    ct(cnt);
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

int main(){
	vector<string> t(6);
	string s = "afkpu";
	rep(i, 5) rep(j, 5){
		t[i].push_back(s[i]+j);
	}
	t[5] = "z.?! ";

	string in;
	while(cin >> in){
		string buf;
		bool ok = true;
		if(in.size()%2) ok = false;
		rep(i, in.size()){
			if(in[i] < '1' || in[i] > '6'-(i%2)) ok = false;
		}
		if(ok) for(int i = 0; i < in.size(); i+= 2){
			int a = in[i]-'1';
			int b = in[i+1]-'1';
			buf += t[a][b];
		}
		if(buf.size()) cout << buf << endl;
		else cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define prvsort(v) sort(v.begin(), v.end(), greater<pair<ll, ll>>())
#define ll long long
#define ld long double
#define fixset(val) fixed << setprecision(10) << val 
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define mod 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll N, K; cin >> N >> K;
  vector<ll> A(N);
  rep(i, 0, N) cin >> A[i];
  ld kitai = 0;
  rep(i, 0, K) {
  	kitai += (A[i] + 1) / 2.0;
  }
  ld ans = kitai;
  rep(i, 0, N - K) {
    kitai += (A[i + K] - A[i]) / 2.0;
    if (ans < kitai) ans = kitai;
  }
  cout << fixset(ans) << endl;
}

Measured memory_bytes: 4752
def main():
    n, m = map(int, input().split())
    a = [list(map(int, input().split())) for _ in range(m)]
    a.sort()
    INF = 10 ** 18
    dp = [INF for i in range(n)]
    dp[0] = 0
    for l, r, c in a:
        if dp[l - 1] == INF:
            print(-1)
            return None
        tp = dp[l - 1] + c
        for i in range(r - 1, l - 1, -1):
            if dp[i] == INF:
                dp[i] = tp
            elif tp < dp[i]:
                dp[i] = tp
            else:
                break
    if dp[-1] == INF:
        print(-1)
    else:
        print(dp[-1])


main()


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

class Program
{
    static void Main(string[] args)
    {
        double sum = 0;
        int n = int.Parse(Console.ReadLine());
        int[] arr = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        for (int i = 1; i <= n; i++) sum += reciprocal(arr[i - 1]);
        Console.WriteLine(reciprocal(sum));



    }

    static double reciprocal(double element) { return 1 / element; }


}



Measured memory_bytes: 11220
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int A, B, C;
    cin >> A >> B >> C;

    if (A <= C && C <= B) {
        cout << "Yes" << endl;
        return;
    } else if (B <= C && C <= A) {
        cout << "Yes" << endl;
        return;
    } else {
        cout << "No" << endl;
        return;
    }

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c) puts("1");
	else if ((a == b && b != c) || (a == c && c != b) || (b == c && c != a)) puts("2");
	else if (a != b && b != c && c != a) puts("3");
	return 0;
}

Measured memory_bytes: 256
<?php
$mark = array('S'=>0,'H'=>1,'C'=>2,'D'=>3);
for ($i=1;$i<=52;$i++) $cards[$i]=false;
$n = (int)fgets(STDIN);
$res = '';
while (--$n >= 0) {
  $set = explode(' ', trim(fgets(STDIN)));
  $cards[$mark[$set[0]]*13+(int)$set[1]] = true;
}
foreach(array('S','H','C','D') as $val) {
  for ($i = 1; $i <= 13; $i++) {
    if (!$cards[$mark[$val]*13+$i]) $res = $res."$val $i".PHP_EOL;
  }
}
echo $res;

Measured memory_bytes: 15088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

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

Measured memory_bytes: 256
int main(){
  int N,Y;
  scanf("%d %d",&N,&Y);
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N-i;j++){
      if(10000*i + 5000*j + 1000*(N-i-j) == Y){
        printf("%d %d %d",i,j,N-i-j);return 0;
      }
    }
  }
  printf("-1 -1 -1");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

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

typedef long long ll;



int main() {
    int a,b;
    cin >> a >> b ;
    if (a*b%2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;

    return 0;
}


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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);                      \
	cin.exceptions(cin.failbit);
#define int long long int //Comment when Unnecessary
#define ll long long
#define sz(a) (int)((a).size())
#define all(a) a.begin(), a.end()
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define pii pair<int, int>
#define vi vector<int>
#define F first
#define S second
#define endl "\n" // Remove on Interactive

const int N = 300009;
const int mod = 1000000007;

int t, n, m;
string s;

int32_t main()
{
	IOS;

	cin >> n;
	m = 0;
	rep(i,	1,n+1)
	{
		rep(j,1,n+1)
		{
			rep(k,1,n+1)
			{
				m+=__gcd(i,__gcd(j,k));
			}
		}
	}
	cout<<m<<endl;
	return 0;
}


Measured memory_bytes: 3640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AParking solver = new AParking();
        solver.solve(1, in, out);
        out.close();
    }

    static class AParking {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();
            out.print(Math.min(n * a, b));
        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

        public void close() {
        }

    }
}



Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A, B, C;
    cin >> A >> B >> C;
    int ans=0;
    
    if (A == B) {
        if (B == C) {
            ans = 1;
        } else {
            ans = 0;
        }
    } else if ( B == C) {
        if (C == A) {
            ans = 1;
        } else {
            ans = 0;
        }
    } else if ( C == A) {
        if (A == B) {
            ans = 1;
        } else {
            ans = 0;
        }
    } else if ( A != B && B!= C) {
        ans = 1;
    }
    
    if (ans == 1) {
        cout << "No";
    } else {
        cout << "Yes";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  
  string s="";
  while(n!=0){
    int num=n%26;
    if(num==0) num=26;
    s+='a'+num-1;
    n-=num;
    n/=26;
  }
  reverse(s.begin(),s.end() );
  cout<<s<<endl;

  return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

string s;
set<string> st;

bool f = false;

void calc(string t) {
	//cout << t << endl;
	if(st.count(t)) return;
	st.insert(t);
	if(f) return;
	if(t == "ABC") {
		f = true;
		return;
	}
	for(int i = 0; i +2 < t.size(); i++) {
		if(t[i] == 'A' && t[i+1] == 'B' && t[i+2] == 'C') {
			t = t.substr(0, i) + "X" + t.substr(i + 3);
		}
	}
	bool f2[3] = {};
	for(auto& c : t) f2[c- 'A'] = true;
	for(int i = 0; i < 3; i++) {
		if(f2[i] == false) {
			string u = t;
			for(int j = 0; j < u.size(); j++) if(u[j] == 'X') u[j] = ('A' + i);
			calc(u);
		}
	}
}

int main(){
	cin >> s;
	calc(s);
	cout << (f?"Yes":"No") << endl;
}

Measured memory_bytes: 28768
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    Forn(i, n)
    {
        if(i*108/100 == n)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}


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

typedef long long ll;
typedef long double ld;

void solve()
{
    int d, t, s;
    cin >> d >> t >> s;

    cout << (1.0 * t * s >= d ? "Yes" : "No") << endl;
}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);

#ifdef _DEBUG
    freopen("a-input-1.txt", "r", stdin);
    //freopen("a-output-1.txt", "w", stdout);
#endif

    solve();
    //int t; cin >> t; while(t--) solve();

    return 0;
}


Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

signed main() {
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      string s;
      cin >> s;
      if (s == "snuke") {
        for (char c = 'A'; c + 1 != 'Z'; c++) {
          if (c - 'A' == j) {
            cout << c << i + 1 << endl;
            return 0;
          }
        }
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
a500 = int(input())
b100 = int(input())
c50 = int(input())
X = int(input())
ans = 0
goukei = 0
is_over = False
for i in range(a500+1):
  for j in range(b100+1):
    for k in range(c50+1):
      goukei = i * 500 + j * 100 + k * 50
      if goukei == X:
        ans += 1
        break
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
typedef pair<int,int> pii;
#define mp make_pair
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=2010,Mod=924844033;
int n,k,g[N][N][4],p[N],fac[N];
int main()
{
	n=gi();k=gi();fac[0]=1;
	for(int i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%Mod;
	int m=(n-1)/k+1;
	g[1][0][0]=g[1][1][2]=1;
	for(int i=1;i<m;i++)
		for(int j=0;j<=i;j++)
			for(int q=0;q<4;q++)
			{
				if(!g[i][j][q])continue;
				g[i+1][j][q>>1]=(g[i+1][j][q>>1]+g[i][j][q])%Mod;
				if(!(q&1))g[i+1][j+1][q>>1]=(g[i+1][j+1][q>>1]+g[i][j][q])%Mod;
				g[i+1][j+1][q>>1|2]=(g[i+1][j+1][q>>1|2]+g[i][j][q])%Mod;
			}
	p[0]=1;int s=0;
	for(int i=1;i<=k;i++)
	{
		int ed=(n-i)/k+1;s+=ed;
		for(int j=s;j;j--)
			for(int k=1;k<=ed;k++)
				if(j>=k)p[j]=(p[j]+1ll*p[j-k]*((g[ed][k][0]+g[ed][k][1])%Mod)%Mod)%Mod;
	}
	int ans=0;
	for(int i=0;i<=n;i++)
		if(i&1)ans=(ans-1ll*fac[n-i]*p[i]%Mod+Mod)%Mod;
		else ans=(ans+1ll*fac[n-i]*p[i]%Mod)%Mod;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 61312
#include <stdio.h>
                                                                                                
  
int main(void){
                                                                                                
   
    int r, g, b , x;
      
      
    scanf("%d %d %d", &r , &g , &b);
   
    x = r * 100 + g * 10 + b;

    if( x % 4 == 0 ) printf("YES\n");

    else printf("NO\n");
   

    return 0;
                                                          
}

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

int main(){
  int N;
  string A,B,C;
  cin >> N >> A >> B >> C;
  int ans=0;
  for(int i=0;i<N;i++){
    if(A.at(i)==B.at(i)&&B.at(i)==C.at(i)){
      continue;
    }else if(A.at(i)!=B.at(i)&&B.at(i)!=C.at(i)&&A.at(i)!=C.at(i)){
      ans+=2;
    }else{
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int t = scan.nextInt();
        while (t > 0) {
            int n = scan.nextInt();
            int s;
            int f;
            int sum = 0;
            for (int i = 0; i < n; i++) {
                s = scan.nextInt();
                f = scan.nextInt();
                sum += f - s;
            }

            if (t <= sum) {
                System.out.println("OK");
            } else {
                System.out.println(t - sum);
            }
            t = scan.nextInt();
        }
    }
}



Measured memory_bytes: 31696
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        Set<Long> set = new HashSet<>();
        Set<Long> ans = new HashSet<>();

        set.add(n);
        for (long i = 2; i * i <= n; i++) {
            if (n % i == 0) {
                set.add(i);
                set.add(n / i);
            }
        }

        for (long i : set) {
            long nn = n;
            while (nn % i == 0) {
                nn = nn / i;
            }
            if (nn == 1 || (nn - 1) % i == 0) ans.add(i);
        }


        if (n != 2) ans.add(n - 1);
        for (long i = 2; i * i <= n; i++) {
            if ((n - 1) % i == 0) {
                ans.add(i);
                ans.add((n - 1) / i);
            }
        }

        System.out.println(ans.size());

    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 22724
# import sys
# input = sys.stdin.readline
import bisect

# template input
def IT():  # 整数1個
    return int(input())

def IL():  # 整数複数
    return [int(_) for _ in input().split()]

def IS():  # 文字列複数
    return [_ for _ in input().split()]

def ILS(n):  # 整数1つ　縦にズラーってなってるやつ
    return [int(input()) for _ in range(n)]

def SLS(n):  # 文字列　縦にズラーってなってるやつ
    return [input() for _ in range(n)]

def ILSS(n):  # 整数複数　縦にズラーってなってるやつ
    return [[int(_) for _ in input().split()] for j in range(n)]

# template technique
def bit_full_search(ss):
    n = len(ss)
    for i in range(1 << n):
        s = ""
        for j in range(n + 1):
            if ((1 & i >> j) == 1):
                s += ss[j]
        print(s)

def bit_full_search2(A):
    # https://blog.rossywhite.com/2018/08/06/bit-search/
    value = []
    for i in range(1 << len(A)):
        output = []

        for j in range(len(A)):
            if ((i >> j) & 1) == 1:
                # output.append(A[j])
                output.append(A[j])
        value.append([format(i, 'b').zfill(16), sum(output)])

    value.sort(key=lambda x: x[1])
    bin = [value[k][0] for k in range(len(value))]
    val = [value[k][1] for k in range(len(value))]
    return bin, val

def matching_bisect(list1_val, list2_val, n):
    # 2分探索
    j = 0
    for i in range(len(list1_val)):
        j = bisect.bisect_left(list2_val, n - list1_val[i])
        if j < len(list2_val):
            if list1_val[i] + list2_val[j] == n:
                # ans = list2_bin[j] + list1_bin[i]
                break
    return j

"""ここからメインコード"""

def main():
    n, a, b = IL()
    aa  =min(a, b)
    bb = max(0, a+b-n)
    print(aa, bb)
main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll dp[5002][5002];
int main() {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll ans=0;
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n;j++){
			if(i==j){
				continue;
			}
			if(s[i]==s[j]){
				if(i==0||j==0){
					dp[i][j]=1;
				}
				else{
				dp[i][j]=dp[i-1][j-1]+1;
				}
			}
			if(i<j){
				if(i+dp[i][j]>j){
					continue;
				}
			}
			if(j<i){
				if(j+dp[i][j]>i){
					continue;
				}
			}
			ans=max(ans,dp[i][j]);
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

int main()
{
	int x[100], i, j = 0, n = 1, sum[100];
	while (1)
	{
		sum[j] = 0;
		cin >> n;
		if (n == 0)
			break;

		for (i = 0; i < n; i++)
		{
			cin >> x[i];
		}
		sort(x, x + n);
		for (i = 1; i < n - 1; i++)
		{
			sum[j] += x[i];
		}
		sum[j] = sum[j] / (n - 2);
		j++;
	}
	for (i = 0; i < j ; i++)
	{
		cout << sum[i] << endl;
	}
	return 0;

}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
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; }

char maze[1010][1010];
int H,W;
int sx,sy;
int gx,gy;
int d[1010][1010];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int bfs(){
    queue<pair<int,int>> que;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            d[i][j]=INF;
        }
    }
    que.push(make_pair(sx,sy));
    d[sx][sy]=0;
    while(!que.empty()){
        pair<int,int> p=que.front();
        que.pop();
        if(p.first==gx && p.second==gy) break;
        for(int i=0;i<4;i++){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            if(0<=nx && nx<H && 0<=ny && ny<W && maze[nx][ny]!='#' && d[nx][ny]==INF){
                que.push(make_pair(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
            }
        }
    }
    return d[gx][gy];
}

int main(){
    cin>>H>>W;
    int ans=0,cnt1=0,cnt2=0;
    queue<pair<int,int>> q;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>maze[i][j];
            if(maze[i][j]=='#'){
                q.push(make_pair(i,j));
                cnt1++;
            }
        }
    }
    while(!q.empty()){
        if(cnt1==0){
            ans++;
            cnt1=cnt2;
            cnt2=0;
        }
        pair<int,int> p=q.front();
        q.pop();
        cnt1--;
        for(int i=0;i<4;i++){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            if(0<=nx && nx<H && 0<=ny && ny<W && maze[nx][ny]!='#'){
                q.push(make_pair(nx,ny));
                cnt2++;
                maze[nx][ny]='#';
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11408
// +build ignore
package main

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

func solve(sc *scanner, wr *bufio.Writer) int {
	H1 := sc.i()
	M1 := sc.i()
	H2 := sc.i()
	M2 := sc.i()
	K := sc.i()

	min1 := H1*60 + M1
	min2 := H2*60 + M2

	fmt.Println(min2 - min1 - K)
	return 0
}

func main() {
	sc := newScanner(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	ret := solve(sc, wr)
	wr.Flush()
	os.Exit(ret)
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}


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

lst = [0] *(N + 1)
for a in A:
    lst[a] += 1

ans = 0
for tmp in lst:
    ans += (tmp * (tmp - 1)) // 2

# print (lst)
for a in A:
    print (ans - lst[a] * (lst[a] - 1) // 2 + (lst[a] - 1) * (lst[a] - 2) // 2)

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

int main()
{
	int w, h, x, y, r;

	cin >> w >> h >> x >> y >> r;

		if (x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h){
		cout << "Yes" << endl;
	}
	else {
	 cout << "No" << endl;
	}
	return (0);
}

Measured memory_bytes: 1156
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>

using namespace std;
int N;

void dfsa(string s,char mx){
    if(s.length()==N){
        cout<<s<<endl;
    }else{
        for(char c = 'a'; c <= mx; c++){
            dfsa(s+c,c==mx?(char)mx+1:mx);
        }
    }
}

int main(){
    cin>>N;
    string s="";
    dfsa(s,'a');

}



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


int main() {
  string S;
  cin >> S;
  
  int cnt = 0;
  for(int i ; i < S.size() ; i++ ){
    if(S.at(i) == '+'){
      cnt ++;
    }
    else{
      cnt --;
    }
  }
  
  cout << cnt << endl;
}


Measured memory_bytes: 256
/**
 * 
 */

import java.io.InputStream;
import java.lang.reflect.Array;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;

/**
 * @author kumar1
 * 
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		InputStream in = System.in;
		Scanner scanner = new Scanner(in);
		LinkedList<Integer> ans = new LinkedList<Integer>();
		while (true) {
			int n = scanner.nextInt();
			int p = scanner.nextInt();
			if (n == 0 || p == 0)
				break;
			int[] temoto = new int[n];
			for (int i = 0;; i++) {
				if(p == 0) {
					int j;
					for(j=0; j < n; j++) {
						if(i != j && temoto[j] != 0)
							break;
					}
					if(j >= n) {
						ans.add(i);
						break;
					}
					p = temoto[i];
					temoto[i] = 0;
				} else {
					temoto[i]++;
					p--;
				}
				
				if(i == n-1)
					i = -1;
			}
		}
		for (int a : ans)
			System.out.println(a);
	}

}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,cnt=0;
	long double d,x,y;
	cin>>n>>d;
	for(int i=0;i<n;i++){
		cin>>x>>y;
		if(pow( pow(x,2)+pow(y,2),0.5)<=d){
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3836
a,b,c=map(int,input().split())
ans=0
s=[a,b,c]
s=sorted(s)
x=s[2]-s[0]
y=s[2]-s[1]
if x%2==y%2:
    print((x+y)//2)
else:
    print(1+(x+y+1)//2)

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

using namespace std;
using ll = long long;

int main(){
    ll X=0,t=0;
    cin>>X>>t;
    if (X-t>0){
        cout<<X-t<<endl;
    }
    else{
        cout<<0<<endl;
    }
    return 0;
}


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

using namespace std;

int main(void){
  int N;
  cin >> N;
  vector<int> L(N);
  int i, j;
  for(i=0; i<N; i++)
    cin >> L[i];

  //昇順にソート
  sort(L.begin(), L.end());

  //題意を満たす三角形の数を数える
  int count = 0;

  //a b c d e L[j] f g h L[i] k l
  //右からi番目を固定し，それに合わせてj番目を決めていく
  //L[i]+L[j]の値未満となる場所をunder_nに格納する
  //under_n - i - 1個三角形が作れる
  int under_n;
  for(i=N-2; i>=0; i--){
    for(j=i-1; j>=0; j--){
      under_n = lower_bound(L.begin(), L.end(), L[i]+L[j]) - L.begin();
      count = count + (under_n - i - 1);
    }
  }

  cout << count << endl;
  
  return 0;
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int gcd(int,int);

int main(){
    int x,y;
    int ans = 0;
    cin >> x >> y;
    int g = gcd(x,y);
    x /= g;
    y /= g;

    REP(i,g) ans += ((x-1)+(y - 1));
    ans += (g + 1);
    cout << ans << endl;
    return 0;
}

int gcd(int a, int b){
    if(a < b) swap(a, b);
    if(b == 0) return a;
    else gcd(b,(a % b));
}


Measured memory_bytes: 3108
#include <iostream>

int main() {
	int A, B;
	std::cin >> A >> B;

	if ((A - B) % 2 == 0)
	{
		std::cout << A - (A - B) / 2 << std::endl;
	}
	else
	{
		std::cout << "IMPOSSIBLE" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef pair<int,int> P;
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define lowbit(x) (x&-x)
const ll INF=0x3f3f3f3f;
const double EPS=1e-7;
const int N=3e5+10;
const ll mod=1e9+7;
const ll MOD=998244353;
inline ll read()  
{  ll f=1,x=0;char ch=getchar();
   for(;ch>'9'||ch<'0';ch=getchar())if(ch=='-') f=-1;
   for(;ch<='9'&&ch>='0';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);
   return x*f;
}
ll n,m,k,ans;
int a[3005][3005];
ll dp[2][3005][4];
int main()
{  cin>>n>>m>>k;
   for(int i=1;i<=k;i++)
   {  int x,y,v;
      cin>>x>>y>>v;
      a[x][y]=v;
   }
   int t=0;
   for(int i=1;i<=n;i++)
   {  t=t^1;
      for(int j=1;j<=m;j++)
        {  ll temp=0,v=a[i][j];
           for(int k=0;k<=3;k++)temp=max(temp,dp[t^1][j][k]);
           dp[t][j][0]=max(dp[t][j-1][0],max(dp[t][j-1][0],temp));
           dp[t][j][1]=max(dp[t][j-1][1],max(dp[t][j-1][0]+v,temp+v));
           dp[t][j][2]=max(dp[t][j-1][2],dp[t][j-1][1]+v);
           dp[t][j][3]=max(dp[t][j-1][3],dp[t][j-1][2]+v);   
        }
   }
   for(int i=0;i<=3;i++)ans=max(ans,dp[t][m][i]);
   cout<<ans;
}

Measured memory_bytes: 38908
N = int(input().rstrip())
A = list(map(int,input().rstrip().split()))
B = list(map(int,input().rstrip().split()))
C = list(map(int,input().rstrip().split()))
ans = sum(B)
for i in range(N-1):
    if A[i]+1 == A[i+1]:
        ans += C[A[i]-1]
print(ans)

Measured memory_bytes: 9000
#include<bits/stdc++.h>
using namespace std;
int main(){

  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];}
  
  long long int max[n];
  for(int i=1;i<n;i++){
  	max[i]=INT_MAX;
  }
  max[0]=0;
  for(int i=1;i<n;i++){
  	for(int j=1;j<=k;j++){
  		if(i-j<0)
  		break;
  		max[i]=min(max[i],max[i-j]+abs(a[i]-a[i-j]));
  		//cout<<max[i]<<"jhv"<<endl;
  	}
  	//max[i]=min(max[i-2]+abs(a[i]-a[i-2]),max[i-1]+abs(a[i]-a[i-1]));
  }
  
  cout<<max[n-1]<<endl;
  
  return 0;
}

Measured memory_bytes: 1408
A = []
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))

N = int(input())
B = []
for _ in range(N):
  B.append(int(input()))
  
# judge
flg = False

for i in range(3):
  if A[i][0] in B and A[i][1] in B and A[i][2] in B:
    flg = True
  if A[0][i] in B and A[1][i] in B and A[2][i] in B:
    flg = True
  
if A[0][0] in B and A[1][1] in B and A[2][2] in B:
  flg = True
if A[2][0] in B and A[1][1] in B and A[0][2] in B:
  flg = True
  
print("Yes" if flg else "No")

Measured memory_bytes: 3064
# your code goes he
def minn(a,b):
  if a>b:
    return b
  return a
n=int(input())
a=list(map(int,input().split()))

b=list(map(int,input().split()))
sm=0
tmp=0

for i in range(n):
  tmp=minn(a[i],b[i])
  sm=sm+tmp
  a[i]=a[i]-tmp
  b[i]=b[i]-tmp
  tmp=minn(a[i+1],b[i])
  sm=sm+tmp
  a[i+1]=a[i+1]-tmp
  b[i]=b[i]-tmp
  
print(sm)

Measured memory_bytes: 18476
(defmacro aif(test then else)
  `(let ((it ,test))
     (if it ,then ,else)))

(defun split (pattern str)
  (aif (search pattern str)
       (cons (subseq str 0 it) (split pattern (subseq str (+ it (length pattern)))))
       (list str)))

(defun main ()
  (let* ((input (split " " (read-line)))
         (a (parse-integer (first input)))
         (b (parse-integer (second input)))
         (tt (parse-integer (third input))))
    (print (* (floor tt a) b))))
(main)

Measured memory_bytes: 13924
#include <iostream>

#include <vector>

#include <stdio.h>

using namespace std;

#define PI 3.141592653589




int main(){

    int n, mark, num;

    char t;

    int c[4][13]={0};

    cin>>n;

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

        cin>>t>>num;

        if(t=='S')mark=0;

        if(t=='H')mark=1;

        if(t=='C')mark=2;

        if(t=='D')mark=3;

        c[mark][num-1]=1;

    }

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

        for(int j=0;j<13;j++){

            if(c[i][j]==0){

                if(i==0)t='S';

                if(i==1)t='H';

                if(i==2)t='C';

                if(i==3)t='D';

                cout<<t<<" "<<j+1<<endl;

            }

        }

    }

    return 0;

}

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

#define int long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

signed main() {
    string s;
    cin >> s;
    int n = (int)s.size();
    int cnt = 0;
    bool flag = true;
    int l = 0, r = n-1;
    while ( r-l >= 1 ) {
        if ( s[l] == s[r] ) l++, r--;
        else if ( s[l] == 'x' ) l++, cnt++;
        else if ( s[r] == 'x' ) r--, cnt++;
        else { flag = false; break; }
    }
    if ( !flag ) cout << -1 << endl;
    else cout << cnt << endl;
}


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

#define endl "\n"
#define INF 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cout << #x << " => " << x << "\n"
#define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n";
#define debm(x) cout << #x << "\n"; for (auto a : x){for(auto b : a) cout << b << " "; cout << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int32_t main() { fastio;
    vector<int> arr(3);
    for (int i = 0; i < 3; i++) {
        cin >> arr[i];
    }
    sort(arr.begin(), arr.end());
    if (arr[0] == arr[1] and arr[1] == arr[2]) {
        cout << "No" << endl;
    } else if (arr[0] == arr[1] or arr[1] == arr[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;

int main(){ 
        int a,b;
        cin >> a >> b;
        if(b%a==0)      cout << a+b;
        else cout << b-a;
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;
int n;
int p[20010];
ll a[20010];
ll b[20010];
int x;
int main()
{
	cin >> n;
	repp(i, 1, n+1)
	{
		cin >> x;
		p[x]=i;
	}
	repp(i, 1, n+1)
	{
		a[i]=1+(i-1)*n+p[i];
		b[i]=1+(n-i)*n;
	}
	cout << a[1];
	repp(i, 2, n+1)
	{
		cout << " " << a[i];
	}
	cout << endl;
	cout << b[1];
	repp(i, 2, n+1)
	{
		cout << " " << b[i];
	}
	cout << endl;
	return 0;
}

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

using namespace std ;

#define N 100010
char a[ N ] ;

int main() {
	int cnt = 0 ;
	scanf( "%s" , a + 1 ) ;
	int n = strlen( a + 1 ) , k = n & 1 ; 
	puts( abs( k - ( a[ n ] == a[ 1 ] ) ) & 1 ? "First" : "Second" ) ; 
} 

Measured memory_bytes: 384
s = gets.strip.to_s
a = s[0].to_i*10+s[1].to_i
b = s[2].to_i*10+s[3].to_i
if 1<=a && a<=12
  unless 1<=b && b<=12
    puts "MMYY"
  else
    puts "AMBIGUOUS"
  end
else
  if 1<=b && b<=12
     puts "YYMM"
  else
    puts "NA"
  end
end

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===




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

	int N; cin >> N;
	Vi A(N);
	vector<Vi> X(N), Y(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		X[i].reserve(A[i]);
		Y[i].reserve(A[i]);
		for (int j = 0; j < A[i]; ++j) {
			int xi, yi;
			cin >> xi >> yi;
			--xi;
			X[i].push_back(xi);
			Y[i].push_back(yi);
		}
	}

	Vi is_shoujiki(N);
	bool ok = true;
	int bMAX = (1 << N);
	int ans = 0;

	for (int bit = 0; bit < bMAX; ++bit) {
		ok = true;
		int bit_tmp = bit;
		for (int i = 0; i < N; ++i) {
			if (bit_tmp & 1) is_shoujiki[i] = 1;
			else is_shoujiki[i] = 0;
			bit_tmp >>= 1;
		}

		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < A[i]; ++j) {
				if (is_shoujiki[i]) {
					if (Y[i][j] == 1 - is_shoujiki[X[i][j]]) ok = false;
				}
			}
		}

		if (ok) {
			int tmp = 0;
			for (int i = 0; i < N; ++i) {
				if (is_shoujiki[i] == 1) ++tmp;
			}
			ans = max(ans, tmp);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){	
    char a[105];
    scanf("%s",a);
    int s,flag=0;
    s=strlen(a);
    for(int i=0;i<s;i++){
    	if(a[i]==55){
    		flag=1;
    		cout<<"Yes"<<endl;
    		break;
		}
	}
	if(flag==0) cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値取得
		int N = scan.nextInt();

		char[] c = scan.next().toCharArray();

		//演算
		int red = 0;
		for (int i = 0; i < N; i++) {
			if (c[i] == 'R') {
				red++;
			}
		}

		int count = 0;
		for (int i = 0; i < red; i++) {
			if (c[i] == 'W') {
				count++;
			}
		}

		//結果出力
		System.out.println(count);
	}
}


Measured memory_bytes: 40784
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;

/*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 { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

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

    rep(i, n) {
        ans[a[i] - 1] = i;
    }

    rep(i, n) {
        cout << ans[i] + 1 << " ";
    }
    
    return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=5000 +117;
const int MM=5000 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
char s[NN]={};
char t[NN]={};
int a[NN]={};
int b[NN]={};
int acnt,bcnt;
int chk(int x){
	int res=0;
	int ap,bp;
	for(int i=min(1,1-x),top=max(acnt,bcnt-x);i<=top;++i){
		if(1<=i&&i<=acnt)ap=a[i];
		if(i<1)ap=1;
		if(i>acnt)ap=n+1;
		int tp=i+x;
		if(1<=tp&&tp<=bcnt)bp=b[tp];
		if(tp<1)bp=1;
		if(tp>bcnt)bp=n+1;
		res+=abs(ap-bp);
	}
	return res;
}
int main(){
	//open();
	n=read();
	scanf("%s",s+1);
	scanf("%s",t+1);
	for(int i=1;i<=n;++i){
		if(s[i]!=s[i-1]){
			a[++acnt]=i;
		}
		if(t[i]!=t[i-1]){
			b[++bcnt]=i;
		}
	}
	int ans=1e9+1;
	int ad=0;
	if(s[1]!=t[1])ad=1;
	int st=-acnt;
	if(ad!=(acnt&1))st-=1;
	for(int i=st;i<=bcnt+1;i+=2){
		ans=min(ans,chk(i));
	}
	printf("%d\n",ans);
	close();
	return 0;
}

Measured memory_bytes: 256
//O(n^2)の解法
#include<iostream>
#include<algorithm>
using namespace std;

struct point {
	int x; int y;
};

// x座標が小さい順になるように並び替えたいので、このような順序を定義。
bool order(point a, point b) {
	return a.x < b.x;
}

point blue[200];
point red[200];
// 配列の宣言のときに = {}をつけると全部の要素が0になる。
// 必要だったら「配列　初期化」とかでググるとよい。
// この配列usedの役割は後で説明する。
int used[200] = {};

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int p, q;
		cin >> p >> q;
		red[i] = { p,q };
	}
	for (int i = 0; i < n; i++) {
		int p, q;
		cin >> p >> q;
		blue[i] = { p,q };
	}
	int ans = 0;
	//青点をx座標の小さい順にソートする。
	sort(blue, blue + n, order);
	//i番目の青点から見ていく。
	for (int i = 0; i < n; i++) {
		int bx = blue[i].x;
		int by = blue[i].y;
		//今、次のa～cの条件を満たす中で、もっともy座標が大きい赤点を探したいのだった。
		int max_red = -1;
		int max_red_y = -1000000;
		for (int j = 0; j < n; j++) {
			if (used[j] == 0 && red[j].x < bx && red[j].y < by && red[j].y > max_red_y) {
				max_red = j;
				max_red_y = red[j].y;
			}
		}
		if (max_red != -1) {
			ans++;
			used[max_red] = 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
D=[0]*N
cnt=0
S=0
for i in range(N):
    D[i]=A[i]-B[i]
    if D[i]<0:
        S-=D[i]
        cnt+=1

D.sort(reverse=True)

if S==0:
    print(0)
    exit()


i=0
while S>0 and i<N:
    S-=D[i]
    cnt+=1
    i+=1

if i>=N:
    print(-1)
elif S<=0:
    print(cnt)


Measured memory_bytes: 18356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1000000000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repM(i, n) for (int i = n; i > 0; i--)

//string abc = {"abcdefghijklmnopqrstuvwxyz"};
string abc = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
char shift_Char(char S,int N){
    int Snum = -1;
    rep(i,26){
        if(abc[i]==S){
            Snum = i;
            break;
        }
    }
    if(Snum == -1) return '0';
    if(Snum + N < 26) return abc[Snum+N];
    else return abc[Snum-26+N];
}

int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;
    string ans = "";
    rep(i,S.length()){
        ans = ans + shift_Char(S[i], N);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256